瀏覽代碼

治疗方案合并到推理接口

Zhaops 6 年之前
父節點
當前提交
44c48440c8

+ 9 - 0
icss-service/src/main/java/com/diagbot/client/bean/ResponseData.java

@@ -16,6 +16,15 @@ public class ResponseData {
     private List<FeatureRate> dis = new ArrayList<>(10);
     private List<FeatureRate> labs = new ArrayList<>(10);
     private List<FeatureRate> pacs = new ArrayList<>(10);
+    private Map<String,String> treat;
+
+    public Map<String, String> getTreat() {
+        return treat;
+    }
+
+    public void setTreat(Map<String, String> treat) {
+        this.treat = treat;
+    }
 
     private Map<String, Map<String, String>> inputs = new HashMap<>(10, 0.5f);
 

+ 12 - 0
icss-service/src/main/java/com/diagbot/client/bean/SearchData.java

@@ -1,5 +1,7 @@
 package com.diagbot.client.bean;
 
+import com.diagbot.vo.LisResult;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -24,6 +26,8 @@ public class SearchData {
     private String diag = "";
     private String past = "";
     private String other = "";
+    private List<LisResult> lisArr;
+
 
     //特征类别
     private String featureType;
@@ -256,4 +260,12 @@ public class SearchData {
     public void setAlgorithmClassifyValue(String algorithmClassifyValue) {
         this.algorithmClassifyValue = algorithmClassifyValue;
     }
+
+    public List<LisResult> getLisArr() {
+        return lisArr;
+    }
+
+    public void setLisArr(List<LisResult> lisArr) {
+        this.lisArr = lisArr;
+    }
 }

+ 1 - 0
icss-service/src/main/java/com/diagbot/dto/PushDTO.java

@@ -19,4 +19,5 @@ public class PushDTO {
     private List<QuestionDTO> lab;
     private List<QuestionDTO> pacs;
     private Map<String, List<QuestionDTO>> dis;
+    private Map<String,Object> treat;
 }

+ 20 - 5
icss-service/src/main/java/com/diagbot/facade/PushFacade.java

@@ -53,6 +53,8 @@ public class PushFacade {
     private DeptVitalFacade deptVitalFacade;
     @Autowired
     private VitalOrderFacade vitalOrderFacade;
+    @Autowired
+    private TreatmentFacade treatmentFacade;
 
     /**
      * 推理接口
@@ -65,7 +67,8 @@ public class PushFacade {
         searchData.setAge(pushVO.getAge());
         searchData.setSymptom(pushVO.getSymptom());
         searchData.setVital(pushVO.getVital());
-        searchData.setLis(pushVO.getLis());
+        searchData.setLisArr(pushVO.getLis());
+
         searchData.setPacs(pushVO.getPacs());
         searchData.setPast(pushVO.getPast());
         searchData.setOther(pushVO.getOther());
@@ -108,6 +111,7 @@ public class PushFacade {
         List<FeatureRate> dis = data.getDis();
         List<FeatureRate> pacs = data.getPacs();
         List<FeatureRate> labs = data.getLabs();
+        Map<String, String> treat = data.getTreat();
 
         Map<String, Object> symptomMap = list2Map(symptom);
         Map<String, Object> disMap = list2Map(dis);
@@ -119,7 +123,7 @@ public class PushFacade {
             pushDTO.setLab(labDTO);
         }
         if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Pacs.getKey()))) {
-            List<QuestionDTO> pacsDTO = getTagListByMap(labMap, pushVO, QuestionTypeEnum.Pacs.getKey());
+            List<QuestionDTO> pacsDTO = getTagListByMap(pacsMap, pushVO, QuestionTypeEnum.Pacs.getKey());
             pushDTO.setPacs(pacsDTO);
         }
         //诊断 返回tagName+标签
@@ -149,6 +153,14 @@ public class PushFacade {
             pushDTO.setVital(vitalDTO);
 
         }
+        //治疗方案
+        if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Drug.getKey()))) {
+            if (pushVO.getDiseaseId() == null) {
+                throw new CommonException(CommonErrorCode.PARAM_ERROR, "请输入诊断id");
+            }
+            Map<String, Object> treatmentMap = treatmentFacade.getTreatment(treat, pushVO.getDiseaseId());
+            pushDTO.setTreat(treatmentMap);
+        }
         return pushDTO;
     }
 
@@ -204,14 +216,17 @@ public class PushFacade {
         pushVO.setSex(pushKYJVO.getSex());
 
         //参数预处理
-        String lis = "";
+        /*String lis = "";
         List<String> lisResultList = Lists.newArrayList();
-        for (LisKYJVO lisKYJVO : pushKYJVO.getLisKYJVOList()) {
+        for (LisKYJVO lisKYJVO : pushKYJVO.getLisResultList()) {
             lisKYJVO = resultCalculation(lisKYJVO);
             lisResultList.addAll(getLisInputs(lisKYJVO));
         }
         lis = String.join(",", lisResultList);
-        pushVO.setLis(lis);
+        pushVO.setLis(lis);*/
+
+        //化验结果
+        pushVO.setLis(pushKYJVO.getLisResultList());
 
         ResponseData responseData = pushAI(pushVO);
         PushKYJDTO pushKYJDTO = new PushKYJDTO();

+ 13 - 29
icss-service/src/main/java/com/diagbot/facade/TreatmentFacade.java

@@ -2,12 +2,8 @@ package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.client.TreatServiceClient;
-import com.diagbot.client.bean.GdbResponse;
 import com.diagbot.client.bean.Medicition;
 import com.diagbot.client.bean.MedicitionClass;
-import com.diagbot.client.bean.Response;
-import com.diagbot.client.bean.TreatInput;
-import com.diagbot.dto.TreatmentDTO;
 import com.diagbot.entity.IntroduceDetail;
 import com.diagbot.entity.IntroduceMap;
 import com.diagbot.entity.QuestionInfo;
@@ -19,7 +15,6 @@ import com.diagbot.exception.CommonException;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.FastJsonUtils;
 import com.diagbot.util.StringUtil;
-import com.diagbot.vo.TreatmentVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -48,22 +43,19 @@ public class TreatmentFacade {
     /**
      * 获取治疗方案
      *
-     * @param treatmentVO
+     * @param
      * @return
      */
-    public TreatmentDTO getTreatment(TreatmentVO treatmentVO) {
-        TreatmentDTO treatmentDTO = new TreatmentDTO();
+    public Map<String,Object> getTreatment(Map<String,String> treatmentMap,Long diseaseId) {
         Map<String, Object> retMap = new LinkedHashMap<>();
-
-        TreatInput treatInput = new TreatInput();
-        treatInput.setDisease(treatmentVO.getDiag());
-        treatInput.setFilds(treatmentVO.getSymptom());
-
-        Long diseaseId = treatmentVO.getDiseaseId();
-        QuestionInfo disease = questionFacade.getById(diseaseId);
-        if (!disease.getTagName().equals(treatmentVO.getDiag())) {
+        QuestionInfo disease=questionFacade.getById(diseaseId);
+        if(disease==null) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, "诊断不存在");
+        }
+        if(!treatmentMap.containsKey(disease.getTagName())){
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "诊断名称和id不匹配");
         }
+
         //一般治疗
         List<IntroduceDetail> commonTreatmentDetailList = getIntroduceDetailList(diseaseId, IntroducePositionEnum.CommonTreatment.getKey());
         retMap.put("commonTreatment", commonTreatmentDetailList.size() > 0 ? commonTreatmentDetailList.get(0).getContent() : "");
@@ -73,19 +65,12 @@ public class TreatmentFacade {
         retMap.put("surgeryTreatment", surgeryTreatmentDetailList.size() > 0 ? surgeryTreatmentDetailList.get(0).getContent() : "");
 
         //获取知识图谱治疗方案
-        Response<GdbResponse> responseTreatData = treatServiceClient.treatPageData(treatInput);
-        Map<String, String> resultMap = responseTreatData.getData().getResult();
-        if (resultMap.size() == 0) {
-            treatmentDTO.setMap(retMap);
-            return treatmentDTO;
-        }
-        String resultDes = resultMap.get("des");
-        if (StringUtil.isBlank(resultDes)) {
-            treatmentDTO.setMap(retMap);
-            return treatmentDTO;
+        String treatment=treatmentMap.get(disease.getTagName());
+        if (StringUtil.isBlank(treatment)) {
+            return retMap;
         }
 
-        List<MedicitionClass> drugsList = FastJsonUtils.getJsonToListByKey(resultDes, "treatment", MedicitionClass.class);
+        List<MedicitionClass> drugsList = FastJsonUtils.getJsonToListByKey(treatment, "treatment", MedicitionClass.class);
 
         List<String> classNameList = drugsList.stream().map(drugs -> drugs.getDrugsName()).collect(Collectors.toList());
         List<QuestionInfo> drugClassList = getTopQuestionList(classNameList, QuestionTypeEnum.DrugClass.getKey());
@@ -122,8 +107,7 @@ public class TreatmentFacade {
         }
 
         retMap.put("treatment", drugsList);
-        treatmentDTO.setMap(retMap);
-        return treatmentDTO;
+        return retMap;
     }
 
 

+ 1 - 1
icss-service/src/main/java/com/diagbot/vo/LisInfo.java

@@ -10,7 +10,7 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-public class LisInfo {
+public class LisResult {
     private String name;//套餐名称
     private String detailName;//化验项名称
     private Double value;//值

+ 1 - 1
icss-service/src/main/java/com/diagbot/vo/PushKYJVO.java

@@ -18,5 +18,5 @@ public class PushKYJVO {
     private Integer age;
     @NotNull(message = "请输入性别")
     private Integer sex;
-    private List<LisKYJVO> lisKYJVOList;
+    private List<LisResult> lisResultList;
 }

+ 3 - 1
icss-service/src/main/java/com/diagbot/vo/PushVO.java

@@ -4,6 +4,7 @@ import lombok.Getter;
 import lombok.Setter;
 
 import javax.validation.constraints.NotNull;
+import java.util.List;
 
 /**
  * @Description:
@@ -20,9 +21,10 @@ public class PushVO {
     private String symptom;
     private String diag;
     private String vital;
-    private String lis;
+    private List<LisResult> lis;
     private String pacs;
     private String past;
     private String other;
     private String featureType;
+    private Long diseaseId;
 }

+ 5 - 3
icss-service/src/main/java/com/diagbot/web/PushController.java

@@ -42,7 +42,8 @@ public class PushController {
                     "lis:化验<br>" +
                     "pacs:辅检<br>" +
                     "dis:诊断<br>" +
-                    "featureType:类型,1:症状,4:查体,5:化验,6:辅检,7:诊断(必填)<br>")
+                    "featureType:类型,1:症状,4:查体,5:化验,6:辅检,7:诊断,8:治疗方案(必填)<br>"+
+                    "diseaeId:取治疗方案的诊断<br>" )
     @PostMapping("/pushInner")
     @SysLogger("pushInner")
     public RespDTO<PushDTO> pushInner(@RequestBody @Valid PushVO pushVO) {
@@ -58,7 +59,8 @@ public class PushController {
                     "lis:化验<br>" +
                     "pacs:辅检<br>" +
                     "dis:诊断<br>" +
-                    "featureType:类型,1:症状,4:查体,5:化验,6:辅检,7:诊断(必填)<br>")
+                    "featureType:类型,1:症状,4:查体,5:化验,6:辅检,7:诊断,8:治疗方案(必填)<br>"+
+                    "diseaeId:取治疗方案的诊断<br>" )
     @PostMapping("/pushText")
     @SysLogger("pushText")
     public RespDTO<PushDTO> pushText(@RequestBody @Valid PushVO pushVO) {
@@ -74,7 +76,7 @@ public class PushController {
                     "lis:化验<br>" +
                     "pacs:辅检<br>" +
                     "dis:诊断<br>" +
-                    "featureType:类型,1:症状,4:查体,5:化验,6:辅检,7:诊断(必填)<br>")
+                    "featureType:类型,1:症状,4:查体,5:化验,6:辅检,7:诊断,8:治疗方案(必填)<br>")
     @PostMapping("/pushAI")
     @SysLogger("pushAI")
     public RespDTO<ResponseData> pushAI(@RequestBody @Valid PushVO pushVO) {

+ 2 - 2
icss-service/src/main/java/com/diagbot/web/TreatmentController.java

@@ -37,7 +37,7 @@ public class TreatmentController {
     @PostMapping("/getTreatment")
     @SysLogger("getTreatment")
     public RespDTO<TreatmentDTO> getTreatment(@RequestBody @Valid TreatmentVO treatmentVO) {
-        TreatmentDTO data = treatmentFacade.getTreatment(treatmentVO);
-        return RespDTO.onSuc(data);
+        //TreatmentDTO data = treatmentFacade.getTreatment(treatmentVO);
+        return RespDTO.onSuc(null);
     }
 }