|
@@ -2,14 +2,24 @@ package com.diagbot.facade;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.client.bean.AdverseReaction;
|
|
|
+import com.diagbot.client.bean.Medicition;
|
|
|
+import com.diagbot.client.bean.MedicitionClass;
|
|
|
import com.diagbot.dto.ConceptDetailDTO;
|
|
|
+import com.diagbot.dto.ConceptRes;
|
|
|
import com.diagbot.entity.Concept;
|
|
|
import com.diagbot.entity.ConceptDetail;
|
|
|
+import com.diagbot.entity.wrapper.ConceptWrapper;
|
|
|
+import com.diagbot.enums.ConceptTypeEnum;
|
|
|
+import com.diagbot.enums.DisTypeEnum;
|
|
|
import com.diagbot.enums.IntroducePositionEnum;
|
|
|
+import com.diagbot.enums.LexiconRSTypeEnum;
|
|
|
import com.diagbot.enums.LexiconTypeEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.FastJsonUtils;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.vo.ConceptBaseVO;
|
|
|
import com.diagbot.vo.ConceptIntroduceVO;
|
|
@@ -17,8 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
+import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description:治疗方案业务处理
|
|
@@ -32,24 +44,23 @@ public class TreatmentFacade {
|
|
|
@Autowired
|
|
|
ConceptDetailFacade conceptDetailFacade;
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 获取治疗方案
|
|
|
*
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String, Object> getTreatment(Map<String, JSONObject> treatmentMap, String diseaseName) {
|
|
|
+ public Map<String, Object> getTreatment(Map<String, JSONObject> treatmentMap, String diseaseName, Integer disType) {
|
|
|
Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
- QueryWrapper<Concept> conceptQueryWrapper=new QueryWrapper<>();
|
|
|
- ConceptBaseVO conceptBaseVO=new ConceptBaseVO();
|
|
|
+ QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
|
|
|
+ ConceptBaseVO conceptBaseVO = new ConceptBaseVO();
|
|
|
conceptBaseVO.setName(diseaseName);
|
|
|
conceptBaseVO.setLibType(LexiconTypeEnum.DIAGNOSIS.getKey());
|
|
|
- Concept disease =conceptFacade.exist(conceptBaseVO);
|
|
|
+ Concept disease = conceptFacade.exist(conceptBaseVO);
|
|
|
if (disease == null) {
|
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "诊断不存在");
|
|
|
}
|
|
|
- if (treatmentMap==null||treatmentMap.size() == 0) {
|
|
|
+ if (treatmentMap == null || treatmentMap.size() == 0) {
|
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "未找到治疗方案");
|
|
|
}
|
|
|
if (!treatmentMap.containsKey(diseaseName)) {
|
|
@@ -57,12 +68,12 @@ public class TreatmentFacade {
|
|
|
}
|
|
|
|
|
|
//一般治疗
|
|
|
- ConceptIntroduceVO conceptIntroduceVO=new ConceptIntroduceVO();
|
|
|
+ ConceptIntroduceVO conceptIntroduceVO = new ConceptIntroduceVO();
|
|
|
conceptIntroduceVO.setName(diseaseName);
|
|
|
conceptIntroduceVO.setLibType(LexiconTypeEnum.DIAGNOSIS.getKey());
|
|
|
conceptIntroduceVO.setPosition(IntroducePositionEnum.CommonTreatment.getKey());
|
|
|
- List<ConceptDetail> commonTreatmentDetailList=conceptDetailFacade.getConceptDetailList(conceptIntroduceVO);
|
|
|
- ConceptDetailDTO commonDetailDTO=new ConceptDetailDTO();
|
|
|
+ List<ConceptDetail> commonTreatmentDetailList = conceptDetailFacade.getConceptDetailList(conceptIntroduceVO);
|
|
|
+ ConceptDetailDTO commonDetailDTO = new ConceptDetailDTO();
|
|
|
if (ListUtil.isNotEmpty(commonTreatmentDetailList)) {
|
|
|
BeanUtil.copyProperties(commonTreatmentDetailList.get(0), commonDetailDTO);
|
|
|
}
|
|
@@ -84,8 +95,84 @@ public class TreatmentFacade {
|
|
|
return retMap;
|
|
|
}
|
|
|
|
|
|
+ List<MedicitionClass> drugsList = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "treatment", MedicitionClass.class);
|
|
|
+ List<String> cateBigNameList = drugsList.stream().map(drugs -> drugs.getBigdrugsName()).collect(Collectors.toList());
|
|
|
+ List<Concept> cateBigConceptList = conceptFacade.getListByNamesAndType(cateBigNameList, LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey());
|
|
|
+ Map<String, Concept> cateBigConceptMap = EntityUtil.makeEntityMap(cateBigConceptList, "libName");
|
|
|
+ List<String> cateSmallNameList = drugsList.stream().map(drugs -> drugs.getSubdrugsName()).collect(Collectors.toList());
|
|
|
+ List<Concept> cateSmallConceptList = conceptFacade.getListByNamesAndType(cateSmallNameList, LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey());
|
|
|
+ Map<String, Concept> cateSmallConceptMap = EntityUtil.makeEntityMap(cateSmallConceptList, "libName");
|
|
|
+
|
|
|
+ for (MedicitionClass medicitionClass : drugsList) {
|
|
|
+ Concept cateBigConcept = cateBigConceptMap.get(medicitionClass.getBigdrugsName());
|
|
|
+ medicitionClass.setBigdrugsConceptId(cateBigConcept.getId());
|
|
|
+ medicitionClass.setBigdrgusLibType(ConceptTypeEnum.Drug_Category_Big.getKey());
|
|
|
+ Concept cateSmallConcept = cateSmallConceptMap.get(medicitionClass.getSubdrugsName());
|
|
|
+ medicitionClass.setSubdrugsConceptId(cateSmallConcept.getId());
|
|
|
+ medicitionClass.setSubdrugsLibType(ConceptTypeEnum.Drug_Category_Small.getKey());
|
|
|
+
|
|
|
+ if (cateBigConcept != null) {
|
|
|
+ conceptBaseVO.setLibType(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey());
|
|
|
+ conceptBaseVO.setName(cateBigConcept.getLibName());
|
|
|
+ if (conceptDetailFacade.exist(conceptBaseVO)) {
|
|
|
+ medicitionClass.setShowInfo("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LinkedList<Medicition> medicitionList = medicitionClass.getMedicitionsList();
|
|
|
+ List<String> drugNameList = medicitionList.stream().map(medicition -> medicition.getMedicitionName()).collect(Collectors.toList());
|
|
|
+ List<Concept> drugList = conceptFacade.getListByNamesAndType(drugNameList, LexiconTypeEnum.DRUGS.getKey());
|
|
|
+ Map<String, Concept> drugMap = EntityUtil.makeEntityMap(drugList, "libName");
|
|
|
+ Map<String, Concept> drugDetailMap = conceptDetailFacade.existList(drugNameList, LexiconTypeEnum.DRUGS.getKey());
|
|
|
+ for (Medicition medicition : medicitionList) {
|
|
|
+ Concept drugConcept = drugMap.get(medicition.getMedicitionName());
|
|
|
+ if (drugConcept != null) {
|
|
|
+ medicition.setConceptId(drugConcept.getId());
|
|
|
+ }
|
|
|
+ if (drugDetailMap != null && drugDetailMap.containsKey(medicition.getMedicitionName())) {
|
|
|
+ medicition.setShowInfo("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ medicitionClass.setMedicitionsList(medicitionList);
|
|
|
+ }
|
|
|
+ retMap.put("treatment", drugsList);
|
|
|
|
|
|
+ //判断是否慢病,慢病增加回访时间,上次用药,不良反应
|
|
|
+ if (disType.equals(DisTypeEnum.CHRONIC.getKey())) {
|
|
|
+ //验证是否慢病
|
|
|
+ conceptBaseVO.setName("慢病");
|
|
|
+ conceptBaseVO.setLibType(LexiconTypeEnum.TYPES_OF_DISEASE.getKey());
|
|
|
+ Concept chronicConcept = conceptFacade.exist(conceptBaseVO);
|
|
|
+ ConceptWrapper conceptWrapper = new ConceptWrapper();
|
|
|
+ conceptWrapper.setStartId(disease.getId());
|
|
|
+ conceptWrapper.setStartName(diseaseName);
|
|
|
+ conceptWrapper.setStartType(LexiconTypeEnum.DIAGNOSIS.getKey());
|
|
|
+ conceptWrapper.setEndId(chronicConcept.getId());
|
|
|
+ conceptWrapper.setEndName(chronicConcept.getLibName());
|
|
|
+ conceptWrapper.setEndType(LexiconTypeEnum.TYPES_OF_DISEASE.getKey());
|
|
|
+ conceptWrapper.setRelationType(LexiconRSTypeEnum.BELONG_TO.getKey());
|
|
|
+ List<ConceptRes> conceptResList = conceptFacade.getConcept(conceptWrapper);
|
|
|
+ Boolean isChronic = ListUtil.isNotEmpty(conceptResList);
|
|
|
+ if (isChronic) {
|
|
|
+ //慢病,增加回访时间,暂时前端写死, 以后由只是图谱返回
|
|
|
+ retMap.put("followUp", null);
|
|
|
+ //上次用药-icss层处理
|
|
|
+ retMap.put("drugHistory", null);
|
|
|
+ //不良反应
|
|
|
+ List<AdverseReaction> adverseReactionList = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "adverseEvent", AdverseReaction.class);
|
|
|
+ List<String> adNameList = adverseReactionList.stream().map(adverseReaction -> adverseReaction.getName()).collect(Collectors.toList());
|
|
|
+ List<Concept> adConceptList = conceptFacade.getListByNamesAndType(adNameList, LexiconTypeEnum.SIDE_EFFECTS.getKey());
|
|
|
+ Map<String, Concept> adConceptMap = EntityUtil.makeEntityMap(adConceptList, "libName");
|
|
|
+ Map<String, Concept> adConceptDetailMap = conceptDetailFacade.existList(adNameList, LexiconTypeEnum.SIDE_EFFECTS.getKey());
|
|
|
+ for (AdverseReaction adverseReaction : adverseReactionList) {
|
|
|
+ Concept adConcept = adConceptMap.get(adverseReaction.getName());
|
|
|
+ adverseReaction.setConceptId(adConcept.getId());
|
|
|
+ if (adConceptDetailMap != null && adConceptDetailMap.containsKey(adverseReaction.getName())) {
|
|
|
+ adverseReaction.setShowInfo("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ retMap.put("adverseReactions", adverseReactionList);
|
|
|
+ }
|
|
|
+ }
|
|
|
return retMap;
|
|
|
}
|
|
|
-
|
|
|
-}
|
|
|
+}
|