Sfoglia il codice sorgente

死亡记录/出院小结

chengyao 4 anni fa
parent
commit
fc2d2589b6

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

@@ -38,6 +38,12 @@ public class StructureFacade {
             case "死亡病例讨论记录":
                 targetTran = new DeathCaseDiscussionTran();
                 break;
+            case "死亡记录":
+                targetTran = new DeathRecordTran();
+                break;
+            case "出院小结":
+                targetTran = new LeaveHospitalTran();
+                break;
            /* case "上级医师查房记录":
                 targetTran = new WardRecordTran();
                 break;*/

+ 161 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/DeathRecordTran.java

@@ -0,0 +1,161 @@
+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.model.doc.DeathRecordDoc;
+import com.lantone.structure.util.MapUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.time.DateUtils;
+
+
+import java.util.*;
+
+
+/**
+ * @Description:死亡记录
+ * @author: cy
+ * @time: 2021/2/24 09:33
+ */
+@Slf4j
+public class DeathRecordTran extends TargetTran {
+
+    @Override
+    public Map<String, String> convert(String text) {
+        DeathRecordDoc deathRecordDoc = new DeathRecordDoc();
+        deathRecordDoc.setText(text);
+        inputInfo.setDeathRecordDoc(deathRecordDoc);
+        Map<String, String> structureMap = cutWord(text);
+        Map<String, String> retMap = new HashMap<String, String>();
+        deathRecordContrast(inputInfo.getDeathRecordDoc(), structureMap);
+        mapKeyContrastCommon(structureMap,stagesContrasts,retMap);
+        return retMap;
+    }
+
+    private List<String> stagesContrasts = Lists.newArrayList(
+            "姓名=患者姓名",
+            "入院日期=入院日期时间",
+            "诊疗经过=诊疗过程描述",
+            "死亡日期=死亡日期时间",
+            "死亡诊断=死亡诊断名称"
+    );
+    private Map<String, String> cutWord(String text) {
+        Map<String, String> sourceMap = Maps.newHashMap();
+        List<String> titles = CommonAnalysisUtil.sortTitles(
+                //
+                Lists.newArrayList("姓名","性别","年龄","职业","入院日期","入院诊断", "死亡日期",
+                        "住院天数","死亡诊断","入院情况","诊疗经过", "抢救措施","死亡诊断","死亡原因(包括死亡讨论结果)"),
+                text
+        );
+
+        CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
+        if(sourceMap.containsKey("性别")||sourceMap.containsKey("职业")||sourceMap.containsKey("住院天数")
+                ||sourceMap.containsKey("入院诊断")  ||sourceMap.containsKey("抢救措施")){
+            sourceMap.remove("性别");
+            sourceMap.remove("职业");
+            sourceMap.remove("住院天数");
+            sourceMap.remove("入院诊断");
+            sourceMap.remove("抢救措施");
+        }
+        return sourceMap;
+    }
+
+
+    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));
+            }
+        }
+    }
+
+
+    /**
+     * 抽取文本中的最后时间
+     *
+     * @param top
+     * @return
+     */
+    public static String lastTime(String top) {
+        int length = top.trim().length();
+        String stringDate = top.trim().substring(length - 12, length);
+        Date date = null;
+        try {
+             date = DateUtils.parseDate(stringDate, StringUtil.dateFormats);
+        } catch (Exception e) {
+           log.error(e.getMessage(),e);
+        }
+        if(date!= null){
+            return stringDate;
+        }else{
+            return "";
+        }
+    }
+
+
+    public void deathRecordContrast(  DeathRecordDoc deathRecordDoc, Map<String, String> retMap) {
+        if(deathRecordDoc != null) {
+            //年龄
+            if (StringUtil.isNotEmpty(retMap.get("年龄"))) {
+                String value = retMap.get("年龄");
+                if (value.contains("岁")) {
+                    retMap.put("年龄(岁)", value);
+                    retMap.remove("年龄");
+                }
+                if (value.contains("月")) {
+                    retMap.put("年龄(月)", value);
+                    retMap.remove("年龄");
+                }
+            }
+
+
+            //直接死亡原因名称
+            if (StringUtil.isNotEmpty(retMap.get("死亡诊断"))) {
+                String deathDiagnosislName = retMap.get("死亡诊断");
+                String trueRet = "";
+                if (deathDiagnosislName.contains("2.")) {
+                    trueRet = deathDiagnosislName.substring(0, deathDiagnosislName.indexOf("2."));
+                    if (trueRet.contains("1.")) {
+                        trueRet = trueRet.substring(2);
+                    }
+                }
+                retMap.put("直接死亡原因名称", trueRet);
+            }
+
+
+            //签名日期时间
+            if(StringUtil.isNotEmpty(retMap.get("死亡原因(包括死亡讨论结果)"))){
+                String lastText = retMap.get("死亡原因(包括死亡讨论结果)");
+                String sginTime= lastTime(lastText);
+                if(StringUtil.isNotEmpty(sginTime)){
+                    retMap.put("签名日期时间", sginTime);
+                }
+                retMap.remove("死亡原因(包括死亡讨论结果)");
+            }
+
+
+        }
+    }
+
+
+}

+ 131 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/LeaveHospitalTran.java

@@ -0,0 +1,131 @@
+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.model.doc.LeaveHospitalDoc;
+import com.lantone.structure.util.MapUtil;
+import lombok.extern.slf4j.Slf4j;
+
+
+import java.util.*;
+
+/**
+ * @Description:出院小结
+ * @author: cy
+ * @time: 2021/2/24 09:33
+ */
+@Slf4j
+public class LeaveHospitalTran extends TargetTran {
+
+    @Override
+    public Map<String, String> convert(String text) {
+        LeaveHospitalDoc leaveHospitalDoc = new LeaveHospitalDoc();
+        leaveHospitalDoc.setText(text);
+        inputInfo.setLeaveHospitalDoc(leaveHospitalDoc);
+        Map<String, String> structureMap = cutWord(text);
+        Map<String, String> retMap = new HashMap<String, String>();
+        leaveHospitalContrast(inputInfo.getLeaveHospitalDoc(), structureMap);
+        mapKeyContrastCommon(structureMap,stagesContrasts,retMap);
+        return retMap;
+    }
+
+    private List<String> stagesContrasts = Lists.newArrayList(
+            "入院日期=入院日期时间",
+            "出院日期=出院日期时间",
+            "阳性结果=阳性辅助检查结果",
+            "治疗经过=诊疗过程描述",
+            "经治/主治医师=住院医师签名",
+            "首席医师=上级医师签名",
+            "填写日期=签名日期时间"
+    );
+    private Map<String, String> cutWord(String text) {
+        Map<String, String> sourceMap = Maps.newHashMap();
+        List<String> titles = CommonAnalysisUtil.sortTitles(
+                //
+                Lists.newArrayList("入院日期","出院日期","入院诊断","入院情况","阳性结果","阴性结果","住院期间的辅助检查","治疗经过","出院情况","并发症","治疗效果","出院医嘱","出院注意事项","首席医师","经治/主治医师","填写日期"),
+                text
+        );
+
+        CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
+        if(sourceMap.containsKey("入院诊断")||(sourceMap.containsKey("住院期间的辅助检查"))||(sourceMap.containsKey("出院注意事项"))||sourceMap.containsKey("阴性结果")){
+            sourceMap.remove("入院诊断");
+            sourceMap.remove("住院期间的辅助检查");
+            sourceMap.remove("出院注意事项");
+            sourceMap.remove("阴性结果");
+        }
+        return sourceMap;
+    }
+
+
+    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));
+            }
+        }
+    }
+
+
+
+
+
+    public void leaveHospitalContrast( LeaveHospitalDoc leaveHospitalDoc, Map<String, String> retMap) {
+        if (leaveHospitalDoc != null) {
+            if (StringUtil.isNotEmpty(retMap.get("经治/主治医师"))) {
+                String value = retMap.get("经治/主治医师");
+                String retValue = parseString(value);
+                retMap.put("经治/主治医师",retValue);
+            }
+            if (StringUtil.isNotEmpty(retMap.get("出院日期"))) {
+                String value = retMap.get("出院日期");
+                if (value.contains("日")) {
+                    String[] targetStr = value.split("日");
+                    retMap.put("出院日期", targetStr[0]+"日");
+                    retMap.put("实际住院天数", targetStr[1]);
+                }
+            }
+
+            if (StringUtil.isNotEmpty(retMap.get("出院情况"))) {
+                retMap.put("出院时症状与体征", retMap.get("出院情况"));
+                if (StringUtil.isNotEmpty(retMap.get("并发症"))) {
+                    retMap.put("出院情况", retMap.get("出院情况")+"并发症:"+retMap.get("并发症"));
+                }
+                if (StringUtil.isNotEmpty(retMap.get("治疗效果"))) {
+                    retMap.put("出院情况", retMap.get("出院情况")+"治疗效果:"+retMap.get("治疗效果"));
+                }
+                retMap.remove("并发症");
+                retMap.remove("治疗效果");
+
+            }
+        }
+    }
+
+    public static String parseString(String text){
+        if(text.contains("/")){
+            text = text.substring(text.lastIndexOf("/")+1);
+            text= parseString(text);
+        }
+        return text;
+    }
+}