Browse Source

Merge remote-tracking branch 'origin/dev/neo2mysql20210120' into dev/neo2mysql20210120

gaodm 4 years ago
parent
commit
25f4f2297b

+ 52 - 0
cdssman-service/src/main/java/com/diagbot/facade/DrugConfigFacade.java

@@ -458,6 +458,58 @@ public class DrugConfigFacade {
         return retMap;
     }
 
+    /**
+     * 获取映射关系-公表名
+     *
+     * @param hospitalId
+     * @param hisNames
+     * @param uniqueNames
+     * @return Map<uniqueName,Map<form,Map<hisName,List<id>>>>
+     */
+    public Map<String, Map<String,Map<String, List<Long>>>> getUniqueFormConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, Map<String, List<Long>>>> retMap = new HashMap<>();
+        QueryWrapper<DrugConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            queryWrapper.in("unique_name", uniqueNames);
+        }
+        List<DrugConfig> records = drugConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        records.forEach(record -> {
+            if (StringUtil.isBlank(record.getForm())) {
+                record.setForm("");
+            }
+        });
+
+        Map<String, List<DrugConfig>> uniqueNameMap = EntityUtil.makeEntityListMap(records, "uniqueName");
+        for (Map.Entry<String, List<DrugConfig>> entry : uniqueNameMap.entrySet()) {
+            if (ListUtil.isNotEmpty(entry.getValue())) {
+                Map<String, Map<String, List<Long>>> subMap = new HashMap<>();
+                Map<String, List<DrugConfig>> hisNameMap
+                        = EntityUtil.makeEntityListMap(entry.getValue(), "form");
+                for (Map.Entry<String, List<DrugConfig>> hisEntry : hisNameMap.entrySet()) {
+                    if (ListUtil.isNotEmpty(hisEntry.getValue())) {
+                        Map<String, List<DrugConfig>> thirdMap = EntityUtil.makeEntityListMap(hisEntry.getValue(), "hisName");
+                        Map<String, List<Long>> idMap = new HashMap<>();
+                        for (Map.Entry<String, List<DrugConfig>> thirdEntry : thirdMap.entrySet()) {
+                            idMap.put(thirdEntry.getKey(), thirdEntry.getValue().stream().map(i -> i.getId()).distinct().collect(Collectors.toList()));
+                        }
+                        subMap.put(hisEntry.getKey(), idMap);
+                    }
+                }
+                retMap.put(entry.getKey(), subMap);
+            }
+        }
+        return retMap;
+    }
+
     /**
      * 获取映射关系-公表名
      *

+ 27 - 44
cdssman-service/src/main/java/com/diagbot/facade/MedRuleConvertFacade.java

@@ -28,6 +28,7 @@ import org.springframework.stereotype.Component;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
@@ -132,7 +133,7 @@ public class MedRuleConvertFacade {
 
         Map<String, Map<String, Map<String, List<Long>>>> lisConfigMap = lisConfigFacade.getUniqueConfigMap(hospitalId, null, null);
         Map<String, Map<String, List<Long>>> pacsConfigMap = pacsConfigFacade.getUniqueConfigMap(hospitalId, null, null);
-        Map<String, Map<String, Map<String, List<Long>>>> drugConfigMap = drugConfigFacade.getUniqueConfigMap(hospitalId, null, null);
+        Map<String, Map<String, Map<String, List<Long>>>> drugConfigMap = drugConfigFacade.getUniqueFormConfigMap(hospitalId, null, null);
         Map<String, Map<String, List<Long>>> diseaseConfigMap = diseaseConfigFacade.getUniqueConfigMap(hospitalId, null, null);
         Map<String, Map<String, List<Long>>> operationConfigMap = operationConfigFacade.getUniqueConfigMap(hospitalId, null, null);
         Map<String, Map<String, List<Long>>> transfusionConfigMap = transfusionConfigFacade.getUniqueConfigMap(hospitalId, null, null);
@@ -958,8 +959,9 @@ public class MedRuleConvertFacade {
      * @param type
      * @return
      */
-    public List<ResultRule> getMappingResult_medicine(ResultRule result, Map<String, Map<String,
-            Map<String, List<Long>>>> configMap, Integer type, Integer ruleType) {
+    public List<ResultRule> getMappingResult_medicine(ResultRule result,
+                                                      Map<String, Map<String, Map<String, List<Long>>>> configMap,
+                                                      Integer type, Integer ruleType) {
         List<ResultRule> retList = Lists.newLinkedList();
         if (configMap == null || configMap.size() == 0) {
             result.setSuccess(0);
@@ -979,54 +981,36 @@ public class MedRuleConvertFacade {
         }
 
         if (ruleType.equals(RuleTypeEnum.HighRisk.getKey())) {
-            Map<String, Map<String, List<Long>>> hisMap = configMap.containsKey(keyName)
+            Map<String, Map<String, List<Long>>> formMap = configMap.containsKey(keyName)
                     ? configMap.get(keyName)
                     : new HashMap<>();
-            if (hisMap.size() > 0) {
-                for (Map.Entry<String, Map<String, List<Long>>> hisEntry : hisMap.entrySet()) {
-                    if (result.getRuleBaseLibType().equals(LexiconEnum.Form.getKey())
-                            && StringUtil.isNotBlank(result.getRuleBaseLibName())) {
-                        if (hisEntry.getValue() == null || hisEntry.getValue().size() == 0) {
-                            ResultRule bmResult = new ResultRule();
-                            BeanUtil.copyProperties(result, bmResult);
-                            bmResult.setSuccess(0);
-                            if (type.equals(1)) {
-                                bmResult.setMessage(result.getMessage() + result.getRuleLibName() + "(" + result.getRuleLibTypeName()
-                                        + ")+" + result.getRuleBaseLibName() + "(" + result.getRuleBaseLibTypeName() + ")缺少医院端映射;");
-                            } else if (type.equals(2)) {
-                                bmResult.setMessage(result.getMessage() + result.getRuleBaseLibName() + "(" + result.getRuleBaseLibTypeName() + ")缺少医院端映射;");
-                            }
-                            retList.add(bmResult);
-                        } else {
-                            ResultRule bmResult = new ResultRule();
-                            BeanUtil.copyProperties(result, bmResult);
-                            if (hisEntry.getValue().containsKey(result.getRuleBaseLibName())) {
-                                if (type.equals(1)) {
-                                    bmResult.setRuleHisName(hisEntry.getKey());
-                                } else if (type.equals(2)) {
-                                    bmResult.setRuleBaseHisName(hisEntry.getKey());
-                                }
-                            } else {
-                                bmResult.setSuccess(0);
-                                if (type.equals(1)) {
-                                    bmResult.setMessage(result.getMessage() + result.getRuleLibName() + "(" + result.getRuleLibTypeName()
-                                            + ")+" + result.getRuleBaseLibName() + "(" + result.getRuleBaseLibTypeName() + ")缺少医院端映射;");
-                                } else if (type.equals(2)) {
-                                    bmResult.setMessage(result.getMessage() + result.getRuleBaseLibName() + "(" + result.getRuleBaseLibTypeName() + ")缺少医院端映射;");
-                                }
-                            }
-                            retList.add(bmResult);
-                        }
-                    } else {
+            if (formMap.size() > 0) {
+                String form = "";
+                if (result.getRuleBaseLibType().equals(LexiconEnum.Form.getKey())
+                        && StringUtil.isNotBlank(result.getRuleBaseLibName())) {
+                    form = result.getRuleBaseLibName();
+                }
+                if (formMap.containsKey(form)) {
+                    List<String> hisNames = formMap.get(form).keySet().stream().collect(Collectors.toList());
+                    for (String hisName : hisNames) {
                         ResultRule bmResult = new ResultRule();
                         BeanUtil.copyProperties(result, bmResult);
                         if (type.equals(1)) {
-                            bmResult.setRuleHisName(hisEntry.getKey());
+                            bmResult.setRuleHisName(hisName);
                         } else if (type.equals(2)) {
-                            bmResult.setRuleBaseHisName(hisEntry.getKey());
+                            bmResult.setRuleBaseHisName(hisName);
                         }
                         retList.add(bmResult);
                     }
+                } else {
+                    result.setSuccess(0);
+                    if (type.equals(1)) {
+                        result.setMessage(result.getMessage() + result.getRuleLibName() + "(" + result.getRuleLibTypeName()
+                                + ")+" + result.getRuleBaseLibName() + "(" + result.getRuleBaseLibTypeName() + ")缺少医院端映射;");
+                    } else if (type.equals(2)) {
+                        result.setMessage(result.getMessage() + result.getRuleBaseLibName() + "(" + result.getRuleBaseLibTypeName() + ")缺少医院端映射;");
+                    }
+                    retList.add(result);
                 }
             } else {
                 result.setSuccess(0);
@@ -1039,8 +1023,7 @@ public class MedRuleConvertFacade {
             }
         } else {
             List<String> hisNames = configMap.containsKey(keyName)
-                    //? configMap.get(keyName).values().stream().map(i -> i.keySet()).flatMap(Collection::stream).distinct().collect(Collectors.toList())
-                    ? new ArrayList<>(configMap.get(keyName).keySet())
+                    ? configMap.get(keyName).values().stream().map(i -> i.keySet()).flatMap(Collection::stream).distinct().collect(Collectors.toList())
                     : new ArrayList<>();
             if (ListUtil.isNotEmpty(hisNames)) {
                 for (String hisName : hisNames) {