Pārlūkot izejas kodu

恩泽:病危通知书解析更改

wangsy 4 gadi atpakaļ
vecāks
revīzija
be2b3e6bf2

+ 29 - 20
structure-center/src/main/java/com/lantone/structure/facade/tran/CriticallyIllNoticeDocTran.java

@@ -2,8 +2,8 @@ package com.lantone.structure.facade.tran;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import com.lantone.common.util.StringUtil;
 import com.lantone.structure.facade.tran.util.CommonAnalysisUtil;
+import com.lantone.structure.util.MapUtil;
 import lombok.extern.slf4j.Slf4j;
 
 import java.util.*;
@@ -27,24 +27,39 @@ public class CriticallyIllNoticeDocTran extends TargetTran {
         Map<String, String> sourceMap = Maps.newHashMap();
         String dateStr = "";
         List<String> titles = CommonAnalysisUtil.sortTitles(
-                Lists.newArrayList("科别", "住院号", "入院日期", "入住院日期", "姓名", "性别", "年龄", "职业", "临床诊断", "病情概要", "病重情况", "病情危重情况", "主要抢救措施",
-                        "病人家属签名", "关系", "时间", "签名日期", "通知时间", "经治医师"),
+                Lists.newArrayList("科别", "住院号", "入院日期", "入住院日期", "姓名", "性别", "年龄", "职业", "临床诊断", "病情概要", "病重情况", "病情危重情况", "主要抢救措施"),
+//                        "病人家属签名", "关系", "时间", "签名日期", "通知时间", "经治医师"),
                 text
         );
+        text = text.replace("年   月   日   时   分", "");
         CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
         List<String> keys = Lists.newArrayList("病情概要", "主要抢救措施");
         if (sourceMap != null) {
-            joinWord(sourceMap, keys);
-            if (sourceMap.containsKey("时间")) {
-                dateStr = sourceMap.get("时间");
-            } else if (sourceMap.containsKey("签名日期")) {
-                dateStr = sourceMap.get("签名日期");
+            if (sourceMap.containsKey("主要抢救措施")) {
+                dateStr = sourceMap.get("主要抢救措施");
+                sourceMap.put("主要抢救措施", dateStr.substring(0, Math.max(0, dateStr.indexOf("病人家属签名"))));
             }
-            disDate(sourceMap, dateStr);
+            joinWord(sourceMap, keys);
+            List<String> listTitle = Lists.newArrayList(
+                    "病人家属签名", "关系", "签名日期", "通知时间", "经治医师", "科主任"
+            );
+            CommonAnalysisUtil.cutByTitlesNoColon(dateStr, listTitle, 0, sourceMap);
+            removeKey(sourceMap, "病情概要", "主要抢救措施");
+            disDate(sourceMap, "关系", "时间");
         }
         return sourceMap;
     }
 
+    private void disDate(Map sourceMap, String... args) {
+        Map<String, String> sourceMap_ = MapUtil.copyMap(sourceMap);
+        if (sourceMap.containsKey(args[0]) && sourceMap_.get(args[0]).contains(args[1])) {
+            int index = sourceMap_.get(args[0]).indexOf(args[1]);
+            sourceMap.put(args[0], sourceMap_.get(args[0]).substring(0, index));
+            sourceMap.put(args[0] + args[1], sourceMap_.get(args[0]).substring(index).replace(args[1], "").replaceAll("[::]", ""));
+        }
+    }
+
+
     private void joinWord(Map<String, String> sourceMap, List<String> keys) {
         StringBuffer sb = new StringBuffer();
         for (String key : keys) {
@@ -55,17 +70,10 @@ public class CriticallyIllNoticeDocTran extends TargetTran {
         sourceMap.put("病情概况及主要抢救措施", sb.toString());
     }
 
-    private void disDate(Map<String, String> sourceMap, String dateStr) {
-        if (StringUtil.isBlank(dateStr)) {
-            return;
-        }
-        int infIndex = dateStr.indexOf("通知时间");
-        int docIndex = dateStr.indexOf("经治医师");
-        if (infIndex > 0) {
-            sourceMap.put("时间", dateStr.substring(0, infIndex));
-            if (docIndex > infIndex) {
-                sourceMap.put("通知时间", dateStr.substring(infIndex, docIndex).replace("通知时间", ""));
-                sourceMap.put("经治医师", dateStr.substring(docIndex).replace("经治医师", ""));
+    private void removeKey(Map<String, String> sourceMap, String... args) {
+        for (String dateStr : args) {
+            if (sourceMap.containsKey(dateStr)) {
+                sourceMap.remove(dateStr);
             }
         }
     }
@@ -84,6 +92,7 @@ public class CriticallyIllNoticeDocTran extends TargetTran {
             "病人家属签名=法定代理人签名",
             "关系=法定代理人与患者关系",
             "时间=法定代理人签名日期时间",
+            "关系时间=法定代理人签名日期时间",
             "签名日期=法定代理人签名日期时间",
             "经治医师=医师签名"
     );