Browse Source

添加crf依赖

kongwz 5 years ago
parent
commit
5917905a35

+ 18 - 1
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/BeHospitalizedAI.java

@@ -76,6 +76,22 @@ public class BeHospitalizedAI {
         JSONObject midData = getOutputs(data);
         //处理主诉
         putAllCrfData(midData.getJSONObject(Content.chief),crfOut);
+        putAllCrfData(midData.getJSONObject(Content.present), crfOut);
+        putAllCrfData(midData.getJSONObject(Content.special_exam), crfOut);
+
+        //存放CRF模型既往史、家族史返回数据
+        putAllCrfData(midData.getJSONObject(Content.past), crfOut);
+        putAllCrfData(midData.getJSONObject(Content.family), crfOut);
+        //存放CRF模型一般查体(体格检查(一))返回数据
+        putAllCrfData(midData.getJSONObject(Content.phys_exam), crfOut);
+        //存放CRF模型个人史、月经史、婚育史返回数据
+        putAllCrfData(midData.getJSONObject(Content.personal), crfOut);
+        putAllCrfData(midData.getJSONObject(Content.menses), crfOut);
+        putAllCrfData(midData.getJSONObject(Content.marriage), crfOut);
+        //存放CRF模型病历特点、初步诊断、诊断依据返回数据
+        putAllCrfData(midData.getJSONObject(Content.case_feature), crfOut);
+        putAllCrfData(midData.getJSONObject(Content.pridiag), crfOut);
+        putAllCrfData(midData.getJSONObject(Content.diag_basis), crfOut);
         return crfOut;
     }
 
@@ -91,7 +107,8 @@ public class BeHospitalizedAI {
         add2Output(new EntityProcessVital(), outputs, outputInfo);//体征
         add2Output(new EntityProcessLis(), outputs, outputInfo);//化验
         add2Output(new EntityProcessPacs(), outputs, outputInfo);//辅检
-
+        add2Output(new EntityProcessDiag(), outputs, outputInfo);//诊断
+        add2Output(new EntityProcessPast(), outputs, outputInfo);
 
         medOut.add(outputInfo);
         crfOut.put(jsonObject.getString("detail_title"),medOut);

+ 2 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/model/CrfOut.java

@@ -15,5 +15,7 @@ public class CrfOut {
     List<Pacs> pacses = new ArrayList<>();
     List<GeneralDesc> generals = new ArrayList<>();//基本情况
     List<Lis> lises = new ArrayList<>();
+    List<Diag> diags = new ArrayList<>();
+    List<Past> pasts = new ArrayList<>();
 
 }

+ 42 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessDiag.java

@@ -0,0 +1,42 @@
+package com.lantone.qc.kernel.structure.ai.process;
+
+import com.alibaba.fastjson.JSONObject;
+import com.lantone.qc.kernel.structure.ai.model.CrfOut;
+import com.lantone.qc.kernel.structure.ai.model.EntityEnum;
+import com.lantone.qc.pub.model.entity.Diag;
+import com.lantone.qc.pub.model.entity.Possible;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class EntityProcessDiag extends EntityProcess {
+    @Override
+    public void extractEntity(JSONObject outputs, CrfOut outputInfo) {
+        List<Diag> diagnose = new ArrayList<>();
+        Diag diag = null;
+        List<Map<String, String>> diagEntityList = processJson(outputs, EntityEnum.DIEASE.toString());
+        for (Map<String, String> diagEntityMap : diagEntityList) {
+            if (StringUtils.isEmpty(diagEntityMap.get(EntityEnum.DIEASE.toString()))) {
+                continue;
+            }
+            diag = new Diag();
+            for (String key : diagEntityMap.keySet()) {
+                String value = StringUtils.isEmpty(diagEntityMap.get(key)) ? "" : diagEntityMap.get(key);
+                switch (EntityEnum.parseOfValue(key)) {
+                    case DIEASE:
+                        diag.setName(value);
+                        break;
+                    case POSSIBLE:
+                        Possible possible = new Possible();
+                        possible.setName(value);
+                        diag.setPossible(possible);
+                        break;
+                }
+            }
+            diagnose.add(diag);
+        }
+        outputInfo.setDiags(diagnose);
+    }
+}

+ 121 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessPast.java

@@ -0,0 +1,121 @@
+package com.lantone.qc.kernel.structure.ai.process;
+
+import com.alibaba.fastjson.JSONObject;
+import com.lantone.qc.kernel.structure.ai.model.CrfOut;
+import com.lantone.qc.kernel.structure.ai.model.EntityEnum;
+import com.lantone.qc.pub.model.entity.Negative;
+import com.lantone.qc.pub.model.entity.Past;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class EntityProcessPast extends EntityProcess {
+    public static String allergy_history = "过敏史";
+    public static String disease_history = "疾病史";
+    public static String surgery_history = "手术史";
+    public static String injury_history = "外伤史";
+    public static String blood_history = "输血史";
+    public static String vaccination_history = "预防接种史";
+    public static String infect_history = "传染病史";
+    @Override
+    public void extractEntity(JSONObject outputs, CrfOut outputInfo) {
+        List<Past> pasts = new ArrayList<>();
+        //疾病史
+        addPast(outputs, pasts);
+        //手术史
+        addPast(outputs, pasts, EntityEnum.OPERATION, 1, EntityProcessPast.surgery_history);
+        addPast(outputs, pasts, EntityEnum.OPERATION_KEYWORD, 1, EntityProcessPast.surgery_history);
+
+        //外伤史
+        addPast(outputs, pasts, EntityEnum.INJURY, 2, EntityProcessPast.injury_history);
+
+        //过敏史
+        addPast(outputs, pasts, EntityEnum.ALLERGY, 3, EntityProcessPast.allergy_history);
+        addPast(outputs, pasts, EntityEnum.FOOD_ALLERGY, 3, EntityProcessPast.allergy_history);
+        addPast(outputs, pasts, EntityEnum.DRUG_ALLERGY, 3, EntityProcessPast.allergy_history);
+        addPast(outputs, pasts, EntityEnum.ALLERGY_SYMPTOM, 3, EntityProcessPast.allergy_history);
+
+        //输血史
+        addPast(outputs, pasts, EntityEnum.BLOOD_TRANSFUSION, 4, EntityProcessPast.blood_history);
+
+        //预防接种史
+        addPast(outputs, pasts, EntityEnum.VACCINATION, 5, EntityProcessPast.vaccination_history);
+
+        //传染病史
+        addPast(outputs, pasts, EntityEnum.INFECTIOUS_KEYWORD, 7, EntityProcessPast.infect_history);
+        outputInfo.setPasts(pasts);
+
+
+
+    }
+    private void addPast(JSONObject outputs, List<Past> pasts) {
+        Past past = null;
+        List<Map<String, String>> pastEntityList = processJson(outputs, EntityEnum.DIEASE.toString());
+        for (Map<String, String> pastEntityMap : pastEntityList) {
+            if (StringUtils.isEmpty(pastEntityMap.get(EntityEnum.DIEASE.toString()))) {
+                continue;
+            }
+            past = new Past();
+            String cureValue = "";
+            for (String key : pastEntityMap.keySet()) {
+                switch (EntityEnum.parseOfValue(key)) {
+                    case DIEASE:
+                        past.setType(6);
+                        past.setTitle(EntityProcessPast.disease_history);
+                        past.setValue(pastEntityMap.get(key));
+                        break;
+                    case CURE:
+                        past.setTreat(pastEntityMap.get(key));
+                        break;
+                    case CURE_AIM:
+                        cureValue += "," + pastEntityMap.get(key);
+                        break;
+                    case TREND:
+                        cureValue += "," + pastEntityMap.get(key);
+                        break;
+                    case TIME:
+                        cureValue += "," + pastEntityMap.get(key);
+                        break;
+                    case FREQUENCY:
+                        cureValue += "," + pastEntityMap.get(key);
+                        break;
+                    case MODIFICATION:
+                        cureValue += "," + pastEntityMap.get(key);
+                        break;
+                    case NEGATIVE:
+                        Negative negative = new Negative();
+                        negative.setName(StringUtils.isEmpty(pastEntityMap.get(key)) ? "" : pastEntityMap.get(key));
+                        past.setNegative(negative);
+                        break;
+                    //TODO   PD
+                }
+            }
+            past.setDescribe(cureValue.startsWith(",") ? cureValue.substring(1, cureValue.length()) : cureValue);
+            pasts.add(past);
+        }
+    }
+    private void addPast(JSONObject outputs, List<Past> pasts, EntityEnum entityType, int pastType, String pastTypeString) {
+        Past past = null;
+        List<Map<String, String>> pastEntityList = processJson(outputs, entityType.toString());
+        for (Map<String, String> pastEntityMap : pastEntityList) {
+            if (StringUtils.isEmpty(pastEntityMap.get(entityType.toString()))) {
+                continue;
+            }
+            past = new Past();
+            for (String key : pastEntityMap.keySet()) {
+                if (key.equals(entityType.toString())) {
+                    past.setType(pastType);
+                    past.setTitle(pastTypeString);
+                    past.setValue(pastEntityMap.get(key));
+                } else if (key.equals(EntityEnum.NEGATIVE.toString())) {
+                    Negative negative = new Negative();
+                    negative.setName(StringUtils.isEmpty(pastEntityMap.get(key)) ? "" : pastEntityMap.get(key));
+                    past.setNegative(negative);
+                }
+            }
+            pasts.add(past);
+        }
+    }
+}

+ 1 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Diag.java

@@ -13,5 +13,6 @@ import lombok.Setter;
 @Getter
 @Setter
 public class Diag extends General {
+    private Possible possible;
     private String ICD;
 }

+ 18 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Past.java

@@ -0,0 +1,18 @@
+package com.lantone.qc.pub.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+@Setter
+@Getter
+public class Past extends General {
+    // 0:健康情况,1:手术史,2:外伤史,3:过敏史,4:输血史,5:预防接种史,6:疾病史,7:传染病史
+    private int Type;
+    private String Title;
+    private String Value;
+    private String treat;
+    private String describe;
+    private List<PD> periods;
+    private Negative negative;
+}