Sfoglia il codice sorgente

添加化验特异性逻辑

kongwz 4 anni fa
parent
commit
bd7a5579f8

+ 23 - 20
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -225,6 +225,22 @@ public class NeoFacade {
         Integer sex = pushVO.getSex();
         List<NeoPushDTO> neoPushDTOS = new ArrayList<>();
         List<String> allDis = Lists.newArrayList();
+        //如果化验有特异性就直接推送疾病
+        List<Lis> lises = null;
+        LisPushVo lisPushVo = pushVO.getLisPushVo();
+        if(lisPushVo != null){
+            lises = lisPushVo.getLises();
+        }
+        if(ListUtil.isNotEmpty(lises)){
+            List<String> lis_dis = lises.parallelStream()
+                    .map(x -> nodeRepository.getDisByLis_Special(x.getUniqueName(), x.getDetailName()))
+                    .flatMap(List::stream).collect(Collectors.toList());
+            filterAndSort(neoPushDTOS,lis_dis);
+            if(ListUtil.isNotEmpty(neoPushDTOS)){
+                return neoPushDTOS;
+            }
+        }
+
         // 如果没有诊断名称,则通过其它信息推送诊断
         ChiefPushVo chiefPushVo = pushVO.getChiefPushVo();
         PresentPushVo presentPushVo = pushVO.getPresentPushVo();
@@ -246,9 +262,7 @@ public class NeoFacade {
         List<String> allDis_bySymptom = getDisBySymptom(symptoms,age,sex);
         allDis.addAll(allDis_bySymptom);
         //化验推出的疾病
-        LisPushVo lisPushVo = pushVO.getLisPushVo();
-        if(lisPushVo != null){
-            List<Lis> lises = lisPushVo.getLises();
+
             if(ListUtil.isNotEmpty(lises)){
                 /*List<String> lis_dis = lises.parallelStream()
                         .map(x -> nodeRepository.getDisByLis(x.getUniqueName(), x.getDetailName()))
@@ -259,7 +273,7 @@ public class NeoFacade {
                         .flatMap(List::stream).collect(Collectors.toList());
                 allDis.addAll(lis_dis);
             }
-        }
+
         //辅检推出的疾病
         PacsPushVo pacsPushVo = pushVO.getPacsPushVo();
         if(pacsPushVo !=null){
@@ -270,31 +284,22 @@ public class NeoFacade {
                 allDis.addAll(allDis_byPacsResult);
             }
         }
+        filterAndSort(neoPushDTOS, allDis);
+
+        return neoPushDTOS;
+    }
 
+    private void filterAndSort(List<NeoPushDTO> neoPushDTOS, List<String> allDis) {
         //推送出的所有疾病进行性别和年龄的过滤
         Map<Long,List<String>> numberDiseasesMap = disCountSort(allDis);
         //根据发病率排序
         Map<String, Double> disdistributionCache = self.getDisdistributionCache();
-        /*numberDiseasesMap.forEach((x,y)->{
-            y.forEach(z ->{
-                if(disdistributionCache.containsKey(z)){
-                    disdistributionCache.put(z,disdistributionCache.get(z));
-                }else {
-                    disdistributionCache.put(z,0.0);
-                }
-            });
-        });*/
         Map<Long,Map<String,Double>> disPack = new LinkedHashMap<>();
         numberDiseasesMap.forEach((x,y)->{
             Map<String, Double> collect = y.stream()
                     .collect(Collectors.toMap(v -> v, v -> disdistributionCache.get(v) != null?disdistributionCache.get(v):0.0, (e1, e2) -> e2));
             disPack.put(x,collect);
         });
-        /*numberDiseasesMap.forEach((x,y)->{
-            Map<String,Double> dis_dbt = new HashMap<>();
-            y.forEach(dis -> dis_dbt.put(dis,disdistributionCache.get(dis)));
-            disPack.put(x,dis_dbt);
-        });*/
         disPack.forEach((x,y)->{
             Map<String, Double> collect = y.entrySet().stream()
                     .sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
@@ -308,8 +313,6 @@ public class NeoFacade {
                 neoPushDTOS.add(neoPushDTO);
             });
         });
-
-        return neoPushDTOS;
     }
 
     public List<String> getDisBySymptom(List<String> symptoms,Double age,Integer sex){

+ 4 - 0
src/main/java/com/diagbot/repository/BaseNodeRepository.java

@@ -45,6 +45,10 @@ public interface BaseNodeRepository extends Neo4jRepository<BaseNode, Long> {
     @Query("match(d:医保疾病名称)-[r1]->(l:化验套餐名称{name:{lisBig}})-[r:化验套餐名称相关化验细项及结果]->(lr:化验细项及结果{name:{subres}}),(d)-[r2]->(lr) return d.name")
     List<String> getDisByLis(@Param("lisBig") String lisBig,@Param("subres") String subres);
 
+    //化验查疾病(有特异性)
+    @Query("match(d:医保疾病名称)-[r1]->(l:化验套餐名称{name:{lisBig}})-[r:化验套餐名称相关化验细项及结果]->(lr:化验细项及结果{name:{subres}}),(d)-[r2]->(lr) where lr.特异性=1 return d.name")
+    List<String> getDisByLis_Special(@Param("lisBig") String lisBig,@Param("subres") String subres);
+
     @Query("match(d:医保疾病名称)-[r:医保疾病名称相关性别]->(h) return DISTINCT d.name+'&'+h.name")
     List<String> getDisSexClass();