Ver código fonte

术前小结

chengyao 4 anos atrás
pai
commit
6b93efa6e3

+ 27 - 3
structure-center/src/main/java/com/lantone/structure/ai/process/EntityProcessOperation.java

@@ -20,22 +20,46 @@ public class EntityProcessOperation extends EntityProcess {
         try {
 
             //过敏史
+            StringBuffer sbxx = new StringBuffer();
+            int allergy = 0;
             List<Lemma> indicationAllergy = createEntityTree(aiOut, EntityEnum.ALLERGYRECORD.toString());
             for (Lemma lemma : indicationAllergy) {
-                preoperativeDiscussionLabel.setAllergyRecord(lemma.getText());
+                allergy++;
+                if(indicationAllergy.size()>1){
+                    sbxx.append(allergy+lemma.getText()+" ");
+                }else{
+                    sbxx.append(lemma.getText());
+                }
             }
+            preoperativeDiscussionLabel.setAllergyRecord(sbxx.toString());
 
             //手术禁忌症
+            StringBuffer sbx = new StringBuffer();
+            int opContrain = 0;
             List<Lemma> indicationOpContrain = createEntityTree(aiOut, EntityEnum.OPCONTRAINDICATION.toString());
             for (Lemma lemma : indicationOpContrain) {
-                preoperativeDiscussionLabel.setOpContraindication(lemma.getText());
+                opContrain++;
+                if(indicationOpContrain.size()>1){
+                    sbx.append(opContrain+lemma.getText()+" ");
+                }else{
+                    sbx.append(lemma.getText());
+                }
             }
+            preoperativeDiscussionLabel.setOpContraindication(sbx.toString());
 
             //拟实施手术目标部位名称
+          StringBuffer sb = new StringBuffer();
+            int count = 0;
             List<Lemma> indicationOpBottom = createEntityTree(aiOut, EntityEnum.OPBOTTOMNAME.toString());
             for (Lemma lemma : indicationOpBottom) {
-                preoperativeDiscussionLabel.setOpBottomName(lemma.getText());
+                count++;
+                if(indicationOpBottom.size()>1){
+                    sb.append(count+lemma.getText()+" ");
+                }else{
+                    sb.append(lemma.getText());
+                }
             }
+            preoperativeDiscussionLabel.setOpBottomName(sb.toString());
         } catch (Exception e) {
             e.printStackTrace();
             logger.error(e.getMessage(), e);

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

@@ -95,6 +95,9 @@ public class StructureFacade {
             case "术前讨论":
                 targetTran = new PreoperativeDiscussionTran();
                 break;
+            case "术后首次病程记录":
+                targetTran = new OperationDiscussionTran();
+                break;
             default:
                 break;
         }

+ 4 - 7
structure-center/src/main/java/com/lantone/structure/facade/tran/DeathRecordTran.java

@@ -46,16 +46,13 @@ public class DeathRecordTran extends TargetTran {
         Map<String, String> sourceMap = Maps.newHashMap();
         List<String> titles = CommonAnalysisUtil.sortTitles(
                 //
-                Lists.newArrayList("姓名","性别","年龄","职业","入院日期","入院时间","入院诊断", "死亡日期","死亡时间","主    诉",
+                Lists.newArrayList("姓名","姓    名","性别","性    别","年龄","年    龄","业"," 职    业","入院日期","入院时间","入院诊断", "死亡日期","死亡时间","主    诉",
                         "住院天数","死亡诊断","最后诊断","入院情况","流行病史","表格<诊断>内容","诊疗经过", "治疗经过","抢救措施","死亡原因","死亡原因(包括死亡讨论结果)"),
                 text
         );
 
         CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
-        if(sourceMap.containsKey("性别")||sourceMap.containsKey("职业")||sourceMap.containsKey("住院天数")
-                ||sourceMap.containsKey("入院诊断")  ||sourceMap.containsKey("流行病史")  ||sourceMap.containsKey("补充诊断")){
-            sourceMap.remove("性别");
-            sourceMap.remove("职业");
+        if(sourceMap.containsKey("住院天数")||sourceMap.containsKey("入院诊断")  ||sourceMap.containsKey("流行病史")  ||sourceMap.containsKey("补充诊断")){
             sourceMap.remove("住院天数");
             sourceMap.remove("入院诊断");
             sourceMap.remove("流行病史");
@@ -262,7 +259,7 @@ public class DeathRecordTran extends TargetTran {
             if (StringUtil.isEmpty(retMap.get("入院时间"))) {
                 retMap.remove("入院时间");
             }
-            String text = deathRecordDoc.getText();
+      /*      String text = deathRecordDoc.getText();
             String[] split = text.split("\n");
             for (int i = 0; i < split.length; i++) {
                 if( split[i].contains("姓    名:")){
@@ -299,7 +296,7 @@ public class DeathRecordTran extends TargetTran {
                     }
                 }
 
-            }
+            }*/
         }
     }
 

+ 139 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/OperationDiscussionTran.java

@@ -0,0 +1,139 @@
+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.operation.OperationDiscussionDoc;
+import com.lantone.structure.model.doc.operation.OperationDoc;
+import com.lantone.structure.model.doc.operation.PreoperativeDiscussionDoc;
+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/3/16 14:12
+ */
+@Slf4j
+public class OperationDiscussionTran extends TargetTran {
+
+    @Override
+    public Map<String, String> convert(String text) {
+         List<OperationDoc> operationDocs = new ArrayList<>();
+        OperationDoc operationDoc  = new OperationDoc();
+        OperationDiscussionDoc operationDiscussionDoc  = new OperationDiscussionDoc();
+        operationDiscussionDoc.setText(text);
+        operationDoc.setOperationDiscussionDoc(operationDiscussionDoc);
+        operationDocs.add(operationDoc);
+        inputInfo.setOperationDocs(operationDocs);
+        Map<String, String> structureMap = new HashMap<String, String>();
+        Map<String, String> retMap = new HashMap<String, String>();
+            structureMap = cutWord(text);
+        oDContrast(inputInfo.getOperationDocs(), structureMap);
+        mapKeyContrastCommon(structureMap,stagesContrasts,retMap);
+      //  preoperativeDiscussionDoc.setStructureMap(retMap);
+     //   aiProcess();
+    //    lastSovle(inputInfo.getOperationDocs(),retMap);
+        return retMap;
+    }
+
+    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.remove("术前诊断");
+        }
+        return sourceMap;
+    }
+
+    private List<String> stagesContrasts = Lists.newArrayList(
+            "手术指征=手术指征",
+            "手术指征=手术适应证"
+    );
+
+    public void oDContrast(List<OperationDoc> operationDocs,Map<String, String> retMap) {
+        String text = operationDocs.get(0).getOperationDiscussionDoc().getText();
+        if(text.contains("\n")){
+            String[] split = text.split("\n");
+            for (int i = 0; i < split.length; i++) {
+                if(i<=1){
+                    String date= extractDate(split[i]);
+                    if(StringUtil.isNotEmpty(date)){
+                        retMap.put("记录日期时间",date);
+                    }
+                }
+            }
+        }
+        if(text.contains("患者诊断")){
+            String sureStr = text.substring(text.indexOf("患者诊断") + "患者诊断".length());
+            if(sureStr.contains("禁忌症")){
+                sureStr = sureStr.substring(0,sureStr.indexOf("禁忌症"));
+            }
+            if(sureStr.contains("手术指征")){
+                sureStr = sureStr.substring(0,sureStr.indexOf("手术指征"));
+            }
+            if(sureStr.contains("明确")){
+                sureStr = sureStr.substring(0,sureStr.indexOf("明确"));
+            }
+            retMap.put("术后诊断名称",sureStr);
+        }
+
+    }
+
+    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}");
+        Matcher matcher = pattern.matcher(top);
+        if (matcher.find()) {
+            return matcher.group(0);
+        } else {
+            Pattern p1 = Pattern.compile("[0-9]{4}年[0-9]+月[0-9]+日");
+            Matcher m1 = p1.matcher(top);
+            if (m1.find()) {
+                return m1.group(0);
+            }
+        }
+        return null;
+    }
+}

+ 8 - 4
structure-center/src/main/java/com/lantone/structure/facade/tran/PreoperativeDiscussionTran.java

@@ -97,10 +97,14 @@ public class PreoperativeDiscussionTran extends TargetTran {
         String text = operationDocs.get(0).getPreoperativeDiscussionDoc().getText();
         if(flag == false){
         //小结日期时间
-        String sumdDate = extractDate(text);
-        if(StringUtil.isNotEmpty(sumdDate)){
-            retMap.put("小结日期时间",sumdDate);
-        }
+            if(text.contains("简要病情")){
+                String caseFile = text.substring(0,text.indexOf("简要病情:"));
+                String sumdDate = extractDate(caseFile);
+                if(StringUtil.isNotEmpty(sumdDate)){
+                    retMap.put("小结日期时间",sumdDate);
+                }
+            }
+
 
         //病历摘要   诊断依据
         if(StringUtil.isNotEmpty(retMap.get("简要病情"))) {