Bläddra i källkod

合理用药信息

DESKTOP-0GD05B0\Administrator 2 år sedan
förälder
incheckning
38949b2c66

+ 2 - 2
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/EmrController.java

@@ -41,8 +41,8 @@ public class EmrController {
     }
 
     @GetMapping("/getEmrTree")
-    public ResultVo<Map<String, List<JSONObject>>> getEmrTree() {
-        return server.getEmrTree();
+    public ResultVo<Map<String, List<JSONObject>>> getEmrTree(@RequestParam("type") String type) {
+        return server.getEmrTree(type);
     }
 
     @PostMapping("/insertEmrData")

+ 235 - 2
src/main/java/thyyxxk/webserver/dao/his/heliyongyao/RationalUseDao.java

@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Select;
 import thyyxxk.webserver.entity.heliyongyao.RationalUsePatient;
 import thyyxxk.webserver.entity.heliyongyao.XunHuanJieDian;
 import thyyxxk.webserver.entity.heliyongyao.YaoPin;
+import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYzActOrder;
 
 import java.util.List;
 import java.util.Map;
@@ -47,16 +48,248 @@ public interface RationalUseDao {
     RationalUsePatient huanZheXinXi(@Param("patNo") String patNo,
                                     @Param("times") Integer times);
 
+
+    @Select("select                     a.act_order_no, " +
+            "                           cast(cast(a.act_order_no as decimal) as varchar) id, " +
+            "                           order_code, " +
+            "                           order_name, " +
+            "                           rtrim(frequ_code)                                frequ_code, " +
+            "    frequ_code_name      = (select rtrim(comm) " +
+            "                            from yz_order_frequency " +
+            "                            where code = frequ_code), " +
+            "                           instruction, " +
+            "                           discription, " +
+            "                           infant_flag, " +
+            "                           order_time, " +
+            "                           physician, " +
+            "                           start_time, " +
+            "                           drug_specification, " +
+            "                           drug_quan, " +
+            "    drug_quan_name       = (select name " +
+            "                            from yp_zd_unit with (NOLOCK) " +
+            "                            where code = mini_unit), " +
+            "                           supply_code, " +
+            "    supply_code_name     = (select supply_name " +
+            "                            from yz_supply_type with (NOLOCK) " +
+            "                            where yz_supply_type.supply_code = a.supply_code), " +
+            "                           a.inpatient_no, " +
+            "                           a.admiss_times, " +
+            "                           drug_flag, " +
+            "                           enter_oper, " +
+            "    enter_oper_name      = (select top (1) rtrim(name) " +
+            "                            from a_employee_mi with (NOLOCK) " +
+            "                            where code = enter_oper) /* 录入人 */, " +
+            "                           enter_time, " +
+            "                           mini_unit, " +
+            "                           drug_weight, " +
+            "                           drug_weight_unit, " +
+            "                           rtrim(status_flag)                               status_flag, " +
+            "                           status_time, " +
+            "                           parent_no, " +
+            "    parent_no_name       = (select kfc.order_name from yz_act_order kfc where kfc.act_order_no = a.parent_no), " +
+            "                           self_buy, " +
+            "                           dose, " +
+            "                           dose_unit, " +
+            "    dose_unit_name       = (select name " +
+            "                            from yp_zd_unit with (NOLOCK) " +
+            "                            where dose_unit = code), " +
+            "                           drug_occ, " +
+            "                           drug_volume, " +
+            "                           drug_vol_unit, " +
+            "                           exclu_back_time, " +
+            "                           exclu_act_order_no, " +
+            "                           pay_self, " +
+            "                           serial, " +
+            "                           group_no, " +
+            "                           signer, " +
+            "                           cl_code, " +
+            "                           doctor_flag, " +
+            "                           emergency_flag, " +
+            "    exclu_type='', " +
+            "    end_time_b=end_time, " +
+            "                           exec_unit, " +
+            "                           dept_code, " +
+            "                           ward_code, " +
+            "    new_flag='0', " +
+            "    order_no_pattern=0, " +
+            "    suprice_flag='', " +
+            "    self_flag            ='', " +
+            "    pack_size=0.0, " +
+            "    parent_no_c=           -1000, " +
+            "                           reg_flag, " +
+            "    parent_flag='', " +
+            "                           yb_self_flag, " +
+            "                           kf_flag, " +
+            "                           refer_physician, " +
+            "                           consult_physician, " +
+            "    physician_name       = (select top (1) rtrim(name) " +
+            "                            from a_employee_mi with (NOLOCK) " +
+            "                            where code = physician) /* 开这个医嘱的医生 */, " +
+            "    exec_unit_name       = (select top (1) rtrim(name) " +
+            "                            from zd_unit_code with (NOLOCK) " +
+            "                            where code = exec_unit), " +
+            "    /*管床医生*/ " +
+            "    refer_physician_name = (select rtrim(name) " +
+            "                            from a_employee_mi with (NOLOCK) " +
+            "                            where code = refer_physician), " +
+            "    group_no_name        = (select rtrim(group_name) " +
+            "                            from yp_zd_group_name with (NOLOCK) " +
+            "                            where a.group_no = group_no), " +
+            "    signer_name          = (select top (1) rtrim(name) " +
+            "                            from a_employee_mi with (NOLOCK) " +
+            "                            where code = signer) /*确认人*/, " +
+            "                           confirm_time /*确认时间*/, " +
+            "                           modifier, " +
+            "    modifier_name        = (select top (1) rtrim(name) " +
+            "                            from a_employee_mi with (NOLOCK) " +
+            "                            where code = modifier) /*停止人*/, " +
+            "                           end_time /*停止时间*/, " +
+            "                           b.new_ward as                                    zkWardCode, " +
+            "                           b.new_dept as                                    zkDeptCode, " +
+            "                           kss.yyfs, " +
+            "                           kss.ssqk, " +
+            "                           kss.yysj, " +
+            "    executer1            = (select name from a_employee_mi where code = executer1), " +
+            "    executer2=             (select name from a_employee_mi where code = executer2) " +
+            "from yz_act_order a with (NOLOCK) " +
+            "         left join " +
+            "     zy_order_zk b with (NOLOCK) on (a.act_order_no = b.act_order_no) " +
+            "         left join " +
+            "     yz_act_record_kss kss on (a.act_order_no = kss.act_order_no) " +
+            "where convert(varchar(10), order_time, 120) = CONVERT(varchar(10), getdate(), 120) " +
+            "  and a.inpatient_no = #{patNo} " +
+            "  and a.admiss_times = #{times} " +
+            "  and frequ_code = 'ONCE' " +
+            "  and status_flag > '1' " +
+            "  and serial <> '00' " +
+            "union all " +
+            "select                     a.act_order_no, " +
+            "                           cast(cast(a.act_order_no as decimal) as varchar) id, " +
+            "                           order_code, " +
+            "                           order_name, " +
+            "                           rtrim(frequ_code)                                frequ_code, " +
+            "    frequ_code_name      = (select rtrim(comm) " +
+            "                            from yz_order_frequency " +
+            "                            where code = frequ_code), " +
+            "                           instruction, " +
+            "                           discription, " +
+            "                           infant_flag, " +
+            "                           order_time, " +
+            "                           physician, " +
+            "                           start_time, " +
+            "                           drug_specification, " +
+            "                           drug_quan, " +
+            "    drug_quan_name       = (select name " +
+            "                            from yp_zd_unit with (NOLOCK) " +
+            "                            where code = mini_unit), " +
+            "                           supply_code, " +
+            "    supply_code_name     = (select supply_name " +
+            "                            from yz_supply_type with (NOLOCK) " +
+            "                            where yz_supply_type.supply_code = a.supply_code), " +
+            "                           a.inpatient_no, " +
+            "                           a.admiss_times, " +
+            "                           drug_flag, " +
+            "                           enter_oper, " +
+            "    enter_oper_name      = (select top (1) rtrim(name) " +
+            "                            from a_employee_mi with (NOLOCK) " +
+            "                            where code = enter_oper) /* 录入人 */, " +
+            "                           enter_time, " +
+            "                           mini_unit, " +
+            "                           drug_weight, " +
+            "                           drug_weight_unit, " +
+            "                           rtrim(status_flag)                               status_flag, " +
+            "                           status_time, " +
+            "                           parent_no, " +
+            "    parent_no_name       = (select kfc.order_name from yz_act_order kfc where kfc.act_order_no = a.parent_no), " +
+            "                           self_buy, " +
+            "                           dose, " +
+            "                           dose_unit, " +
+            "    dose_unit_name       = (select name " +
+            "                            from yp_zd_unit with (NOLOCK) " +
+            "                            where dose_unit = code), " +
+            "                           drug_occ, " +
+            "                           drug_volume, " +
+            "                           drug_vol_unit, " +
+            "                           exclu_back_time, " +
+            "                           exclu_act_order_no, " +
+            "                           pay_self, " +
+            "                           serial, " +
+            "                           group_no, " +
+            "                           signer, " +
+            "                           cl_code, " +
+            "                           doctor_flag, " +
+            "                           emergency_flag, " +
+            "    exclu_type='', " +
+            "    end_time_b=end_time, " +
+            "                           exec_unit, " +
+            "                           dept_code, " +
+            "                           ward_code, " +
+            "    new_flag='0', " +
+            "    order_no_pattern=0, " +
+            "    suprice_flag='', " +
+            "    self_flag            ='', " +
+            "    pack_size=0.0, " +
+            "    parent_no_c=           -1000, " +
+            "                           reg_flag, " +
+            "    parent_flag='', " +
+            "                           yb_self_flag, " +
+            "                           kf_flag, " +
+            "                           refer_physician, " +
+            "                           consult_physician, " +
+            "    physician_name       = (select top (1) rtrim(name) " +
+            "                            from a_employee_mi with (NOLOCK) " +
+            "                            where code = physician) /* 开这个医嘱的医生 */, " +
+            "    exec_unit_name       = (select top (1) rtrim(name) " +
+            "                            from zd_unit_code with (NOLOCK) " +
+            "                            where code = exec_unit), " +
+            "    /*管床医生*/ " +
+            "    refer_physician_name = (select rtrim(name) " +
+            "                            from a_employee_mi with (NOLOCK) " +
+            "                            where code = refer_physician), " +
+            "    group_no_name        = (select rtrim(group_name) " +
+            "                            from yp_zd_group_name with (NOLOCK) " +
+            "                            where a.group_no = group_no), " +
+            "    signer_name          = (select top (1) rtrim(name) " +
+            "                            from a_employee_mi with (NOLOCK) " +
+            "                            where code = signer) /*确认人*/, " +
+            "                           confirm_time /*确认时间*/, " +
+            "                           modifier, " +
+            "    modifier_name        = (select top (1) rtrim(name) " +
+            "                            from a_employee_mi with (NOLOCK) " +
+            "                            where code = modifier) /*停止人*/, " +
+            "                           end_time /*停止时间*/, " +
+            "                           b.new_ward as                                    zkWardCode, " +
+            "                           b.new_dept as                                    zkDeptCode, " +
+            "                           kss.yyfs, " +
+            "                           kss.ssqk, " +
+            "                           kss.yysj, " +
+            "    executer1            = (select name from a_employee_mi where code = executer1), " +
+            "    executer2=             (select name from a_employee_mi where code = executer2) " +
+            "from yz_act_order a with (NOLOCK) " +
+            "         left join " +
+            "     zy_order_zk b with (NOLOCK) on (a.act_order_no = b.act_order_no) " +
+            "         left join " +
+            "     yz_act_record_kss kss on (a.act_order_no = kss.act_order_no) " +
+            "where " +
+            "  a.inpatient_no = #{patNo} " +
+            "  and a.admiss_times = #{times} " +
+            "  and frequ_code <> 'ONCE' " +
+            "  and status_flag in ('3', '4') " +
+            "  and serial <> '00' " +
+            " ")
+    List<XinZhenYzActOrder> getHistoricalMedicalOrders(@Param("patNo") String patNo,
+                                                       @Param("times") Integer times);
+
     @Select("select allergen_code code, b.name as name, case b.class when 'A' then '1' when 'B' then '2' end as type " +
             "from patient_allergen_info a, " +
             "     zd_allergen b " +
             "where a.allergen_code = b.code " +
-            "  and pat_no = '0363308' " +
+            "  and pat_no = #{patNo} " +
             "  and a.type = 0 " +
             "union all " +
             "select allergen_code, (select name from yp_zd_dict where yp_zd_dict.code = allergen_code) as allergenName, type = 5 " +
             "from patient_allergen_info " +
-            "where pat_no = '0363308' " +
+            "where pat_no = #{patNo} " +
             "  and type = 1")
     List<XunHuanJieDian> guoMin(@Param("patNo") String patNo);
 

+ 7 - 0
src/main/java/thyyxxk/webserver/entity/heliyongyao/RationalUsePatient.java

@@ -1,6 +1,7 @@
 package thyyxxk.webserver.entity.heliyongyao;
 
 import lombok.Data;
+import thyyxxk.webserver.utils.StringUtil;
 
 /**
  * <p>
@@ -77,5 +78,11 @@ public class RationalUsePatient {
      */
     private String pregnant;
 
+    public String getSexName() {
+        if (StringUtil.isBlank(sex)) {
+            return "未知";
+        }
+        return "1".equals(sex) ? "男" : "女";
+    }
 
 }

+ 52 - 30
src/main/java/thyyxxk/webserver/service/heliyongyao/RationalUseServer.java

@@ -56,9 +56,11 @@ public class RationalUseServer {
                 .eq("isnull(a.self_buy,'0')", "0")
                 .ne("a.serial", "00");
         XinZhenYiZhu patInfo = orderDao.queryPatientInfo(patNo, times);
-        // 获取医嘱列表
+        // 获取新开的医嘱
         patInfo.setList(orderDao.selectOrderNo(qw));
-        JSONObject js = verify(patInfo);
+        List<XinZhenYzActOrder> historicalData = dao.getHistoricalMedicalOrders(patNo, times);
+
+        JSONObject js = verify(patInfo, historicalData);
         return ResultVoUtil.success(js);
     }
 
@@ -72,7 +74,7 @@ public class RationalUseServer {
         return ResultVoUtil.success(http.auditingInterface(url));
     }
 
-    public JSONObject verify(XinZhenYiZhu param) {
+    public JSONObject verify(XinZhenYiZhu param, List<XinZhenYzActOrder> historicalData) {
         String userCode = TokenUtil.getTokenUserId();
         // 医生信息
         Map<String, String> doctMap = doctorInfo(userCode);
@@ -81,7 +83,31 @@ public class RationalUseServer {
         List<XinZhenYzActOrder> yp = new ArrayList<>();
         QueryWrapper<?> qw = new QueryWrapper<>();
         List<String> drugList = new ArrayList<>();
-        for (XinZhenYzActOrder item : param.getList()) {
+        addTheDrugCode(param.getList(), yp, drugList);
+        addTheDrugCode(historicalData, yp, drugList);
+
+        if (ListUtil.isBlank(drugList)) {
+            return new JSONObject();
+        }
+        qw.in("rtrim(code) + rtrim(serial)", drugList);
+        Map<String, YaoPin> drugMap = dao.selectDrug(qw).stream().collect(
+                Collectors.toMap(YaoPin::getId, a -> a, (k1, k2) -> k1)
+        );
+        String detailsXml = drugInfoFunc(param.getInpatientNo(), param.getAdmissTimes(), yp, doctXml, drugMap, historicalData);
+        String js = String.format("{\"BaseXml\": \"%s\", \"DetailsXml\" : \"%s\"}", baseXml, detailsXml);
+        log.info("js:{}", js);
+        return http.rationalUse(js);
+    }
+
+    /**
+     * 添加药品编码
+     *
+     * @param list
+     * @param yp
+     * @param drugList
+     */
+    private static void addTheDrugCode(List<XinZhenYzActOrder> list, List<XinZhenYzActOrder> yp, List<String> drugList) {
+        for (XinZhenYzActOrder item : list) {
             if (StringUtil.notBlank(item.getSerial())) {
                 if (!"00".equals(item.getSerial())) {
                     yp.add(item);
@@ -92,17 +118,6 @@ public class RationalUseServer {
                 }
             }
         }
-        if (ListUtil.isBlank(drugList)) {
-            return new JSONObject();
-        }
-        qw.in("rtrim(code) + rtrim(serial)", drugList);
-        Map<String, YaoPin> drugMap = dao.selectDrug(qw).stream().collect(
-                Collectors.toMap(YaoPin::getId, a -> a, (k1, k2) -> k1)
-        );
-
-        String detailsXml = drugInfoFunc(param.getInpatientNo(), param.getAdmissTimes(), yp, doctXml, drugMap);
-        String js = String.format("{\"BaseXml\": \"%s\", \"DetailsXml\" : \"%s\"}", baseXml, detailsXml);
-        return http.rationalUse(js);
     }
 
     public Map<String, String> doctorInfo(String code) {
@@ -154,7 +169,8 @@ public class RationalUseServer {
                                Integer times,
                                List<XinZhenYzActOrder> drugData,
                                String doct,
-                               Map<String, YaoPin> drugMap) {
+                               Map<String, YaoPin> drugMap,
+                               List<XinZhenYzActOrder> historicalData) {
         log.info("数据:{}", JSON.toJSONString(drugData));
         StringBuilder sb = new StringBuilder();
         RationalUsePatient patient = dao.huanZheXinXi(patNo, times);
@@ -182,7 +198,7 @@ public class RationalUseServer {
                 .append("<name>").append(nullToBlank(patient.getName())).append("</name>")
                 .append("<is_infant>").append(PublicServer.getInfantFlag(patNo)).append("</is_infant>")
                 .append("<birth>").append(nullToBlank(patient.getBirth())).append("</birth>")
-                .append("<sex>").append(nullToBlank(patient.getSex())).append("</sex>")
+                .append("<sex>").append(nullToBlank(patient.getSexName())).append("</sex>")
                 .append("<weight>").append("</weight>")
                 .append("<height>").append("</height>")
                 .append("<id_card>").append(patient.getIdCard()).append("</id_card>")
@@ -223,7 +239,7 @@ public class RationalUseServer {
                 for (int i = 0; i < arr.size(); i++) {
                     JSONObject item = arr.getJSONObject(i);
                     XunHuanJieDian temp = new XunHuanJieDian();
-                    temp.setType("0");
+                    temp.setType("2");
                     temp.setCode(item.getString("code"));
                     temp.setName(item.getString("name"));
                     diagnosticData.add(temp);
@@ -235,14 +251,21 @@ public class RationalUseServer {
         xunHuanJieDian(sb, diagnosticData, "diagnose");
         sb.append("</diagnose_data>")
                 .append("</patient>");
+        sb.append("<prescription_data>");
+        // 循环处方节点
+        prescribingInformation(drugData, doct, drugMap, sb, 1);
+        prescribingInformation(historicalData, doct, drugMap, sb, 0);
 
-        // 处方信息
-        sb.append("<prescription_data>")
-                .append("<prescription>")
-                .append("<id>").append("0").append("</id>")
+        sb.append("</prescription_data></details_xml>");
+        return sb.toString();
+    }
+
+    private void prescribingInformation(List<XinZhenYzActOrder> drugData, String doct, Map<String, YaoPin> drugMap, StringBuilder sb,
+                                        int current) {
+        sb.append("<prescription>").append("<id>").append("0").append("</id>")
                 .append("<reason>").append("</reason>")
-                .append("<is_current>").append("1").append("</is_current>")
-                .append("<pres_type>").append("T").append("</pres_type>")
+                .append("<is_current>").append(current).append("</is_current>")
+                .append("<pres_type>").append("</pres_type>")
                 .append("<pres_time>").append(DateUtil.formatDatetime(new Date())).append("</pres_time>")
                 // 药品信息节点,可循环
                 .append("<medicine_data>");
@@ -255,7 +278,7 @@ public class RationalUseServer {
             sb.append("<medicine>")
                     .append("<cf_id>").append("0").append("</cf_id>")
                     .append("<oeridid>").append(item.getActOrderNo().stripTrailingZeros().toPlainString()).append("</oeridid>")
-                    .append("<is_current>").append("1").append("</is_current>")
+                    .append("<is_current>").append(current).append("</is_current>")
                     .append("<pres_type>").append("ONCE".equals(item.getFrequCode()) ? "T" : "L").append("</pres_type>")
                     .append("<pres_time>").append(DateUtil.formatDatetime(item.getOrderTime())).append("</pres_time>")
                     .append("<name>").append(item.getOrderName()).append("</name>")
@@ -264,12 +287,12 @@ public class RationalUseServer {
                     .append("<approval>").append(nullToBlank(yp.getPzwh())).append("</approval>")
                     .append("<spec>").append(nullToBlank(item.getDrugSpecification())).append("</spec>")
                     .append("<quantity>").append(nullToBlank(item.getDrugQuan() + item.getMiniUnitName())).append("</quantity>")
-                    .append("<group>").append(item.getParentNo() == null ? "" : item.getParentNo().stripTrailingZeros().toPlainString()).append("</group>")
+                    .append("<group>").append(item.getParentNo() == null ? item.getActOrderNo().stripTrailingZeros().toPlainString() : item.getParentNo().stripTrailingZeros().toPlainString()).append("</group>")
                     .append("<reason>").append("</reason>")
                     .append("<dose_unit>").append(nullToBlank(item.getDoseUnitName())).append("</dose_unit>")
                     .append("<dose>").append(item.getDose()).append("</dose>")
-                    .append("<kyzl>").append("</kyzl>")
-                    .append("<zl_unit>").append("</zl_unit>")
+                    .append("<kyzl>").append(item.getDose()).append("</kyzl>")
+                    .append("<zl_unit>").append(item.getDoseUnit()).append("</zl_unit>")
                     .append("<freq>").append("ZY").append(nullToBlank(item.getFrequCode())).append("</freq>")
                     .append("<administer>").append("ZY").append(item.getSupplyCode()).append("</administer>")
                     .append("<begin_time>").append(DateUtil.formatDatetime(item.getStartTime())).append("</begin_time>")
@@ -280,8 +303,7 @@ public class RationalUseServer {
                     .append("<money>").append(yp.getPackRetprice().multiply(item.getDrugQuan())).append("</money>")
                     .append("</medicine>");
         }
-        sb.append("</medicine_data></prescription></prescription_data></details_xml>");
-        return sb.toString();
+        sb.append("</medicine_data></prescription>");
     }
 
     /**

+ 10 - 1
src/main/java/thyyxxk/webserver/service/inpatient/PatientService.java

@@ -21,6 +21,7 @@ import thyyxxk.webserver.entity.drg.DiseInfoList;
 import thyyxxk.webserver.entity.drg.OprtInfoList;
 import thyyxxk.webserver.entity.inpatient.dismiss.ZyDisYbDiag;
 import thyyxxk.webserver.entity.inpatient.patient.*;
+import thyyxxk.webserver.entity.shitijian.TiJianYuYuePojo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.HuanZheFeiYong;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYiZhu;
 import thyyxxk.webserver.service.externalhttp.DrgWebServices;
@@ -151,7 +152,15 @@ public class PatientService {
             } catch (Exception e) {
                 continue;
             }
-            JSONArray oprtNameVals = oprtName.getJSONArray("value");
+            if (oprtName == null) {
+                continue;
+            }
+            JSONArray oprtNameVals = null;
+            try {
+                oprtNameVals = oprtName.getJSONArray("value");
+            } catch (Exception ignored) {
+            }
+
             if (null == oprtNameVals) {
                 continue;
             }