浏览代码

1、推理术语映射

zhaops 4 年之前
父节点
当前提交
8740d31246

+ 58 - 22
src/main/java/com/diagbot/aggregate/AssemblePushAggregate.java

@@ -2,6 +2,7 @@ package com.diagbot.aggregate;
 
 import com.diagbot.dto.PushBaseDTO;
 import com.diagbot.dto.PushDTO;
+import com.diagbot.enums.ConceptTypeEnum;
 import com.diagbot.facade.DiseaseConfigFacade;
 import com.diagbot.facade.DrugConfigFacade;
 import com.diagbot.facade.LisConfigFacade;
@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -103,15 +105,19 @@ public class AssemblePushAggregate {
             List<String> uniqueNameList = retLis.stream()
                     .map(i -> i.getName())
                     .collect(Collectors.toList());
-            Map<String, Map<String, Long>> uniqueNameMap
-                    = lisConfigFacade.getUniqueNameConfigMap(hospitalId, null, uniqueNameList);
+            Map<String, Map<String, Map<String, List<String>>>> uniqueNameMap
+                    = mappingConfigFacade.groupByUniqueNameWithName(uniqueNameList, ConceptTypeEnum.LisPack.getKey(), hospitalId);
+
             if (uniqueNameMap != null && uniqueNameMap.size() > 0) {
                 retLis.forEach(item -> {
                     if (uniqueNameMap.get(item.getName()) != null) {
-                        item.setHisNameList(new ArrayList<>(uniqueNameMap.get(item.getName()).keySet()));
+                        item.setHisNameList(uniqueNameMap.get(item.getName())
+                                .values().stream()
+                                .map(i -> i.keySet())
+                                .flatMap(Collection::stream)
+                                .collect(Collectors.toList()));
                     }
                 });
-
             }
         }
         return retLis;
@@ -127,12 +133,17 @@ public class AssemblePushAggregate {
             List<String> uniqueNameList = retPacs.stream()
                     .map(i -> i.getName())
                     .collect(Collectors.toList());
-            Map<String, Map<String, Long>> uniqueNameMap
-                    = pacsConfigFacade.getUniqueNameConfigMap(hospitalId, null, uniqueNameList);
+            Map<String, Map<String, Map<String, List<String>>>> uniqueNameMap
+                    = mappingConfigFacade.groupByUniqueNameWithName(uniqueNameList, ConceptTypeEnum.Pacs.getKey(), hospitalId);
+
             if (uniqueNameMap != null && uniqueNameMap.size() > 0) {
                 retPacs.forEach(item -> {
                     if (uniqueNameMap.get(item.getName()) != null) {
-                        item.setHisNameList(new ArrayList<>(uniqueNameMap.get(item.getName()).keySet()));
+                        item.setHisNameList(uniqueNameMap.get(item.getName())
+                                .values().stream()
+                                .map(i -> i.keySet())
+                                .flatMap(Collection::stream)
+                                .collect(Collectors.toList()));
                     }
                 });
             }
@@ -155,13 +166,18 @@ public class AssemblePushAggregate {
                 }
             }
             if (ListUtil.isNotEmpty(uniqueNameList)) {
-                Map<String, Map<String, Long>> uniqueNameMap
-                        = diseaseConfigFacade.getUniqueNameConfigMap(hospitalId, null, uniqueNameList);
+                Map<String, Map<String, Map<String, List<String>>>> uniqueNameMap
+                        = mappingConfigFacade.groupByUniqueNameWithName(uniqueNameList, ConceptTypeEnum.Disease.getKey(), hospitalId);
+
                 for (Map.Entry<String, List<PushBaseDTO>> entry : retMap.entrySet()) {
                     if (uniqueNameMap != null && uniqueNameMap.size() > 0) {
                         entry.getValue().forEach(item -> {
                             if (uniqueNameMap.get(item.getName()) != null) {
-                                item.setHisNameList(new ArrayList<>(uniqueNameMap.get(item.getName()).keySet()));
+                                item.setHisNameList(uniqueNameMap.get(item.getName())
+                                        .values().stream()
+                                        .map(i -> i.keySet())
+                                        .flatMap(Collection::stream)
+                                        .collect(Collectors.toList()));
                             }
                         });
                     }
@@ -181,12 +197,17 @@ public class AssemblePushAggregate {
             List<String> uniqueNameList = retOperation.stream()
                     .map(i -> i.getName())
                     .collect(Collectors.toList());
-            Map<String, Map<String, Long>> uniqueNameMap
-                    = operationConfigFacade.getUniqueNameConfigMap(hospitalId, null, uniqueNameList);
+            Map<String, Map<String, Map<String, List<String>>>> uniqueNameMap
+                    = mappingConfigFacade.groupByUniqueNameWithName(uniqueNameList, ConceptTypeEnum.Operation.getKey(), hospitalId);
+
             if (uniqueNameMap != null && uniqueNameMap.size() > 0) {
                 retOperation.forEach(item -> {
                     if (uniqueNameMap.get(item.getName()) != null) {
-                        item.setHisNameList(new ArrayList<>(uniqueNameMap.get(item.getName()).keySet()));
+                        item.setHisNameList(uniqueNameMap.get(item.getName())
+                                .values().stream()
+                                .map(i -> i.keySet())
+                                .flatMap(Collection::stream)
+                                .collect(Collectors.toList()));
                     }
                 });
             }
@@ -204,12 +225,17 @@ public class AssemblePushAggregate {
             List<String> uniqueNameList = retDrug.stream()
                     .map(i -> i.getName())
                     .collect(Collectors.toList());
-            Map<String, Map<String, Long>> uniqueNameMap
-                    = drugConfigFacade.getUniqueNameConfigMapWithoutForm(hospitalId, null, uniqueNameList);
+            Map<String, Map<String, Map<String, List<String>>>> uniqueNameMap
+                    = mappingConfigFacade.groupByUniqueNameWithName(uniqueNameList, ConceptTypeEnum.Drug.getKey(), hospitalId);
+
             if (uniqueNameMap != null && uniqueNameMap.size() > 0) {
                 retDrug.forEach(item -> {
                     if (uniqueNameMap.get(item.getName()) != null) {
-                        item.setHisNameList(new ArrayList<>(uniqueNameMap.get(item.getName()).keySet()));
+                        item.setHisNameList(uniqueNameMap.get(item.getName())
+                                .values().stream()
+                                .map(i -> i.keySet())
+                                .flatMap(Collection::stream)
+                                .collect(Collectors.toList()));
                     }
                 });
             }
@@ -227,12 +253,17 @@ public class AssemblePushAggregate {
             List<String> uniqueNameList = retScale.stream()
                     .map(i -> i.getName())
                     .collect(Collectors.toList());
-            Map<String, Map<String, Long>> uniqueNameMap
-                    = scaleConfigFacade.getUniqueNameConfigMap(hospitalId, null, uniqueNameList);
+            Map<String, Map<String, Map<String, List<String>>>> uniqueNameMap
+                    = mappingConfigFacade.groupByUniqueNameWithName(uniqueNameList, ConceptTypeEnum.Scale.getKey(), hospitalId);
+
             if (uniqueNameMap != null && uniqueNameMap.size() > 0) {
                 retScale.forEach(item -> {
                     if (uniqueNameMap.get(item.getName()) != null) {
-                        item.setHisNameList(new ArrayList<>(uniqueNameMap.get(item.getName()).keySet()));
+                        item.setHisNameList(uniqueNameMap.get(item.getName())
+                                .values().stream()
+                                .map(i -> i.keySet())
+                                .flatMap(Collection::stream)
+                                .collect(Collectors.toList()));
                     }
                 });
             }
@@ -250,12 +281,17 @@ public class AssemblePushAggregate {
             List<String> uniqueNameList = retNurse.stream()
                     .map(i -> i.getName())
                     .collect(Collectors.toList());
-            Map<String, Map<String, Long>> uniqueNameMap
-                    = nurseConfigFacade.getUniqueNameConfigMap(hospitalId, null, uniqueNameList);
+            Map<String, Map<String, Map<String, List<String>>>> uniqueNameMap
+                    = mappingConfigFacade.groupByUniqueNameWithName(uniqueNameList, ConceptTypeEnum.Nurse.getKey(), hospitalId);
+
             if (uniqueNameMap != null && uniqueNameMap.size() > 0) {
                 retNurse.forEach(item -> {
                     if (uniqueNameMap.get(item.getName()) != null) {
-                        item.setHisNameList(new ArrayList<>(uniqueNameMap.get(item.getName()).keySet()));
+                        item.setHisNameList(uniqueNameMap.get(item.getName())
+                                .values().stream()
+                                .map(i -> i.keySet())
+                                .flatMap(Collection::stream)
+                                .collect(Collectors.toList()));
                     }
                 });
             }

+ 83 - 0
src/main/java/com/diagbot/facade/MappingConfigFacade.java

@@ -1236,6 +1236,89 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
         return retMap;
     }
 
+
+    /**
+     * 根据标准名称分组-返回名称
+     *
+     * @param uniqueNames
+     * @param type
+     * @param hospitalId
+     * @return uniqueName, form, hisName, hisDetailName
+     */
+    public Map<String, Map<String, Map<String, List<String>>>> groupByUniqueNameWithName(List<String> uniqueNames, Integer type, Long hospitalId) {
+        Map<String, Map<String, Map<String, List<String>>>> retMap = new HashMap<>();
+
+        List<Long> conceptIds = Lists.newArrayList();
+
+        ConceptVO conceptVO = new ConceptVO();
+        RespDTO<List<IndexBatchDTO>> respDTO = null;
+        List<IndexBatchDTO> indexList = Lists.newArrayList();
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            conceptVO.setType(type);
+            conceptVO.setNames(uniqueNames);
+            conceptVO.setSource(MatchSourceEnum.StandWord.getKey());
+            respDTO = cdssCoreClient.getConceptNames(conceptVO);
+            if (RespDTOUtil.respIsOK(respDTO)) {
+                indexList.addAll(respDTO.data);
+            }
+
+            if (type.equals(ConceptTypeEnum.LisPack.getKey())) {
+                conceptVO.setType(ConceptTypeEnum.Lis.getKey());
+                respDTO = cdssCoreClient.getConceptNames(conceptVO);
+                if (RespDTOUtil.respIsOK(respDTO)) {
+                    indexList.addAll(respDTO.data);
+                }
+            }
+        }
+
+        if (ListUtil.isNotEmpty(indexList)) {
+            conceptIds = indexList.stream().map(IndexBatchDTO::getId).distinct().collect(Collectors.toList());
+        }
+
+        QueryWrapper<MappingConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("is_match", 1)
+                .eq("type", type);
+        if (hospitalId != null) {
+            queryWrapper.eq("hospital_id", hospitalId);
+        }
+        if (ListUtil.isNotEmpty(conceptIds)) {
+            queryWrapper.in("concept_id", conceptIds);
+        }
+        List<MappingConfig> list = this.list(queryWrapper);
+
+        if (ListUtil.isEmpty(list)) {
+            return retMap;
+        }
+
+        List<MappingConfigWrapper> wrapperList = BeanUtil.listCopyTo(list, MappingConfigWrapper.class);
+        wrapperList = addNames(wrapperList);
+        wrapperList.forEach(item -> {
+            if (StringUtil.isBlank(item.getForm())) {
+                item.setForm("");
+            }
+            if (StringUtil.isBlank(item.getHisDetailName())) {
+                item.setHisDetailName("");
+            }
+        });
+
+
+        Map<String, List<MappingConfigWrapper>> map = wrapperList.stream().collect(Collectors.groupingBy(MappingConfigWrapper::getUniqueName));
+
+        for (Map.Entry<String, List<MappingConfigWrapper>> entry : map.entrySet()) {
+            Map<String, Map<String, List<String>>> subMap = new HashMap<>();
+            Map<String, List<MappingConfigWrapper>> formMap
+                    = entry.getValue().stream().collect(Collectors.groupingBy(MappingConfigWrapper::getForm));
+            for (Map.Entry<String, List<MappingConfigWrapper>> subEntry : formMap.entrySet()) {
+                subMap.put(subEntry.getKey(), subEntry.getValue().stream().collect(Collectors.groupingBy(MappingConfigWrapper::getHisName,
+                        Collectors.mapping(MappingConfigWrapper::getHisDetailName, Collectors.toList()))));
+            }
+            retMap.put(entry.getKey(), subMap);
+        }
+
+        return retMap;
+    }
+
     /**
      * 返回结果添加标准术语,药品剂型
      *