|
@@ -0,0 +1,412 @@
|
|
|
+package com.diagbot.aggregate;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.diagbot.client.TranServiceClient;
|
|
|
+import com.diagbot.client.bean.FeatureRate;
|
|
|
+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.PushDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.entity.Concept;
|
|
|
+import com.diagbot.enums.ConceptTypeEnum;
|
|
|
+import com.diagbot.enums.FeatureTypeEnum;
|
|
|
+import com.diagbot.enums.LexiconTypeEnum;
|
|
|
+import com.diagbot.facade.ConceptFacade;
|
|
|
+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.LisConfigVO;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import io.github.lvyahui8.spring.annotation.DataConsumer;
|
|
|
+import io.github.lvyahui8.spring.annotation.DataProvider;
|
|
|
+import io.github.lvyahui8.spring.annotation.InvokeParameter;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @author: gaodm
|
|
|
+ * @time: 2019/10/17 11:32
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class PushItemAggregate {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ConceptFacade conceptFacade;
|
|
|
+ @Autowired
|
|
|
+ private TranServiceClient tranServiceClient;
|
|
|
+
|
|
|
+ @DataProvider("setAll")
|
|
|
+ public PushDTO setAll(
|
|
|
+ @InvokeParameter("pushDTO") PushDTO pushDTO,
|
|
|
+ @DataConsumer("getDept") ConceptPushDTO dept,
|
|
|
+ @DataConsumer("setSymptom") List<ConceptPushDTO> symptom,
|
|
|
+ @DataConsumer("setVital") List<ConceptPushDTO> vital,
|
|
|
+ @DataConsumer("setLab") List<ConceptPushDTO> lab,
|
|
|
+ @DataConsumer("setPacs") List<ConceptPushDTO> pacs,
|
|
|
+ @DataConsumer("setDis") Map<String, List<ConceptPushDTO>> dis,
|
|
|
+ @DataConsumer("setMedicalIndications") List<MedicalIndication> medicalIndications) {
|
|
|
+ if (null != dept) {
|
|
|
+ pushDTO.setDept(dept);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(symptom)) {
|
|
|
+ pushDTO.setSymptom(symptom);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(vital)) {
|
|
|
+ pushDTO.setVital(vital);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(lab)) {
|
|
|
+ pushDTO.setLab(lab);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(pacs)) {
|
|
|
+ pushDTO.setPacs(pacs);
|
|
|
+ }
|
|
|
+ if (null != dis) {
|
|
|
+ pushDTO.setDis(dis);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(medicalIndications)) {
|
|
|
+ pushDTO.setMedicalIndications(medicalIndications);
|
|
|
+ }
|
|
|
+ return pushDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据诊断推送确定科室
|
|
|
+ *
|
|
|
+ * @param dis
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @DataProvider("getDept")
|
|
|
+ public ConceptPushDTO getDept(@InvokeParameter("dis") 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DataProvider("setSymptom")
|
|
|
+ public List<ConceptPushDTO> setSymptom(@InvokeParameter("featureTypeSet") Set<String> featureTypeSet,
|
|
|
+ @InvokeParameter("data") ResponseData data) {
|
|
|
+ List<ConceptPushDTO> symptomRes = ListUtil.newArrayList();
|
|
|
+ //症状 概念列表
|
|
|
+ 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)) {
|
|
|
+ symptomRes = getConceptDTOList(nameList, LexiconTypeEnum.SYMPTOM.getKey());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return symptomRes;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DataProvider("setVital")
|
|
|
+ public List<ConceptPushDTO> setVital(@InvokeParameter("featureTypeSet") Set<String> featureTypeSet,
|
|
|
+ @InvokeParameter("data") ResponseData data) {
|
|
|
+ List<ConceptPushDTO> vitalRes = ListUtil.newArrayList();
|
|
|
+ //查体 查体结果
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Vital_Result.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)) {
|
|
|
+ vitalRes = getConceptDTOList(nameList, LexiconTypeEnum.VITAL_RESULT.getKey());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //查体 查体指标
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Vital_Index.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)) {
|
|
|
+ vitalRes = getConceptDTOList(nameList, LexiconTypeEnum.VITAL_INDEX.getKey());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vitalRes;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DataProvider("setLab")
|
|
|
+ public List<ConceptPushDTO> setLab(@InvokeParameter("featureTypeSet") Set<String> featureTypeSet,
|
|
|
+ @InvokeParameter("data") ResponseData data,
|
|
|
+ @InvokeParameter("isConnect") Boolean isConnect,
|
|
|
+ @InvokeParameter("hosCode") String hosCode) {
|
|
|
+ List<ConceptPushDTO> labRes = ListUtil.newArrayList();
|
|
|
+ //化验 概念列表-公表项
|
|
|
+ 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_PACKAGE.getKey());
|
|
|
+ if (isConnect) {
|
|
|
+ lisDTO = addClientName(lisDTO, hosCode, ConceptTypeEnum.Lis.getKey());
|
|
|
+ //lisDTO = removeLisDetail(lisDTO);
|
|
|
+ }
|
|
|
+ labRes = lisDTO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return labRes;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DataProvider("setPacs")
|
|
|
+ public List<ConceptPushDTO> setPacs(@InvokeParameter("featureTypeSet") Set<String> featureTypeSet,
|
|
|
+ @InvokeParameter("data") ResponseData data,
|
|
|
+ @InvokeParameter("isConnect") Boolean isConnect,
|
|
|
+ @InvokeParameter("hosCode") String hosCode) {
|
|
|
+ List<ConceptPushDTO> labRes = ListUtil.newArrayList();
|
|
|
+ //辅检 概念列表
|
|
|
+ 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, hosCode, ConceptTypeEnum.Pacs.getKey());
|
|
|
+ }
|
|
|
+ labRes = pacsDTO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return labRes;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DataProvider("setDis")
|
|
|
+ public Map<String, List<ConceptPushDTO>> setDis(@InvokeParameter("featureTypeSet") Set<String> featureTypeSet,
|
|
|
+ @InvokeParameter("dis") List<FeatureRate> dis,
|
|
|
+ @InvokeParameter("isConnect") Boolean isConnect,
|
|
|
+ @InvokeParameter("hosCode") String hosCode) {
|
|
|
+ Map<String, List<ConceptPushDTO>> disRes = new HashMap<>();
|
|
|
+ //诊断 map
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Feature_Type_Disease.getKey()))) {
|
|
|
+ if (ListUtil.isNotEmpty(dis)) {
|
|
|
+ Map<String, List<ConceptPushDTO>> disMapDTO = new LinkedHashMap<>();
|
|
|
+ Map<String, List<FeatureRate>> disFeatureMap = new LinkedHashMap<>();
|
|
|
+ //诊断分类
|
|
|
+ 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, hosCode, ConceptTypeEnum.Disease.getKey());
|
|
|
+ }
|
|
|
+ disMapDTO.put(entry.getKey(), disDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ disRes = disMapDTO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return disRes;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DataProvider("setMedicalIndications")
|
|
|
+ public List<MedicalIndication> setMedicalIndications(@InvokeParameter("featureTypeSet") Set<String> featureTypeSet,
|
|
|
+ @InvokeParameter("data") ResponseData data) {
|
|
|
+ List<MedicalIndication> medicalIndicationRes = ListUtil.newArrayList();
|
|
|
+ //核心指标 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ medicalIndicationRes = medicalIndicationList;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return medicalIndicationRes;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推理返回概念
|
|
|
+ *
|
|
|
+ * @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 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.setClientNames(clientNames);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } 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.setClientNames(clientNames);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } 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)) {
|
|
|
+ List<String> clientNames = Lists.newLinkedList();
|
|
|
+ clientNames.add(clientName);
|
|
|
+ concept.setClientNames(clientNames);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return concepts;
|
|
|
+ }
|
|
|
+}
|