Prechádzať zdrojové kódy

Merge branch 'master' into innerDevelop

gaodm 4 rokov pred
rodič
commit
d6c3966f8c

+ 1 - 1
src/main/java/com/diagbot/config/CacheDeleteInit.java

@@ -32,7 +32,7 @@ public class CacheDeleteInit implements CommandLineRunner {
         cacheFacade.loadDrugTypeCache();
         log.info("CDSS-CORE服务启动加载药品类型对应关系缓存成功!");
 
-        neoFacade.getSymptomCache();
+        cacheFacade.getSymptomCache();
         log.info("CDSS-CORE服务启动加载图谱症状缓存成功!");
 
         cacheFacade.loadDiseaseTypeCache();

+ 1 - 0
src/main/java/com/diagbot/enums/RedisEnum.java

@@ -12,6 +12,7 @@ import lombok.Setter;
 public enum RedisEnum implements KeyedNamed {
 
     drugType(1, "drugType:"),
+    symptomVitalType(3, "symptomVitalType:"),
     diseaseType(2, "diseaseType:");
 
     @Setter

+ 11 - 0
src/main/java/com/diagbot/facade/CacheFacade.java

@@ -77,6 +77,17 @@ public class CacheFacade {
 
     }
 
+    /**
+     * 加载图谱中的症状、体征缓存
+     *
+     * @return
+     */
+    public void getSymptomCache() {
+        redisUtil.deleteByPrex(RedisEnum.symptomVitalType.getName());
+        neoFacade.symptomVitalCache();
+
+    }
+
     public void clearLoadCache(String str) {
         redisUtil.deleteByPrex(str);
     }

+ 3 - 0
src/main/java/com/diagbot/facade/CommonFacade.java

@@ -258,6 +258,9 @@ public class CommonFacade {
         CoreUtil.setPropertyList(presentLabel.getClinicals(), map.get(StandConvertEnum.symptom.toString()));
         //诊断回填
         CoreUtil.setPropertyList(diagLabel.getDiags(), map.get(StandConvertEnum.disease.toString()));
+        CoreUtil.setPropertyList(chiefLabel.getDiags(), map.get(StandConvertEnum.disease.toString()));
+        CoreUtil.setPropertyList(presentLabel.getDiags(), map.get(StandConvertEnum.disease.toString()));
+        CoreUtil.setPropertyList(pastLabel.getDiags(), map.get(StandConvertEnum.disease.toString()));
         CoreUtil.setPropertyList(wordCrfDTO.getDiagOrder(), "name", "uniqueName", map.get(StandConvertEnum.disease.toString()));
         CoreUtil.setPropertyList(wordCrfDTO.getDiag(), "name", "uniqueName", map.get(StandConvertEnum.disease.toString()));
         CoreUtil.setPropertyList(wordCrfDTO.getDiseaseName(), "name", "uniqueName", map.get(StandConvertEnum.disease.toString()));

+ 85 - 12
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -163,6 +163,18 @@ public class NeoFacade {
         }
     }
 
+    public void symptomVitalCache() {
+        List<String> diseaseProperty = nodeRepository.getSymptomClass();
+        if (ListUtil.isNotEmpty(diseaseProperty)) {
+            Map map = diseaseProperty.stream().collect(Collectors.toMap(
+                    k -> RedisEnum.symptomVitalType.getName() + k,
+                    v -> v,
+                    (v1, v2) -> (v2)
+            ));
+            redisTemplate.opsForValue().multiSet(map);
+        }
+    }
+
     /**
      * 返回图谱中所有症状缓存信息
      *
@@ -476,12 +488,11 @@ public class NeoFacade {
     }
 
     public List<String> getDisBySymptom(List<String> symptoms) {
-        List<String> symptomCache = getSymptomCache();
-        //取交集
-        symptoms.retainAll(symptomCache);
-        long start = System.currentTimeMillis();
-        List<String> allDis_bySymptom = pushDisBySymptom(symptomRepository, symptoms);
-        long end = System.currentTimeMillis();
+        List<String> sv = redisUtil.getSv(symptoms);
+//        List<String> symptomCache = getSymptomCache();
+//        //取交集
+//        symptoms.retainAll(symptomCache);
+        List<String> allDis_bySymptom = pushDisBySymptom(symptomRepository, sv);
         return allDis_bySymptom;
     }
 
@@ -505,11 +516,8 @@ public class NeoFacade {
      */
     public List<String> pushDisBySymptom(SymptomNameRepository symptomNameRepository, List<String> symptoms) {
         List<String> allDis = Lists.newArrayList();
-        /*List<Symptom> byNameIn = symptomNameRepository.findByNameIn(symptoms);
-        allDis = byNameIn.parallelStream()
-                .map(z -> z.getDisease().stream().filter(o -> NeoUtil.matchBasic(o,sex,age)).map(y -> y.getName()).collect(Collectors.toList())).flatMap(List::stream)
-                .collect(Collectors.toList());*/
-        allDis = symptomNameRepository.getDisBySymptoms(symptoms);
+//        allDis = symptomNameRepository.getDisBySymptoms(symptoms);
+        allDis = symptomNameRepository.getDisBySymptoms_1(symptoms);
         return allDis;
     }
 
@@ -1012,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);
@@ -1107,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);
+    }
 }

+ 5 - 0
src/main/java/com/diagbot/repository/SymptomNameRepository.java

@@ -19,5 +19,10 @@ public interface SymptomNameRepository extends Neo4jRepository<Symptom, Long> {
     @Query("match(d:医保疾病名称)-[r{典型:1}]->(s) where any(label in labels(s) WHERE label in ['症状', '体征']) and s.name in {py} return d.name")
 //    @Query("match(d:医保疾病名称)-[r]->(s) where any(label in labels(s) WHERE label in ['症状', '体征']) and s.name in {py} return d.name")
     List<String> getDisBySymptoms(@Param("py")List<String> symptoms);
+
+    @Query("match(d:医保疾病名称)-[r{典型:1}]->(s:症状) where  s.name in {py} return d.name\n" +
+            "union all\n" +
+            "match(d:医保疾病名称)-[r{典型:1}]->(s:体征) where  s.name in {py} return d.name")
+    List<String> getDisBySymptoms_1(@Param("py")List<String> symptoms);
 }
 

+ 6 - 0
src/main/java/com/diagbot/util/RedisUtil.java

@@ -108,6 +108,12 @@ public class RedisUtil {
         return list;
     }
 
+    public List<String> getSv(List<String> keys) {
+        keys = keys.stream().map(x ->RedisEnum.symptomVitalType.getName()+x).collect(Collectors.toList());
+        List<String> list = redisTemplate.opsForValue().multiGet(keys);
+        return list;
+    }
+
     /**
      * 根据指定key获取value
      *