DESKTOP-0GD05B0\Administrator преди 2 години
родител
ревизия
6a77908763

+ 15 - 0
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/EmrControlRuleController.java

@@ -1,7 +1,9 @@
 package thyyxxk.webserver.controller.zhuyuanyizheng;
 
 import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.config.auth.PassToken;
 import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emrcontrolrule.QualityControlAnalysisOfMedicalRecords;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emrcontrolrule.RuleAdd;
 import thyyxxk.webserver.service.zhuyuanyisheng.EmrControlRuleSever;
 
@@ -29,4 +31,17 @@ public class EmrControlRuleController {
     public ResultVo<List<Map<String, Object>>> getAvailableObjects() {
         return server.getAvailableObjects();
     }
+
+    @GetMapping("/text")
+    @PassToken
+    public void text() {
+        server.hospitalWidePatients();
+    }
+
+    @GetMapping("/accessToYourOwnPatientMedicalRecords")
+    @PassToken
+    public ResultVo<List<QualityControlAnalysisOfMedicalRecords>> accessToYourOwnPatientMedicalRecords() {
+        return server.accessToYourOwnPatientMedicalRecords();
+    }
+
 }

+ 18 - 0
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/EmrControlDao.java

@@ -81,4 +81,22 @@ public interface EmrControlDao {
                                           Date date,
                                           List<String> codeList);
 
+    @Select("select rtrim(code_rs) " +
+            "from dj_user_role a, " +
+            "     a_employee_mi b " +
+            "where role_id = 38 " +
+            "  and a.user_code = b.code " +
+            "  and isnull(b.del_flag, 0) = 0")
+    List<String> peopleWhoGetMedicalDepartment();
+
+    @Select("select rtrim(inpatient_no)                                                  as inpatient_no, " +
+            "       admiss_times, " +
+            "       (select rtrim(name) from zd_unit_code where code = zk_ward)          as deptName, " +
+            "       (select rtrim(name) from a_employee_mi where code = refer_physician) as tubeBedDoctorName, " +
+            "       admiss_date " +
+            "from zy_actpatient " +
+            "where refer_physician = '01038'")
+    List<QualityControlAnalysisOfMedicalRecords> accessToYourOwnPatientMedicalRecords(String code);
+
+
 }

+ 25 - 0
src/main/java/thyyxxk/webserver/scheduled/ResidentPhysicians.java

@@ -0,0 +1,25 @@
+package thyyxxk.webserver.scheduled;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import thyyxxk.webserver.service.zhuyuanyisheng.EmrControlRuleSever;
+
+@Component
+public class ResidentPhysicians {
+    @Value("${execute-scheduled}")
+    private Boolean executeScheduled;
+    private final EmrControlRuleSever emrControlRuleSever;
+
+    public ResidentPhysicians(EmrControlRuleSever emrControlRuleSever) {
+        this.emrControlRuleSever = emrControlRuleSever;
+    }
+
+    @Scheduled(cron = "0 0 8 * * ?")
+    public void qualityControlOfMedicalRecords() {
+        if (executeScheduled) {
+            emrControlRuleSever.hospitalWidePatients();
+        }
+    }
+
+}

+ 52 - 21
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/EmrControlRuleSever.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
@@ -65,7 +66,7 @@ public class EmrControlRuleSever {
         return ResultVoUtil.success(dao.getAvailableObjects());
     }
 
-    // todo 完成质控发送消息
+
     public void hospitalWidePatients() {
         List<QualityControlAnalysisOfMedicalRecords> list;
         String admissDate = dao.selectedSpecifyTheTimeOfAdmissionSql();
@@ -73,30 +74,28 @@ public class EmrControlRuleSever {
             return;
         }
         list = dao.selectedPatientsAdmittedAtTheSpecifiedTime(admissDate);
-        getPatientsAdmittedAtTheSpecifiedTime(list);
+        getPatientsAdmittedAtTheSpecifiedTime(list, true);
     }
 
-    public void getPatientsAdmittedAtTheSpecifiedTime(List<QualityControlAnalysisOfMedicalRecords> list) {
-        Map<String, QualityControlAnalysisOfMedicalRecords> retainPatientInformation = new HashMap<>(list.size());
+    public List<QualityControlAnalysisOfMedicalRecords> getPatientsAdmittedAtTheSpecifiedTime(List<QualityControlAnalysisOfMedicalRecords> patientList, boolean whetherToSendTheMessage) {
+        Map<String, QualityControlAnalysisOfMedicalRecords> retainPatientInformation = new HashMap<>(patientList.size());
         List<EmrRule> ruleList = dao.selectedRules();
-        Map<String, Map<String, Integer>> messageBody = new HashMap<>();
-        try {
-            Thread.sleep(5000);
-        } catch (Exception ignored) {
-        }
-
+        Map<String, Map<String, Integer>> messageBody = new LinkedHashMap<>(ruleList.size());
 
         for (EmrRule rule : ruleList) {
             List<String> code = dao.selectedEmrCode(rule.getId());
             String sql = rule.getSql();
-            Map<String, Integer> count = new HashMap<>(Capacity.FOUR);
-            count.put("超时创建", 0);
+            Map<String, Integer> count = new LinkedHashMap<>(Capacity.FOUR);
+
+            if (whetherToSendTheMessage) {
+                count.put("通过质控", 0);
+            }
+
             count.put("超时未创建", 0);
+            count.put("超时创建", 0);
             count.put("未超时未创建", 0);
-            count.put("通过质控", 0);
-            count.put("质控人数", list.size());
 
-            for (QualityControlAnalysisOfMedicalRecords p : list) {
+            for (QualityControlAnalysisOfMedicalRecords p : patientList) {
                 medicalRecordData(retainPatientInformation, p);
                 String replacementSql = sql.replace("#{PATNO}", "'" + p.getInpatientNo() + "'")
                         .replace("#{TIMES}", "'" + p.getAdmissTimes() + "'");
@@ -104,32 +103,64 @@ public class EmrControlRuleSever {
                 if (executeSql == null) {
                     continue;
                 }
-                // 是否超时 true  false
+                // 是否超时 true 超时 false
                 boolean whetherToTimeOut = DateUtil.moreThanHours((Date) executeSql.get("date"), rule.getPrescription());
-                // 是否创建
+                // 是否创建 true 创建 false
                 boolean whetherToCreate = dao.determineWhetherTheDataWasCreated(p.getInpatientNo(), p.getAdmissTimes(), (Date) executeSql.get("date"), code) > 0;
                 String str = "";
 
                 if (whetherToTimeOut && whetherToCreate) {
                     str = "超时创建";
                 }
+
                 if (whetherToTimeOut && !whetherToCreate) {
                     str = "超时未创建";
                 }
+
                 if (!whetherToTimeOut && !whetherToCreate) {
                     str = "未超时未创建";
                 }
+
+                if (StringUtil.notBlank(str)) {
+                    p.setPromptStatements((p.getPromptStatements() == null ? "" : p.getPromptStatements() + ",") + rule.getPromptStatement());
+                }
+
                 if (!whetherToTimeOut && whetherToCreate) {
                     str = "通过质控";
                 }
+
                 count.replace(str, count.get(str) + 1);
-                messageBody.put(rule.getName(), count);
                 p.setMessage((p.getMessage() == null ? "" : p.getMessage() + ",") + rule.getName() + ":【" + str + "】");
             }
+            messageBody.put(rule.getName(), count);
         }
-        sendWxInfoService.sendCorpWxMsg("3811", JSON.toJSONString(messageBody));
-        log.info("发送消息:{}", JSON.toJSONString(messageBody));
-        log.info("数据:{}", JSON.toJSONString(list));
+
+        StringBuilder body = new StringBuilder();
+
+        body.append("时间:【").append(DateUtil.formatDatetime(new Date(), DateUtil.DEFAULT_PATTERN)).append("】\n");
+        body.append("质控人数:【").append(patientList.size()).append("】\n");
+
+        for (Map.Entry<String, Map<String, Integer>> item : messageBody.entrySet()) {
+            body.append(item.getKey()).append(": 【\n");
+            for (Map.Entry<String, Integer> entry : item.getValue().entrySet()) {
+                body.append("  ").append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
+            }
+            body.append("】\n");
+        }
+
+        if (whetherToSendTheMessage) {
+            dao.peopleWhoGetMedicalDepartment().forEach(item -> {
+                sendWxInfoService.sendCorpWxMsg(item, body.toString());
+            });
+        }
+        return patientList;
+    }
+
+    public ResultVo<List<QualityControlAnalysisOfMedicalRecords>> accessToYourOwnPatientMedicalRecords() {
+        List<QualityControlAnalysisOfMedicalRecords> list = dao.accessToYourOwnPatientMedicalRecords(TokenUtil.getTokenUserId());
+        getPatientsAdmittedAtTheSpecifiedTime(list, false);
+        log.info("本人科室:{}", JSON.toJSONString(list));
+        return ResultVoUtil.success(list);
     }
 
     private void medicalRecordData(Map<String, QualityControlAnalysisOfMedicalRecords> retainPatientInformation, QualityControlAnalysisOfMedicalRecords p) {