Browse Source

出院带药

xiao 2 years ago
parent
commit
abc5375fae

+ 31 - 0
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/YiZhuLuRuDao.java

@@ -715,6 +715,22 @@ public interface YiZhuLuRuDao {
     @Select("select cast(isnull(NULLIF(doctor_xz_yp, ''), 0) as int) from a_employee_mi with (NOLOCK) where code = #{code}")
     Integer huoQuYiShenDengJi(String code);
 
+
+    /**
+     * 出院带药数量
+     *
+     * @param patNo 住院号
+     * @param times 住院次数
+     * @return
+     */
+    @Select("select count(*) " +
+            "from yz_act_order " +
+            "where inpatient_no = #{patNo} " +
+            "  and admiss_times = #{times} " +
+            "  and self_buy = '4' " +
+            "  and status_flag in ('1', '2') ")
+    int obtainTheNumberOfDischargedDrugs(String patNo, Integer times);
+
     @Select("select rtrim(supply_code) code,rtrim(supply_name) name " +
             "from yz_supply_type with (NOLOCK) " +
             "where ps_flag in ('1', '0')")
@@ -1475,6 +1491,14 @@ public interface YiZhuLuRuDao {
     void updateTheThirdLevelDoctor(@Param("param") Overview param);
 
 
+    /**
+     * 插入药品汇总单
+     *
+     * @param pageNo   药单好
+     * @param patInfo  患者信息
+     * @param userCode 插入数据
+     * @param groupNo  药房
+     */
     @Insert("insert into yz_yp_page_no (page_no, dept_code, ward_code, submit_time, " +
             "                           submit_name, submit_flag, " +
             "                           page_class, page_name, " +
@@ -1484,6 +1508,13 @@ public interface YiZhuLuRuDao {
     void summarySheetOfDrugs(Integer pageNo, XinZhenYiZhu patInfo, String userCode, String groupNo);
 
 
+    @Insert("insert into yz_yp_zy_order (inpatient_no, admiss_times, name, bed_no, dept_code, ward_code, charge_code, " +
+            "  amount,\n" +
+            " retprice, charge_date, infant_flag, drawer, always_flag, status_flag/*1*/, drug_class,\n" +
+            " serail/*0*/,\n" +
+            " occ_time, act_order_no, page_no, pay_self/*0*/, serial/*serial*/,\n" +
+            " group_no, doctor_name, page_class, yb_self_flag)\n" +
+            "values ();")
     void insertDetailedMedicineList();
 
 }

+ 41 - 9
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -203,7 +203,7 @@ public class YiZhuLuRuServer {
 
 
     /**
-     * 确认医嘱
+     * 确认医嘱 , 这个是最新的正确的
      *
      * @param param 数据
      * @return 返回提示
@@ -218,11 +218,15 @@ public class YiZhuLuRuServer {
         if (ListUtil.isBlank(yiZhuList)) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有需要确认的医嘱.");
         }
+        if (dao.obtainTheNumberOfDischargedDrugs(param.getInpatientNo(), param.getAdmissTimes()) > 4) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "出院带药医嘱不得超过 4 种,却不得超过 7 天。");
+        }
+
         // 药品 code
         Set<String> yaoPingCode = new HashSet<>();
         // 项目的 code
         Set<String> xiangMuCode = new HashSet<>();
-        // 出院带药需要生成药单
+        // 出院带药需要生成药单 key 是不同的药房。不同的药房就要
         Map<String, List<XinZhenYzActOrder>> takeTheMedicineList = new HashMap<>(Capacity.TWO);
 
         for (XinZhenYzActOrder item : yiZhuList) {
@@ -288,11 +292,11 @@ public class YiZhuLuRuServer {
             if (count > 0) {
                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "有未确认和未执行的医嘱,无法确认全排斥医嘱。");
             }
-            dao.stopOrder(param.getInpatientNo(), param.getAdmissTimes(), excludeOrders, userCode);
+//            dao.stopOrder(param.getInpatientNo(), param.getAdmissTimes(), excludeOrders, userCode);
         }
         // TODO 出院带药的问题
-//        dischargeMedicineList(takeTheMedicineList, huanZheXinXi);
-        dao.confirmOrders(confirmOrderInformation, TokenUtil.getTokenUserId(), param.getInpatientNo(), param.getAdmissTimes());
+        dischargeMedicineList(takeTheMedicineList, huanZheXinXi);
+//        dao.confirmOrders(confirmOrderInformation, TokenUtil.getTokenUserId(), param.getInpatientNo(), param.getAdmissTimes());
         log.info("确认的医嘱:{}", JSON.toJSONString(yiZhuList));
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
     }
@@ -301,8 +305,8 @@ public class YiZhuLuRuServer {
         log.info("出院带药药单:{}", JSON.toJSONString(map));
         String userCode = TokenUtil.getTokenUserId();
         for (Map.Entry<String, List<XinZhenYzActOrder>> entry : map.entrySet()) {
-            Integer pageNo = publicServer.getTheDrugListNo();
-            dao.summarySheetOfDrugs(pageNo, huanZheXinXi, userCode, entry.getKey());
+//            Integer pageNo = publicServer.getTheDrugListNo();
+//            dao.summarySheetOfDrugs(pageNo, huanZheXinXi, userCode, entry.getKey());
         }
 
     }
@@ -972,8 +976,25 @@ public class YiZhuLuRuServer {
                         }
                     }
                 }
-                // 计算费用金额
-                calculateDrugAmount(item, feiYongXinXi, 错误信息);
+                if (item.getSelfBuy() != null && item.getSelfBuy().equals("4")) {
+                    if (item.getStartTime() == null) {
+                        错误信息.add("出院带药请输入开始时间。");
+                    }
+                    if (item.getEndTime() == null) {
+                        错误信息.add("出院带药请输入结束时间。");
+                    } else {
+                        long cha = item.getEndTime().getTime() - item.getStartTime().getTime();
+                        long nd = 1000 * 24 * 60 * 60;
+                        if (cha / nd > 7) {
+                            错误信息.add("出院带药天数不得超过 7 天,计算方式结束时间减去开始时间。");
+                        }
+                    }
+
+                } else {
+                    // 计算 durg_quan durg_occ
+                    calculateDrugAmount(item, feiYongXinXi, 错误信息);
+                }
+
             }
         }
 
@@ -1535,5 +1556,16 @@ public class YiZhuLuRuServer {
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
     }
 
+    /**
+     * 出院带药数据校验
+     *
+     * @param patInfo 患者信息
+     * @param param   参数
+     * @return 返回提示
+     */
+    public String verificationAfterDischarge(XinZhenYiZhu patInfo, XinZhenYzActOrder param) {
+        return "";
+    }
+
 
 }

+ 1 - 2
src/main/java/thyyxxk/webserver/utils/DateUtil.java

@@ -336,15 +336,14 @@ public class DateUtil {
 
     public static boolean judgmentDate(Date date1, Date date2) {
         long cha = date1.getTime() - date2.getTime();
-        System.out.println(cha);
         if (cha < 0) {
             return false;
         }
         double result = cha * 1.0 / (1000 * 60 * 60);
-        System.out.println(result);
         return result <= 24;
     }
 
+
     public static boolean within24Hours(Date date) {
         long l = System.currentTimeMillis();
         long mills = l - date.getTime();