Ver código fonte

添加crf依赖

kongwz 5 anos atrás
pai
commit
57763324ff
18 arquivos alterados com 296 adições e 39 exclusões
  1. 2 1
      kernel/src/main/java/com/lantone/qc/kernel/KernelApplication.java
  2. 7 0
      kernel/src/main/java/com/lantone/qc/kernel/analysis/QCAnalysis.java
  3. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/client/CRFServiceClient.java
  4. 1 6
      kernel/src/main/java/com/lantone/qc/kernel/client/hystrix/CRFServiceHystrix.java
  5. 25 0
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/AIAnalyze.java
  6. 19 11
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/BeHospitalizedAI.java
  7. 3 3
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/model/CrfOut.java
  8. 44 0
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessGenerals.java
  9. 52 0
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessLis.java
  10. 48 0
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessPacs.java
  11. 23 13
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessSymptom.java
  12. 59 0
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessVital.java
  13. 2 1
      kernel/src/main/java/com/lantone/qc/kernel/web/controller/QCController.java
  14. 3 1
      public/src/main/java/com/lantone/qc/pub/model/entity/Clinical.java
  15. 1 0
      public/src/main/java/com/lantone/qc/pub/model/entity/GeneralDesc.java
  16. 3 0
      public/src/main/java/com/lantone/qc/pub/model/entity/Lis.java
  17. 2 1
      public/src/main/java/com/lantone/qc/pub/model/entity/Pacs.java
  18. 1 1
      public/src/main/java/com/lantone/qc/pub/model/entity/Trend.java

+ 2 - 1
kernel/src/main/java/com/lantone/qc/kernel/KernelApplication.java

@@ -3,8 +3,9 @@ package com.lantone.qc.kernel;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.ComponentScan;
-
+@EnableFeignClients
 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
 @ComponentScan("com.lantone.qc")
 public class KernelApplication {

+ 7 - 0
kernel/src/main/java/com/lantone/qc/kernel/analysis/QCAnalysis.java

@@ -1,9 +1,12 @@
 package com.lantone.qc.kernel.analysis;
 
+import com.lantone.qc.kernel.client.CRFServiceClient;
+import com.lantone.qc.kernel.structure.ai.AIAnalyze;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.trans.TransDispatch;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 /**
@@ -14,9 +17,13 @@ import org.springframework.stereotype.Component;
  */
 @Component
 public class QCAnalysis {
+    @Autowired
+    CRFServiceClient crfServiceClient;
     public OutputInfo anlysis(QueryVo queryVo) {
         OutputInfo outputInfo = new OutputInfo();
         InputInfo inputInfo = TransDispatch.trans(queryVo);
+        AIAnalyze AIAnalyze = new AIAnalyze(crfServiceClient);
+        AIAnalyze.AIprocess(inputInfo);
         return outputInfo;
     }
 }

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/client/CRFServiceClient.java

@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody;
  * @author: Mark Huang
  * @time: 2019/12/13 9:52
  */
-@FeignClient(value = "CRF-service", url="${CRF.url}", fallback = CRFServiceHystrix.class)
+@FeignClient(value = "CRF-service", url="${CRF.url}")
 public interface CRFServiceClient {
 
     @PostMapping(value = "")

+ 1 - 6
kernel/src/main/java/com/lantone/qc/kernel/client/hystrix/CRFServiceHystrix.java

@@ -9,11 +9,6 @@ import org.springframework.stereotype.Component;
 
 
 @Component
-public class CRFServiceHystrix implements CRFServiceClient{
+public class CRFServiceHystrix {
 
-    @Override
-    public String getAnnotation(CRFVo crfVo) {
-
-        return null;
-    }
 }

+ 25 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/AIAnalyze.java

@@ -0,0 +1,25 @@
+package com.lantone.qc.kernel.structure.ai;
+
+import com.lantone.qc.kernel.client.CRFServiceClient;
+import com.lantone.qc.kernel.structure.ai.model.CrfOut;
+import com.lantone.qc.pub.model.InputInfo;
+
+import java.util.List;
+import java.util.Map;
+
+public class AIAnalyze {
+
+    private CRFServiceClient crfServiceClient;
+    BeHospitalizedAI beHospitalizedAI = new BeHospitalizedAI();
+
+    public AIAnalyze(CRFServiceClient crfService) {
+        this.crfServiceClient = crfService;
+    }
+    public void AIprocess(InputInfo inputInfo){
+        Map<String, List<CrfOut>> beHospitalized_out = beHospitalizedAI.medrec(inputInfo, crfServiceClient);
+        System.out.printf("");
+
+    }
+
+
+}

+ 19 - 11
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/BeHospitalizedAI.java

@@ -6,12 +6,12 @@ import com.alibaba.fastjson.JSONObject;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.client.CRFServiceClient;
 import com.lantone.qc.kernel.structure.ai.model.CrfOut;
-import com.lantone.qc.kernel.structure.ai.process.EntityProcess;
-import com.lantone.qc.kernel.structure.ai.process.EntityProcessSymptom;
+import com.lantone.qc.kernel.structure.ai.process.*;
 import com.lantone.qc.pub.Content;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
 import com.lantone.qc.pub.model.entity.Annotation;
+import com.lantone.qc.pub.model.entity.Lis;
 import com.lantone.qc.pub.model.vo.CRFVo;
 import com.lantone.qc.pub.util.StringUtil;
 
@@ -36,7 +36,9 @@ public class BeHospitalizedAI extends QCCatalogue {
             "GeneralVital_cx", "chief_present");
     public static String entityRelationObject = "entity_relation_object";
     public static String outputs = "outputs";
-    public void medrec(InputInfo inputInfo,CRFServiceClient crfServiceClient){
+
+    public Map<String,List<CrfOut>> medrec(InputInfo inputInfo,CRFServiceClient crfServiceClient){
+
         Map<String,List<CrfOut>> crfOut = new HashMap<>();//主诉-->
         JSONArray crfContent = new JSONArray();
         BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
@@ -72,21 +74,27 @@ public class BeHospitalizedAI extends QCCatalogue {
         //获取CRF模型返回数据
         JSONArray data = getAnnotation(crfServiceClient, crfVo).getData();
         JSONObject midData = getOutputs(data);
-        putAllCrfData(midData.getJSONObject(Content.chief),crfOut,Content.chief);
-
-
-
+        //处理主诉
+        putAllCrfData(midData.getJSONObject(Content.chief),crfOut);
+        return crfOut;
     }
-    public void putAllCrfData(JSONObject jsonObject,Map<String,List<CrfOut>> crfOut,String sign){
+
+    public void putAllCrfData(JSONObject jsonObject,Map<String,List<CrfOut>> crfOut){
         if (jsonObject == null) {
             return;
         }
-        Map<String,List<CrfOut>> detailOutput = new HashMap<>();
         JSONObject outputs = jsonObject.getJSONObject(entityRelationObject).getJSONObject(BeHospitalizedAI.outputs);
-        List<CrfOut> outputInfos = new ArrayList<>();
+        List<CrfOut> medOut = new ArrayList<>();
         CrfOut outputInfo = new CrfOut();
-        add2Output(new EntityProcessSymptom(), outputs, outputInfo);
+        add2Output(new EntityProcessSymptom(), outputs, outputInfo);//临床表现
+        add2Output(new EntityProcessGenerals(), outputs, outputInfo);//一般情况描述
+        add2Output(new EntityProcessVital(), outputs, outputInfo);//体征
+        add2Output(new EntityProcessLis(), outputs, outputInfo);//化验
+        add2Output(new EntityProcessPacs(), outputs, outputInfo);//辅检
+
 
+        medOut.add(outputInfo);
+        crfOut.put(jsonObject.getString("detail_title"),medOut);
     }
     public void add2Output(EntityProcess entityProcess, JSONObject outputs, CrfOut outputInfo){
         entityProcess.extractEntity(outputs, outputInfo);

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

@@ -1,8 +1,6 @@
 package com.lantone.qc.kernel.structure.ai.model;
 
-import com.lantone.qc.pub.model.entity.Clinical;
-import com.lantone.qc.pub.model.entity.Pacs;
-import com.lantone.qc.pub.model.entity.Vital;
+import com.lantone.qc.pub.model.entity.*;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -15,5 +13,7 @@ public class CrfOut {
     List<Clinical> symptoms = new ArrayList<Clinical>();//症状
     List<Vital> vitals = new ArrayList<>();
     List<Pacs> pacses = new ArrayList<>();
+    List<GeneralDesc> generals = new ArrayList<>();//基本情况
+    List<Lis> lises = new ArrayList<>();
 
 }

+ 44 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessGenerals.java

@@ -0,0 +1,44 @@
+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.General;
+import com.lantone.qc.pub.model.entity.GeneralDesc;
+import com.lantone.qc.pub.model.entity.Negative;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class EntityProcessGenerals extends EntityProcess{
+
+    @Override
+    public void extractEntity(JSONObject outputs, CrfOut outputInfo) {
+        List<GeneralDesc> generals = new ArrayList<>();
+        GeneralDesc general;
+        List<Map<String, String>> generalEntityList = processJson(outputs, EntityEnum.GENERAL.toString());
+        for (Map<String, String> generalEntityMap : generalEntityList) {
+            if (StringUtils.isEmpty(generalEntityMap.get(EntityEnum.GENERAL.toString()))) {
+                continue;
+            }
+            general = new GeneralDesc();
+            for (String key : generalEntityMap.keySet()) {
+                String entity = StringUtils.isEmpty(generalEntityMap.get(key)) ? "" : generalEntityMap.get(key);
+                switch (EntityEnum.parseOfValue(key)){
+                    case GENERAL:
+                        general.setName(entity);
+                        break;
+                    case NEGATIVE:
+                        Negative negative = new Negative();
+                        negative.setName(entity);
+                        general.setNegative(negative);
+                        break;
+                }
+            }
+            generals.add(general);
+        }
+        outputInfo.setGenerals(generals);
+    }
+}

+ 52 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessLis.java

@@ -0,0 +1,52 @@
+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.Lis;
+import com.lantone.qc.pub.model.entity.LisValue;
+import com.lantone.qc.pub.model.entity.PD;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class EntityProcessLis extends EntityProcess {
+    @Override
+    public void extractEntity(JSONObject outputs, CrfOut outputInfo) {
+        List<Lis> lises = new ArrayList<>();
+        Lis lis = null;
+        List<Map<String, String>> lisEntityList = processJson(outputs, EntityEnum.LABORATORY.toString());
+        for (Map<String, String> lisEntityMap : lisEntityList) {
+            if (StringUtils.isEmpty(lisEntityMap.get(EntityEnum.LABORATORY.toString()))) {
+                continue;
+            }
+            lis = new Lis();
+            for (String key : lisEntityMap.keySet()) {
+                String entity = StringUtils.isEmpty(lisEntityMap.get(key)) ? "" : lisEntityMap.get(key);
+                switch (EntityEnum.parseOfValue(key)) {
+                    case LABORATORY:
+                        lis.setName(entity);
+                        break;
+                    case LABORATORY_VALUE:
+                        LisValue lisValue = new LisValue();
+                        lisValue.setName(entity);
+                        lis.setLisValue(lisValue);
+                        PD pd = new PD();
+                        String value = entity;
+                        String[] val_unit = new String[2];
+                        if (value.trim().length() > 0) {
+                            val_unit = extract_digit(value);
+                        }
+                        pd.setValue(val_unit[0]);
+                        pd.setUnit(val_unit[1]);
+                        lis.setPd(pd);
+                        break;
+                }
+            }
+            lises.add(lis);
+        }
+        outputInfo.setLises(lises);
+    }
+}

+ 48 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessPacs.java

@@ -0,0 +1,48 @@
+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.BodyPart;
+import com.lantone.qc.pub.model.entity.Pacs;
+import com.lantone.qc.pub.model.entity.PacsValue;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class EntityProcessPacs extends EntityProcess {
+    @Override
+    public void extractEntity(JSONObject outputs, CrfOut outputInfo) {
+        List<Pacs> pacses = new ArrayList<>();
+        Pacs pacs = null;
+        List<Map<String, String>> pacsEntityList = processJson(outputs, EntityEnum.AUXILIARY_EXAMINATION.toString());
+        for (Map<String, String> pacsEntityMap : pacsEntityList) {
+            if (StringUtils.isEmpty(pacsEntityMap.get(EntityEnum.AUXILIARY_EXAMINATION.toString()))) {
+                continue;
+            }
+            pacs = new Pacs();
+            for (String key : pacsEntityMap.keySet()) {
+                String entity = StringUtils.isEmpty(pacsEntityMap.get(key)) ? "" : pacsEntityMap.get(key);
+                switch (EntityEnum.parseOfValue(key)) {
+                    case AUXILIARY_EXAMINATION:
+                        pacs.setName(entity);
+                        break;
+                    case AUXILIARY_DESCRIPT:
+                        PacsValue pacsValue = new PacsValue();
+                        pacsValue.setName(entity);
+                        pacs.setPacsValues(pacsValue);
+                        break;
+                    case BODY:
+                        BodyPart bodyPart = new BodyPart();
+                        bodyPart.setName(entity);
+                        pacs.setBodyPart(bodyPart);
+                        break;
+                }
+            }
+            pacses.add(pacs);
+        }
+        outputInfo.setPacses(pacses);
+    }
+}

+ 23 - 13
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessSymptom.java

@@ -4,9 +4,7 @@ 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.BodyPart;
-import com.lantone.qc.pub.model.entity.Clinical;
-import com.lantone.qc.pub.model.entity.Negative;
+import com.lantone.qc.pub.model.entity.*;
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.ArrayList;
@@ -40,21 +38,33 @@ public class EntityProcessSymptom extends EntityProcess {
                         BodyPart bodyPart = new BodyPart();
                         bodyPart.setName(entity);
                         clinical.setBodyPart(bodyPart);
-                    case MODIFICATION:
-
-
-
-
-
-
-
+                    case TREND:
+                        Trend trend = new Trend();
+                        trend.setName(entity);
+                        clinical.setTrend(trend);
+                    case CAUSE:
+                        Cause cause = new Cause();
+                        cause.setName(entity);
+                        clinical.setCause(cause);
+                    case TIME:
+                        List<PD> timestamp = new ArrayList<>();
+                        PD pd = new PD();
+                        String[] val_unit = new String[2];
+                        if(entity.trim().length()>0){
+                            val_unit = extract_digit(entity);
+                        }
+                        pd.setValue(val_unit[0]);
+                        pd.setUnit(val_unit[1]);
+                        timestamp.add(pd);
+                        clinical.setTimestamp(timestamp);
+                        break;
 
                 }
 
             }
-
+            clinicals.add(clinical);
         }
-
+        outputInfo.setSymptoms(clinicals);
 
     }
 }

+ 59 - 0
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessVital.java

@@ -0,0 +1,59 @@
+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.*;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class EntityProcessVital extends EntityProcess {
+    @Override
+    public void extractEntity(JSONObject outputs, CrfOut outputInfo) {
+        List<Vital> vitals = new ArrayList<>();
+        Vital vital =null;
+        List<Map<String, String>> vitalEntityList = processJson(outputs, EntityEnum.SIGN.toString());
+        for (Map<String, String> vitalEntityMap : vitalEntityList) {
+            if (StringUtils.isEmpty(vitalEntityMap.get(EntityEnum.SIGN.toString()))) {
+                continue;
+            }
+            vital = new Vital();
+            for (String key:vitalEntityMap.keySet()) {
+                String entity = vitalEntityMap.get(key);
+                switch (EntityEnum.parseOfValue(key)) {
+                    case SIGN:
+                        vital.setVitalName(entity);
+                        break;
+                    case NEGATIVE:
+                        Negative negative = new Negative();
+                        negative.setName(entity);
+                        vital.setNegative(negative);
+                        break;
+                    case BODY:
+                        BodyPart bodyPart = new BodyPart();
+                        bodyPart.setName(entity);
+                        vital.setBodyPart(bodyPart);
+                        break;
+                    case INDEX_VALUE:
+                        vital.setValue(StringUtils.isEmpty(entity)?"":entity);
+                        PD pd =new PD();
+                        pd.setValue(StringUtils.isEmpty(entity)?"":entity);
+                        vital.setPd(pd);
+                        break;
+                    case MODIFICATION:
+                        if(entity.contains("度")){
+                            Degree degree = new Degree();
+                            degree.setName(entity);
+                            vital.setDegree(degree);
+                        }
+                        break;
+                }
+            }
+            vitals.add(vital);
+        }
+        outputInfo.setVitals(vitals);
+    }
+}

+ 2 - 1
kernel/src/main/java/com/lantone/qc/kernel/web/controller/QCController.java

@@ -5,6 +5,8 @@ import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.pub.res.Response;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -26,7 +28,6 @@ public class QCController {
 
     @Autowired
     private QCAnalysis qCAnalysis;
-
     @ApiOperation(value = "质控外部接口,需要token信息", notes = "")
     @PostMapping("rec")
     public Response<Map<String, Object>> extract(@RequestBody QueryVo queryVo) {

+ 3 - 1
public/src/main/java/com/lantone/qc/pub/model/entity/Clinical.java

@@ -13,7 +13,9 @@ import java.util.List;
 public class Clinical extends General {
     private Negative negative;
     private BodyPart bodyPart;
-    private Degree degree;
+    private Trend trend;//趋势
+    private Degree degree;//程度
     private Cause cause;
     private PD pds;
+    private List<PD> timestamp;
 }

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

@@ -12,4 +12,5 @@ import lombok.Setter;
 @Getter
 @Setter
 public class GeneralDesc extends General {
+    private Negative negative;
 }

+ 3 - 0
public/src/main/java/com/lantone/qc/pub/model/entity/Lis.java

@@ -13,4 +13,7 @@ import lombok.Setter;
 @Getter
 @Setter
 public class Lis extends General {
+    private LisValue lisValue;
+    private PD pd;
+
 }

+ 2 - 1
public/src/main/java/com/lantone/qc/pub/model/entity/Pacs.java

@@ -15,5 +15,6 @@ import java.util.List;
 @Setter
 @Getter
 public class Pacs extends General{
-    List<PacsValue> pacsValues;
+    private PacsValue pacsValues;
+    private BodyPart bodyPart;
 }

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

@@ -6,5 +6,5 @@ package com.lantone.qc.pub.model.entity;
  * @Author : 楼辉荣
  * @Date: 2020-03-03 18:31
  */
-public class Trend {
+public class Trend extends General{
 }