|
@@ -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;
|
|
|
+ }
|
|
|
+}
|