فهرست منبع

恩泽:抢救记录crf模型逻辑增加

wangsy 4 سال پیش
والد
کامیت
9f5f9ba018
16فایلهای تغییر یافته به همراه408 افزوده شده و 0 حذف شده
  1. 6 0
      structure-center/src/main/java/com/lantone/structure/ai/AIAnalyze.java
  2. 87 0
      structure-center/src/main/java/com/lantone/structure/ai/RescueAI.java
  3. 142 0
      structure-center/src/main/java/com/lantone/structure/ai/process/EntityProcessRescue.java
  4. 2 0
      structure-center/src/main/java/com/lantone/structure/model/doc/RescueDoc.java
  5. 15 0
      structure-center/src/main/java/com/lantone/structure/model/entity/AuxiliaryQuantitative.java
  6. 15 0
      structure-center/src/main/java/com/lantone/structure/model/entity/AuxiliaryResult.java
  7. 20 0
      structure-center/src/main/java/com/lantone/structure/model/entity/AuxiliaryTest.java
  8. 17 0
      structure-center/src/main/java/com/lantone/structure/model/entity/Condition.java
  9. 15 0
      structure-center/src/main/java/com/lantone/structure/model/entity/Count.java
  10. 15 0
      structure-center/src/main/java/com/lantone/structure/model/entity/Diagnosis.java
  11. 1 0
      structure-center/src/main/java/com/lantone/structure/model/entity/Drug.java
  12. 15 0
      structure-center/src/main/java/com/lantone/structure/model/entity/Intervention.java
  13. 16 0
      structure-center/src/main/java/com/lantone/structure/model/entity/Method.java
  14. 1 0
      structure-center/src/main/java/com/lantone/structure/model/entity/Operation.java
  15. 15 0
      structure-center/src/main/java/com/lantone/structure/model/entity/OperationLocation.java
  16. 26 0
      structure-center/src/main/java/com/lantone/structure/model/label/RescueLabel.java

+ 6 - 0
structure-center/src/main/java/com/lantone/structure/ai/AIAnalyze.java

@@ -16,6 +16,9 @@ public class AIAnalyze {
     ThreeLevelWardAI threeLevelWardAI = new ThreeLevelWardAI();
     OperationAI operationAI = new OperationAI();
     ConsultationAI consultationAI = new ConsultationAI();
+    ClinicalbloodAI clinicalbloodAI = new ClinicalbloodAI();
+    StagesSummaryAI stagesSummaryAI = new StagesSummaryAI();
+    RescueAI rescueAI = new RescueAI();
 
     public AIAnalyze(CRFServiceClient crfService, SimilarityServiceClient similarityServiceClient) {
         this.crfServiceClient = crfService;
@@ -29,6 +32,9 @@ public class AIAnalyze {
         threeLevelWardAI.medrec(inputInfo, crfServiceClient);
         operationAI.medrec(inputInfo, crfServiceClient);
         consultationAI.medrec(inputInfo, crfServiceClient);
+        clinicalbloodAI.medrec(inputInfo, crfServiceClient);
+        stagesSummaryAI.medrec(inputInfo, crfServiceClient);
+        rescueAI.medrec(inputInfo, crfServiceClient);
     }
 
 }

+ 87 - 0
structure-center/src/main/java/com/lantone/structure/ai/RescueAI.java

@@ -0,0 +1,87 @@
+package com.lantone.structure.ai;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
+import com.lantone.common.util.CatalogueUtil;
+import com.lantone.common.util.StringUtil;
+import com.lantone.structure.ai.process.EntityProcessRescue;
+import com.lantone.structure.client.CRFServiceClient;
+import com.lantone.structure.model.Content;
+import com.lantone.structure.model.InputInfo;
+import com.lantone.structure.model.doc.RescueDoc;
+import com.lantone.structure.model.label.RescueLabel;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName : RescueAI
+ * @Description :抢救记录
+ * @Author : wsy
+ * @Date: 2021-01-25 17:16
+ */
+public class RescueAI extends ModelAI {
+
+    public static List<String> medicalTextType = Arrays.asList("Taizhou_rescue_record");
+    public static String entityRelationObject = "entity_relation_object";
+    public static String outputs = "outputs";
+    public static String content = "content";
+    public static List<String> mapKey = Lists.newArrayList("抢救内容");
+
+    public void medrec(InputInfo inputInfo, CRFServiceClient crfServiceClient) {
+        JSONArray crfContent = new JSONArray();
+        List<RescueDoc> resultsDocs = inputInfo.getRescueDocs();
+        for (int i = 0; i < resultsDocs.size(); i++) {
+            Map<String, String> structureMap = resultsDocs.get(i).getStructureMap();
+            String content = CatalogueUtil.structureMapJoin(structureMap, mapKey);
+            putContent(crfContent, medicalTextType.get(0), content, Content.rescue);
+        }
+
+        JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
+
+        for (int i = 0; i < resultsDocs.size(); i++) {
+            if (midData.get(Content.rescue) == null) {
+                continue;
+            }
+            RescueDoc resultsDoc = resultsDocs.get(i);
+            RescueLabel rescueLabel = putRescueCrfData(midData.getJSONObject(Content.rescue), inputInfo);
+            if (rescueLabel != null) {
+                resultsDoc.setRescueLabel(rescueLabel);
+            }
+        }
+    }
+
+
+    /**
+     * 处理抢救记录
+     *
+     * @param jsonObject
+     */
+    public RescueLabel putRescueCrfData(JSONObject jsonObject, InputInfo inputInfo) {
+        RescueLabel rescueLabel = new RescueLabel();
+        if (jsonObject == null) {
+            return rescueLabel;
+        }
+        JSONObject aiOut = jsonObject.getJSONObject(entityRelationObject).getJSONObject(RescueAI.outputs);
+        if (aiOut == null) {
+            return rescueLabel;
+        }
+        EntityProcessRescue entityProcessRescue = new EntityProcessRescue();
+        rescueLabel = entityProcessRescue.extractEntity(aiOut);
+        return rescueLabel;
+    }
+
+    protected void putContent(JSONArray crfContent, String medicalTextType, String text, String sign) {
+        String move_text = CatalogueUtil.removeSpecialChar(text);
+        if (StringUtil.isEmpty(move_text)) {
+            return;
+        }
+        JSONObject detailContent = new JSONObject();
+        detailContent.put("medical_text_type", medicalTextType);
+        detailContent.put("content", move_text);
+        detailContent.put("detail_title", sign);
+        crfContent.add(detailContent);
+    }
+}

+ 142 - 0
structure-center/src/main/java/com/lantone/structure/ai/process/EntityProcessRescue.java

@@ -0,0 +1,142 @@
+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.entity.*;
+import com.lantone.structure.model.label.RescueLabel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 抢救记录处理
+ */
+public class EntityProcessRescue extends EntityProcess {
+    private Logger logger = LoggerFactory.getLogger(EntityProcessRescue.class);
+
+    public RescueLabel extractEntity(JSONObject aiOut) {
+        RescueLabel rescueLabel = new RescueLabel();
+        try {
+            //疾病诊断名称
+            List<Lemma> diagnosisLemma = createEntityTree(aiOut, EntityEnum.DIAGNOSIS_NAME.toString());
+            List<Diagnosis> diagnosisList = new ArrayList<>();
+            for (Lemma lemma : diagnosisLemma) {
+                Diagnosis diagnosis = new Diagnosis();
+                diagnosis.setName(lemma.getText());
+                diagnosisList.add(diagnosis);
+            }
+            rescueLabel.setDiagnosis(diagnosisList);
+
+            //抢救病情
+            List<Lemma> conditionLemma = createEntityTree(aiOut, EntityEnum.CONDITION.toString());
+            List<Condition> conditionList = new ArrayList<>();
+            for (Lemma lemma : conditionLemma) {
+                Condition condition = new Condition();
+                condition.setName(lemma.getText());
+                if (lemma.isHaveChildren()) {
+                    for (Lemma relationLemma : lemma.getRelationLemmas()) {
+                        if (relationLemma.getProperty().equals(EntityEnum.TIME.toString())) {
+                            condition.setPd(addPD(relationLemma));
+                        }
+                    }
+                }
+                conditionList.add(condition);
+            }
+            rescueLabel.setConditions(conditionList);
+
+            //手术及操作名称
+            List<Lemma> operationLemma = createEntityTree(aiOut, EntityEnum.OPERATION_OF_NAME.toString());
+            List<Operation> operationList = new ArrayList<>();
+            for (Lemma lemma : operationLemma) {
+                Operation operation = new Operation();
+                operation.setName(lemma.getText());
+                operation.setOperationLocation(findT(lemma, new OperationLocation(), EntityEnum.OPERATION_OF_POSITION_NAME.toString()));
+                operationList.add(operation);
+            }
+            rescueLabel.setOperations(operationList);
+
+            //操作方法
+            List<Lemma> methodLemma = createEntityTree(aiOut, EntityEnum.OPERATION_METHOD.toString());
+            List<Method> methodList = new ArrayList<>();
+            for (Lemma lemma : methodLemma) {
+                Method method = new Method();
+                method.setName(lemma.getText());
+                method.setCount(findT(lemma, new Count(), EntityEnum.OPERATION_COUNT.toString()));
+                methodList.add(method);
+            }
+            rescueLabel.setMethods(methodList);
+
+            //辅检名称
+            List<Lemma> auxiliaryTestLemma = createEntityTree(aiOut, EntityEnum.AUXILIARY_TEST.toString());
+            List<AuxiliaryTest> auxiliaryTestList = new ArrayList<>();
+            for (Lemma lemma : auxiliaryTestLemma) {
+                AuxiliaryTest auxiliaryTest = new AuxiliaryTest();
+                auxiliaryTest.setName(lemma.getText());
+                if (lemma.isHaveChildren()) {
+                    List<AuxiliaryResult> auxiliaryResultList = new ArrayList<>();
+                    for (Lemma relationLemma : lemma.getRelationLemmas()) {
+                        if (relationLemma.getProperty().equals(EntityEnum.AUXILIARY_RESULT.toString())) {
+                            AuxiliaryResult auxiliaryResult = new AuxiliaryResult();
+                            auxiliaryResult.setName(relationLemma.getText());
+                            auxiliaryResultList.add(auxiliaryResult);
+                        }
+                    }
+                    auxiliaryTest.setAuxiliaryResult(auxiliaryResultList);
+                }
+                auxiliaryTest.setAuxiliaryQuantitative(findT(lemma, new AuxiliaryQuantitative(), EntityEnum.AUXILIARY_QUANTITATIVE.toString()));
+                auxiliaryTestList.add(auxiliaryTest);
+            }
+            rescueLabel.setAuxiliaryTest(auxiliaryTestList);
+
+            //抢救药品
+            List<Lemma> drugLemma = createEntityTree(aiOut, EntityEnum.SALVAGE_DRUG.toString());
+            List<Drug> DrugList = new ArrayList<>();
+            for (Lemma lemma : drugLemma) {
+                Drug drug = new Drug();
+                drug.setName(lemma.getText());
+                if (lemma.isHaveChildren()) {
+                    for (Lemma relationLemma : lemma.getRelationLemmas()) {
+                        if (relationLemma.getProperty().equals(EntityEnum.TIME.toString())) {
+                            drug.setPd(addPD(relationLemma));
+                        }
+                    }
+                }
+                DrugList.add(drug);
+            }
+            rescueLabel.setDrugs(DrugList);
+
+            //介入物名称
+            List<Lemma> interventionLemma = createEntityTree(aiOut, EntityEnum.INTERVENTION.toString());
+            List<Intervention> interventionList = new ArrayList<>();
+            for (Lemma lemma : interventionLemma) {
+                Intervention intervention = new Intervention();
+                intervention.setName(lemma.getText());
+                interventionList.add(intervention);
+            }
+            rescueLabel.setInterventions(interventionList);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error(e.getMessage(), e);
+        }
+        return rescueLabel;
+    }
+
+
+    /**
+     * 时间
+     *
+     * @param timeLemma
+     * @return
+     */
+    private PD addPD(Lemma timeLemma) {
+        PD pd = new PD();
+        pd.setName(timeLemma.getText());
+        pd.setValue(timeLemma.getText());
+        return pd;
+    }
+}

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

@@ -1,5 +1,6 @@
 package com.lantone.structure.model.doc;
 
+import com.lantone.structure.model.label.RescueLabel;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -12,4 +13,5 @@ import lombok.Setter;
 @Setter
 @Getter
 public class RescueDoc extends ModelDoc {
+    private RescueLabel rescueLabel;
 }

+ 15 - 0
structure-center/src/main/java/com/lantone/structure/model/entity/AuxiliaryQuantitative.java

@@ -0,0 +1,15 @@
+package com.lantone.structure.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : AuxiliaryQuantitative
+ * @Description : 辅检定量结果
+ * @Author : wsy
+ * @Date: 2021-01-25 20:19
+ */
+@Setter
+@Getter
+public class AuxiliaryQuantitative extends General {
+}

+ 15 - 0
structure-center/src/main/java/com/lantone/structure/model/entity/AuxiliaryResult.java

@@ -0,0 +1,15 @@
+package com.lantone.structure.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : AuxiliaryResult
+ * @Description : 辅检结果
+ * @Author : wsy
+ * @Date: 2021-01-25 19:15
+ */
+@Setter
+@Getter
+public class AuxiliaryResult extends General {
+}

+ 20 - 0
structure-center/src/main/java/com/lantone/structure/model/entity/AuxiliaryTest.java

@@ -0,0 +1,20 @@
+package com.lantone.structure.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName : AuxiliaryTest
+ * @Description : 辅检名称
+ * @Author : wsy
+ * @Date: 2021-01-25 19:15
+ */
+@Setter
+@Getter
+public class AuxiliaryTest extends General {
+    private List<AuxiliaryResult> auxiliaryResult = new ArrayList<>();  //辅检结果
+    private AuxiliaryQuantitative auxiliaryQuantitative;                //辅检定量结果
+}

+ 17 - 0
structure-center/src/main/java/com/lantone/structure/model/entity/Condition.java

@@ -0,0 +1,17 @@
+package com.lantone.structure.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : Condition
+ * @Description : 抢救病情
+ * @Author : wsy
+ * @Date: 2021-01-25 19:15
+ */
+
+@Setter
+@Getter
+public class Condition extends General {
+    private PD pd; //时间
+}

+ 15 - 0
structure-center/src/main/java/com/lantone/structure/model/entity/Count.java

@@ -0,0 +1,15 @@
+package com.lantone.structure.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : Count
+ * @Description : 操作次数
+ * @Author : wsy
+ * @Date: 2021-01-25 19:15
+ */
+@Setter
+@Getter
+public class Count extends General {
+}

+ 15 - 0
structure-center/src/main/java/com/lantone/structure/model/entity/Diagnosis.java

@@ -0,0 +1,15 @@
+package com.lantone.structure.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : Diagnosis
+ * @Description : 疾病诊断名称
+ * @Author : wsy
+ * @Date: 2021-01-25 19:15
+ */
+@Setter
+@Getter
+public class Diagnosis extends General {
+}

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

@@ -17,4 +17,5 @@ public class Drug extends General {
     private Frequency frequency;            //频率
     private Stop stop;                      //停用
     private ReasonsForAntibiotic reasonsForAntibiotic;  //抗生素使用原因
+    private PD pd;                          //时间
 }

+ 15 - 0
structure-center/src/main/java/com/lantone/structure/model/entity/Intervention.java

@@ -0,0 +1,15 @@
+package com.lantone.structure.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : Intervention
+ * @Description : 介入物名称
+ * @Author : wsy
+ * @Date: 2021-01-25 20:18
+ */
+@Setter
+@Getter
+public class Intervention extends General {
+}

+ 16 - 0
structure-center/src/main/java/com/lantone/structure/model/entity/Method.java

@@ -0,0 +1,16 @@
+package com.lantone.structure.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : Method
+ * @Description : 操作方法
+ * @Author : wsy
+ * @Date: 2021-01-25 19:15
+ */
+@Setter
+@Getter
+public class Method extends General {
+    private Count count;  //操作次数
+}

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

@@ -16,4 +16,5 @@ public class Operation extends General {
     private PD pd;  //手术时间
     private OperationResult operationResult;    //手术结果
     private Diag diag;  //手术原因
+    private OperationLocation operationLocation; //手术及操作目标部位名称
 }

+ 15 - 0
structure-center/src/main/java/com/lantone/structure/model/entity/OperationLocation.java

@@ -0,0 +1,15 @@
+package com.lantone.structure.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @ClassName : OperationLocation
+ * @Description : 手术及操作目标部位名称
+ * @Author : wsy
+ * @Date: 2021-01-25 19:15
+ */
+@Setter
+@Getter
+public class OperationLocation extends General {
+}

+ 26 - 0
structure-center/src/main/java/com/lantone/structure/model/label/RescueLabel.java

@@ -0,0 +1,26 @@
+package com.lantone.structure.model.label;
+
+import com.lantone.structure.model.entity.*;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName : RescueLabel
+ * @Description : 抢救记录
+ * @Author : wsy
+ * @Date: 2021-01-25 19:51
+ */
+@Getter
+@Setter
+public class RescueLabel {
+    private List<Diagnosis> diagnosis = new ArrayList<>();   //疾病诊断名称
+    private List<Condition> conditions = new ArrayList<>();  //抢救病情
+    private List<Operation> operations = new ArrayList<>();  //手术及操作名称
+    private List<Method> methods = new ArrayList<>();        //操作方法
+    private List<AuxiliaryTest> auxiliaryTest = new ArrayList<>();                 //辅检名称
+    private List<Drug> drugs = new ArrayList<>();             //抢救药品
+    private List<Intervention> interventions = new ArrayList<>();                  //介入物名称
+}