Browse Source

Merge branch 'dev/standconvert'

zhoutg 4 years ago
parent
commit
b97e076763
1 changed files with 66 additions and 1 deletions
  1. 66 1
      src/main/java/com/diagbot/facade/NeoFacade.java

+ 66 - 1
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -1020,7 +1020,7 @@ public class NeoFacade {
         getConvertMap(crfMap, StandConvertEnum.operation.toString(), operationConList, standConvert.getOperationList(), map);
         getConvertMap(crfMap, StandConvertEnum.drug.toString(), drugConList, standConvert.getDrugList(), map);
         getConvertMap(crfMap, StandConvertEnum.vital.toString(), vitallConList, standConvert.getVitalList(), map);
-        getConvertMap(crfMap, StandConvertEnum.disease.toString(), diseaseConList, standConvert.getDiaglList(), map);
+        getConvertMapDisease(crfMap, StandConvertEnum.disease.toString(), diseaseConList, standConvert.getDiaglList(), map);
         getConvertMap(crfMap, StandConvertEnum.pacs.toString(), pacsConList, standConvert.getPacsList(), map);
         getConvertMap(crfMap, StandConvertEnum.lis.toString(), lisConList, standConvert.getLisList(), map);
         getConvertMap(crfMap, StandConvertEnum.transfusion.toString(), transfusionConList, standConvert.getTransfusionList(), map);
@@ -1115,4 +1115,69 @@ public class NeoFacade {
         }
         map.put(type, typeMap);
     }
+
+
+    /**
+     * 获取标准词转换map结果,并更新redis
+     *
+     * @param crfDTO
+     * @param type
+     * @param convertList
+     * @param map
+     */
+    public void getConvertMapDisease(Map<String, Map<String, StandConvertCrfDTO>> crfDTO, String type, List<String> convertList,
+                              List<String> originList, Map<String, Map<String, String>> map) {
+        Map<String, String> typeMap = new LinkedHashMap<>();
+
+        if (ListUtil.isNotEmpty(convertList)) {
+            Map<String, StandConvertCrfDTO> crfMap = crfDTO.get(type);
+            for (String s : convertList) {
+                boolean convertFlag = false;
+                String lastS = s;
+                if (StringUtil.isBlank(s)) {
+                    continue;
+                }
+                if (crfMap != null) {
+                    StandConvertCrfDTO standConvertCrfDTO = crfMap.get(s);
+                    if (standConvertCrfDTO != null) {
+                        List<Map<String, String>> list = standConvertCrfDTO.getStandard_words();
+                        if (ListUtil.isEmpty(list)) {
+                            redisUtil.updateValue(type + "Conv:" + s, "");
+                        } else {
+                            String rateStr = standConvertCrfDTO.getStandard_words().get(0).get("rate");
+                            if (StringUtil.isBlank(rateStr)) {
+                                redisUtil.updateValue(type + "Conv:" + s, "");
+                            } else {
+                                BigDecimal rate = new BigDecimal(rateStr);
+                                int flag = rate.compareTo(new BigDecimal(standConvertRate));
+                                if (flag < 0) {
+                                    redisUtil.updateValue(type + "Conv:" + s, "");
+                                } else {
+                                    redisUtil.updateValue(type + "Conv:" + s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
+                                    lastS = standConvertCrfDTO.getStandard_words().get(0).get("standard_word");
+                                    convertFlag = true;
+                                }
+                            }
+                        }
+                    } else {
+                        redisUtil.updateValue(type + "Conv:" + s, "");
+                    }
+                } else {
+                    redisUtil.updateValue(type + "Conv:" + s, "");
+                }
+                if (convertFlag) {
+                    typeMap.put(s, lastS);
+                } else {
+                    typeMap.put(s, "");
+                }
+            }
+        }
+        // 将所有的词放入typeMap中
+        for (String s : originList) {
+            if (!typeMap.containsKey(s)) {
+                typeMap.put(s, s);
+            }
+        }
+        map.put(type, typeMap);
+    }
 }