|
@@ -1,9 +1,11 @@
|
|
package com.diagbot.facade;
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.diagbot.client.bean.AdverseReaction;
|
|
import com.diagbot.client.bean.AdverseReaction;
|
|
import com.diagbot.client.bean.Medicition;
|
|
import com.diagbot.client.bean.Medicition;
|
|
import com.diagbot.client.bean.MedicitionClass;
|
|
import com.diagbot.client.bean.MedicitionClass;
|
|
|
|
+import com.diagbot.client.bean.MeditionDetail;
|
|
|
|
+import com.diagbot.client.bean.Treat;
|
|
|
|
+import com.diagbot.client.bean.TreatmentPlan;
|
|
import com.diagbot.dto.ConceptRes;
|
|
import com.diagbot.dto.ConceptRes;
|
|
import com.diagbot.entity.Concept;
|
|
import com.diagbot.entity.Concept;
|
|
import com.diagbot.entity.ConceptDetail;
|
|
import com.diagbot.entity.ConceptDetail;
|
|
@@ -13,8 +15,8 @@ import com.diagbot.enums.LexiconRSTypeEnum;
|
|
import com.diagbot.enums.LexiconTypeEnum;
|
|
import com.diagbot.enums.LexiconTypeEnum;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
import com.diagbot.exception.CommonException;
|
|
import com.diagbot.exception.CommonException;
|
|
-import com.diagbot.util.FastJsonUtils;
|
|
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
|
|
+import com.diagbot.util.StringUtil;
|
|
import com.diagbot.vo.ConceptBaseVO;
|
|
import com.diagbot.vo.ConceptBaseVO;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
|
|
import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
|
|
@@ -48,8 +50,8 @@ public class TreatmentFacade {
|
|
* @param
|
|
* @param
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public Map<String, Object> getTreatment(Map<String, JSONObject> treatmentMap, String diseaseName, Integer disType) {
|
|
|
|
- Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
|
|
|
+ public Treat getTreatment(Treat treat, String diseaseName, Integer disType) {
|
|
|
|
+ List<MedicitionClass> drugsList = Lists.newLinkedList();
|
|
List<String> conceptNameList = Lists.newLinkedList();
|
|
List<String> conceptNameList = Lists.newLinkedList();
|
|
conceptNameList.add(diseaseName);
|
|
conceptNameList.add(diseaseName);
|
|
ConceptBaseVO conceptBaseVO = new ConceptBaseVO();
|
|
ConceptBaseVO conceptBaseVO = new ConceptBaseVO();
|
|
@@ -59,49 +61,62 @@ public class TreatmentFacade {
|
|
if (disease == null) {
|
|
if (disease == null) {
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "诊断不存在");
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "诊断不存在");
|
|
}
|
|
}
|
|
- if (treatmentMap == null || treatmentMap.size() == 0 || !treatmentMap.containsKey(diseaseName)) {
|
|
|
|
|
|
+ if (treat == null) {
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "未找到治疗方案");
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "未找到治疗方案");
|
|
}
|
|
}
|
|
|
|
|
|
//治疗方案对应诊断
|
|
//治疗方案对应诊断
|
|
- retMap.put("diseaseName", diseaseName);
|
|
|
|
|
|
+ treat.setDiseaseName(diseaseName);
|
|
|
|
|
|
- //获取知识图谱治疗方案
|
|
|
|
- JSONObject treatmentJson = treatmentMap.get(diseaseName);
|
|
|
|
- if (treatmentJson == null || treatmentJson.isEmpty()) {
|
|
|
|
- return retMap;
|
|
|
|
- }
|
|
|
|
- //推荐药物
|
|
|
|
- List<MedicitionClass> drugsList
|
|
|
|
- = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "treatment", MedicitionClass.class);
|
|
|
|
|
|
+ //推荐治疗方案
|
|
|
|
+ List<TreatmentPlan> treatmentPlanList = treat.getTreatmentPlan();
|
|
//不良反应
|
|
//不良反应
|
|
- List<AdverseReaction> adverseReactionList
|
|
|
|
- = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "adverseEvent", AdverseReaction.class);
|
|
|
|
- if (ListUtil.isNotEmpty(drugsList)) {
|
|
|
|
- //药品大类
|
|
|
|
- List<String> cateBigNameList = drugsList
|
|
|
|
- .stream()
|
|
|
|
- .map(drugs -> drugs.getBigdrugsName())
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- conceptNameList.addAll(cateBigNameList);
|
|
|
|
- //药品小类
|
|
|
|
- List<String> cateSmallNameList = drugsList
|
|
|
|
- .stream()
|
|
|
|
- .map(drugs -> drugs.getSubdrugsName())
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- conceptNameList.addAll(cateSmallNameList);
|
|
|
|
- //药品
|
|
|
|
- List<Medicition> medicitionTotalList = Lists.newLinkedList();
|
|
|
|
- for (MedicitionClass medicitionClass : drugsList) {
|
|
|
|
- if (medicitionClass.getMedicitionsList() != null) {
|
|
|
|
- medicitionTotalList.addAll(medicitionClass.getMedicitionsList());
|
|
|
|
|
|
+ List<AdverseReaction> adverseReactionList = treat.getAdverseEvent();
|
|
|
|
+
|
|
|
|
+ if (ListUtil.isNotEmpty(treatmentPlanList)) {
|
|
|
|
+ for (int index = 0; index < treatmentPlanList.size(); index++) {
|
|
|
|
+ TreatmentPlan treatmentPlan = treatmentPlanList.get(index);
|
|
|
|
+ List<MeditionDetail> meditionDetailList = treatmentPlan.getMeditionDetails();
|
|
|
|
+ if (ListUtil.isNotEmpty(meditionDetailList)) {
|
|
|
|
+ for (MeditionDetail meditionDetail : meditionDetailList) {
|
|
|
|
+ //药品推荐
|
|
|
|
+ List<MedicitionClass> treatmentDrugList = meditionDetail.getTreatment();
|
|
|
|
+ if (ListUtil.isNotEmpty(treatmentDrugList)) {
|
|
|
|
+ drugsList.addAll(treatmentDrugList);
|
|
|
|
+ //药品大类
|
|
|
|
+ List<String> cateBigNameList = treatmentDrugList
|
|
|
|
+ .stream()
|
|
|
|
+ .map(drugs -> drugs.getBigdrugsName())
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ conceptNameList.addAll(cateBigNameList);
|
|
|
|
+ //药品小类
|
|
|
|
+ List<String> cateSmallNameList = treatmentDrugList
|
|
|
|
+ .stream()
|
|
|
|
+ .map(drugs -> drugs.getSubdrugsName())
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ conceptNameList.addAll(cateSmallNameList);
|
|
|
|
+ //药品
|
|
|
|
+ List<Medicition> medicitionTotalList = Lists.newLinkedList();
|
|
|
|
+ for (MedicitionClass medicitionClass : treatmentDrugList) {
|
|
|
|
+ if (medicitionClass.getMedicitionsList() != null) {
|
|
|
|
+ medicitionTotalList.addAll(medicitionClass.getMedicitionsList());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<String> drugNameList = medicitionTotalList
|
|
|
|
+ .stream()
|
|
|
|
+ .map(m -> m.getMedicitionName())
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ conceptNameList.addAll(drugNameList);
|
|
|
|
+ } else {
|
|
|
|
+ if (StringUtil.isBlank(meditionDetail.getDescription())) {
|
|
|
|
+ treatmentPlanList.remove(index);
|
|
|
|
+ index--;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- List<String> drugNameList = medicitionTotalList
|
|
|
|
- .stream()
|
|
|
|
- .map(m -> m.getMedicitionName())
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- conceptNameList.addAll(drugNameList);
|
|
|
|
}
|
|
}
|
|
if (ListUtil.isNotEmpty(adverseReactionList)) {
|
|
if (ListUtil.isNotEmpty(adverseReactionList)) {
|
|
List<String> adNameList = adverseReactionList
|
|
List<String> adNameList = adverseReactionList
|
|
@@ -138,155 +153,32 @@ public class TreatmentFacade {
|
|
|
|
|
|
try {
|
|
try {
|
|
Map<String, Object> invokeParams = new HashMap<>();
|
|
Map<String, Object> invokeParams = new HashMap<>();
|
|
- invokeParams.put("treatmentMap", retMap);
|
|
|
|
|
|
+ invokeParams.put("treat", treat);
|
|
invokeParams.put("diseaseName", diseaseName);
|
|
invokeParams.put("diseaseName", diseaseName);
|
|
invokeParams.put("drugsList", drugsList);
|
|
invokeParams.put("drugsList", drugsList);
|
|
|
|
+ invokeParams.put("treatmentPlan", treatmentPlanList);
|
|
invokeParams.put("conceptMap", conceptMap);
|
|
invokeParams.put("conceptMap", conceptMap);
|
|
invokeParams.put("hasConDetailMap", hasConDetailMap);
|
|
invokeParams.put("hasConDetailMap", hasConDetailMap);
|
|
invokeParams.put("adverseReactionList", adverseReactionList);
|
|
invokeParams.put("adverseReactionList", adverseReactionList);
|
|
invokeParams.put("isChronic", isChronic);
|
|
invokeParams.put("isChronic", isChronic);
|
|
|
|
|
|
- retMap
|
|
|
|
- = dataBeanAggregateQueryFacade.get("setTreatmentAll", invokeParams, Map.class);
|
|
|
|
|
|
+ treat = dataBeanAggregateQueryFacade.get("setTreatmentAll", invokeParams, Treat.class);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
}
|
|
}
|
|
//判断是否慢病,慢病增加回访时间,上次用药,不良反应
|
|
//判断是否慢病,慢病增加回访时间,上次用药,不良反应
|
|
if (isChronic) {
|
|
if (isChronic) {
|
|
- if (retMap == null) {
|
|
|
|
- retMap = new LinkedHashMap<>();
|
|
|
|
|
|
+ if (treat == null) {
|
|
|
|
+ treat = new Treat();
|
|
|
|
+ treat.setDiseaseName(diseaseName);
|
|
}
|
|
}
|
|
|
|
+ treat.setDisType(1);
|
|
//慢病,增加回访时间,暂时前端写死, 以后由只是图谱返回
|
|
//慢病,增加回访时间,暂时前端写死, 以后由只是图谱返回
|
|
- retMap.put("followUp", null);
|
|
|
|
|
|
+ treat.setFollowUp(null);
|
|
//上次用药-icss层处理
|
|
//上次用药-icss层处理
|
|
- retMap.put("drugHistory", null);
|
|
|
|
|
|
+ treat.setDrugHistory(null);
|
|
}
|
|
}
|
|
-
|
|
|
|
- // //一般治疗&&手术治疗
|
|
|
|
- // if (hasConDetailMap != null && hasConDetailMap.get(diseaseName) != null
|
|
|
|
- // && ListUtil.isNotEmpty(hasConDetailMap
|
|
|
|
- // .get(diseaseName)
|
|
|
|
- // .get(Long.valueOf(LexiconTypeEnum.DIAGNOSIS.getKey())))) {
|
|
|
|
- // List<ConceptDetail> diseaseConDetailList
|
|
|
|
- // = hasConDetailMap.get(diseaseName).get(Long.valueOf(LexiconTypeEnum.DIAGNOSIS.getKey()));
|
|
|
|
- // for (ConceptDetail conceptDetail : diseaseConDetailList) {
|
|
|
|
- // ConceptDetailDTO conceptDetailDTO = new ConceptDetailDTO();
|
|
|
|
- // List<String> positionList = Arrays.asList(conceptDetail.getPosition().split(",|,"));
|
|
|
|
- // if (positionList.contains(String.valueOf(PositionTypeEnum.T3.getKey()))
|
|
|
|
- // && retMap.get("commonTreatment") == null) {
|
|
|
|
- // BeanUtil.copyProperties(conceptDetail, conceptDetailDTO);
|
|
|
|
- // retMap.put("commonTreatment", conceptDetailDTO);
|
|
|
|
- // }
|
|
|
|
- // if (positionList.contains(String.valueOf(PositionTypeEnum.T4.getKey()))
|
|
|
|
- // && retMap.get("surgeryTreatment") == null) {
|
|
|
|
- // BeanUtil.copyProperties(conceptDetail, conceptDetailDTO);
|
|
|
|
- // retMap.put("surgeryTreatment", conceptDetailDTO);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // if (!retMap.containsKey("commonTreatment")) {
|
|
|
|
- // retMap.put("commonTreatment", null);
|
|
|
|
- // }
|
|
|
|
- // if (!retMap.containsKey("surgeryTreatment")) {
|
|
|
|
- // retMap.put("surgeryTreatment", null);
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // if (ListUtil.isNotEmpty(drugsList)) {
|
|
|
|
- // for (MedicitionClass medicitionClass : drugsList) {
|
|
|
|
- // if (conceptMap != null
|
|
|
|
- // && conceptMap.get(medicitionClass.getBigdrugsName()) != null
|
|
|
|
- // && conceptMap.get(medicitionClass
|
|
|
|
- // .getBigdrugsName())
|
|
|
|
- // .containsKey(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey()))) {
|
|
|
|
- // Concept cateBigConcept = conceptMap
|
|
|
|
- // .get(medicitionClass.getBigdrugsName())
|
|
|
|
- // .get(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey()));
|
|
|
|
- // if (cateBigConcept != null) {
|
|
|
|
- // medicitionClass.setBigdrugsConceptId(cateBigConcept.getId());
|
|
|
|
- // if (hasConDetailMap != null
|
|
|
|
- // && hasConDetailMap.get(cateBigConcept.getLibName()) != null
|
|
|
|
- // && hasConDetailMap.get(cateBigConcept.getLibName())
|
|
|
|
- // .containsKey(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey()))) {
|
|
|
|
- // medicitionClass.setShowInfo("1");
|
|
|
|
- // } else {
|
|
|
|
- // medicitionClass.setShowInfo("0");
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // medicitionClass.setBigdrgusLibType(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey());
|
|
|
|
- // medicitionClass.setBigdrugsType(ConceptTypeEnum.Drug_Category_Big.getKey());
|
|
|
|
- // if (conceptMap != null
|
|
|
|
- // && conceptMap.get(medicitionClass.getSubdrugsName()) != null
|
|
|
|
- // && conceptMap.get(medicitionClass.getSubdrugsName())
|
|
|
|
- // .containsKey(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey()))) {
|
|
|
|
- // Concept cateSmallConcept = conceptMap
|
|
|
|
- // .get(medicitionClass.getSubdrugsName())
|
|
|
|
- // .get(Long.valueOf(LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey()));
|
|
|
|
- // if (cateSmallConcept != null) {
|
|
|
|
- // medicitionClass.setSubdrugsConceptId(cateSmallConcept.getId());
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // medicitionClass.setSubdrugsLibType(LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey());
|
|
|
|
- // medicitionClass.setSubdrugsType(ConceptTypeEnum.Drug_Category_Small.getKey());
|
|
|
|
- //
|
|
|
|
- // LinkedList<Medicition> medicitionList = medicitionClass.getMedicitionsList();
|
|
|
|
- // for (Medicition medicition : medicitionList) {
|
|
|
|
- // if (conceptMap != null
|
|
|
|
- // && conceptMap.get(medicition.getMedicitionName()) != null
|
|
|
|
- // && conceptMap.get(medicition.getMedicitionName())
|
|
|
|
- // .containsKey(Long.valueOf(LexiconTypeEnum.DRUGS.getKey()))) {
|
|
|
|
- // Concept drugConcept = conceptMap
|
|
|
|
- // .get(medicition.getMedicitionName())
|
|
|
|
- // .get(Long.valueOf(LexiconTypeEnum.DRUGS.getKey()));
|
|
|
|
- // if (drugConcept != null) {
|
|
|
|
- // medicition.setConceptId(drugConcept.getId());
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // medicition.setLibType(LexiconTypeEnum.DRUGS.getKey());
|
|
|
|
- // medicition.setType(ConceptTypeEnum.Drug.getKey());
|
|
|
|
- // if (hasConDetailMap != null
|
|
|
|
- // && hasConDetailMap.get(medicition.getMedicitionName()) != null
|
|
|
|
- // && hasConDetailMap.get(medicition.getMedicitionName())
|
|
|
|
- // .containsKey(Long.valueOf(LexiconTypeEnum.DRUGS.getKey()))) {
|
|
|
|
- // medicition.setShowInfo("1");
|
|
|
|
- // } else {
|
|
|
|
- // medicition.setShowInfo("0");
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // medicitionClass.setMedicitionsList(medicitionList);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // retMap.put("treatment", drugsList);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // //不良反应
|
|
|
|
- // for (AdverseReaction adverseReaction : adverseReactionList) {
|
|
|
|
- // if (conceptMap != null
|
|
|
|
- // && conceptMap.get(adverseReaction.getName()) != null
|
|
|
|
- // && conceptMap.get(adverseReaction.getName())
|
|
|
|
- // .containsKey(Long.valueOf(LexiconTypeEnum.SIDE_EFFECTS.getKey()))) {
|
|
|
|
- // Concept adConcept = conceptMap
|
|
|
|
- // .get(adverseReaction.getName())
|
|
|
|
- // .get(Long.valueOf(LexiconTypeEnum.SIDE_EFFECTS.getKey()));
|
|
|
|
- // if (adConcept != null) {
|
|
|
|
- // adverseReaction.setConceptId(adConcept.getId());
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // adverseReaction.setLibType(LexiconTypeEnum.SIDE_EFFECTS.getKey());
|
|
|
|
- // adverseReaction.setType(ConceptTypeEnum.SIDE_EFFECTS.getKey());
|
|
|
|
- // if (hasConDetailMap != null
|
|
|
|
- // && hasConDetailMap.get(adverseReaction.getName()) != null
|
|
|
|
- // && hasConDetailMap.get(adverseReaction.getName())
|
|
|
|
- // .containsKey(Long.valueOf(LexiconTypeEnum.SIDE_EFFECTS.getKey()))) {
|
|
|
|
- // adverseReaction.setShowInfo("1");
|
|
|
|
- // } else {
|
|
|
|
- // adverseReaction.setShowInfo("0");
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // retMap.put("adverseReactions", adverseReactionList);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- return retMap;
|
|
|
|
|
|
+ return treat;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|