kongwz 4 anni fa
parent
commit
2ef728a75d

+ 64 - 21
src/main/java/com/diagbot/aggregate/PushDisAggregate.java

@@ -1,6 +1,5 @@
 package com.diagbot.aggregate;
 
-import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.facade.NeoFacade;
 import com.diagbot.util.ListUtil;
 import com.diagbot.vo.NeoPushVO;
@@ -26,18 +25,21 @@ public class PushDisAggregate {
     private NeoFacade neoFacade;
     @DataProvider("pushAll")
     public List<String> getDis(
-            @InvokeParameter("allDis") List<String> allDis,
             @InvokeParameter("pushVo") NeoPushVO pushVO,
-            @InvokeParameter("lis") List<Lis> lises,
             @DataConsumer("pushDisBySymptom_main") List<String> disBySm,
-            @DataConsumer("pushDisBySymptomOrVital") List<String> disBySv,
-            @DataConsumer("pushDisByLis") List<String> disByLis,
-            @DataConsumer("pushDisByPr") List<String> disByPr
+            @DataConsumer("pushDisBySymptom_other") List<String> disBySo,
+            @DataConsumer("pushDisByVital") List<String> disByVital,
+            @DataConsumer("pushDisByLis_nospecial") List<String> disByLis
     ){
         List<String> allPushDis = new ArrayList<>();
-        addDis(allPushDis,disBySv);
-        addDis(allPushDis,disByLis);
-        addDis(allPushDis,disByPr);
+        if(ListUtil.isNotEmpty(disBySm)){
+            disBySo.retainAll(disBySm);
+            disByVital.retainAll(disBySm);
+            disByLis.retainAll(disBySm);
+            allPushDis.addAll(disBySo);
+            allPushDis.addAll(disByVital);
+            allPushDis.addAll(disByLis);
+        }
         return allPushDis;
     }
 
@@ -47,28 +49,69 @@ public class PushDisAggregate {
         }
     }
 
+    /**
+     * 主症状推送诊断
+     * @param pushVO
+     * @return
+     */
     @DataProvider("pushDisBySymptom_main")
     public List<String> pushDisBySm(@InvokeParameter("pushVo") NeoPushVO pushVO) {
         List<String> pushDisBySm = neoFacade.pushDisBySymptom_main(pushVO);
         return pushDisBySm;
     }
 
-    @DataProvider("pushDisBySymptomOrVital")
-    public List<String> pushDisBySym(@InvokeParameter("pushVo") NeoPushVO pushVO,@InvokeParameter("allDis") List<String> allDis) {
-        neoFacade.pushDisBySymptomOrVital(pushVO,allDis);
-        return allDis;
+    /**
+     * 其他症状推送诊断
+     * @param pushVO
+     * @return
+     */
+    @DataProvider("pushDisBySymptom_other")
+    public List<String> pushDisBySo(@InvokeParameter("pushVo") NeoPushVO pushVO) {
+        List<String> pushDisBySm = neoFacade.getDisBySymptom_other(pushVO);
+        return pushDisBySm;
+    }
+
+    /**
+     * 化验特异性诊断
+     * @param pushVO
+     * @return
+     */
+    @DataProvider("pushDisBySpecialLis")
+    public List<String> pushDisBySl(@InvokeParameter("pushVo") NeoPushVO pushVO) {
+        List<String> pushDisBySm = neoFacade.pushDisBySpecialLis(pushVO);
+        return pushDisBySm;
     }
 
-    @DataProvider("pushDisByLis")
-    public List<String> pushDisByL(@InvokeParameter("pushVo") NeoPushVO pushVO) {
-        List<String> pushDisByLis = neoFacade.pushDisByLis(pushVO);
-        return pushDisByLis;
+    /**
+     * 辅检特异性诊断
+     * @param pushVO
+     * @return
+     */
+    @DataProvider("pushDisByPacs")
+    public List<String> pushDisByPs(@InvokeParameter("pushVo") NeoPushVO pushVO) {
+        List<String> pushDisBySm = neoFacade.pushDisByPacs(pushVO);
+        return pushDisBySm;
     }
 
-    @DataProvider("pushDisByPr")
-    public List<String> pushDisByPacsRes(@InvokeParameter("pushVo") NeoPushVO pushVO) {
-        List<String> pushDisByPacsRes = neoFacade.pushDisByPacs(pushVO);
-        return pushDisByPacsRes;
+    /**
+     * 体征推送诊断
+     * @param pushVO
+     * @return
+     */
+    @DataProvider("pushDisByVital")
+    public List<String> pushDisByVl(@InvokeParameter("pushVo") NeoPushVO pushVO) {
+        List<String> pushDisBySm = neoFacade.getDisByVital(pushVO);
+        return pushDisBySm;
     }
 
+    /**
+     * 非特异性化验推送诊断
+     * @param pushVO
+     * @return
+     */
+    @DataProvider("pushDisByLis_nospecial")
+    public List<String> pushDisByLisNo(@InvokeParameter("pushVo") NeoPushVO pushVO) {
+        List<String> pushDisBySm = neoFacade.getDisByLis_other(pushVO);
+        return pushDisBySm;
+    }
 }

+ 3 - 0
src/main/java/com/diagbot/config/CacheDeleteInit.java

@@ -35,6 +35,9 @@ public class CacheDeleteInit implements CommandLineRunner {
         cacheFacade.getSymptomCache();
         log.info("CDSS-CORE服务启动加载图谱症状缓存成功!");
 
+        cacheFacade.getVitalCache();
+        log.info("CDSS-CORE服务启动加载图谱体征缓存成功!");
+
         cacheFacade.loadDiseaseTypeCache();
         log.info("CDSS-CORE服务启动加载疾病属性(性别、年龄、发病率)缓存成功!");
 

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

@@ -14,6 +14,7 @@ public enum RedisEnum implements KeyedNamed {
     drugType(1, "drugType:"),
     symptomVitalType(3, "symptomVitalType:"),
     symptomNumType(4, "symptomNumType:"),
+    vitalType(5, "vitalType:"),
     diseaseType(2, "diseaseType:");
 
     @Setter

+ 12 - 1
src/main/java/com/diagbot/facade/CacheFacade.java

@@ -78,7 +78,7 @@ public class CacheFacade {
     }
 
     /**
-     * 加载图谱中的症状、体征缓存
+     * 加载图谱中的症状缓存
      *
      * @return
      */
@@ -88,6 +88,17 @@ public class CacheFacade {
 
     }
 
+    /**
+     * 加载图谱中的体征缓存
+     *
+     * @return
+     */
+    public void getVitalCache() {
+        redisUtil.deleteByPrex(RedisEnum.vitalType.getName());
+        neoFacade.vitalCache();
+
+    }
+
     /**
      * 加载图谱中的疾病对应的症状个数
      *

+ 60 - 9
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -176,6 +176,18 @@ public class NeoFacade {
         }
     }
 
+    public void vitalCache() {
+        List<String> diseaseProperty = nodeRepository.getVitalClass();
+        if (ListUtil.isNotEmpty(diseaseProperty)) {
+            Map map = diseaseProperty.stream().collect(Collectors.toMap(
+                    k -> RedisEnum.vitalType.getName() + k,
+                    v -> v,
+                    (v1, v2) -> (v2)
+            ));
+            redisTemplate.opsForValue().multiSet(map);
+        }
+    }
+
     public void symptomNumCache() {
         List<SymptomNumOfDiS> diseaseProperty = nodeRepository.getSymptomNum();
         if (ListUtil.isNotEmpty(diseaseProperty)) {
@@ -286,6 +298,7 @@ public class NeoFacade {
      */
     public List<String> getPush(NeoPushVO pushVO) {
         List<String> pushDis = Lists.newArrayList();
+        List<String> pushSpeDis = Lists.newArrayList();
         //年龄
         Double age = pushVO.getAgeNum();
         //性别
@@ -310,20 +323,32 @@ public class NeoFacade {
         List<String> pushDisByPacs = pushDisByPacs(pushVO);
 
         List<String> allDis = Lists.newArrayList();
-        /*try {
+        try {
             Map<String, Object> invokeParams = new HashMap<>();
-            invokeParams.put("allDis", allDis);
             invokeParams.put("pushVo", pushVO);
-            invokeParams.put("lis", lises);
             allDis = DataFacade.get("pushAll", invokeParams, List.class);
         } catch (Exception e) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "并行推送疾病出错" + e.getMessage());
-        }*/
+        }
 
         filterAndSort(pushDis, allDis, sex, age, pd,depts);
-        pushDis = addDiagFromPresent(pushDis, presentDiags);
-
-        return pushDis;
+        //特异值推送的诊断添加到症状推送诊断的头部
+        pushDisByPacs.removeAll(pushDisByLis);
+        pushDisByLis.addAll(pushDisByPacs);
+        filterAndSort(pushSpeDis,pushDisByLis, sex, age, pd,depts);
+        pushDis.removeAll(pushSpeDis);
+        pushSpeDis.addAll(pushDis);
+
+        //初步诊断、现病史拟诊、主诉诊断添加头部
+        chiefDiags.removeAll(presentDiags);
+        presentDiags.addAll(chiefDiags);
+        presentDiags.removeAll(disByDiag);
+        disByDiag.addAll(presentDiags);
+
+        pushSpeDis.removeAll(disByDiag);
+        disByDiag.addAll(pushSpeDis);
+
+        return disByDiag;
     }
 
     private List<String> getDiseaseByChief(NeoPushVO pushVO) {
@@ -519,15 +544,41 @@ public class NeoFacade {
         allDis.addAll(allDis_bySymptom);
     }
 
-    public List<String> getDisBySymptom_vital_other(NeoPushVO pushVO){
+    public List<String> getDisBySymptom_other(NeoPushVO pushVO){
+        List<String> disBySymptoms_1 = Lists.newArrayList();
         List<String> symptoms = getSymptoms(pushVO);
         if(ListUtil.isNotEmpty(symptoms) && symptoms.size() > 2){
             symptoms = symptoms.size() >= 5?symptoms.subList(1,5):symptoms;
             List<String> sv = redisUtil.getSv(symptoms,RedisEnum.symptomVitalType.getName());
-            List<String> disBySymptoms_1 = symptomRepository.getDisBySymptoms_1(sv);
+            disBySymptoms_1 = symptomRepository.getDisBySymptoms_1(sv);
+        }
+        return disBySymptoms_1;
+    }
+
+    public List<String> getDisByVital(NeoPushVO pushVO){
+        List<String> disByVital = Lists.newArrayList();
+        List<String> symptoms = getSymptoms(pushVO);
+        if(ListUtil.isNotEmpty(symptoms)){
+            List<String> sv = redisUtil.getSv(symptoms,RedisEnum.vitalType.getName());
+            disByVital = symptomRepository.getDisByVital(sv);
         }
+        return disByVital;
+    }
 
+    public List<String> getDisByLis_other(NeoPushVO pushVO){
+        List<Lis> lises = null;
+        LisPushVo lisPushVo = pushVO.getLisPushVo();
+        if (lisPushVo != null) {
+            lises = lisPushVo.getLises();
+        }
+        List<String> neoPushDTOS = new ArrayList<>();
+        if (ListUtil.isNotEmpty(lises)) {
+            neoPushDTOS = lises.parallelStream()
+                    .map(x -> nodeRepository.getDisByLis_Other(x.getName(), x.getUniqueName() + x.getResult()))
+                    .flatMap(List::stream).collect(Collectors.toList());
 
+        }
+        return neoPushDTOS;
     }
 
     public void filterAndSort(List<String> dises, List<String> allDis, int gender_code, double age, PD pd, List<String> depts) {

+ 0 - 6
src/main/java/com/diagbot/process/PushProcess.java

@@ -40,12 +40,6 @@ public class PushProcess {
         NeoPushVO pushVO = commonFacade.generatePushInput(wordCrfDTO);
         Map<String, List<PushBaseDTO>> dis = new HashMap<>();
         List<String> push = neoFacade.getPush(pushVO);
-        if (pushVO.getDiagVo() != null && ListUtil.isNotEmpty(pushVO.getDiagVo().getDiags())) {
-            List<String> collect = pushVO.getDiagVo().getDiags().stream().map(x -> x.getName()).collect(Collectors.toList());
-            push.removeAll(collect);
-            collect.addAll(push);
-            push = collect;
-        }
         if (ListUtil.isNotEmpty(push)) {
             //先把所有疾病推出来
             if (ruleTypeList.contains("7")) {

+ 8 - 1
src/main/java/com/diagbot/repository/BaseNodeRepository.java

@@ -48,9 +48,12 @@ public interface BaseNodeRepository extends Neo4jRepository<BaseNode, Long> {
             " RETURN DISTINCT(m.name)+'::'+c.name")
     List<String> getMedJiePouClass();
 
-    @Query("match(s) where any(label in labels(s) where label in ['症状','体征']) return distinct s.name")
+    @Query("match(d:症状) return distinct d.name")
     List<String> getSymptomClass();
 
+    @Query("match(d:体征) return distinct d.name")
+    List<String> getVitalClass();
+
     //化验查疾病
     @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);
@@ -59,6 +62,10 @@ public interface BaseNodeRepository extends Neo4jRepository<BaseNode, Long> {
     @Query("match(d:医保疾病名称)-[r1]->(l:化验套餐名称{name:{lisBig}})-[r:化验套餐名称相关化验细项及结果]->(lr:化验细项及结果{name:{subres}}),(d)-[r2]->(lr) where lr.special='是' return d.name")
     List<String> getDisByLis_Special(@Param("lisBig") String lisBig,@Param("subres") String subres);
 
+    //化验查疾病(无特异性)
+    @Query("match(d:医保疾病名称)-[r1]->(l:化验套餐名称{name:{lisBig}})-[r:化验套餐名称相关化验细项及结果]->(lr:化验细项及结果{name:{subres}}),(d)-[r2]->(lr) where not exists(lr.special) return d.name")
+    List<String> getDisByLis_Other(@Param("lisBig") String lisBig,@Param("subres") String subres);
+
     @Query("match(d:医保疾病名称)-[r:医保疾病名称相关性别]->(h) return DISTINCT d.name+'&'+h.name")
     List<String> getDisSexClass();
 

+ 4 - 3
src/main/java/com/diagbot/repository/SymptomNameRepository.java

@@ -36,11 +36,12 @@ public interface SymptomNameRepository extends Neo4jRepository<Symptom, Long> {
 //    @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")
+    @Query("match(d:医保疾病名称)-[r:医保疾病名称相关症状]->(s:症状) where s.name in {py} return d.name")
     List<String> getDisBySymptoms_1(@Param("py")List<String> symptoms);
 
+    @Query("match(d:医保疾病名称)-[r:医保疾病名称相关体征]->(s:体征) where s.name in {py} return d.name")
+    List<String> getDisByVital(@Param("py")List<String> vitals);
+
     @Query("MATCH (n:症状) return distinct(n.name) as name LIMIT {size}")
     List<String> getSymptomNames(@Param("size") Integer size);
 }

+ 1 - 0
src/main/java/com/diagbot/web/CacheController.java

@@ -36,6 +36,7 @@ public class CacheController {
         cacheFacade.loadDrugTypeCache();
         cacheFacade.loadDiseaseTypeCache();
         cacheFacade.getSymptomCache();
+        cacheFacade.getVitalCache();
         cacheFacade.getSymptomNumCache();
         return RespDTO.onSuc(true);
     }