Browse Source

优化住院药房发药

hsh 1 year ago
parent
commit
7648eeee3c

+ 23 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/zy/YpZyPatientMapper.java

@@ -308,4 +308,27 @@ public interface YpZyPatientMapper {
     })
     List<YpZyPatient> selectYpZyPatientForByj(@Param("pageNo") Integer pageNo);
 
+    /**
+     * 根据唯一键信息查询药单明细
+     * @param ypZyPatient 病人发药药单明细信息
+     * @return int
+     */
+    @Select(" select count(*) from yp_zy_patient WITH(NOLOCK) where order_date = #{orderDate} and dept_code = #{deptCode} " +
+            " and ward_code = #{wardCode} and charge_code = #{chargeCode} and amount = #{amount} " +
+            " and act_order_no = #{actOrderNo} and group_no = #{groupNo} and page_no = #{pageNo} " +
+            " and inpatient_no =#{inpatientNo} and admiss_times = #{admissTimes} ")
+    int selectYpZyPatientRepetition(YpZyPatient ypZyPatient);
+
+    /**
+     * 增加药品数量
+     * @param ypZyPatient 病人发药药单明细信息
+     * @return int
+     */
+    @Update(" update yp_zy_patient set amount = amount + #{amount,jdbcType=DECIMAL} where order_date = #{orderDate} and dept_code = #{deptCode} " +
+            " and ward_code = #{wardCode} and charge_code = #{chargeCode} and amount = #{amount} " +
+            " and act_order_no = #{actOrderNo} and group_no = #{groupNo} and page_no = #{pageNo} " +
+            " and inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} ")
+    int updateYpZyPatientAmount(YpZyPatient ypZyPatient);
+
+
 }

+ 7 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/yf/YfWardPrescriptionServiceImpl.java

@@ -494,7 +494,13 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                             ypZyPatients.add(ypZyPatient);
                         }
                     }
-                    ypZyPatientMapper.insertYpZyPatient(ypZyPatient);
+
+                    // 查询发药药单记录保存是否重复
+                    if(ypZyPatientMapper.selectYpZyPatientRepetition(ypZyPatient) == 1){
+                        ypZyPatientMapper.updateYpZyPatientAmount(ypZyPatient);
+                    } else {
+                        ypZyPatientMapper.insertYpZyPatient(ypZyPatient);
+                    }
                 }
                 if (ypZyPatient.getAmount() != 0) {
                     if (1 == ypBaseYfMapper.updateStockAmount(ypZyPatient.getChargeCode(), ypZyPatient.getSerial()