浏览代码

后接口化分析接口加入

rengb 4 年之前
父节点
当前提交
2e162cda4d

+ 2 - 0
structure-center/src/main/java/com/lantone/StructureCenterApplication.java

@@ -4,9 +4,11 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
 
 @SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
 @EnableEurekaClient
+@EnableFeignClients
 public class StructureCenterApplication {
 
     public static void main(String[] args) {

+ 1 - 1
structure-center/src/main/java/com/lantone/structure/ai/BeHospitalizedAI.java

@@ -146,7 +146,7 @@ public class BeHospitalizedAI extends ModelAI {
                 putContent(crfContent, medicalTextType.get(6), suppleDiagText, Content.supple_diag);
             }
 
-            JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);
+            JSONObject midData = loadAI(crfContent, crfServiceClient);
 
             /* 处理主诉 */
             if (beHospitalizedDoc.getChiefLabel() != null && beHospitalizedDoc.getChiefLabel().isCrfLabel()) {

+ 1 - 1
structure-center/src/main/java/com/lantone/structure/ai/ConsultationAI.java

@@ -47,7 +47,7 @@ public class ConsultationAI extends ModelAI {
             putContent(crfContent, medicalTextType.get(0), content, i + "药物");
         }
 
-        JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
+        JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
 
         for (int i = 0; i < resultsDocs.size(); i++) {
             if (midData.get(i + "药物") == null) {

+ 1 - 1
structure-center/src/main/java/com/lantone/structure/ai/FirstCourseRecordAI.java

@@ -116,7 +116,7 @@ public class FirstCourseRecordAI extends ModelAI {
                 }
             }
 
-            JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
+            JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
             //if (midData.containsKey(Content.case_feature)) {
             //  putCaseCharacteristicCrfData(midData.getJSONObject(Content.case_feature), inputInfo);//处理病历特点
             //}

+ 1 - 1
structure-center/src/main/java/com/lantone/structure/ai/LeaveHospitalAI.java

@@ -67,7 +67,7 @@ public class LeaveHospitalAI extends ModelAI {
             String drugContent = CatalogueUtil.structureMapJoin(leaveHospitalStructureMap, Lists.newArrayList("诊治经过", "出院带药"));
             putContent(crfContent, medicalTextType.get(2), drugContent, "药品");
 
-            JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
+            JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
             if (midData.containsKey(Content.discharge)) {
                 putDischargeCrfData(midData.getJSONObject(Content.discharge), inputInfo);//出院小结
             }

+ 2 - 2
structure-center/src/main/java/com/lantone/structure/ai/ModelAI.java

@@ -32,7 +32,7 @@ public class ModelAI {
      * @param crfServiceClient
      * @return
      */
-    protected JSONObject loadAI(boolean useCrfCache, String behospitalCode, JSONArray crfContent, CRFServiceClient crfServiceClient) {
+    protected JSONObject loadAI(JSONArray crfContent, CRFServiceClient crfServiceClient) {
         JSONArray data = null;
         String classname = this.getClass().getName();
         if (data == null) {
@@ -43,7 +43,7 @@ public class ModelAI {
             //获取CRF模型返回数据
             data = getAnnotation(crfServiceClient, crfVo).getData();
             long t2 = System.currentTimeMillis();
-            log.error(behospitalCode + "-----" + classname + "(CRF)  耗时:" + (t2 - t1));
+            log.error("-----" + classname + "(CRF)  耗时:" + (t2 - t1));
         }
         JSONObject midData = getOutputs(data);
         return midData;

+ 1 - 1
structure-center/src/main/java/com/lantone/structure/ai/OperationAI.java

@@ -61,7 +61,7 @@ public class OperationAI extends ModelAI {
             }
         }
 
-        JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
+        JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
 
         for (int i = 0; i < operationDocs.size(); i++) {
             if (midData.get("手术记录" + i + "药物") != null) {

+ 1 - 1
structure-center/src/main/java/com/lantone/structure/ai/ThreeLevelWardAI.java

@@ -98,7 +98,7 @@ public class ThreeLevelWardAI extends ModelAI {
             }
         }
 
-        JSONObject midData = loadAI(inputInfo.isUseCrfCache(), inputInfo.getMedicalRecordInfoDoc().getStructureMap().get("behospitalCode"), crfContent, crfServiceClient);//crf返回数据
+        JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
 
         //主治医师首次查房记录模型输出
         if (midData.get(Content.attend) != null) {

+ 0 - 44
structure-center/src/main/java/com/lantone/structure/controller/DbController.java

@@ -1,44 +0,0 @@
-package com.lantone.structure.controller;
-
-import com.google.common.collect.Lists;
-import com.lantone.qc.dbanaly.facade.changx.ChangxXmlDataAnalysisFacade;
-import com.lantone.qc.dbanaly.facade.comsis.ModuleHelper;
-import com.lantone.qc.dbanaly.facade.comsis.RedisFacade;
-import com.lantone.qc.dbanaly.facade.shaoyf.ShaoyfXmlDataAnalysisFacade;
-import com.lantone.qc.dbanaly.facade.taizhou.TaiZhouXmlDataAnalysisFacade;
-import com.lantone.qc.dbanaly.facade.yiwu.YiWuXmlDataAnalysisFacade;
-import com.lantone.qc.dbanaly.vo.AnalyzeXmlVO;
-import com.lantone.qc.dbanaly.vo.CrfCacheRemoveVO;
-import com.lantone.qc.pub.res.Response;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-
-/**
- * @ClassName : QCController
- * @Description : 质控总入口
- * @Author : 楼辉荣
- * @Date: 2020-03-03 19:57
- */
-@Slf4j
-@Api(value = "数据对接接口", tags = { "数据对接接口" })
-@RestController
-@RequestMapping(value = "/db")
-public class DbController {
-
-    @ApiOperation(value = "模板信息加载")
-    @PostMapping("loadModuleInfo")
-    public Response<Boolean> loadModuleInfo() {
-        Response response = new Response();
-        response.setData(moduleHelper.loadModuleInfo());
-        return response;
-    }
-
-}

+ 29 - 0
structure-center/src/main/java/com/lantone/structure/controller/StructureController.java

@@ -0,0 +1,29 @@
+package com.lantone.structure.controller;
+
+import com.lantone.structure.dto.AnalysisDTO;
+import com.lantone.structure.dto.RespDTO;
+import com.lantone.structure.facade.StructureFacade;
+import com.lantone.structure.vo.AnalysisVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api(value = "后结构化接口", tags = { "后结构化接口" })
+@RestController
+@RequestMapping(value = "/lt/structure")
+public class StructureController {
+
+    @Autowired
+    private StructureFacade structureFacade;
+
+    @ApiOperation(value = "解析")
+    @PostMapping("analysis")
+    public RespDTO<AnalysisDTO> analysis(@RequestBody AnalysisVO analysisVO) {
+        return RespDTO.onSuc(structureFacade.analysis(analysisVO));
+    }
+
+}

+ 12 - 0
structure-center/src/main/java/com/lantone/structure/dto/AnalysisDTO.java

@@ -0,0 +1,12 @@
+package com.lantone.structure.dto;
+
+import lombok.Data;
+
+import java.util.Map;
+
+@Data
+public class AnalysisDTO {
+
+    private Map<String, Object> result;
+
+}

+ 29 - 6
structure-center/src/main/java/com/lantone/structure/dto/RespDTO.java

@@ -1,9 +1,32 @@
 package com.lantone.structure.dto;
 
-/**
- * @Description:
- * @author: rengb
- * @time: 2020/12/18 16:10
- */
-public class RespDTO {
+import java.io.Serializable;
+
+public class RespDTO<T> implements Serializable {
+    
+    public String code = "0";
+    public String msg = "";
+    public T data;
+
+    public static RespDTO onSuc(Object data) {
+        RespDTO resp = new RespDTO();
+        resp.data = data;
+        return resp;
+    }
+
+    public static RespDTO onError(String errMsg) {
+        RespDTO resp = new RespDTO();
+        resp.code = "-1";
+        resp.msg = errMsg;
+        return resp;
+    }
+
+    @Override
+    public String toString() {
+        return "RespDTO{" +
+                "code=" + code +
+                ", error='" + msg + '\'' +
+                ", data=" + data +
+                '}';
+    }
 }

+ 63 - 0
structure-center/src/main/java/com/lantone/structure/facade/StructureFacade.java

@@ -0,0 +1,63 @@
+package com.lantone.structure.facade;
+
+import com.google.common.collect.Maps;
+import com.lantone.common.util.FastJsonUtils;
+import com.lantone.structure.ai.AIAnalyze;
+import com.lantone.structure.client.CRFServiceClient;
+import com.lantone.structure.client.SimilarityServiceClient;
+import com.lantone.structure.dto.AnalysisDTO;
+import com.lantone.structure.model.InputInfo;
+import com.lantone.structure.model.doc.BeHospitalizedDoc;
+import com.lantone.structure.model.label.PresentLabel;
+import com.lantone.structure.vo.AnalysisVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2020/12/18 16:22
+ */
+@Slf4j
+@Component
+public class StructureFacade {
+    @Autowired
+    CRFServiceClient crfServiceClient;
+    @Autowired
+    SimilarityServiceClient similarityServiceClient;
+
+
+    public AnalysisDTO analysis(AnalysisVO analysisVO) {
+        AnalysisDTO analysisDTO = new AnalysisDTO();
+        InputInfo inputInfo = new InputInfo();
+
+        BeHospitalizedDoc beHospitalizedDoc = new BeHospitalizedDoc();
+
+        PresentLabel presentLabel = new PresentLabel();
+        presentLabel.setText(analysisVO.getText());
+        beHospitalizedDoc.setPresentLabel(presentLabel);
+
+        inputInfo.setBeHospitalizedDoc(beHospitalizedDoc);
+
+        AIAnalyze aiAnalyze = new AIAnalyze(crfServiceClient, similarityServiceClient);
+        try {
+            aiAnalyze.aiProcess(inputInfo);
+        } catch (Exception e) {
+            log.error("AI模型执行错误:" + e.getMessage(), e);
+        }
+
+        Map<String, Object> map = Maps.newHashMap();
+        Map<String, Object> jsonMap = FastJsonUtils.getJsonToMap(FastJsonUtils.getBeanToJson(inputInfo.getBeHospitalizedDoc().getPresentLabel()));
+        jsonMap.remove("text");
+        jsonMap.remove("aiText");
+        jsonMap.remove("crfLabel");
+        jsonMap.remove("crfOutput");
+        map.put("现病史", jsonMap);
+        analysisDTO.setResult(map);
+        return analysisDTO;
+    }
+
+}

+ 19 - 0
structure-center/src/main/java/com/lantone/structure/vo/AnalysisVO.java

@@ -0,0 +1,19 @@
+package com.lantone.structure.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+@Data
+public class AnalysisVO {
+
+    @NotBlank(message = "文本类型必传!")
+    @ApiModelProperty(value = "文本类型", required = true)
+    private String type;
+
+    @NotBlank(message = "文本内容必传!")
+    @ApiModelProperty(value = "文本内容", required = true)
+    private String text;
+
+}