|
@@ -4,9 +4,10 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.diagbot.client.bean.AdverseReaction;
|
|
|
import com.diagbot.client.bean.Medicition;
|
|
|
import com.diagbot.client.bean.MedicitionClass;
|
|
|
-import com.diagbot.dto.ConceptIntroduceDTO;
|
|
|
+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;
|
|
@@ -15,15 +16,15 @@ import com.diagbot.enums.LexiconTypeEnum;
|
|
|
import com.diagbot.enums.PositionTypeEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
-import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.FastJsonUtils;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.vo.ConceptBaseVO;
|
|
|
-import com.diagbot.vo.ConceptIntroduceVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
@@ -50,6 +51,8 @@ public class TreatmentFacade {
|
|
|
*/
|
|
|
public Map<String, Object> getTreatment(Map<String, JSONObject> treatmentMap, String diseaseName, Integer disType) {
|
|
|
Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
+ List<String> conceptNameList = Lists.newLinkedList();
|
|
|
+ conceptNameList.add(diseaseName);
|
|
|
ConceptBaseVO conceptBaseVO = new ConceptBaseVO();
|
|
|
conceptBaseVO.setName(diseaseName);
|
|
|
conceptBaseVO.setLibType(LexiconTypeEnum.DIAGNOSIS.getKey());
|
|
@@ -63,50 +66,26 @@ public class TreatmentFacade {
|
|
|
if (!treatmentMap.containsKey(diseaseName)) {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "诊断名不在诊断列表中");
|
|
|
}
|
|
|
-
|
|
|
- //一般治疗
|
|
|
- ConceptIntroduceVO conceptIntroduceVO = new ConceptIntroduceVO();
|
|
|
- conceptIntroduceVO.setName(diseaseName);
|
|
|
- conceptIntroduceVO.setLibType(LexiconTypeEnum.DIAGNOSIS.getKey());
|
|
|
- conceptIntroduceVO.setPosition(PositionTypeEnum.T3.getKey());
|
|
|
- conceptIntroduceVO.setType(ConceptTypeEnum.Disease.getKey());
|
|
|
- ConceptIntroduceDTO commonTreatmentDetail = conceptDetailFacade.getConceptDetail(conceptIntroduceVO);
|
|
|
- if (commonTreatmentDetail != null && ListUtil.isNotEmpty(commonTreatmentDetail.getDetails())) {
|
|
|
- retMap.put("commonTreatment", commonTreatmentDetail.getDetails().get(0));
|
|
|
- } else {
|
|
|
- retMap.put("commonTreatment", null);
|
|
|
- }
|
|
|
-
|
|
|
- //手术治疗
|
|
|
- conceptIntroduceVO.setPosition(PositionTypeEnum.T4.getKey());
|
|
|
- ConceptIntroduceDTO surgeryTreatmentDetail = conceptDetailFacade.getConceptDetail(conceptIntroduceVO);
|
|
|
- if (surgeryTreatmentDetail != null && ListUtil.isNotEmpty(surgeryTreatmentDetail.getDetails())) {
|
|
|
- retMap.put("surgeryTreatment", surgeryTreatmentDetail.getDetails().get(0));
|
|
|
- } else {
|
|
|
- retMap.put("surgeryTreatment", null);
|
|
|
- }
|
|
|
+ //治疗方案对应诊断
|
|
|
+ retMap.put("diseaseName", diseaseName);
|
|
|
|
|
|
//获取知识图谱治疗方案
|
|
|
JSONObject treatmentJson = treatmentMap.get(diseaseName);
|
|
|
if (treatmentJson == null || treatmentJson.isEmpty()) {
|
|
|
return retMap;
|
|
|
}
|
|
|
-
|
|
|
//推荐药物
|
|
|
List<MedicitionClass> drugsList = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "treatment", MedicitionClass.class);
|
|
|
+ //不良反应
|
|
|
+ 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());
|
|
|
- List<Concept> cateBigConceptList = conceptFacade.getListByNamesAndType(cateBigNameList, LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey());
|
|
|
- Map<String, Concept> cateBigConceptMap = EntityUtil.makeEntityMap(cateBigConceptList, "libName");
|
|
|
- Map<String, Concept> cateBigInfoExistMap = conceptDetailFacade.existList(cateBigNameList, LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey());
|
|
|
+ conceptNameList.addAll(cateBigNameList);
|
|
|
//药品小类
|
|
|
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");
|
|
|
- //Map<String, Concept> cateSmallInfoExistMap = conceptDetailFacade.existList(cateSmallNameList, LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey());
|
|
|
-
|
|
|
- //药品说明信息
|
|
|
+ conceptNameList.addAll(cateSmallNameList);
|
|
|
+ //药品
|
|
|
List<Medicition> medicitionTotalList = Lists.newLinkedList();
|
|
|
for (MedicitionClass medicitionClass : drugsList) {
|
|
|
if (medicitionClass.getMedicitionsList() != null) {
|
|
@@ -114,38 +93,74 @@ public class TreatmentFacade {
|
|
|
}
|
|
|
}
|
|
|
List<String> drugNameList = medicitionTotalList.stream().map(m -> m.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());
|
|
|
+ conceptNameList.addAll(drugNameList);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(adverseReactionList)) {
|
|
|
+ List<String> adNameList = adverseReactionList.stream().map(a -> a.getName()).collect(Collectors.toList());
|
|
|
+ conceptNameList.addAll(adNameList);
|
|
|
+ }
|
|
|
+ //概念
|
|
|
+ List<Concept> conceptList=conceptFacade.getListByNames(conceptNameList);
|
|
|
+ //概念map
|
|
|
+ Map<String, Map<Long, Concept>> conceptMap = conceptList2Map(conceptList);
|
|
|
+ //说明信息是否存在
|
|
|
+ Map<String, Map<Long, List<ConceptDetail>>> hasConDetailMap = conceptDetailFacade.hasConDetail(conceptList);
|
|
|
|
|
|
+ //一般治疗&&手术治疗
|
|
|
+ if (hasConDetailMap != null && hasConDetailMap.get(diseaseName) != null && ListUtil.isNotEmpty(hasConDetailMap.get(diseaseName).get(LexiconTypeEnum.DIAGNOSIS.getKey()))) {
|
|
|
+ List<ConceptDetail> diseaseConDetailList = hasConDetailMap.get(diseaseName).get(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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ retMap.put("commonTreatment", null);
|
|
|
+ retMap.put("surgeryTreatment", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(drugsList)) {
|
|
|
for (MedicitionClass medicitionClass : drugsList) {
|
|
|
- Concept cateBigConcept = cateBigConceptMap.get(medicitionClass.getBigdrugsName());
|
|
|
- if (cateBigConcept != null) {
|
|
|
- medicitionClass.setBigdrugsConceptId(cateBigConcept.getId());
|
|
|
- if (cateBigInfoExistMap.containsKey(cateBigConcept.getLibName())) {
|
|
|
- medicitionClass.setShowInfo("1");
|
|
|
- } else {
|
|
|
- medicitionClass.setShowInfo("0");
|
|
|
+ if (conceptMap != null && conceptMap.containsKey(medicitionClass.getBigdrugsName()) && conceptMap.get(medicitionClass.getBigdrugsName()) != null && conceptMap.get(medicitionClass.getBigdrugsName()).containsKey(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey())) {
|
|
|
+ Concept cateBigConcept = conceptMap.get(medicitionClass.getBigdrugsName()).get(LexiconTypeEnum.DRUG_CATEGORY_BIG.getKey());
|
|
|
+ if (cateBigConcept != null) {
|
|
|
+ medicitionClass.setBigdrugsConceptId(cateBigConcept.getId());
|
|
|
+ if (hasConDetailMap != null && hasConDetailMap.containsKey(cateBigConcept.getLibName()) && hasConDetailMap.get(cateBigConcept.getLibName()) != null && hasConDetailMap.get(cateBigConcept.getLibName()).containsKey(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());
|
|
|
- Concept cateSmallConcept = cateSmallConceptMap.get(medicitionClass.getSubdrugsName());
|
|
|
- if (cateSmallConcept != null) {
|
|
|
- medicitionClass.setSubdrugsConceptId(cateSmallConcept.getId());
|
|
|
+ if (conceptMap != null && conceptMap.containsKey(medicitionClass.getSubdrugsName()) && conceptMap.get(medicitionClass.getSubdrugsName()) != null && conceptMap.get(medicitionClass.getSubdrugsName()).containsKey(LexiconTypeEnum.DRUG_CATEGORY_SMALL.getKey())) {
|
|
|
+ Concept cateSmallConcept = conceptMap.get(medicitionClass.getSubdrugsName()).get(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) {
|
|
|
- Concept drugConcept = drugMap.get(medicition.getMedicitionName());
|
|
|
- if (drugConcept != null) {
|
|
|
- medicition.setConceptId(drugConcept.getId());
|
|
|
+ if (conceptMap != null && conceptMap.containsKey(medicition.getMedicitionName()) && conceptMap.get(medicition.getMedicitionName()) != null && conceptMap.get(medicition.getMedicitionName()).containsKey(LexiconTypeEnum.DRUGS.getKey())) {
|
|
|
+ Concept drugConcept = conceptMap.get(medicition.getMedicitionName()).get(LexiconTypeEnum.DRUGS.getKey());
|
|
|
+ if (drugConcept != null) {
|
|
|
+ medicition.setConceptId(drugConcept.getId());
|
|
|
+ }
|
|
|
}
|
|
|
medicition.setLibType(LexiconTypeEnum.DRUGS.getKey());
|
|
|
medicition.setType(ConceptTypeEnum.Drug.getKey());
|
|
|
- if (drugDetailMap != null && drugDetailMap.containsKey(medicition.getMedicitionName())) {
|
|
|
+ if (hasConDetailMap != null && hasConDetailMap.containsKey(medicition.getMedicitionName()) && hasConDetailMap.get(medicition.getMedicitionName()) != null && hasConDetailMap.get(medicition.getMedicitionName()).containsKey(LexiconTypeEnum.DRUGS.getKey())) {
|
|
|
medicition.setShowInfo("1");
|
|
|
} else {
|
|
|
medicition.setShowInfo("0");
|
|
@@ -178,19 +193,16 @@ public class TreatmentFacade {
|
|
|
//上次用药-icss层处理
|
|
|
retMap.put("drugHistory", null);
|
|
|
//不良反应
|
|
|
- List<AdverseReaction> adverseReactionList = FastJsonUtils.getJsonToListByKey(treatmentJson.toString(), "adverseEvent", AdverseReaction.class);
|
|
|
- List<String> adNameList = adverseReactionList.stream().map(a -> a.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());
|
|
|
- if (adConcept != null) {
|
|
|
- adverseReaction.setConceptId(adConcept.getId());
|
|
|
+ if (conceptMap != null && conceptMap.get(adverseReaction.getName()) != null && conceptMap.get(adverseReaction.getName()).containsKey(LexiconTypeEnum.SIDE_EFFECTS.getKey())) {
|
|
|
+ Concept adConcept = conceptMap.get(adverseReaction.getName()).get(LexiconTypeEnum.SIDE_EFFECTS.getKey());
|
|
|
+ if (adConcept != null) {
|
|
|
+ adverseReaction.setConceptId(adConcept.getId());
|
|
|
+ }
|
|
|
}
|
|
|
adverseReaction.setLibType(LexiconTypeEnum.SIDE_EFFECTS.getKey());
|
|
|
adverseReaction.setType(ConceptTypeEnum.SIDE_EFFECTS.getKey());
|
|
|
- if (adConceptDetailMap != null && adConceptDetailMap.containsKey(adverseReaction.getName())) {
|
|
|
+ if (hasConDetailMap != null && hasConDetailMap.get(adverseReaction.getName()) != null && hasConDetailMap.get(adverseReaction.getName()).containsKey(LexiconTypeEnum.SIDE_EFFECTS.getKey())) {
|
|
|
adverseReaction.setShowInfo("1");
|
|
|
} else {
|
|
|
adverseReaction.setShowInfo("0");
|
|
@@ -201,4 +213,26 @@ public class TreatmentFacade {
|
|
|
}
|
|
|
return retMap;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转换概念list到map Map<概念名称,Map<词性,概念对象>>
|
|
|
+ *
|
|
|
+ * @param conceptList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Map<Long, Concept>> conceptList2Map(List<Concept> conceptList) {
|
|
|
+ Map<String, Map<Long, Concept>> retMap = new LinkedHashMap<>();
|
|
|
+ Map<Long, Concept> retSubMap = new LinkedHashMap<>();
|
|
|
+ for (Concept concept : conceptList) {
|
|
|
+ if (retMap.containsKey(concept.getLibName())) {
|
|
|
+ retSubMap = retMap.get(concept.getLibName());
|
|
|
+ }
|
|
|
+ if (retSubMap == null) {
|
|
|
+ retSubMap = new LinkedHashMap<>();
|
|
|
+ }
|
|
|
+ retSubMap.put(concept.getLibType(), concept);
|
|
|
+ retMap.put(concept.getLibName(), retSubMap);
|
|
|
+ }
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
}
|