浏览代码

crf补充

chengyao 4 年之前
父节点
当前提交
1658b485fc

+ 18 - 17
structure-center/src/main/java/com/lantone/structure/ai/OperationAI.java

@@ -18,6 +18,7 @@ import com.lantone.structure.model.entity.Drug;
 import com.lantone.structure.model.label.OperationDiscussionLabel;
 import com.lantone.structure.model.label.OperationRecordLabel;
 import com.lantone.common.util.StringUtil;
+import com.lantone.structure.model.label.PreoperativeDiscussionLabel;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -34,7 +35,7 @@ public class OperationAI extends ModelAI {
     /**
      *
      */
-    public static List<String> medicalTextType = Arrays.asList("CourseAfterOperation_cx", "CourseRecordSRR","Taizhou_preoperativeDiscussion_record");
+    public static List<String> medicalTextType = Arrays.asList("CourseAfterOperation_cx", "CourseRecordSRR","Taizhou_pDiscussion_record");
     public static String entityRelationObject = "entity_relation_object";
     public static String outputs = "outputs";
     public static String content = "content";
@@ -51,10 +52,7 @@ public class OperationAI extends ModelAI {
                 String text = preoperativeDiscussionDoc.getText();
                 String opName = structureMap.get("拟实施手术及操作名称");
                 StringBuffer sb = new StringBuffer();
-                if(StringUtil.isNotEmpty(opName)){
-                    sb.append("拟实施手术名称:"+opName+"\n");
-                }
-
+                putContent(crfContent, medicalTextType.get(2),opName,Content.opName);
                 String opFlag = structureMap.get("手术指征");
                 if(StringUtil.isNotEmpty(opFlag)){
                     sb.append("手术指征:"+opFlag+"\n");
@@ -65,10 +63,15 @@ public class OperationAI extends ModelAI {
                     sb.append("简要病情:"+simCase+"\n");
                 }
 
+                String pillCase = structureMap.get("药物、食物过敏史");
+                if(StringUtil.isNotEmpty(pillCase) && StringUtil.isEmpty(simCase)){
+                    sb.append("药物、食物过敏史:"+pillCase+"\n");
+                }
+
                 if(StringUtil.isNotEmpty(sb.toString())){
                     text = sb.toString();
                 }
-                putContent(crfContent, medicalTextType.get(2),text, content, Content.preoperativeDiscussion);
+                putContent(crfContent, medicalTextType.get(2),text,Content.preoperativeDiscussion);
             }
             if (operationDocs.get(i).getOperationRecordDoc() != null) {
                 OperationRecordDoc operationRecordDoc = operationDocs.get(i).getOperationRecordDoc();
@@ -90,13 +93,13 @@ public class OperationAI extends ModelAI {
 
         JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
 
-/*        for (int i = 0; i < operationDocs.size(); i++) {
+        for (int i = 0; i < operationDocs.size(); i++) {
             if (midData.get(Content.preoperativeDiscussion) == null) {
                 continue;
             }
-            PreoperativeDiscussionDoc preoperativeDiscussionDoc = putPreoperativeDiscussionCrfData(midData.getJSONObject(Content.preoperativeDiscussion));
-            operationDocs.get(i).setPreoperativeDiscussionDoc(preoperativeDiscussionDoc);
-        }*/
+            putPreoperativeDiscussionCrfData(midData.getJSONObject(Content.preoperativeDiscussion),inputInfo);
+            putPreoperativeDiscussionCrfData(midData.getJSONObject(Content.opName),inputInfo);
+        }
 
         for (int i = 0; i < operationDocs.size(); i++) {
             if (midData.get("手术记录" + i + "药物") != null) {
@@ -140,7 +143,6 @@ public class OperationAI extends ModelAI {
 
     /**
      * 存放抓取的药品
-     *
      * @param jsonObject
      */
     public List<Drug> putDrugCrfData(JSONObject jsonObject) {
@@ -158,18 +160,17 @@ public class OperationAI extends ModelAI {
      *
      * @param jsonObject
      */
-    public PreoperativeDiscussionDoc putPreoperativeDiscussionCrfData(JSONObject jsonObject) {
-        PreoperativeDiscussionDoc preoperativeDiscussionDoc = new PreoperativeDiscussionDoc();
+    public void putPreoperativeDiscussionCrfData(JSONObject jsonObject,InputInfo inputInfo) {
         if (jsonObject == null) {
-            return preoperativeDiscussionDoc;
+            return;
         }
         JSONObject aiOut = jsonObject.getJSONObject(entityRelationObject).getJSONObject(BeHospitalizedAI.outputs);
         if (aiOut == null) {
-            return preoperativeDiscussionDoc;
+            return ;
         }
         EntityProcessOperation entityProcessOperation = new EntityProcessOperation();
-        PreoperativeDiscussionDoc preoperativeDiscussionDoc1 = entityProcessOperation.extractEntity(aiOut);
-        return preoperativeDiscussionDoc1;
+        PreoperativeDiscussionLabel preoperativeDiscussionLabel = entityProcessOperation.extractEntity(aiOut);
+        inputInfo.getOperationDocs().get(0).getPreoperativeDiscussionDoc().setPreoperativeDiscussionLabel(preoperativeDiscussionLabel);
     }
 
     protected void putContent(JSONArray crfContent, String medicalTextType, String text, String sign) {

+ 20 - 21
structure-center/src/main/java/com/lantone/structure/ai/ThreeLevelWardAI.java

@@ -38,34 +38,32 @@ public class ThreeLevelWardAI extends ModelAI {
     /**
      *
      */
-    public static List<String> medicalTextType = Arrays.asList("CourseRecord_cx", "CourseRecordLast_cx", "CourseRecordSRR","Taizhou_Ward_Record");
+    public static List<String> medicalTextType = Arrays.asList("CourseRecord_cx", "CourseRecordLast_cx", "CourseRecordSRR","Taizhou_ThreeLevelWard_Record");
     public static String entityRelationObject = "entity_relation_object";
     public static String outputs = "outputs";
     public static String content = "content";
 
     public void medrec(InputInfo inputInfo, CRFServiceClient crfServiceClient) {
         JSONArray crfContent = new JSONArray();
-        List<WardRecordDoc> wardRecordDocList = inputInfo.getWardRecordDocs();
-        if(ListUtil.isNotEmpty(wardRecordDocList)){
-            for (int i = 0; i < wardRecordDocList.size(); i++) {
-                String content = wardRecordDocList.get(i).getText();
-                putContent(crfContent, medicalTextType.get(3), content, Content.wardRecord);
-            }
+        List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
+        //  "============恩泽医嘱crf单独处理================="
+        if (ListUtil.isNotEmpty(threeLevelWardDocs) && StringUtil.isNotEmpty(threeLevelWardDocs.get(0).getText())) {
+            Map<String, String> structureMap = threeLevelWardDocs.get(0).getStructureMap();
+            if (StringUtil.isNotEmpty(structureMap.get("诊疗计划"))) {
+            String content = structureMap.get("诊疗计划");
+            putContent(crfContent, medicalTextType.get(3), content, Content.wardRecord);
+
             JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
-            for (int i = 0; i < wardRecordDocList.size(); i++) {
+            for (int i = 0; i < threeLevelWardDocs.size(); i++) {
                 if (midData.get(Content.wardRecord) == null) {
                     continue;
                 }
-                WardRecordDoc wardRecordDoc = wardRecordDocList.get(i);
-                ThreeLevelWardLabel threeLevelWardLabel = putRescueCrfData(midData.getJSONObject(Content.wardRecord), inputInfo);
-                if (threeLevelWardLabel != null) {
-                    wardRecordDoc.setThreeLevelWardLabel(threeLevelWardLabel);
-                }
+                putRescueCrfData(midData.getJSONObject(Content.wardRecord), inputInfo);
             }
-            return;
         }
+    }
+        //  "============恩泽医嘱crf单独处理完成================="
 
-        List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
         if (threeLevelWardDocs.size() == 0) {
             return;
         }
@@ -171,18 +169,19 @@ public class ThreeLevelWardAI extends ModelAI {
      *
      * @param jsonObject
      */
-    public ThreeLevelWardLabel putRescueCrfData(JSONObject jsonObject, InputInfo inputInfo) {
-        ThreeLevelWardLabel threeLevelWardLabel = new ThreeLevelWardLabel();
+    public void putRescueCrfData(JSONObject jsonObject, InputInfo inputInfo) {
         if (jsonObject == null) {
-            return threeLevelWardLabel;
+            return;
         }
         JSONObject aiOut = jsonObject.getJSONObject(entityRelationObject).getJSONObject(ThreeLevelWardAI.outputs);
         if (aiOut == null) {
-            return threeLevelWardLabel;
+            return;
         }
         EntityProcessThreeLevelWard entityProcessThreeLevelWard = new EntityProcessThreeLevelWard();
-        threeLevelWardLabel = entityProcessThreeLevelWard.extractEntityLate(aiOut);
-        return threeLevelWardLabel;
+        ThreeLevelWardLabel threeLevelWardLabel = entityProcessThreeLevelWard.extractEntityLate(aiOut);
+        List<ThreeLevelWardLabel> threeLevelWardLabels = new ArrayList<>();
+        threeLevelWardLabels.add(threeLevelWardLabel);
+        inputInfo.getThreeLevelWardDocs().get(0).setThreeLevelWardLabel(threeLevelWardLabels);
     }
 
     protected void putContent(JSONArray crfContent, String medicalTextType, String text, String sign, String wardDate) {

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

@@ -4,7 +4,7 @@ package com.lantone.structure.ai.process;
 import com.alibaba.fastjson.JSONObject;
 import com.lantone.structure.ai.model.EntityEnum;
 import com.lantone.structure.ai.model.Lemma;
-import com.lantone.structure.model.doc.operation.PreoperativeDiscussionDoc;
+import com.lantone.structure.model.label.PreoperativeDiscussionLabel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import java.util.List;
@@ -15,31 +15,31 @@ import java.util.List;
 public class EntityProcessOperation extends EntityProcess {
     private Logger logger = LoggerFactory.getLogger(EntityProcessOperation.class);
 
-    public PreoperativeDiscussionDoc extractEntity(JSONObject aiOut) {
-        PreoperativeDiscussionDoc preoperativeDiscussionDoc = new PreoperativeDiscussionDoc();
+    public PreoperativeDiscussionLabel extractEntity(JSONObject aiOut) {
+        PreoperativeDiscussionLabel preoperativeDiscussionLabel= new PreoperativeDiscussionLabel();
         try {
 
             //过敏史
             List<Lemma> indicationAllergy = createEntityTree(aiOut, EntityEnum.ALLERGYRECORD.toString());
             for (Lemma lemma : indicationAllergy) {
-                preoperativeDiscussionDoc.setAllergyRecord(lemma.getText());
+                preoperativeDiscussionLabel.setAllergyRecord(lemma.getText());
             }
 
             //手术禁忌症
             List<Lemma> indicationOpContrain = createEntityTree(aiOut, EntityEnum.OPCONTRAINDICATION.toString());
             for (Lemma lemma : indicationOpContrain) {
-                preoperativeDiscussionDoc.setOpContraindication(lemma.getText());
+                preoperativeDiscussionLabel.setOpContraindication(lemma.getText());
             }
 
             //拟实施手术目标部位名称
             List<Lemma> indicationOpBottom = createEntityTree(aiOut, EntityEnum.OPBOTTOMNAME.toString());
             for (Lemma lemma : indicationOpBottom) {
-                preoperativeDiscussionDoc.setOpBottomName(lemma.getText());
+                preoperativeDiscussionLabel.setOpBottomName(lemma.getText());
             }
         } catch (Exception e) {
             e.printStackTrace();
             logger.error(e.getMessage(), e);
         }
-        return preoperativeDiscussionDoc;
+        return preoperativeDiscussionLabel;
     }
 }

+ 0 - 5
structure-center/src/main/java/com/lantone/structure/ai/process/EntityProcessThreeLevelWard.java

@@ -37,11 +37,6 @@ public class EntityProcessThreeLevelWard extends EntityProcess {
             if(ListUtil.isNotEmpty(lemma)){
                 threeLevelWardLabel.setDoctorAdviceRecord(lemma.get(0).getText());
             }
-            //诊疗计划
-        List<Lemma> lemmaTree = createEntityTree(aiOut, EntityEnum.ASSESSMENTPLAN.toString());
-        if(ListUtil.isNotEmpty(lemmaTree)){
-            threeLevelWardLabel.setAssessmentPlan(lemmaTree.get(0).getText());
-        }
         return threeLevelWardLabel;
     }
 

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

@@ -56,8 +56,8 @@ public class StructureFacade {
             case "疑难病例讨论记录":
                 targetTran = new DifficultCaseDiscussTran();
                 break;
-        /*    case "上级医师查房记录":
-                targetTran = new WardRecordTran();
+          /*  case "上级医师查房记录":
+                targetTran = new ThreeLevelWardTran();
                 break;*/
             default:
                 break;

+ 21 - 18
structure-center/src/main/java/com/lantone/structure/facade/tran/PreoperativeDiscussionTran.java

@@ -8,8 +8,6 @@ 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;
@@ -44,14 +42,17 @@ public class PreoperativeDiscussionTran extends TargetTran {
     private Map<String, String> cutWord(String text) {
         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("术前诊断") ){
+        if(sourceMap.containsKey("手术方式") || sourceMap.containsKey("术前诊断")  || sourceMap.containsKey("月经史")
+                || sourceMap.containsKey("一般情况")){
             sourceMap.remove("手术方式");
             sourceMap.remove("术前诊断");
+            sourceMap.remove("月经史");
+            sourceMap.remove("一般情况");
         }
         return sourceMap;
     }
@@ -234,20 +235,22 @@ public class PreoperativeDiscussionTran extends TargetTran {
     }
 
 
-    public static Map lastSovle(List<OperationDoc> operationDocs,Map<String,String> rep) {
-        PreoperativeDiscussionDoc preoperativeDiscussionDoc = operationDocs.get(0).getPreoperativeDiscussionDoc();
-        String allergyRecord = preoperativeDiscussionDoc.getAllergyRecord();
-        String opBottomName = preoperativeDiscussionDoc.getOpBottomName();
-        String opContraindication = preoperativeDiscussionDoc.getOpContraindication();
-        if(StringUtil.isNotEmpty(allergyRecord)){
-            rep.put("过敏史",allergyRecord);
-        }
-        if(StringUtil.isNotEmpty(opBottomName)){
-            rep.put("拟实施手术目标部位名称",opBottomName);
-        }
-        if(StringUtil.isNotEmpty(opContraindication)){
-            rep.put("手术禁忌症",opContraindication);
+    public static void lastSovle(List<OperationDoc> operationDocs , Map<String,String> rep) {
+        if(!operationDocs.isEmpty() && operationDocs.get(0)!=null && operationDocs.get(0)
+                .getPreoperativeDiscussionDoc()!=null){
+            PreoperativeDiscussionDoc preoperativeDiscussionDoc = operationDocs.get(0).getPreoperativeDiscussionDoc();
+            String allergyRecord = preoperativeDiscussionDoc.getPreoperativeDiscussionLabel().getAllergyRecord();
+            String opBottomName = preoperativeDiscussionDoc.getPreoperativeDiscussionLabel().getOpBottomName();
+            String opContraindication = preoperativeDiscussionDoc.getPreoperativeDiscussionLabel().getOpContraindication();
+            if(StringUtil.isNotEmpty(allergyRecord)){
+                rep.put("过敏史",allergyRecord);
+            }
+            if(StringUtil.isNotEmpty(opBottomName)){
+                rep.put("拟实施手术目标部位名称",opBottomName);
+            }
+            if(StringUtil.isEmpty(rep.get("手术禁忌症")) && StringUtil.isNotEmpty(opContraindication)){
+                rep.put("手术禁忌症",opContraindication);
+            }
         }
-        return rep;
     }
 }

+ 21 - 15
structure-center/src/main/java/com/lantone/structure/facade/tran/WardRecordTran.java

@@ -2,17 +2,11 @@ package com.lantone.structure.facade.tran;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import com.lantone.common.util.ListUtil;
 import com.lantone.common.util.StringUtil;
 import com.lantone.structure.facade.tran.util.CommonAnalysisUtil;
-import com.lantone.structure.model.doc.RescueDoc;
 import com.lantone.structure.model.doc.ThreeLevelWardDoc;
-import com.lantone.structure.model.doc.WardRecordDoc;
-import com.lantone.structure.model.entity.*;
-import com.lantone.structure.model.label.RescueLabel;
+import com.lantone.structure.model.label.ThreeLevelWardLabel;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -25,19 +19,20 @@ import java.util.regex.Pattern;
  * @time: 2021/2/20 14:07
  */
 @Slf4j
-public class WardRecordTran extends TargetTran {
+public class ThreeLevelWardTran extends TargetTran {
 
     @Override
     public Map<String, String> convert(String text) {
-        List<WardRecordDoc> wardRecordDocList = new ArrayList<>();
-        WardRecordDoc wardRecordDoc = new WardRecordDoc();
+        List<ThreeLevelWardDoc> wardRecordDocList = new ArrayList<>();
+        ThreeLevelWardDoc wardRecordDoc = new ThreeLevelWardDoc();
         wardRecordDoc.setText(text);
         wardRecordDocList.add(wardRecordDoc);
-        inputInfo.setWardRecordDocs(wardRecordDocList);
-        aiProcess();
-      //  ============================封装完成==============================
+        inputInfo.setThreeLevelWardDocs(wardRecordDocList);
         Map<String, String> structureMap = cutWord(text);
-        wardRecordContrast(inputInfo.getWardRecordDocs(), structureMap);
+        wardRecordContrast(inputInfo.getThreeLevelWardDocs(), structureMap);
+        wardRecordDoc.setStructureMap(structureMap);
+        aiProcess();
+        lastSovle(inputInfo.getThreeLevelWardDocs(),structureMap);
         return structureMap;
     }
 
@@ -56,7 +51,7 @@ public class WardRecordTran extends TargetTran {
     }
 
 
-    public void wardRecordContrast(  List<WardRecordDoc> wardRecordDoc,Map<String, String> retMap) {
+    public void wardRecordContrast( List<ThreeLevelWardDoc> wardRecordDoc,Map<String, String> retMap) {
         String text = wardRecordDoc.get(0).getText();
         //查房日期时间
         String sumdDate = extractDate(text);
@@ -106,4 +101,15 @@ public class WardRecordTran extends TargetTran {
         }
         return null;
     }
+
+    public static void lastSovle(List<ThreeLevelWardDoc> threeLevelWardDocs, Map<String,String> structureMap) {
+        if(!threeLevelWardDocs.isEmpty() && threeLevelWardDocs.get(0)!=null && threeLevelWardDocs.get(0)
+                .getThreeLevelWardLabel()!=null){
+            ThreeLevelWardLabel threeLevelWardLabel = threeLevelWardDocs.get(0).getThreeLevelWardLabel().get(0);
+            String doctorAdviceRecord = threeLevelWardLabel.getDoctorAdviceRecord();
+            if(StringUtil.isNotEmpty(doctorAdviceRecord)){
+                structureMap.put("医嘱内容",doctorAdviceRecord);
+            }
+        }
+    }
 }

+ 1 - 0
structure-center/src/main/java/com/lantone/structure/model/Content.java

@@ -251,6 +251,7 @@ public class Content {
 
     public static final String timestamp = "timestamp";
     public static final String  preoperativeDiscussion = "术前小结";
+    public static final String  opName = "拟实施手术及操作名称";
     public static final String bloodRecord = "输血记录";
     public static final String stagesSummary = "阶段小结";
     public static final String rescue = "抢救记录";

+ 0 - 2
structure-center/src/main/java/com/lantone/structure/model/InputInfo.java

@@ -79,8 +79,6 @@ public class InputInfo {
     private List<StagesSummaryDoc> stagesSummaryDocs = new ArrayList<>();
     //查房记录
     private List<ThreeLevelWardDoc> threeLevelWardDocs = new ArrayList<>();
-    //上级医师查房记录
-    private List<WardRecordDoc> wardRecordDocs = new ArrayList<>();
     //知情同意书
     private InformedConsentDoc informedConsentDoc;
     //谈话告知书

+ 3 - 3
structure-center/src/main/java/com/lantone/structure/model/doc/operation/PreoperativeDiscussionDoc.java

@@ -1,6 +1,7 @@
 package com.lantone.structure.model.doc.operation;
 
 import com.lantone.structure.model.doc.ModelDoc;
+import com.lantone.structure.model.label.PreoperativeDiscussionLabel;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -14,7 +15,6 @@ import lombok.Setter;
 @Setter
 public class PreoperativeDiscussionDoc extends ModelDoc {
     private String operationName;
-    private String allergyRecord;//过敏史
-    private String opContraindication;//手术禁忌症
-    private String opBottomName;//拟实施手术目标部位名称
+    private PreoperativeDiscussionLabel preoperativeDiscussionLabel;
+
 }

+ 18 - 0
structure-center/src/main/java/com/lantone/structure/model/label/PreoperativeDiscussionLabel.java

@@ -0,0 +1,18 @@
+package com.lantone.structure.model.label;
+import lombok.Getter;
+import lombok.Setter;
+
+
+/**
+ * @ClassName : preoperativeDiscussionLabel
+ * @Description :
+ * @Author : cy
+ * @Date: 2021-03-01 17:04
+ */
+@Getter
+@Setter
+public class PreoperativeDiscussionLabel {
+    private String allergyRecord;//过敏史
+    private String opContraindication;//手术禁忌症
+    private String opBottomName;//拟实施手术目标部位名称
+}

+ 0 - 1
structure-center/src/main/java/com/lantone/structure/model/label/ThreeLevelWardLabel.java

@@ -36,5 +36,4 @@ public class ThreeLevelWardLabel {
     private List<AuxiliaryExamination> auxiliaryExaminations = new ArrayList<>();  //辅助检查
     private List<Drug> drugs = new ArrayList<>();  //药物
     private String doctorAdviceRecord;//医嘱内容
-    private String assessmentPlan;//诊疗计划
 }