Quellcode durchsuchen

死亡病例讨论记录

chengyao vor 4 Jahren
Ursprung
Commit
662e03b06d

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

@@ -35,6 +35,9 @@ public class StructureFacade {
             case "阶段小结":
                 targetTran = new StagesSummaryTran();
                 break;
+            case "死亡病例讨论记录":
+                targetTran = new DeathCaseDiscussionTran();
+                break;
            /* case "上级医师查房记录":
                 targetTran = new WardRecordTran();
                 break;*/

+ 256 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/DeathCaseDiscussionTran.java

@@ -0,0 +1,256 @@
+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.DeathCaseDiscussDoc;
+
+import com.lantone.structure.util.MapUtil;
+import lombok.extern.slf4j.Slf4j;
+
+
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @Description:死亡病例讨论记录
+ * @author: cy
+ * @time: 2021/2/23 09:15
+ */
+@Slf4j
+public class DeathCaseDiscussionTran extends TargetTran {
+
+    @Override
+    public Map<String, String> convert(String text) {
+        DeathCaseDiscussDoc deathCaseDiscussDoc = new DeathCaseDiscussDoc();
+        deathCaseDiscussDoc.setText(text);
+        inputInfo.setDeathCaseDiscussDoc(deathCaseDiscussDoc);
+        Map<String, String> structureMap = cutWord(text);
+        Map<String, String> retMap = new HashMap<String, String>();
+        deathCaseDiscussContrast(inputInfo.getDeathCaseDiscussDoc(), 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
+        );
+        //单独处理参加人员(截取依据:护士不会汇报病史,而且汇报病史的人会出现在参加人员中,所以会有一个人的名字出现两次)
+        List<String> ftitles = CommonAnalysisUtil.sortTitles(
+                Lists.newArrayList("﹙副﹚主任医师","主治医师","医师","护士"),
+                text
+        );
+       /* String stringDate =extractDate(text) ;
+        if(StringUtils.isNotEmpty(stringDate)){
+            sourceMap.put("讨论日期时间",stringDate);
+        }*/
+        CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
+        CommonAnalysisUtil.cutByTitles(text, ftitles, 0, sourceMap);
+        if(sourceMap.containsKey("性别")||sourceMap.containsKey("床号")||sourceMap.containsKey("汇报病史")||sourceMap.containsKey("护士")){
+            sourceMap.remove("性别");
+            sourceMap.remove("床号");
+            sourceMap.remove("汇报病史");
+            sourceMap.remove("护士");
+        }
+
+        return sourceMap;
+    }
+
+    public static String parseString(String text){
+        if(text.contains("/")){
+            text = text.substring(0,text.lastIndexOf("/"));
+            text= parseString(text);
+        }
+        return text;
+    }
+
+    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 extractDate(String top) {
+        Pattern pattern = Pattern.compile("[0-9]{4}[-][0-9]{1,2}[-][0-9]{1,2}([ ][0-9]{1,2}[:][0-9]{1,2}([:][0-9]{1,2})?)?");
+        Matcher matcher = pattern.matcher(top);
+        if (matcher.find()) {
+            return matcher.group(0);
+        } else {
+            Pattern p1 = Pattern.compile("[0-9]{4}年[0-9]+月[0-9]+日[0-9]+时[0-9]+分");
+            Matcher m1 = p1.matcher(top);
+            if (m1.find()) {
+                return m1.group(0);
+            }
+        }
+        return null;
+    }
+
+    public void deathCaseDiscussContrast( DeathCaseDiscussDoc deathCaseDiscussDoc, Map<String, String> retMap) {
+        if(deathCaseDiscussDoc != null){
+            //姓名
+            if(StringUtil.isNotEmpty(retMap.get("姓名"))){
+                String value= resultHandle(retMap.get("姓名"));
+                retMap.put("姓名",value);
+            }
+
+            //年龄
+         if(StringUtil.isNotEmpty(retMap.get("年龄"))){
+             String value= resultHandle(retMap.get("年龄"));
+             if (value.contains("岁")) {
+                 retMap.put("年龄(岁)",value);
+                 retMap.remove("年龄");
+             }
+             if(value.contains("月")){
+                 retMap.put("年龄(月)",value);
+                 retMap.remove("年龄");
+             }
+         }
+
+            //参加讨论人员名单
+         // "﹙副﹚主任医师","主治医师","医师"),
+            List<String> attendNames = new ArrayList<>();
+            String targetRet = "";
+                if(StringUtil.isNotEmpty(retMap.get("参加人员"))){
+                    if(StringUtil.isNotEmpty(retMap.get("﹙副﹚主任医师"))) {
+                        String rName = retMap.get("﹙副﹚主任医师");
+                        transAdd(rName, attendNames);
+                        retMap.remove("﹙副﹚主任医师");
+                    }
+                    if(StringUtil.isNotEmpty(retMap.get("主治医师"))) {
+                        String rName = retMap.get("主治医师");
+                        transAdd(rName, attendNames);
+                        retMap.remove("主治医师");
+                    }
+                    if(StringUtil.isNotEmpty(retMap.get("医师"))) {
+                        String rName = retMap.get("医师");
+                        transAdd(rName, attendNames);
+                        retMap.remove("医师");
+                    }
+                    String attendName = retMap.get("参加人员");
+                    String spiltString = attendName.substring(attendName.indexOf("护士"), attendName.lastIndexOf("医师"));
+                    for (String name : attendNames) {
+                        if(spiltString.contains(name)){
+                            targetRet = attendName.substring(0, attendName.lastIndexOf(name));
+                        }
+                    }
+
+                    retMap.put("参加人员",targetRet);
+                }
+
+
+            //直接死亡原因名称
+            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 directSummary = retMap.get("主持人总结");
+                String trueRet = "";
+                String signDateTime = "";
+                if(directSummary.contains("主持人(签名)") && directSummary.contains("记录者(签名)")){
+                    trueRet = directSummary.substring( directSummary.indexOf("主持人(签名)")+7, directSummary.indexOf("记录者(签名)"));
+                }
+                if(StringUtil.isNotEmpty(trueRet)){
+                    retMap.put("主任医师签名",trueRet);
+                }
+
+                //签名日期时间
+                if(directSummary.contains("记录者(签名)")) {
+                    signDateTime = directSummary.substring(directSummary.indexOf("记录者(签名)") + 7);
+                    if (StringUtil.isNotEmpty(signDateTime)) {
+                        retMap.put("签名日期时间", signDateTime);
+                    }
+                }
+            }
+
+            //主持人总结
+            if(StringUtil.isNotEmpty(retMap.get("主持人总结"))){
+                String directSummary = retMap.get("主持人总结");
+                String trueRet = "";
+                if(directSummary.contains("主持人(签名)")){
+                    trueRet = directSummary.substring(0, directSummary.indexOf("主持人(签名)"));
+                }
+                retMap.put("主持人总结",trueRet);
+            }
+
+
+        }
+
+    }
+
+    private String resultHandle(String value) {
+            if (StringUtil.isNotBlank(value)) {
+                value = StringUtil.trim(value);
+                if (value.endsWith(",") || value.endsWith(",")) {
+                    value = value.substring(0, value.length() - 1);
+                }
+            }
+        return value;
+    }
+    public void transAdd(String name, List<String> attendName){
+          if(name.contains("、")){
+              String value = name.substring(name.lastIndexOf("、")+1);
+              if(StringUtil.isNotEmpty(value)){
+                  attendName.add(value);
+              }
+              transAdd(name.substring(0, name.lastIndexOf("、")), attendName);
+          }else{
+              attendName.add(name);
+          }
+    }
+
+}