Преглед на файлове

优化门诊药房发药队列

hurugang преди 2 години
родител
ревизия
b847e42752

+ 7 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzBlRecordMapper.java

@@ -220,6 +220,13 @@ public interface MzBlRecordMapper {
     int updateMzBlRecordEmrProcess(MzBlRecord mzBlRecord);
 
 
+    /**
+     * 查询最后一个病历号
+     *
+     * @return
+     */
+    @Select("select top 1  emr_no from  mz_bl_record order by emr_no desc")
+    String selectLastEmrNo();
 
 }
 

+ 15 - 15
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzDrugWinMapper.java

@@ -29,21 +29,21 @@ public interface MzDrugWinMapper {
             " mz_drug_win WITH(NOLOCK) where group_no =#{groupNo,jdbcType=CHAR} and win_cate = '0'  order by patient_num asc ")
     MzDrugWin selectMinMzDrugWin(@Param("groupNo") String groupNo);
 
-//    /**
-//     * 更新药房的排队人数
-//     *
-//     * @param mzDrugWin
-//     * @return
-//     */
-//    @Update({"<script>",
-//            "update mz_drug_win ",
-//            "<trim prefix='set' prefixOverrides=',' suffix=' where win_no = #{winNo,jdbcType=CHAR}' >",
-//            "<when test='patientNum!=null'>",
-//            "patient_num =#{patientNum,jdbcType=INTEGER}",
-//            "</when>",
-//            "</trim>"
-//            , "</script>"})
-//    int updateMzDrugWin(MzDrugWin mzDrugWin);
+    /**
+     * 更新药房的排队人数
+     *
+     * @param mzDrugWin
+     * @return
+     */
+    @Update({"<script>",
+            "update mz_drug_win ",
+            "<trim prefix='set' prefixOverrides=',' suffix=' where win_no = #{winNo,jdbcType=CHAR}' >",
+            "<when test='patientNum!=null'>",
+            "patient_num =#{patientNum,jdbcType=INTEGER}",
+            "</when>",
+            "</trim>"
+            , "</script>"})
+    int updateMzDrugWin(MzDrugWin mzDrugWin);
 
     /**
      * 按照组号与窗口号查询窗口名称

+ 22 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzYjReqMapper.java

@@ -8,6 +8,7 @@ import java.util.List;
 import java.util.Map;
 
 public interface MzYjReqMapper {
+
     @Select("select req_no,patient_id,p_name patient_name,birth_date,times,receipt_no,order_no,item_no,p_bar_code,group_name,order_code,order_name,page_no,req_comment,req_doctor," +
             "req_ward,exec_dept,req_date,inspect_part,inspect_stuff,sample_status,rtrim(print_flag) print_flag,rtrim(receive_flag) receive_flag,req_type,result_comment,sys_date," +
             "rtrim(pay_mark) pay_mark,rtrim(status_flag) status_flag,serial_no,cash_id,jy_remark,req_other_result,original_list_no,req_tz_comment,rtrim(jz_flag) jz_flag,req_studyid," +
@@ -385,20 +386,40 @@ public interface MzYjReqMapper {
 
     /**
      * 根据医嘱编码查询当天是否有已经缴费的记录
+     *
      * @param patientId
      * @param orderCode
      * @return
      */
     @Select("select count(1) from  mz_yj_req where patient_id=#{patientId} and order_code =#{orderCode} and pay_mark = 0 and DateDiff(dd,req_date,getDate()) =0 ")
-    int select24HourReqByCode(@Param("patientId") String patientId,@Param("orderCode") String orderCode);
+    int select24HourReqByCode(@Param("patientId") String patientId, @Param("orderCode") String orderCode);
 
 
     /**
      * 根据医嘱编码查询当天的总单检申请数
+     *
      * @param beninTime
      * @param endTime
      * @return
      */
     @Select("select count(1) from  mz_yj_req where order_code in('003585','004764') and pay_mark = 0 and req_date>=#{beninTime} and  req_date<=#{endTime} ")
     int selectTotalReqByCode(@Param("beninTime") Date beninTime, @Param("endTime") Date endTime);
+
+    /**
+     * 查询最后一个申请单号
+     *
+     * @return
+     */
+    @Select("select top 1  req_no from  mz_yj_req order by req_no desc")
+    Integer selectLastReqNo();
+
+
+    /**
+     * 查询最后一个单号
+     *
+     * @return
+     */
+    @Select("select top 1  page_no from  mz_yj_req order by page_no desc")
+    String selectLastPageNo();
+
 }

+ 6 - 6
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzDrugWinServiceImpl.java

@@ -28,12 +28,12 @@ public class MzDrugWinServiceImpl implements MzDrugWinService {
         if (mzDrugWin == null) {
             throw new MzException("当前药房【"+groupNo+"】没有在使用中的发药窗口,请先设置!");
         }
-//        if(mzDrugWin.getPatientNum()==null){
-//            mzDrugWin.setPatientNum(1);
-//        }else {
-//            mzDrugWin.setPatientNum(mzDrugWin.getPatientNum()+1);
-//        }
-//        mzDrugWinMapper.updateMzDrugWin(mzDrugWin);
+        if(mzDrugWin.getPatientNum()==null){
+            mzDrugWin.setPatientNum(1);
+        }else {
+            mzDrugWin.setPatientNum(mzDrugWin.getPatientNum()+1);
+        }
+        mzDrugWinMapper.updateMzDrugWin(mzDrugWin);
         return mzDrugWin;
     }
 

+ 29 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzYshConfigServiceImpl.java

@@ -2,6 +2,8 @@ package cn.hnthyy.thmz.service.impl.his.mz;
 
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.mz.MzYshConfig;
+import cn.hnthyy.thmz.mapper.his.mz.MzBlRecordMapper;
+import cn.hnthyy.thmz.mapper.his.mz.MzYjReqMapper;
 import cn.hnthyy.thmz.mapper.his.mz.MzYshConfigMapper;
 import cn.hnthyy.thmz.service.his.mz.MzYshConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -15,7 +17,12 @@ public class MzYshConfigServiceImpl implements MzYshConfigService {
     @SuppressWarnings("all")
     @Autowired
     private MzYshConfigMapper mzYshConfigMapper;
-
+    @SuppressWarnings("all")
+    @Autowired
+    private MzYjReqMapper mzYjReqMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    private MzBlRecordMapper mzBlRecordMapper;
     /**
      * 医技申请单号
      * @return
@@ -31,6 +38,13 @@ public class MzYshConfigServiceImpl implements MzYshConfigService {
         }
         Integer oldReqNo = mzYshConfig.getReqNo();
         mzYshConfig.setReqNo(mzYshConfig.getReqNo() + 1);
+        Integer lastReqNo= mzYjReqMapper.selectLastReqNo();
+        if(lastReqNo!=null){
+            Integer realLastReqNo =lastReqNo-2000000000;
+            if(realLastReqNo>oldReqNo){
+                mzYshConfig.setReqNo(realLastReqNo + 1);
+            }
+        }
         int num = mzYshConfigMapper.updateReqNo(oldReqNo,mzYshConfig.getReqNo());
         if (num == 0) {
             throw new MzException("获取医技申请单号失败,请重试!");
@@ -54,6 +68,13 @@ public class MzYshConfigServiceImpl implements MzYshConfigService {
         }
         Integer oldReqPageNo = mzYshConfig.getReqPageNo();
         mzYshConfig.setReqPageNo(mzYshConfig.getReqPageNo() + 1);
+        String lastPageNo= mzYjReqMapper.selectLastPageNo();
+        if(lastPageNo!=null){
+            Integer realLastPageNo =Integer.valueOf(lastPageNo.replace("N",""));
+            if(realLastPageNo>oldReqPageNo){
+                mzYshConfig.setReqPageNo(realLastPageNo + 1);
+            }
+        }
         int num = mzYshConfigMapper.updateReqPageNo(oldReqPageNo,mzYshConfig.getReqPageNo());
         if (num == 0) {
             throw new MzException("获取医技申请单号失败,请重试!");
@@ -76,6 +97,13 @@ public class MzYshConfigServiceImpl implements MzYshConfigService {
         }
         Integer oldBlNo = mzYshConfig.getBlNo();
         mzYshConfig.setBlNo(mzYshConfig.getBlNo() + 1);
+        String lastEmrNo= mzBlRecordMapper.selectLastEmrNo();
+        if(lastEmrNo!=null){
+            Integer realLastEmrNo =Integer.valueOf(lastEmrNo.replace("N",""));
+            if(realLastEmrNo>oldBlNo){
+                mzYshConfig.setBlNo(realLastEmrNo + 1);
+            }
+        }
         int num = mzYshConfigMapper.updateBlNo(oldBlNo,mzYshConfig.getBlNo());
         if (num == 0) {
             throw new MzException("获取病历单号失败,请重试!");