|
@@ -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) {
|