ソースを参照

处理辅检模型

kongwz 4 年 前
コミット
95d01ead71

+ 7 - 6
src/main/java/com/diagbot/facade/CommonFacade.java

@@ -7,7 +7,6 @@ import com.diagbot.client.CRFServiceClient;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.enums.StandConvertEnum;
 import com.diagbot.model.ai.AIAnalyze;
-import com.diagbot.model.entity.PacsNew;
 import com.diagbot.model.label.*;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
@@ -96,9 +95,10 @@ public class CommonFacade {
         //所有辅助检查(结构化数据)
         List<String> allPacs = new ArrayList<>();
 //        List<Pacs> pacs = wordCrfDTO.getPacs();
-        List<PacsNew> pacsNews = wordCrfDTO.getPacsLabel().getPacsNewList();
-        if (ListUtil.isNotEmpty(pacsNews)) {
-            List<String> pacss_unique = pacsNews.stream().filter(x -> StringUtils.isBlank(x.getUniqueName()))
+//        List<PacsNew> pacsNews = wordCrfDTO.getPacsLabel().getPacsNewList();
+        List<com.diagbot.model.entity.Pacs> pacses = wordCrfDTO.getPacsLabel().getPacses();
+        if (ListUtil.isNotEmpty(pacses)) {
+            List<String> pacss_unique = pacses.stream().filter(x -> StringUtils.isBlank(x.getStandName()))
                     .map(x -> x.getName()).collect(Collectors.toList());
             allPacs.addAll(pacss_unique);
         }
@@ -144,7 +144,8 @@ public class CommonFacade {
         DiagLabel diagLabel = wordCrfDTO.getDiagLabel();
         List<Lis> lis = wordCrfDTO.getLis();
 //        List<Pacs> pacs = wordCrfDTO.getPacs();
-        List<PacsNew> pacsNews = wordCrfDTO.getPacsLabel().getPacsNewList();
+//        List<PacsNew> pacsNews = wordCrfDTO.getPacsLabel().getPacsNewList();
+        List<com.diagbot.model.entity.Pacs> pacses = wordCrfDTO.getPacsLabel().getPacses();
         VitalLabel vitalLabel = wordCrfDTO.getVitalLabel();
 
         //症状回填
@@ -161,7 +162,7 @@ public class CommonFacade {
         CoreUtil.setPropertyList(lis, "name", "detailName", "uniqueName", map.get(StandConvertEnum.lis.getName()));
         CoreUtil.setPropertyList(wordCrfDTO.getLisOrder(), "name", "detailName", "uniqueName", map.get(StandConvertEnum.lis.getName()));
         // TODO: 2020/8/5 辅助检查回填
-        CoreUtil.setPropertyList(pacsNews, "name", "uniqueName", map.get(StandConvertEnum.pacs.getName()));
+        CoreUtil.setPropertyList(pacses,  map.get(StandConvertEnum.pacs.getName()));
         CoreUtil.setPropertyList(wordCrfDTO.getPacsOrder(), "name", "uniqueName", map.get(StandConvertEnum.pacs.getName()));
         //体征回填
         CoreUtil.setPropertyList(vitalLabel.getVitals(), map.get(StandConvertEnum.vital.getName()));

+ 23 - 14
src/main/java/com/diagbot/model/ai/BeHospitalizedAI.java

@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -153,15 +154,19 @@ public class BeHospitalizedAI extends ModelAI {
                 wordCrfDTO.setPacsLabel(pacsLabel);
             }
 
-            /* *//* 辅助检查(暂用主诉现病史模型,之后会新训练单独模型再做修改) *//*
-            if (StringUtils.isNotBlank(inputInfo.getPacsString())) {
-                String pacsText = inputInfo.getPacsString();
+             //* 辅助检查(暂用主诉现病史模型,之后会新训练单独模型再做修改) *//*
+            if (ListUtil.isNotEmpty(wordCrfDTO.getPacs())) {
+
+                String pacsText = "";
+                List<String> collect = wordCrfDTO.getPacs().stream().map(x -> (StringUtils.isEmpty(x.getUniqueName()) ? x.getName() : x.getUniqueName()) + ":" + x.getResult()).collect(Collectors.toList());
+                pacsText = String.join("\n",collect);
                 PacsLabel pacsLabel = new PacsLabel();
                 pacsLabel.setText(pacsText);
                 pacsLabel.setAiText(pacsText);
                 wordCrfDTO.setPacsLabel(pacsLabel);
-                putContent(crfContent, medicalTextType.get(3), pacsText, Content.pacs);
+                putContent(crfContent, medicalTextType.get(5), pacsText, Content.pacs);
             }
+            /*
             //* 专科检查(专科体格检查)
             if (beHospitalizedDoc.getVitalLabelSpecial() != null && beHospitalizedDoc.getVitalLabelSpecial().isCrfLabel()) {
                 String vitalSpecialText = beHospitalizedDoc.getVitalLabelSpecial().getText();
@@ -255,13 +260,16 @@ public class BeHospitalizedAI extends ModelAI {
                 putSuppleDiagCrfData(midData.getJSONObject(Content.supple_diag), inputInfo);
             }*/
             /* 处理辅助检查 */
-            /*if (wordCrfDTO.getPacsLabel() != null) {
-                putPacsCrfData(midData.getJSONObject(Content.pacs), wordCrfDTO);
-            }*/
+            if (wordCrfDTO.getPacsLabel() != null) {
+                Map<String, String> name_uniqueName = wordCrfDTO.getPacs().stream().filter(x -> StringUtils.isNotBlank(x.getUniqueName()))
+                        .collect(Collectors.toMap(com.diagbot.biz.push.entity.Pacs::getName, com.diagbot.biz.push.entity.Pacs::getUniqueName
+                                , (k1, k2) -> k2));
+                putPacsCrfData(midData.getJSONObject(Content.pacs), wordCrfDTO, name_uniqueName);
+            }
             /**
              * 处理辅检pacsnew
              */
-            if(wordCrfDTO.getPacsLabel() != null && ListUtil.isNotEmpty(wordCrfDTO.getPacsLabel().getPacsNewList())){
+            /*if(wordCrfDTO.getPacsLabel() != null && ListUtil.isNotEmpty(wordCrfDTO.getPacsLabel().getPacsNewList())){
                 EntityProcessPacsNew entityProcessPacsNew = new EntityProcessPacsNew();
                 List<PacsNew> pacsNews = wordCrfDTO.getPacsLabel().getPacsNewList();
                 for (PacsNew pacsnew:pacsNews) {
@@ -278,7 +286,7 @@ public class BeHospitalizedAI extends ModelAI {
                     }
                     entityProcessPacsNew.extractEntity(aiOut, pacsnew);
                 }
-            }
+            }*/
         }
     }
 
@@ -502,7 +510,7 @@ public class BeHospitalizedAI extends ModelAI {
      * @param jsonObject
      * @param wordBillCrfDTO
      */
-    /*public void putPacsCrfData(JSONObject jsonObject, WordCrfDTO wordBillCrfDTO) {
+    public void putPacsCrfData(JSONObject jsonObject, WordCrfDTO wordBillCrfDTO,Map<String, String> name_uniqueName) {
         if (jsonObject == null) {
             return;
         }
@@ -512,8 +520,8 @@ public class BeHospitalizedAI extends ModelAI {
         }
         //放置入inputinfo
         PacsLabel pacsLabel = wordBillCrfDTO.getPacsLabel();
-        pacsLabel.setPacses(loadPacses(aiOut));
-    }*/
+        pacsLabel.setPacses(loadPacses(aiOut,name_uniqueName));
+    }
 
     /**
      * 关系抽取疾病信息
@@ -547,10 +555,11 @@ public class BeHospitalizedAI extends ModelAI {
      * @param aiOut
      * @return
      */
-    public List<Pacs> loadPacses(JSONObject aiOut) {
+    public List<Pacs> loadPacses(JSONObject aiOut,Map<String, String> name_uniqueName) {
         //辅检信息
         EntityProcessPacs entityProcessLis = new EntityProcessPacs();
-        List<Pacs> pacses = entityProcessLis.extractEntity(aiOut);
+        List<Pacs> pacses = entityProcessLis.extractEntity(aiOut,name_uniqueName);
+        pacses = pacses.stream().filter(x ->StringUtils.isNotBlank(x.getName())).collect(Collectors.toList());
         return pacses;
     }
 

+ 3 - 3
src/main/java/com/diagbot/model/ai/process/EntityProcessClinic.java

@@ -94,9 +94,9 @@ public class EntityProcessClinic extends EntityProcess {
             presentLabel.setGenerals(generals);
 
             //辅检信息
-            EntityProcessPacs entityProcessLis = new EntityProcessPacs();
-            List<Pacs> pacses = entityProcessLis.extractEntity(aiOut);
-            presentLabel.setPacses(pacses);
+//            EntityProcessPacs entityProcessLis = new EntityProcessPacs();
+//            List<Pacs> pacses = entityProcessLis.extractEntity(aiOut);
+//            presentLabel.setPacses(pacses);
 
             //治疗
             List<Lemma> cureLemmas = createEntityTree(aiOut, EntityEnum.CURE.toString());

+ 26 - 2
src/main/java/com/diagbot/model/ai/process/EntityProcessPacs.java

@@ -4,29 +4,44 @@ import com.alibaba.fastjson.JSONObject;
 import com.diagbot.model.ai.model.EntityEnum;
 import com.diagbot.model.ai.model.Lemma;
 import com.diagbot.model.entity.*;
+import org.apache.commons.lang3.StringUtils;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 public class EntityProcessPacs extends EntityProcess {
 
-    public List<Pacs> extractEntity(JSONObject aiOut) {
+    public List<Pacs> extractEntity(JSONObject aiOut, Map<String, String> name_uniqueName) {
         //辅检情况
         List<Pacs> pacses = new ArrayList<>();
         List<Lemma> pacsLemmas = createEntityTree(aiOut, EntityEnum.AUXILIARY_EXAMINATION.toString());
         for (Lemma lemma : pacsLemmas) {
             Pacs pacs = new Pacs();
+            if(StringUtils.isBlank(lemma.getText().trim())){
+                continue;
+            }
             pacs.setName(lemma.getText());
+            if(name_uniqueName.containsKey(lemma.getText())){
+                pacs.setStandName(lemma.getText());
+            }
             if (lemma.isHaveChildren()) {
+                List<BodyPart> bodyPartList = new ArrayList<>();
+                List<Diag> diseaseList = new ArrayList<>();
                 for (Lemma relationLemma : lemma.getRelationLemmas()) {
                     if (relationLemma.getProperty().equals(EntityEnum.AUXILIARY_DESCRIPT.toString())) {
                         pacs.setPacsValues(addPacsValue(relationLemma));
                     } else if (relationLemma.getProperty().equals(EntityEnum.BODY.toString())) {
-                        pacs.setBodyPart(addBodyPart(relationLemma));
+                        bodyPartList.add(addBodyPart(relationLemma));
+//                        pacs.setBodyPart(addBodyPart(relationLemma));
+                    } else if(relationLemma.getProperty().equals(EntityEnum.DIEASE.toString())){
+                        diseaseList.add(addDiag(relationLemma));
                     } else if (relationLemma.getProperty().equals(EntityEnum.OUTERCOURTYARD.toString())) {
                         pacs.setOuterCourtyard(addOuterCourtyard(relationLemma));
                     }
                 }
+                pacs.setBodyPartList(bodyPartList);
+                pacs.setDisease(diseaseList);
             }
             pacses.add(pacs);
         }
@@ -51,6 +66,7 @@ public class EntityProcessPacs extends EntityProcess {
     private PacsValue addPacsValue(Lemma relationLemma) {
         PacsValue pacsValue = new PacsValue();
         pacsValue.setName(relationLemma.getText());
+        pacsValue.setStandName(relationLemma.getText());
         return pacsValue;
     }
 
@@ -63,6 +79,14 @@ public class EntityProcessPacs extends EntityProcess {
     private BodyPart addBodyPart(Lemma relationLemma) {
         BodyPart bodyPart = new BodyPart();
         bodyPart.setName(relationLemma.getText());
+        bodyPart.setStandName(relationLemma.getText());
+        return bodyPart;
+    }
+
+    private Diag addDiag(Lemma relationLemma) {
+        Diag bodyPart = new Diag();
+        bodyPart.setName(relationLemma.getText());
+        bodyPart.setStandName(relationLemma.getText());
         return bodyPart;
     }
 

+ 1 - 0
src/main/java/com/diagbot/model/entity/Pacs.java

@@ -19,5 +19,6 @@ public class Pacs extends General{
     private PacsValue pacsValues;
     private BodyPart bodyPart;
     private List<BodyPart> bodyPartList; // 部位列表
+    private List<Diag> disease;//辅检提的诊断
     private OuterCourtyard outerCourtyard; //外院
 }

+ 2 - 1
src/main/java/com/diagbot/model/label/PacsLabel.java

@@ -1,6 +1,7 @@
 package com.diagbot.model.label;
 
 
+import com.diagbot.model.entity.Pacs;
 import com.diagbot.model.entity.PacsNew;
 import lombok.Getter;
 import lombok.Setter;
@@ -17,6 +18,6 @@ import java.util.List;
 @Setter
 @Getter
 public class PacsLabel extends GeneralLabel {
-    // List<Pacs> pacses;
+     List<Pacs> pacses;
     List<PacsNew> pacsNewList = new ArrayList<>(); // 辅检信息
 }