瀏覽代碼

治疗方案

Zhaops 6 年之前
父節點
當前提交
a9ee104c17

+ 5 - 1
config-server/src/main/resources/shared/icss-service-local.yml

@@ -100,4 +100,8 @@ mybatis-plus:
 
 ai:
   server:
-    address: http://192.168.2.234:8080
+    address: http://192.168.2.234:8080
+
+treat:
+  server:
+    address: http://192.168.3.112:8080

+ 20 - 0
icss-service/src/main/java/com/diagbot/client/TreatServiceClient.java

@@ -0,0 +1,20 @@
+package com.diagbot.client;
+
+import com.diagbot.client.bean.Response;
+import com.diagbot.client.bean.ResponseTreatData;
+import com.diagbot.client.bean.SearchData;
+import com.diagbot.client.hystrix.TreatServiceHystrix;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/12/17 15:02
+ */
+@FeignClient(name = "Treat", url = "${treat.server.address}", fallback = TreatServiceHystrix.class)
+public interface TreatServiceClient {
+    @PostMapping(value = "/web/graphdb/treat")
+    Response<ResponseTreatData> treatPageData(@RequestBody SearchData searchData);
+}

+ 20 - 0
icss-service/src/main/java/com/diagbot/client/bean/Medicition.java

@@ -0,0 +1,20 @@
+package com.diagbot.client.bean;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:药品信息
+ * @Author:zhaops
+ * @time: 2018/12/17 13:27
+ */
+@Getter
+@Setter
+public class Medicition {
+    private Long id;
+    private String medicitionName;
+    private String isShow;
+    private String forbidden;
+    private Boolean showInfo;
+    private String rate;
+}

+ 20 - 0
icss-service/src/main/java/com/diagbot/client/bean/MedicitionClass.java

@@ -0,0 +1,20 @@
+package com.diagbot.client.bean;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/12/17 13:32
+ */
+@Getter
+@Setter
+public class MedicitionClass {
+    private Long id;
+    private String className;
+    private Boolean showInfo;
+    private List<Medicition> medicitionList;
+}

+ 19 - 0
icss-service/src/main/java/com/diagbot/client/bean/ResponseTreatData.java

@@ -0,0 +1,19 @@
+package com.diagbot.client.bean;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/12/17 15:05
+ */
+@Getter
+@Setter
+public class ResponseTreatData {
+    private String status;
+    private Map<String, Map<String, List<MedicitionClass>>> result;
+}

+ 23 - 0
icss-service/src/main/java/com/diagbot/client/hystrix/TreatServiceHystrix.java

@@ -0,0 +1,23 @@
+package com.diagbot.client.hystrix;
+
+import com.diagbot.client.TreatServiceClient;
+import com.diagbot.client.bean.Response;
+import com.diagbot.client.bean.ResponseTreatData;
+import com.diagbot.client.bean.SearchData;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/12/17 15:03
+ */
+@Component
+@Slf4j
+public class TreatServiceHystrix implements TreatServiceClient {
+    @Override
+    public Response<ResponseTreatData> treatPageData(SearchData searchData) {
+        log.error("【hystrix】调用{}异常", "treatPageData");
+        return null;
+    }
+}

+ 17 - 0
icss-service/src/main/java/com/diagbot/dto/TreatmentDTO.java

@@ -0,0 +1,17 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/12/17 13:33
+ */
+@Getter
+@Setter
+public class TreatmentDTO {
+    private Map<String,Object> map;
+}

+ 3 - 1
icss-service/src/main/java/com/diagbot/enums/QuestionTypeEnum.java

@@ -14,7 +14,9 @@ public enum QuestionTypeEnum implements KeyedNamed {
     Vital(4, "查体"),
     Lis(5, "化验"),
     Pacs(6, "辅检"),
-    Disease(7, "诊断");
+    Disease(7, "诊断"),
+    Drug(8, "药品"),
+    DrugClass(9, "药品分类");
 
     @Setter
     private Integer key;

+ 136 - 0
icss-service/src/main/java/com/diagbot/facade/TreatmentFacade.java

@@ -0,0 +1,136 @@
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.client.TreatServiceClient;
+import com.diagbot.client.bean.Medicition;
+import com.diagbot.client.bean.MedicitionClass;
+import com.diagbot.client.bean.Response;
+import com.diagbot.client.bean.ResponseTreatData;
+import com.diagbot.client.bean.SearchData;
+import com.diagbot.dto.TreatmentDTO;
+import com.diagbot.entity.IntroduceDetail;
+import com.diagbot.entity.IntroduceMap;
+import com.diagbot.entity.QuestionInfo;
+import com.diagbot.enums.IntroducePositionEnum;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.QuestionTypeEnum;
+import com.diagbot.util.EntityUtil;
+import com.diagbot.vo.TreatmentVO;
+import com.google.common.collect.Lists;
+import feign.QueryMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/12/17 13:41
+ */
+@Component
+public class TreatmentFacade {
+    @Autowired
+    QuestionFacade questionFacade;
+    @Autowired
+    IntroduceDetailFacade introduceDetailFacade;
+    @Autowired
+    TreatServiceClient treatServiceClient;
+    @Autowired
+    IntroduceMapFacade introduceMapFacade;
+
+    public TreatmentDTO getTreatment(TreatmentVO treatmentVO) {
+        TreatmentDTO treatmentDTO = new TreatmentDTO();
+        Map<String, Object> retMap = new LinkedHashMap<>();
+
+        SearchData searchData = new SearchData();
+        searchData.setSymptom(treatmentVO.getSymptom());
+        searchData.setVital(treatmentVO.getVital());
+        searchData.setLis(treatmentVO.getLis());
+        searchData.setPacs(treatmentVO.getPacs());
+        searchData.setOther(treatmentVO.getOther());
+        searchData.setDiag(treatmentVO.getDiag());
+
+        Long diseaseId = treatmentVO.getDiseaseId();
+        QuestionInfo disease = questionFacade.getById(diseaseId);
+        //一般治疗
+        QueryWrapper<IntroduceDetail> introduceDetailQueryWrapper = new QueryWrapper<>();
+        String sql = "select introduce_id from icss_introduce_map where question_id=" + diseaseId + " and type=" + QuestionTypeEnum.Disease.getKey();
+        introduceDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .apply("find_in_set({0},'position')", IntroducePositionEnum.CommonTreatment.getKey())
+                .inSql("introduce_id", sql)
+                .orderByAsc("introduce_id", "order_no");
+        List<IntroduceDetail> commonTreatmentDetailList = introduceDetailFacade.list(introduceDetailQueryWrapper);
+        retMap.put("commonTreatment", commonTreatmentDetailList);
+
+        //手术治疗
+        introduceDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .apply("find_in_set({0},'position')", IntroducePositionEnum.SurgeryTreatment.getKey())
+                .inSql("introduce_id", sql)
+                .orderByAsc("introduce_id", "order_no");
+        List<IntroduceDetail> surgeryTreatmentDetailList = introduceDetailFacade.list(introduceDetailQueryWrapper);
+        retMap.put("surgeryTreatment", surgeryTreatmentDetailList);
+
+        //获取知识图谱治疗方案
+        Response<ResponseTreatData> responseTreatData = treatServiceClient.treatPageData(searchData);
+        Map<String, Map<String, List<MedicitionClass>>> resultMap = responseTreatData.getData().getResult();
+        List<MedicitionClass> medicitionClassList = resultMap.get("des").get("treatment");
+
+        List<String> classNameList = medicitionClassList.stream().map(medicitionClass -> medicitionClass.getClassName()).collect(Collectors.toList());
+        QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
+        questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).in("tagName", classNameList)
+                .eq("sub_type", 0)
+                .eq("type", QuestionTypeEnum.DrugClass.getKey());
+        List<QuestionInfo> drugClassList = questionFacade.list(questionInfoQueryWrapper);
+        Map<String, QuestionInfo> drugClassMap = EntityUtil.makeEntityMap(drugClassList, "tagName");
+        List<Long> drugClassIds = drugClassList.stream().map(drugClass -> drugClass.getId()).collect(Collectors.toList());
+        QueryWrapper<IntroduceMap> introduceMapQueryWrapper = new QueryWrapper<>();
+        introduceDetailQueryWrapper.in("question_id", drugClassIds)
+                .eq("type", QuestionTypeEnum.DrugClass.getKey())
+                .eq("is_deleted", IsDeleteEnum.N.getKey());
+        List<IntroduceMap> introduceMapList = introduceMapFacade.list(introduceMapQueryWrapper);
+        Map<Long, IntroduceMap> introduceMapMap = EntityUtil.makeEntityMap(introduceMapList, "questionId");
+
+        for (MedicitionClass medicitionClass : medicitionClassList) {
+            QuestionInfo drugClass = drugClassMap.get(medicitionClass.getClassName());
+            if (drugClass != null) {
+                medicitionClass.setId(drugClass.getId());
+                if (introduceMapMap.get(drugClass.getId()) != null) {
+                    medicitionClass.setShowInfo(true);
+                }
+            }
+            List<Medicition> medicitionList = medicitionClass.getMedicitionList();
+            List<String> drugNameList = medicitionList.stream().map(medicition -> medicition.getMedicitionName()).collect(Collectors.toList());
+            QueryWrapper<QuestionInfo> drugListQueryWrapper = new QueryWrapper<>();
+            drugListQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).in("tagName", drugNameList)
+                    .eq("sub_type", 0)
+                    .eq("type", QuestionTypeEnum.Drug.getKey());
+            List<QuestionInfo> drugList = questionFacade.list(drugListQueryWrapper);
+            Map<String, QuestionInfo> drugMap = EntityUtil.makeEntityMap(drugList, "tagName");
+            List<Long> drugIds = drugList.stream().map(drug -> drug.getId()).collect(Collectors.toList());
+            QueryWrapper<IntroduceMap> introduceDrugQueryWrapper = new QueryWrapper<>();
+            introduceDrugQueryWrapper.in("question_id", drugIds)
+                    .eq("type", QuestionTypeEnum.Drug.getKey())
+                    .eq("is_deleted", IsDeleteEnum.N.getKey());
+            List<IntroduceMap> drugIntroduceMapList = introduceMapFacade.list(introduceDrugQueryWrapper);
+            Map<Long, IntroduceMap> drugIntroduceMapMap = EntityUtil.makeEntityMap(drugIntroduceMapList, "questionId");
+            for (Medicition medicition : medicitionList) {
+                QuestionInfo drug = drugMap.get(medicition.getMedicitionName());
+                if (drug != null) {
+                    medicition.setId(drug.getId());
+                    if (drugIntroduceMapMap.get(drug.getId()) != null) {
+                        medicition.setShowInfo(true);
+                    }
+                }
+            }
+            medicitionClass.setMedicitionList(medicitionList);
+        }
+
+        retMap.put("treatment", medicitionClassList);
+        treatmentDTO.setMap(retMap);
+        return treatmentDTO;
+    }
+}

+ 24 - 0
icss-service/src/main/java/com/diagbot/vo/TreatmentVO.java

@@ -0,0 +1,24 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/12/17 13:37
+ */
+@Getter
+@Setter
+public class TreatmentVO {
+    @NotNull(message = "请输入诊断id")
+    private Long diseaseId;
+    private String symptom;
+    private String other;
+    private String vital;
+    private String lis;
+    private String pacs;
+    private String diag;
+}

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

@@ -0,0 +1,43 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.dto.TreatmentDTO;
+import com.diagbot.facade.TreatmentFacade;
+import com.diagbot.vo.TreatmentVO;
+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;
+
+import javax.validation.Valid;
+
+/**
+ * @Description:治疗方案相关接口
+ * @Author:zhaops
+ * @time: 2018/12/17 11:42
+ */
+@RestController
+@RequestMapping("/treatment")
+@Api(value = "治疗方案相关API", tags = { "治疗方案相关API" })
+public class TreatmentController {
+    @Autowired
+    TreatmentFacade treatmentFacade;
+
+    @ApiOperation(value = "治疗方案[by:zhaops]",
+            notes = "symptom:症状<br>" +
+                    "other:其它史<br>" +
+                    "vital:查体<br>" +
+                    "lis:化验<br>" +
+                    "pacs:辅检<br>" +
+                    "dis:诊断<br>")
+    @PostMapping("/getTreatment")
+    @SysLogger("getTreatment")
+    public RespDTO<TreatmentDTO> getTreatment(@RequestBody @Valid TreatmentVO treatmentVO) {
+        TreatmentDTO data = treatmentFacade.getTreatment(treatmentVO);
+        return RespDTO.onSuc(data);
+    }
+}

+ 3 - 1
icssman-service/src/main/java/com/diagbot/enums/QuestionTypeEnum.java

@@ -14,7 +14,9 @@ public enum QuestionTypeEnum implements KeyedNamed {
     Vital(4, "查体"),
     Lis(5, "化验"),
     Pacs(6, "辅检"),
-    Disease(7, "诊断");
+    Disease(7, "诊断"),
+    Drug(8, "药品"),
+    DrugClass(9, "药品分类");
 
     @Setter
     private Integer key;