Quellcode durchsuchen

危重患者无上级医师(副高及以上)查房记录

weixuanhuang vor 5 Jahren
Ursprung
Commit
c9818d8276

+ 104 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0434.java

@@ -0,0 +1,104 @@
+package com.lantone.qc.kernel.catalogue.threelevelward;
+
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.util.CatalogueUtil;
+import com.lantone.qc.pub.Content;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.doc.SeriouslyIllNoticeDoc;
+import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
+import com.lantone.qc.pub.util.ListUtil;
+import com.lantone.qc.pub.util.StringUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+/**
+ * @ClassName : THR0434
+ * @Description : 危重患者无上级医师(副高及以上)查房记录
+ * @Author : Mark
+ * @Date: 2020-04-05 16:10
+ */
+@Component
+public class THR0434 extends QCCatalogue {
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        status.set("0");
+        if (ListUtil.isEmpty(inputInfo.getSeriouslyIllNoticeDocs()) || ListUtil.isEmpty(inputInfo.getThreeLevelWardDocs())) {
+            return;
+        }
+        List<SeriouslyIllNoticeDoc> seriouslyIllNoticeDocs = inputInfo.getSeriouslyIllNoticeDocs(); //病危通知书
+        Map<Date, Map<String, String>> dateRecord = new TreeMap<>(new Comparator<Date>() {
+            @Override
+            public int compare(Date o1, Date o2) {
+                // 降序排列
+                return o1.compareTo(o2);
+            }
+        });//按时间key排序,存放病危通知书、查房记录
+        String recordTime = "", title = "";
+        for (SeriouslyIllNoticeDoc seriouslyIllNoticeDoc : seriouslyIllNoticeDocs) {
+            Map<String, String> seriouslyIllNoticeDocMap = seriouslyIllNoticeDoc.getStructureMap();
+            recordTime = seriouslyIllNoticeDocMap.get("签名时间");
+            Date recordDate = StringUtil.parseDateTime(recordTime);
+            if (recordDate == null) {
+                continue;
+            }
+            dateRecord.put(recordDate, seriouslyIllNoticeDocMap);
+        }
+        dateRecord = extractSeriouslyIll(dateRecord);//24小时内记录只取第一条
+        List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();//查房记录
+        for (ThreeLevelWardDoc threeLevelWardDoc : threeLevelWardDocs) {
+            Map<String, String> rescueStructureMap = threeLevelWardDoc.getStructureMap();
+            recordTime = rescueStructureMap.get("查房日期");
+            title = CatalogueUtil.subTitle(rescueStructureMap.get("查房标题"));
+            Date recordDate = StringUtil.parseDateTime(recordTime);
+            if (recordDate == null || StringUtil.isBlank(title) || !title.contains(Content.director)) {//只存副高以上查房记录
+                continue;
+            }
+            dateRecord.put(recordDate, rescueStructureMap);
+        }
+
+        List<Map<String, String>> dateRecordList = new ArrayList<>(dateRecord.values());
+        //如果最后一条是病危通知书,则之后肯定没有查房记录
+        if (dateRecordList.get(dateRecordList.size() - 1).containsKey("病程记录名称")) {
+            status.set("-1");
+            return;
+        }
+        for (int i = 0; i < dateRecordList.size(); i++) {
+            if (i != dateRecordList.size() - 1) {
+                //当前为病危通知书
+                if (!dateRecordList.get(i).containsKey("签名时间")) {
+                    continue;
+                }
+                //病危通知书下一条不是查房记录则报错
+                if (!dateRecordList.get(i + 1).containsKey("查房日期")) {
+                    status.set("-1");
+                    return;
+                }
+            }
+        }
+    }
+
+    /**
+     * 抽取24小时内第一条记录
+     *
+     * @param dateRecord
+     */
+    private Map<Date, Map<String, String>> extractSeriouslyIll(Map<Date, Map<String, String>> dateRecord) {
+        Map<Date, Map<String, String>> record = new TreeMap<>(new Comparator<Date>() {
+            @Override
+            public int compare(Date o1, Date o2) {
+                // 降序排列
+                return o1.compareTo(o2);
+            }
+        });
+        Date lastDate = null;
+        for (Map.Entry<Date, Map<String, String>> dateRecordEntry : dateRecord.entrySet()) {
+            Date difficultCaseDiscussDate = dateRecordEntry.getKey();
+            if (lastDate == null || CatalogueUtil.compareTime(lastDate, difficultCaseDiscussDate, (long) (24 * 60))) {
+                lastDate = difficultCaseDiscussDate;
+                record.put(difficultCaseDiscussDate, dateRecordEntry.getValue());
+            }
+        }
+        return record;
+    }
+}