Procházet zdrojové kódy

恩泽:crf模型病危通知书映射

wangsy před 4 roky
rodič
revize
5934d9e37f

+ 6 - 0
structure-center/src/main/java/com/lantone/structure/facade/StructureFacade.java

@@ -71,6 +71,12 @@ public class StructureFacade {
             case "首次病程记录":
                 targetTran = new FirstCourseRecordTran();
                 break;
+            case "病危通知书":
+                targetTran = new CriticallyIllNoticeDocTran();
+                break;
+//            case "手术知情同意书":
+//                targetTran = new OperationInformedConsentDocTran();
+//                break;
             default:
                 break;
         }

+ 90 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/CriticallyIllNoticeDocTran.java

@@ -0,0 +1,90 @@
+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 lombok.extern.slf4j.Slf4j;
+
+import java.util.*;
+
+/**
+ * @Description:病危通知书
+ * @author: wsy
+ * @time: 2021/3/08 11:29
+ */
+@Slf4j
+public class CriticallyIllNoticeDocTran extends TargetTran {
+    @Override
+    public Map<String, String> convert(String text) {
+        Map<String, String> structureMap = cutWord(text);
+        Map<String, String> retMap = new HashMap<String, String>();
+        CommonAnalysisUtil.mapKeyContrastCommon(structureMap, keyContrasts, retMap);
+        return retMap;
+    }
+
+    private Map<String, String> cutWord(String text) {
+        Map<String, String> sourceMap = Maps.newHashMap();
+        String dateStr = "";
+        List<String> titles = CommonAnalysisUtil.sortTitles(
+                Lists.newArrayList("科别", "住院号", "入院日期", "入住院日期", "姓名", "性别", "年龄", "职业", "临床诊断", "病情概要", "病重情况", "病情危重情况", "主要抢救措施",
+                        "病人家属签名", "关系", "时间", "签名日期", "通知时间", "经治医师"),
+                text
+        );
+        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("签名日期");
+            }
+            disDate(sourceMap, dateStr);
+        }
+        return sourceMap;
+    }
+
+    private void joinWord(Map<String, String> sourceMap, List<String> keys) {
+        StringBuffer sb = new StringBuffer();
+        for (String key : keys) {
+            if (sourceMap.containsKey(key)) {
+                sb.append(key + ":" + sourceMap.get(key)).append("\r\n");
+            }
+        }
+        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 List<String> keyContrasts = Lists.newArrayList(
+            "科别=病区名称",
+            "科室=科室名称",
+            "姓名=患者姓名",
+            "病房=病房号",
+            "病床=病床号",
+            "年龄=年龄(岁)",
+            "病重情况=病危(重)通知内容",
+            "病情危重情况=病危(重)通知内容",
+            "通知时间=病危(重)通知日期时间",
+            "病人家属签名=法定代理人签名",
+            "关系=法定代理人与患者关系",
+            "时间=法定代理人签名日期时间",
+            "签名日期=法定代理人签名日期时间",
+            "经治医师=医师签名"
+    );
+}

+ 69 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/OperationInformedConsentDocTran.java

@@ -0,0 +1,69 @@
+package com.lantone.structure.facade.tran;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.lantone.structure.facade.tran.util.CommonAnalysisUtil;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description:手术知情同意书
+ * @author: wsy
+ * @time: 2021/3/08 15:29
+ */
+@Slf4j
+public class OperationInformedConsentDocTran extends TargetTran {
+    @Override
+    public Map<String, String> convert(String text) {
+        Map<String, String> structureMap = cutWord(text);
+        Map<String, String> retMap = new HashMap<String, String>();
+        CommonAnalysisUtil.mapKeyContrastCommon(structureMap, keyContrasts, retMap);
+        return retMap;
+    }
+
+    private Map<String, String> cutWord(String text) {
+        Map<String, String> sourceMap = Maps.newHashMap();
+        List<String> titles = CommonAnalysisUtil.sortTitles(
+                Lists.newArrayList("二、您的主刀医师是", "三、术前诊断", "拟实施手术名称", "手术指征", "四、医师会用通俗易懂的语言向您解释", "(1)告知可能发生的意外、并发症或风险",
+                        "(2)告知手术后可能出现 的意外和并发症", "3.特殊风险或主要高危因素", "针对上述情况医师将采取的防范措施", "五、替代治疗方案及优缺点", "患者及家属要求手术治疗,并签字为证",
+                        "七、医师声明", "书写者签名", "主刀医师签名", "八、患方意见", "患者(代理人)签名"),
+                text
+        );
+        CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
+        if (sourceMap != null) {
+            disDate(sourceMap, "书写者签名", "签名时间");
+            disDate(sourceMap, "患者(代理人)签名", "签名时间");
+            disDate(sourceMap, "患者及家属要求手术治疗,并签字为证", "七、医师声明");
+            disDate(sourceMap, "主刀医师签名", "八、患方意见");
+        }
+        return sourceMap;
+    }
+
+    private void disDate(Map<String, String> sourceMap, String... args) {
+        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],""));
+        }
+    }
+
+
+    private List<String> keyContrasts = Lists.newArrayList(
+            "三、术前诊断=术前诊断",
+            "拟实施手术名称=拟实施手术及操作日期时间",
+            "(1)告知可能发生的意外、并发症或风险=手术中可能出现的意外及风险",
+            "(2)告知手术后可能出现的意外和并发症=手术后可能出现的意外及并发症",
+            "五、替代治疗方案及优缺点=替代方案",
+            "患者(代理人)签名=患者签名",
+            "患者(代理人)签名=法定代理人签名",
+            "主刀医师签名=手术者签名",
+            "书写者签名=经治医师签名",
+            "书写者签名签名时间=医师签名日期时间",
+            "患者(代理人)签名签名时间=患者/法定代理人签名日期时间",
+            "患者及家属要求手术治疗,并签字为证七、医师声明=医疗机构意见",
+            "主刀医师签名八、患方意见=患者/法定代理人意见"
+    );
+}

+ 29 - 3
structure-center/src/main/java/com/lantone/structure/facade/tran/util/CommonAnalysisUtil.java

@@ -2,11 +2,10 @@ package com.lantone.structure.facade.tran.util;
 
 import com.google.common.collect.Lists;
 import com.lantone.common.util.StringUtil;
+import com.lantone.structure.util.MapUtil;
 import lombok.extern.slf4j.Slf4j;
 
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -257,4 +256,31 @@ public class CommonAnalysisUtil {
             }
         }
     }
+
+    public static void mapKeyContrastCommon(Map sourceMap, List<String> keyContrasts, Map<String, String> retMap) {
+        Map<String, String> sourceMap_ = MapUtil.copyMap(sourceMap);
+        String[] arry = null;
+        String sourceKey = null, targetKey;
+        Set<String> removeKey = new HashSet<>();
+        for (String keyContrast : keyContrasts) {
+            arry = keyContrast.split("=");
+            sourceKey = arry[0];
+            if (arry.length == 1) {
+                targetKey = arry[0];
+            } else {
+                targetKey = arry[1];
+            }
+            if (StringUtil.isNotBlank(sourceMap_.get(sourceKey))
+                    && (!retMap.containsKey(targetKey) || StringUtil.isBlank(retMap.get(targetKey)))) {
+                retMap.put(targetKey, sourceMap_.get(sourceKey));
+            }
+            removeKey.add(sourceKey);
+        }
+        Set<String> keySet = retMap.keySet();
+        for (String key : sourceMap_.keySet()) {
+            if (!keySet.contains(key) && !removeKey.contains(key)) { // 如果之前已放过key就不用放了
+                retMap.put(key, sourceMap_.get(key));
+            }
+        }
+    }
 }