Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/diagbot/facade/CriticalFacade.java
MarkHuang 4 gadi atpakaļ
vecāks
revīzija
1a1dda3191

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

@@ -22,7 +22,4 @@ public class CriticalNeoDTO {
     // 类型,例如:“化验”,“体征”
     private String type;
 
-    // 化验套餐名称
-    private String mealName;
-
 }

+ 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()));

+ 22 - 0
src/main/java/com/diagbot/facade/CriticalFacade.java

@@ -2,6 +2,7 @@ package com.diagbot.facade;
 
 import com.diagbot.dto.CriticalNeoDTO;
 import com.diagbot.dto.IndicationDTO;
+import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.process.CriticalProcess;
 import com.diagbot.vo.CriticalNeoVO;
@@ -9,6 +10,7 @@ import com.diagbot.vo.IndicationPushVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -32,6 +34,26 @@ public class CriticalFacade {
      */
     public void criticalFac(IndicationPushVO indicationPushVO, WordCrfDTO wordCrfDTO, IndicationDTO res) {
         // 危急值图谱接口调用
+        // TODO 测试数据开始
+        List<CriticalNeoDTO> criticalNeoDTOList = new ArrayList<>();
+        CriticalNeoDTO criticalNeoDTO = new CriticalNeoDTO();
+        criticalNeoDTO.setName("血小板计数");
+        criticalNeoDTO.setStandname("血小板计数");
+        criticalNeoDTO.setType("化验");
+        NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
+        nodeNeoDTO.setMax(new BigDecimal("100"));
+        criticalNeoDTO.setCritical(nodeNeoDTO);
+        criticalNeoDTOList.add(criticalNeoDTO);
+
+        CriticalNeoDTO criticalNeoDTO1 = new CriticalNeoDTO();
+        criticalNeoDTO1.setName("红细胞压积");
+        criticalNeoDTO1.setStandname("红细胞压积");
+        criticalNeoDTO1.setType("化验");
+        NodeNeoDTO nodeNeoDTO1 = new NodeNeoDTO();
+        nodeNeoDTO1.setVal("阳性");
+        criticalNeoDTO1.setCritical(nodeNeoDTO1);
+        criticalNeoDTOList.add(criticalNeoDTO1);
+        // TODO 测试数据结束
         // TODO
         CriticalNeoVO criticalNeoVOs = fillCriticalNeo(wordCrfDTO);
         List<CriticalNeoDTO> criticalNeoDTOList = neoFacade.getCritialNeo(criticalNeoVOs);

+ 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);

+ 9 - 3
src/main/java/com/diagbot/process/CriticalProcess.java

@@ -1,6 +1,7 @@
 package com.diagbot.process;
 
 import com.diagbot.biz.push.entity.Lis;
+import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.CriticalNeoDTO;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.NodeNeoDTO;
@@ -26,15 +27,20 @@ public class CriticalProcess {
      * @param res
      */
     public void process(List<CriticalNeoDTO> criticalNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO res) {
+        List<BillMsg> criticalList = res.getCriticalValList();
         for (CriticalNeoDTO critical : criticalNeoDTOList) {
             NodeNeoDTO nodeNeoDTO = critical.getCritical();
             // 化验
             if (TypeEnum.lis.getName().equals(critical.getType())) {
                 List<Lis> lisList = wordCrfDTO.getLis();
                 for (Lis bean : lisList) {
-                    Map<String, Object> map = CoreUtil.compareLis(nodeNeoDTO, bean);
-                    if ((Boolean) map.get("flag") == true) {
-                        // CoreUtil.getCommonBillMsg()
+                    if (critical.getStandname().equals(bean.getUniqueName())) {
+                        Map<String, Object> map = CoreUtil.compareLis(nodeNeoDTO, bean);
+                        if ((Boolean) map.get("flag") == true) {
+                            BillMsg criticalMsg = CoreUtil.getCommonCriticalMsg(critical.getName(), critical.getStandname(),
+                                    (String)map.get("msg"), TypeEnum.lis.getName());
+                            criticalList.add(criticalMsg);
+                        }
                     }
                 }
             }

+ 5 - 8
src/main/java/com/diagbot/util/CoreUtil.java

@@ -217,22 +217,18 @@ public class CoreUtil {
     /**
      * 危急值通用提示信息
      *
-     * @param orderName 原开单项
-     * @param orderStandName 标准开单项
      * @param compareName 匹配名称
      * @param compareStandName 匹配标准名称
      * @param type 类型
      * @return
      */
-    public static BillMsg getCommonCriticalMsg(String orderName, String orderStandName, String compareName,
-                                           String compareStandName, String type) {
+    public static BillMsg getCommonCriticalMsg(String compareName,
+                                           String compareStandName, String message, String type) {
         BillMsg billMsg = new BillMsg();
-        String msg = String.format("该患者" + compareName + ",不宜开%s", orderName);
+        String msg = String.format("该患者%s,请留意", message);
         billMsg.setMsg(msg);
         billMsg.setCompareName(compareName);
         billMsg.setCompareStandName(compareStandName);
-        billMsg.setOrderName(orderName);
-        billMsg.setOrderStandName(orderStandName);
         billMsg.setType(type);
         return billMsg;
     }
@@ -520,7 +516,8 @@ public class CoreUtil {
     }
 
     public static void main(String[] args) {
-
+        String msg = String.format("该患者%s%s%s,请留意", "套餐","明细项","值");
+        System.out.println(msg);
 
     }
 }