|
@@ -0,0 +1,493 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.diagbot.client.TranServiceClient;
|
|
|
+import com.diagbot.client.bean.FeatureRate;
|
|
|
+import com.diagbot.client.bean.GdbResponse;
|
|
|
+import com.diagbot.client.bean.HosCodeVO;
|
|
|
+import com.diagbot.client.bean.MedicalIndication;
|
|
|
+import com.diagbot.client.bean.MedicalIndicationDetail;
|
|
|
+import com.diagbot.client.bean.ResponseData;
|
|
|
+import com.diagbot.dto.ConceptPushDTO;
|
|
|
+import com.diagbot.dto.LisResult;
|
|
|
+import com.diagbot.dto.PushDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.dto.SysSetInfoDTO;
|
|
|
+import com.diagbot.entity.Concept;
|
|
|
+import com.diagbot.enums.ConceptTypeEnum;
|
|
|
+import com.diagbot.enums.FeatureTypeEnum;
|
|
|
+import com.diagbot.enums.LexiconTypeEnum;
|
|
|
+import com.diagbot.enums.LisSourceEnum;
|
|
|
+import com.diagbot.enums.SysTypeEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.FastJsonUtils;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.ParamConvertUtil;
|
|
|
+import com.diagbot.util.RespDTOUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.ConceptBaseVO;
|
|
|
+import com.diagbot.vo.HospitalSetVO;
|
|
|
+import com.diagbot.vo.LisConfigVO;
|
|
|
+import com.diagbot.vo.SearchVo;
|
|
|
+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.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @Author:zhaops
|
|
|
+ * @time: 2019/5/7 16:12
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class PushFacade {
|
|
|
+ @Autowired
|
|
|
+ private ClinicalFacade clinicalFacade;
|
|
|
+ @Autowired
|
|
|
+ private ConceptFacade conceptFacade;
|
|
|
+ @Autowired
|
|
|
+ private TreatmentFacade treatmentFacade;
|
|
|
+ @Autowired
|
|
|
+ private TranServiceClient tranServiceClient;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推理接口
|
|
|
+ *
|
|
|
+ * @param searchVo
|
|
|
+ * @return ResponseData
|
|
|
+ */
|
|
|
+ public PushDTO pushInner(SearchVo searchVo) {
|
|
|
+ PushDTO pushDTO = new PushDTO();
|
|
|
+ //是否对接
|
|
|
+ Boolean isConnect = false;
|
|
|
+ if (StringUtil.isNotBlank(searchVo.getHosCode())) {
|
|
|
+ HosCodeVO hosCodeVO = new HosCodeVO();
|
|
|
+ hosCodeVO.setHosCode(searchVo.getHosCode());
|
|
|
+ HospitalSetVO hospitalSetVO = new HospitalSetVO();
|
|
|
+ hospitalSetVO.setHospitalCode(searchVo.getHosCode());
|
|
|
+ hospitalSetVO.setCode("connect");
|
|
|
+ if (searchVo.getSysType() != null) {
|
|
|
+ hospitalSetVO.setSysType(searchVo.getSysType());
|
|
|
+ } else {
|
|
|
+ hospitalSetVO.setSysType(SysTypeEnum.AIPT_SERVICE.getKey());
|
|
|
+ }
|
|
|
+ RespDTO<List<SysSetInfoDTO>> sysSetInfoListRes = tranServiceClient.getSysSetInfoDatas(hospitalSetVO);
|
|
|
+ if (RespDTOUtil.respIsOK(sysSetInfoListRes)) {
|
|
|
+ List<SysSetInfoDTO> sysSetInfoList = sysSetInfoListRes.data;
|
|
|
+ if (ListUtil.isNotEmpty(sysSetInfoList)) {
|
|
|
+ if (sysSetInfoList.get(0).getValue().equals(1)) {
|
|
|
+ isConnect = true;
|
|
|
+ } else {
|
|
|
+ isConnect = false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ isConnect = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //化验转公表项处理
|
|
|
+ if (isConnect) {
|
|
|
+ List<LisResult> lisArr = searchVo.getLisArr();
|
|
|
+ lisArr = addUniqueName(lisArr, searchVo.getHosCode());
|
|
|
+ searchVo.setLisArr(lisArr);
|
|
|
+ }
|
|
|
+ ResponseData data = clinicalFacade.processClinicalData(searchVo);
|
|
|
+
|
|
|
+ String featureType = searchVo.getFeatureType();
|
|
|
+ String[] featureTypes = featureType.split(",|,");
|
|
|
+ Set<String> featureTypeSet = new HashSet(Arrays.asList(featureTypes));
|
|
|
+
|
|
|
+
|
|
|
+ //确定推送科室
|
|
|
+ List<FeatureRate> dis = data.getDis();
|
|
|
+ pushDTO.setDept(getDept(dis));
|
|
|
+
|
|
|
+ //症状 概念列表
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Symptom.getKey()))) {
|
|
|
+ List<FeatureRate> symptom = data.getSymptom();
|
|
|
+ if (ListUtil.isNotEmpty(symptom)) {
|
|
|
+ List<String> nameList = symptom.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(nameList)) {
|
|
|
+ pushDTO.setSymptom(getConceptDTOList(nameList, LexiconTypeEnum.SYMPTOM.getKey()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查体 概念列表
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Vital.getKey()))) {
|
|
|
+ List<FeatureRate> vital = data.getVitals();
|
|
|
+ if (ListUtil.isNotEmpty(vital)) {
|
|
|
+ List<String> nameList = vital.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(nameList)) {
|
|
|
+ pushDTO.setVital(getConceptDTOList(nameList, LexiconTypeEnum.VITAL_INDEX.getKey()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //化验 概念列表-公表项
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Lis.getKey()))) {
|
|
|
+ List<FeatureRate> lis = data.getLabs();
|
|
|
+ if (ListUtil.isNotEmpty(lis)) {
|
|
|
+ List<String> nameList = lis.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(nameList)) {
|
|
|
+ List<ConceptPushDTO> lisDTO = getConceptDTOList(nameList, LexiconTypeEnum.LIS_TABLES.getKey());
|
|
|
+ if (isConnect) {
|
|
|
+ lisDTO = addClientName(lisDTO, searchVo.getHosCode(), ConceptTypeEnum.Lis.getKey());
|
|
|
+ lisDTO = removeLisDetail(lisDTO);
|
|
|
+ }
|
|
|
+ pushDTO.setLab(lisDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //辅检 概念列表
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Pacs.getKey()))) {
|
|
|
+ List<FeatureRate> pacs = data.getPacs();
|
|
|
+ if (ListUtil.isNotEmpty(pacs)) {
|
|
|
+ List<String> nameList = pacs.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(nameList)) {
|
|
|
+ List<ConceptPushDTO> pacsDTO = getConceptDTOList(nameList, LexiconTypeEnum.PACS_ITEMS.getKey());
|
|
|
+ if (isConnect) {
|
|
|
+ pacsDTO = addClientName(pacsDTO, searchVo.getHosCode(), ConceptTypeEnum.Pacs.getKey());
|
|
|
+ }
|
|
|
+ pushDTO.setPacs(pacsDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //诊断 map
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Disease.getKey()))) {
|
|
|
+ if (ListUtil.isNotEmpty(dis)) {
|
|
|
+ List<String> nameList = dis.stream().map(featureRate -> featureRate.getFeatureName()).distinct().collect(Collectors.toList());
|
|
|
+ Map<String, List<ConceptPushDTO>> disMapDTO = new LinkedHashMap<>();
|
|
|
+ Map<String, List<FeatureRate>> disFeatureMap = new LinkedHashMap<>();
|
|
|
+ //警惕
|
|
|
+ Map<String, String> highRiskMap = new HashMap<>();
|
|
|
+ highRiskMap.put("disease", String.join(",", nameList));
|
|
|
+ SearchVo hrSearchVo = new SearchVo();
|
|
|
+ hrSearchVo.setDiag(String.join(",", nameList));
|
|
|
+ GdbResponse graphRes = clinicalFacade.highRiskPageData(hrSearchVo);
|
|
|
+ if (graphRes != null) {
|
|
|
+ Map<String, String> graphResult = graphRes.getResult();
|
|
|
+ if (graphResult.size() > 0) {
|
|
|
+ List<String> hrNameList = Lists.newLinkedList();
|
|
|
+ for (Map.Entry<String, String> entry : graphResult.entrySet()) {
|
|
|
+ if (entry.getValue().equals("1")) {
|
|
|
+ hrNameList.add(entry.getKey());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(hrNameList)) {
|
|
|
+ List<ConceptPushDTO> hrDisDTO = getConceptDTOList(hrNameList, LexiconTypeEnum.DIAGNOSIS.getKey());
|
|
|
+ if (isConnect) {
|
|
|
+ hrDisDTO = addClientName(hrDisDTO, searchVo.getHosCode(), ConceptTypeEnum.Disease.getKey());
|
|
|
+ }
|
|
|
+ disMapDTO.put("警惕", hrDisDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //诊断分类
|
|
|
+ for (FeatureRate featureRate : dis) {
|
|
|
+ if (StringUtil.isBlank(featureRate.getDesc())) {
|
|
|
+ featureRate.setDesc("{\"可能诊断\":\"\"}");
|
|
|
+ }
|
|
|
+ Map<String, Object> descMap = FastJsonUtils.getJsonToMap(featureRate.getDesc());
|
|
|
+ for (String disClass : descMap.keySet()) {
|
|
|
+ List<FeatureRate> featureRateList = Lists.newLinkedList();
|
|
|
+ if (disFeatureMap.get(disClass) != null) {
|
|
|
+ featureRateList = disFeatureMap.get(disClass);
|
|
|
+ }
|
|
|
+ featureRateList.add(featureRate);
|
|
|
+ disFeatureMap.put(disClass, featureRateList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Map.Entry<String, List<FeatureRate>> entry : disFeatureMap.entrySet()) {
|
|
|
+ List<String> nameListByDisClass = entry.getValue().stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(nameListByDisClass)) {
|
|
|
+ List<ConceptPushDTO> disDTO = getConceptDTOList(nameListByDisClass, LexiconTypeEnum.DIAGNOSIS.getKey());
|
|
|
+ if (isConnect) {
|
|
|
+ disDTO = addClientName(disDTO, searchVo.getHosCode(), ConceptTypeEnum.Disease.getKey());
|
|
|
+ }
|
|
|
+ disMapDTO.put(entry.getKey(), disDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pushDTO.setDis(disMapDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //核心指标 list
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Indication.getKey()))) {
|
|
|
+ List<MedicalIndication> medicalIndicationList = data.getMedicalIndications();
|
|
|
+ ConceptBaseVO conceptBaseVO = new ConceptBaseVO();
|
|
|
+ if (ListUtil.isNotEmpty(medicalIndicationList)) {
|
|
|
+ for (MedicalIndication medicalIndication : medicalIndicationList) {
|
|
|
+ medicalIndication.setLibType(LexiconTypeEnum.CORE_INDICATORS.getKey());
|
|
|
+ medicalIndication.setType(ConceptTypeEnum.Indication.getKey());
|
|
|
+ //关联概念,增加概念id
|
|
|
+ conceptBaseVO.setName(medicalIndication.getName());
|
|
|
+ conceptBaseVO.setLibType(LexiconTypeEnum.CORE_INDICATORS.getKey());
|
|
|
+ Concept medConcept = conceptFacade.getConcept(conceptBaseVO);
|
|
|
+ if (medConcept != null) {
|
|
|
+ medicalIndication.setConceptId(medConcept.getId());
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(medicalIndication.getDetails())) {
|
|
|
+ for (MedicalIndicationDetail detail : medicalIndication.getDetails()) {
|
|
|
+ //量表,增加概念id;其他类型保留图谱返回结果
|
|
|
+ if (detail.getType().equals(1)) {
|
|
|
+ JSONObject scaleJson = detail.getContent();
|
|
|
+ if (null != scaleJson.get("name")) {
|
|
|
+ String scaleName = scaleJson.get("name").toString();
|
|
|
+ conceptBaseVO.setName(scaleName);
|
|
|
+ conceptBaseVO.setLibType(LexiconTypeEnum.GAUGE.getKey());
|
|
|
+ Concept scaleConcept = conceptFacade.getConcept(conceptBaseVO);
|
|
|
+ scaleJson.put("libType", LexiconTypeEnum.GAUGE.getKey());
|
|
|
+ scaleJson.put("type", ConceptTypeEnum.Scale.getKey());
|
|
|
+ if (scaleConcept != null) {
|
|
|
+ scaleJson.put("conceptId", scaleConcept.getId());
|
|
|
+ } else {
|
|
|
+ scaleJson.put("conceptId", null);
|
|
|
+ }
|
|
|
+ detail.setContent(scaleJson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pushDTO.setMedicalIndications(medicalIndicationList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pushDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取管理评估大数据推理内容
|
|
|
+ *
|
|
|
+ * @param searchVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, JSONObject> getManagementEvaluationContent(SearchVo searchVo) {
|
|
|
+ ResponseData data = clinicalFacade.processClinicalData(searchVo);
|
|
|
+
|
|
|
+ String featureType = searchVo.getFeatureType();
|
|
|
+ String[] featureTypes = featureType.split(",|,");
|
|
|
+ Set<String> featureTypeSet = new HashSet(Arrays.asList(featureTypes));
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_ManagementEvaluation.getKey()))) {
|
|
|
+ return data.getManagementEvaluation();
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取量表推理内容
|
|
|
+ *
|
|
|
+ * @param searchVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> scale(SearchVo searchVo) {
|
|
|
+ Map<String, Object> data = clinicalFacade.scale(searchVo);
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取治疗方案
|
|
|
+ *
|
|
|
+ * @param searchVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> getTreatment(SearchVo searchVo) {
|
|
|
+ ResponseData data = clinicalFacade.processClinicalData(searchVo);
|
|
|
+ Map<String, JSONObject> treat = data.getTreat();
|
|
|
+ if (StringUtil.isBlank(searchVo.getDiseaseName())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_ERROR, "请输入需获取治疗方案的诊断名称");
|
|
|
+ }
|
|
|
+ Map<String, Object> treatmentMap = treatmentFacade.getTreatment(treat, searchVo.getDiseaseName(), searchVo.getDisType());
|
|
|
+ return treatmentMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推理返回概念
|
|
|
+ *
|
|
|
+ * @param nameList
|
|
|
+ * @param libType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ConceptPushDTO> getConceptDTOList(List<String> nameList, Integer libType) {
|
|
|
+ List<Concept> concepts = conceptFacade.getListByNamesAndType(nameList, libType);
|
|
|
+ Map<String, Concept> conceptMap = EntityUtil.makeEntityMap(concepts, "libName");
|
|
|
+ List<ConceptPushDTO> conceptDTOS = Lists.newLinkedList();
|
|
|
+ for (String name : nameList) {
|
|
|
+ ConceptPushDTO conceptDTO = new ConceptPushDTO();
|
|
|
+ conceptDTO.setName(name);
|
|
|
+ conceptDTO.setLibType(libType);
|
|
|
+ conceptDTO.setType(ParamConvertUtil.libConvert2Concept(libType));
|
|
|
+ if (conceptMap.containsKey(name) && conceptMap.get(name) != null) {
|
|
|
+ Concept concept = conceptMap.get(name);
|
|
|
+ conceptDTO.setConceptId(concept.getId());
|
|
|
+ }
|
|
|
+ conceptDTOS.add(conceptDTO);
|
|
|
+ }
|
|
|
+ return conceptDTOS;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据诊断推送确定科室
|
|
|
+ *
|
|
|
+ * @param dis
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ConceptPushDTO getDept(List<FeatureRate> dis) {
|
|
|
+ String deptName = "";
|
|
|
+ if (ListUtil.isNotEmpty(dis)) {
|
|
|
+ for (FeatureRate featureRate : dis) {
|
|
|
+ if (StringUtil.isNotBlank(featureRate.getExtraProperty())) {
|
|
|
+ deptName = featureRate.getExtraProperty();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //没有推送信息时,默认取全科模板
|
|
|
+ if (StringUtil.isBlank(deptName)) {
|
|
|
+ deptName = "全科";
|
|
|
+ }
|
|
|
+ ConceptBaseVO conceptBaseVO = new ConceptBaseVO();
|
|
|
+ conceptBaseVO.setName(deptName);
|
|
|
+ conceptBaseVO.setLibType(LexiconTypeEnum.DEPARTMENT.getKey());
|
|
|
+ ConceptPushDTO deptDTO = new ConceptPushDTO();
|
|
|
+ Concept dept = conceptFacade.getConcept(conceptBaseVO);
|
|
|
+ if (dept == null && deptName.equals("全科") == false) {
|
|
|
+ deptName = "全科";
|
|
|
+ conceptBaseVO.setName(deptName);
|
|
|
+ dept = conceptFacade.getConcept(conceptBaseVO);
|
|
|
+ }
|
|
|
+ if (dept != null) {
|
|
|
+ deptDTO.setName(deptName);
|
|
|
+ deptDTO.setConceptId(dept.getId());
|
|
|
+ deptDTO.setLibType(ConceptTypeEnum.DEPARTMENT.getKey());
|
|
|
+ }
|
|
|
+ return deptDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 增加化验公表项
|
|
|
+ *
|
|
|
+ * @param lisResults
|
|
|
+ * @param hosCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<LisResult> addUniqueName(List<LisResult> lisResults, String hosCode) {
|
|
|
+ //化验项转公表内容,参数处理
|
|
|
+ if (ListUtil.isNotEmpty(lisResults)) {
|
|
|
+ List<String> mealNameList = lisResults.stream().map(lisResult -> lisResult.getName()).collect(Collectors.toList());
|
|
|
+ LisConfigVO lisConfigVO = new LisConfigVO();
|
|
|
+ lisConfigVO.setHosCode(hosCode);
|
|
|
+ lisConfigVO.setMealNameList(mealNameList);
|
|
|
+ RespDTO<Map<String, Map<String, String>>> lisConfigRes = tranServiceClient.getLisConfigByMealNameAndHosCode(lisConfigVO);
|
|
|
+ Map<String, Map<String, String>> lisConfigMap = new LinkedHashMap<>();
|
|
|
+ if (RespDTOUtil.respIsOK(lisConfigRes)) {
|
|
|
+ lisConfigMap = lisConfigRes.data;
|
|
|
+ }
|
|
|
+ for (LisResult lisResult : lisResults) {
|
|
|
+ if (!lisResult.getSource().equals(LisSourceEnum.Outer.getKey())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (lisResult.getDetailName() == null) {
|
|
|
+ lisResult.setDetailName("");
|
|
|
+ }
|
|
|
+ if (lisConfigMap.get(lisResult.getName()) != null) {
|
|
|
+ lisResult.setUniqueName(lisConfigMap.get(lisResult.getName()).get(lisResult.getDetailName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return lisResults;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加外部名称(调用方)
|
|
|
+ *
|
|
|
+ * @param concepts
|
|
|
+ * @param hosCode
|
|
|
+ * @param type
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ConceptPushDTO> addClientName(List<ConceptPushDTO> concepts, String hosCode, Integer type) {
|
|
|
+ HosCodeVO hosCodeVO = new HosCodeVO();
|
|
|
+ hosCodeVO.setHosCode(hosCode);
|
|
|
+ LisConfigVO lisConfigVO = new LisConfigVO();
|
|
|
+ lisConfigVO.setHosCode(hosCode);
|
|
|
+ List<String> uniqueNameList = concepts.stream().map(concept -> concept.getName()).collect(Collectors.toList());
|
|
|
+ lisConfigVO.setUniqueNameList(uniqueNameList);
|
|
|
+ if (type.equals(ConceptTypeEnum.Lis.getKey())) {
|
|
|
+ RespDTO<Map<String, List<String>>> lisRes = tranServiceClient.getLisConfigByUniqueNameAndHosCode(lisConfigVO);
|
|
|
+ if (RespDTOUtil.respIsOK(lisRes)) {
|
|
|
+ Map<String, List<String>> lisMappingByUniqueName = lisRes.data;
|
|
|
+ for (ConceptPushDTO concept : concepts) {
|
|
|
+ List<String> clientNames = lisMappingByUniqueName.get(concept.getName());
|
|
|
+ if (ListUtil.isNotEmpty(clientNames)) {
|
|
|
+ concept.setClientName(clientNames.get(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (type.equals(ConceptTypeEnum.Pacs.getKey())) {
|
|
|
+ RespDTO<Map<String, List<String>>> pacsRes = tranServiceClient.getPacsConfigByUniqueNameAndHosCode(hosCodeVO);
|
|
|
+ if (RespDTOUtil.respIsOK(pacsRes)) {
|
|
|
+ Map<String, List<String>> pacsConfigMapByUniqueName = pacsRes.data;
|
|
|
+ for (ConceptPushDTO concept : concepts) {
|
|
|
+ List<String> clientNames = pacsConfigMapByUniqueName.get(concept.getName());
|
|
|
+ if (ListUtil.isNotEmpty(clientNames)) {
|
|
|
+ concept.setClientName(clientNames.get(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (type.equals(ConceptTypeEnum.Disease.getKey())) {
|
|
|
+ RespDTO<Map<String, String>> disRes = tranServiceClient.getDiseaseIcdByHosCode(hosCodeVO);
|
|
|
+ if (RespDTOUtil.respIsOK(disRes)) {
|
|
|
+ Map<String, String> disMap = disRes.data;
|
|
|
+ for (ConceptPushDTO concept : concepts) {
|
|
|
+ String clientName = disMap.get(concept.getName());
|
|
|
+ if (StringUtil.isNotBlank(clientName)) {
|
|
|
+ concept.setClientName(disMap.get(concept.getName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return concepts;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 外部化验返回时,公表匹配出套餐,保留套餐,删除细项;否则保留公表
|
|
|
+ *
|
|
|
+ * @param lisDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ConceptPushDTO> removeLisDetail(List<ConceptPushDTO> lisDTO) {
|
|
|
+ List<ConceptPushDTO> retLisDTO = Lists.newLinkedList();
|
|
|
+ if (ListUtil.isEmpty(lisDTO)) {
|
|
|
+ return retLisDTO;
|
|
|
+ }
|
|
|
+ List<String> mealNameList = lisDTO.stream().map(lis -> lis.getClientName()).filter(mealName -> mealName != null && mealName != "").distinct().collect(Collectors.toList());
|
|
|
+ List<ConceptPushDTO> mealConceptList = getConceptDTOList(mealNameList, LexiconTypeEnum.LIS_TABLES.getKey());
|
|
|
+ Map<String, ConceptPushDTO> mealConceptMap = EntityUtil.makeEntityMap(mealConceptList, "name");
|
|
|
+ List<String> addedName = Lists.newLinkedList();
|
|
|
+ for (ConceptPushDTO conceptPushDTO : lisDTO) {
|
|
|
+ if (addedName.contains(conceptPushDTO.getName())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (StringUtil.isBlank(conceptPushDTO.getClientName()) || conceptPushDTO.getClientName().equals(conceptPushDTO.getName())) {
|
|
|
+ addedName.add(conceptPushDTO.getName());
|
|
|
+ retLisDTO.add(conceptPushDTO);
|
|
|
+ } else {
|
|
|
+ ConceptPushDTO conceptPushDTOConvert = mealConceptMap.get(conceptPushDTO.getClientName());
|
|
|
+ conceptPushDTOConvert.setClientName(conceptPushDTO.getClientName());
|
|
|
+ addedName.add(conceptPushDTOConvert.getName());
|
|
|
+ retLisDTO.add(conceptPushDTOConvert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retLisDTO;
|
|
|
+ }
|
|
|
+}
|