Browse Source

辅检模型抽取

kongwz 4 years atrás
parent
commit
5ac7050937

+ 3 - 0
src/main/java/com/diagbot/dto/PacsBillNeoDTO.java

@@ -39,6 +39,9 @@ public class PacsBillNeoDTO {
     // 禁忌实验室检查
     private List<NodeNeoDTO> lis = new ArrayList<>();
 
+    // 禁忌实验室检查
+    private List<NodeNeoDTO> pacs = new ArrayList<>();
+
     // 禁忌疾病
     private List<NodeNeoDTO> disease = new ArrayList<>();
 

+ 3 - 9
src/main/java/com/diagbot/dto/WordCrfDTO.java

@@ -3,15 +3,8 @@ package com.diagbot.dto;
 import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.biz.push.entity.Pacs;
-import com.diagbot.model.label.ChiefLabel;
-import com.diagbot.model.label.DiagLabel;
-import com.diagbot.model.label.FamilyLabel;
-import com.diagbot.model.label.MaritalLabel;
-import com.diagbot.model.label.MenstrualLabel;
-import com.diagbot.model.label.PastLabel;
-import com.diagbot.model.label.PersonalLabel;
-import com.diagbot.model.label.PresentLabel;
-import com.diagbot.model.label.VitalLabel;
+import com.diagbot.model.entity.PacsNew;
+import com.diagbot.model.label.*;
 import lombok.Data;
 
 import java.util.ArrayList;
@@ -35,6 +28,7 @@ public class WordCrfDTO {
     private List<Lis> lis = new ArrayList<>();
     // 辅检项目和结果
     private List<Pacs> pacs = new ArrayList<>();
+    private List<PacsNew> pacsNews = new ArrayList<>();
     // 主诉
     private ChiefLabel chiefLabel = new ChiefLabel();
     // 现病史

+ 8 - 5
src/main/java/com/diagbot/facade/CommonFacade.java

@@ -6,6 +6,7 @@ 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;
@@ -89,9 +90,10 @@ public class CommonFacade {
 
         //所有辅助检查(结构化数据)
         List<String> allPacs = new ArrayList<>();
-        List<Pacs> pacs = wordCrfDTO.getPacs();
-        if (ListUtil.isNotEmpty(pacs)) {
-            List<String> pacss_unique = pacs.stream().filter(x -> StringUtils.isBlank(x.getUniqueName()))
+//        List<Pacs> pacs = wordCrfDTO.getPacs();
+        List<PacsNew> pacsNews = wordCrfDTO.getPacsNews();
+        if (ListUtil.isNotEmpty(pacsNews)) {
+            List<String> pacss_unique = pacsNews.stream().filter(x -> StringUtils.isBlank(x.getUniqueName()))
                     .map(x -> x.getName()).collect(Collectors.toList());
             allPacs.addAll(pacss_unique);
         }
@@ -137,7 +139,8 @@ public class CommonFacade {
         PastLabel pastLabel = wordCrfDTO.getPastLabel();
         DiagLabel diagLabel = wordCrfDTO.getDiagLabel();
         List<Lis> lis = wordCrfDTO.getLis();
-        List<Pacs> pacs = wordCrfDTO.getPacs();
+//        List<Pacs> pacs = wordCrfDTO.getPacs();
+        List<PacsNew> pacsNews = wordCrfDTO.getPacsNews();
         VitalLabel vitalLabel = wordCrfDTO.getVitalLabel();
 
         //症状回填
@@ -153,7 +156,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(pacs, "name", "uniqueName", map.get(StandConvertEnum.pacs.getName()));
+        CoreUtil.setPropertyList(pacsNews, "name", "uniqueName", 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()));

+ 39 - 26
src/main/java/com/diagbot/model/ai/BeHospitalizedAI.java

@@ -6,31 +6,11 @@ import com.diagbot.client.CRFServiceClient;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
-import com.diagbot.model.ai.process.EntityProcessClinic;
-import com.diagbot.model.ai.process.EntityProcessDiag;
-import com.diagbot.model.ai.process.EntityProcessFamily;
-import com.diagbot.model.ai.process.EntityProcessLis;
-import com.diagbot.model.ai.process.EntityProcessMarital;
-import com.diagbot.model.ai.process.EntityProcessMenses;
-import com.diagbot.model.ai.process.EntityProcessPacs;
-import com.diagbot.model.ai.process.EntityProcessPast;
-import com.diagbot.model.ai.process.EntityProcessPersonal;
-import com.diagbot.model.ai.process.EntityProcessVital;
-import com.diagbot.model.entity.Diag;
-import com.diagbot.model.entity.Lis;
-import com.diagbot.model.entity.PD;
-import com.diagbot.model.entity.Pacs;
-import com.diagbot.model.entity.Vital;
-import com.diagbot.model.label.ChiefLabel;
-import com.diagbot.model.label.DiagLabel;
-import com.diagbot.model.label.FamilyLabel;
-import com.diagbot.model.label.MaritalLabel;
-import com.diagbot.model.label.MenstrualLabel;
-import com.diagbot.model.label.PastLabel;
-import com.diagbot.model.label.PersonalLabel;
-import com.diagbot.model.label.PresentLabel;
-import com.diagbot.model.label.VitalLabel;
+import com.diagbot.model.ai.process.*;
+import com.diagbot.model.entity.*;
+import com.diagbot.model.label.*;
 import com.diagbot.util.Content;
+import com.diagbot.util.ListUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.SearchData;
 import org.apache.commons.lang3.StringUtils;
@@ -40,6 +20,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 /**
  * @ClassName : InHospitalDoc
@@ -158,8 +139,18 @@ public class BeHospitalizedAI extends ModelAI {
                 wordCrfDTO.setFamilyLabel(familyLabel);
                 putContent(crfContent, medicalTextType.get(1), familyText, Content.family);
             }
+            if(ListUtil.isNotEmpty(inputInfo.getPacs())){
+                List<PacsNew> collect = inputInfo.getPacs().stream().map(x -> {
+                    PacsNew pacsNew = new PacsNew();
+                    pacsNew.setName(x.getName());
+                    pacsNew.setUniqueName(x.getUniqueName());
+                    pacsNew.setDesc(x.getDesc());
+                    return pacsNew;
+                }).collect(Collectors.toList());
+                wordCrfDTO.setPacsNews(collect);
+            }
 
-           /* *//* 辅助检查(暂用主诉现病史模型,之后会新训练单独模型再做修改) *//*
+            /* *//* 辅助检查(暂用主诉现病史模型,之后会新训练单独模型再做修改) *//*
             if (StringUtils.isNotBlank(inputInfo.getPacsString())) {
                 String pacsText = inputInfo.getPacsString();
                 PacsLabel pacsLabel = new PacsLabel();
@@ -264,6 +255,28 @@ public class BeHospitalizedAI extends ModelAI {
             /*if (wordCrfDTO.getPacsLabel() != null) {
                 putPacsCrfData(midData.getJSONObject(Content.pacs), wordCrfDTO);
             }*/
+            /**
+             * 处理pacsnew
+             */
+            if(ListUtil.isNotEmpty(wordCrfDTO.getPacsNews())){
+                EntityProcessPacsNew entityProcessPacsNew = new EntityProcessPacsNew();
+                List<PacsNew> pacsNews = wordCrfDTO.getPacsNews();
+                for (PacsNew pacsnew:pacsNews) {
+                    JSONArray crfPacsContent = new JSONArray();
+                    putContent(crfPacsContent, medicalTextType.get(3), pacsnew.getDesc(), Content.pacs);
+                    JSONObject midPacsData = loadAI(crfPacsContent, crfServiceClient);
+                    JSONObject jsonObject = midPacsData.getJSONObject(Content.pacs);
+                    if(jsonObject == null){
+                        continue;
+                    }
+                    JSONObject aiOut = jsonObject.getJSONObject(entityRelationObject).getJSONObject(BeHospitalizedAI.outputs);
+                    if (aiOut == null) {
+                        continue;
+                    }
+                    List<Pacs> pacs = entityProcessPacsNew.extractEntity(aiOut);
+                    pacsnew.setPacsResults(pacs);
+                }
+            }
         }
     }
 
@@ -487,7 +500,7 @@ public class BeHospitalizedAI extends ModelAI {
      * @param jsonObject
      * @param wordBillCrfDTO
      */
-  /*  public void putPacsCrfData(JSONObject jsonObject, WordCrfDTO wordBillCrfDTO) {
+    /*public void putPacsCrfData(JSONObject jsonObject, WordCrfDTO wordBillCrfDTO) {
         if (jsonObject == null) {
             return;
         }

+ 49 - 0
src/main/java/com/diagbot/model/ai/process/EntityProcessPacsNew.java

@@ -0,0 +1,49 @@
+package com.diagbot.model.ai.process;
+
+import com.alibaba.fastjson.JSONObject;
+import com.diagbot.model.ai.model.EntityEnum;
+import com.diagbot.model.ai.model.Lemma;
+import com.diagbot.model.entity.BodyPart;
+import com.diagbot.model.entity.Pacs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author kwz
+ * @date 2020/8/19
+ * @time 14:03
+ */
+public class EntityProcessPacsNew extends EntityProcess {
+    public List<Pacs> extractEntity(JSONObject aiOut) {
+        //辅检情况
+        List<Pacs> pacses = new ArrayList<>();
+        List<Lemma> pacsLemmas = createEntityTree(aiOut, EntityEnum.AUXILIARY_DESCRIPT.toString());
+        for (Lemma lemma : pacsLemmas) {
+            Pacs pacs = new Pacs();
+            pacs.setName(lemma.getText());
+            pacs.setStandName(lemma.getText());
+            if (lemma.isHaveChildren()) {
+                for (Lemma relationLemma : lemma.getRelationLemmas()) {
+                    if (relationLemma.getProperty().equals(EntityEnum.BODY.toString())) {
+                        pacs.setBodyPart(addBodyPart(relationLemma));
+                    }
+                }
+            }
+            pacses.add(pacs);
+        }
+        return pacses;
+    }
+    /**
+     * 添加身体部位
+     *
+     * @param relationLemma
+     * @return
+     */
+    private BodyPart addBodyPart(Lemma relationLemma) {
+        BodyPart bodyPart = new BodyPart();
+        bodyPart.setName(relationLemma.getText());
+        bodyPart.setStandName(relationLemma.getText());
+        return bodyPart;
+    }
+}

+ 18 - 0
src/main/java/com/diagbot/model/entity/PacsNew.java

@@ -0,0 +1,18 @@
+package com.diagbot.model.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author kwz
+ * @date 2020/8/19
+ * @time 13:09
+ */
+@Data
+public class PacsNew  {
+    private String name;
+    private String uniqueName;
+    private String desc;
+    private List<Pacs> pacsResults;
+}

+ 4 - 0
src/main/java/com/diagbot/process/BillProcess.java

@@ -71,6 +71,10 @@ public class BillProcess {
                 nodeNeoDTO.setVal("阳性");
                 billNeoDTO.getPacsBillNeoDTO().getLis().add(nodeNeoDTO);
 
+                NodeNeoDTO nodepacsDTO = new NodeNeoDTO();
+                nodepacsDTO.setName("上腹部平扫");
+                billNeoDTO.getPacsBillNeoDTO().getPacs().add(nodepacsDTO);
+
                 NodeNeoDTO opereat = new NodeNeoDTO();
                 opereat.setName("胸腔镜下左下肺叶切除术");
                 billNeoDTO.getPacsBillNeoDTO().getOperations().add(opereat);