Browse Source

分开查询出院医嘱,以及合理用药获取入院诊断问。

xiaochan 1 month ago
parent
commit
81cd9cd9d3

+ 17 - 11
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/YiZhuLuRuDao.java

@@ -1399,18 +1399,24 @@ public interface YiZhuLuRuDao {
 
     @Select("select count(1)\n" +
             "from yz_act_order\n" +
-            "where inpatient_no = '${patNo}'\n" +
-            "  and admiss_times = #{times}\n" +
-            "  and start_time >= (select top 1 start_time\n" +
-            "                     from yz_act_order a\n" +
-            "                     where a.inpatient_no = '${patNo}'\n" +
-            "                       and a.admiss_times = #{times}\n" +
-            "                       and a.order_code in (select order_code from yz_zd_order_item_confirm where item_name = N'出院')\n" +
-            "                       and serial = '00' " +
-            "  and a.act_order_no <> yz_act_order.act_order_no" +
-            "                     order by start_time desc)")
+            "where inpatient_no = '0434706'\n" +
+            "  and admiss_times = 1\n" +
+            "  and start_time >= #{start}\n" +
+            "  and act_order_no <> #{orderNo} ;")
     Integer prescribeMedicalAdviceAfterDischarge(String patNo,
-                                                 Integer times);
+                                                 Integer times, Date start, BigDecimal orderNo);
+
+    @Select("select top 1 start_time, act_order_no\n" +
+            "            from yz_act_order a\n" +
+            "            where a.inpatient_no = #{patNo}\n" +
+            "              and a.admiss_times = #{times}\n" +
+            "              and a.order_code in (select order_code\n" +
+            "                                   from yz_zd_order_item_confirm\n" +
+            "                                   where item_name = N'出院')\n" +
+            "              and serial = '00'\n" +
+            "            order by start_time desc")
+    YzActOrder selectFinallyOutOrderInfo(String patNo,
+                                         Integer times);
 
 
     @Select("select top 1 ward_code\n" +

+ 14 - 9
src/main/java/thyyxxk/webserver/service/heliyongyao/RationalUseServer.java

@@ -237,17 +237,22 @@ public class RationalUseServer {
         List<XunHuanJieDian> diagnosticData = new ArrayList<>();
         JSONObject medicalRecordDiagnosticData = JSONObject.parseObject(dao.medicalRecordDiagnosticData(patNo, times));
         if (medicalRecordDiagnosticData != null) {
-            JSONArray arr = medicalRecordDiagnosticData.getJSONArray("入院诊断");
-            if (arr != null && !arr.isEmpty()) {
-                for (int i = 0; i < arr.size(); i++) {
-                    JSONObject item = arr.getJSONObject(i);
-                    XunHuanJieDian temp = new XunHuanJieDian();
-                    temp.setType("2");
-                    temp.setCode(item.getString("code"));
-                    temp.setName(item.getString("name"));
-                    diagnosticData.add(temp);
+            try {
+                JSONArray arr = medicalRecordDiagnosticData.getJSONObject("入院诊断").getJSONArray("value");
+                if (arr != null && !arr.isEmpty()) {
+                    for (int i = 0; i < arr.size(); i++) {
+                        JSONObject item = arr.getJSONObject(i);
+                        XunHuanJieDian temp = new XunHuanJieDian();
+                        temp.setType("2");
+                        temp.setCode(item.getString("code"));
+                        temp.setName(item.getString("name"));
+                        diagnosticData.add(temp);
+                    }
                 }
+            } catch (Exception e) {
+                throw new BizException(ExceptionEnum.NOT_EL_MESSAGE, "获取入院诊断错误");
             }
+
         }
 
         // 诊断节点

+ 10 - 4
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -226,8 +226,11 @@ public class YiZhuLuRuServer {
     public ResultVo<Map<String, Object>> confirmOrders(XinZhenYiZhu param) {
         // 判断是否开了出院医嘱后的医嘱
         if (!yzConfig.getPrescribeMedicalAdviceAfterDischarge()) {
-            if (dao.prescribeMedicalAdviceAfterDischarge(param.getInpatientNo(), param.getAdmissTimes()) > 0) {
-                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "有医嘱开在了出院医嘱后无法确认。");
+            YzActOrder ourOrderInfo = dao.selectFinallyOutOrderInfo(param.getInpatientNo(), param.getAdmissTimes());
+            if (ourOrderInfo != null) {
+                if (dao.prescribeMedicalAdviceAfterDischarge(param.getInpatientNo(), param.getAdmissTimes(), ourOrderInfo.getStartTime(), ourOrderInfo.getActOrderNo()) > 0) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "有医嘱开在了出院医嘱后无法确认。");
+                }
             }
         }
 
@@ -1193,8 +1196,11 @@ public class YiZhuLuRuServer {
 
         // 判断是否开了出院医嘱后的医嘱
         if (!yzConfig.getPrescribeMedicalAdviceAfterDischarge()) {
-            if (dao.prescribeMedicalAdviceAfterDischarge(patNo, times) > 0) {
-                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "有医嘱开在了出院医嘱后无法确认。");
+            YzActOrder ourOrderInfo = dao.selectFinallyOutOrderInfo(patNo, times);
+            if (ourOrderInfo != null) {
+                if (dao.prescribeMedicalAdviceAfterDischarge(patNo, times, ourOrderInfo.getStartTime(), ourOrderInfo.getActOrderNo()) > 0) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "有医嘱开在了出院医嘱后无法确认。");
+                }
             }
         }