Browse Source

添加慢病的不良反应

kongwz 6 years ago
parent
commit
ef742a2ece

+ 3 - 2
graph-web/src/main/java/org/diagbot/graphWeb/work/GraphCalculate.java

@@ -82,9 +82,10 @@ public class GraphCalculate {
             // 查找页面诊断里是否有不良反应
             String[] webDiagList = webDiag.split(",|,|、|;|:|;");
             Map<String, List<String>> disUE = neo4jAPI.getDisUE(webDiagList, diseaseType);
-
+            //获取不良反应集合
+            Set<String> ue = neo4jAPI.getUe((String[]) inputList.toArray(new String[inputList.size()]));
             //走平常诊断治疗
-            Map<String, Filnlly> mulDiseaseTreat = neo4jAPI.getMulDiseaseTreat_2(webDiag, diseaseType, diseaseSet,disUE,String.join(",", inputList));
+            Map<String, Filnlly> mulDiseaseTreat = neo4jAPI.getMulDiseaseTreat_2(webDiag, diseaseType, diseaseSet,disUE,ue,String.join(",", inputList));
             responseData.setTreat(mulDiseaseTreat);
         }
         //管理评估(慢病才有)

+ 78 - 7
graph/src/main/java/org/diagbot/graph/jdbc/Neo4jAPI.java

@@ -754,6 +754,74 @@ public class Neo4jAPI {
             return diseaseCondition;
         }
     }
+    /**
+     * 不良反应推送
+     */
+    public Set<String> getUe(String[] keys) {
+        //查找不良反应推送
+        Set<String> indSet = new HashSet<>();
+        List<String> newList = new ArrayList<>();
+        ArrayList<String> fildList = new ArrayList<>();
+        for (String fild : keys) {
+            fildList.add("\"" + fild.trim() + "\"");
+        }
+        logger.info("根据 " + fildList + " 这些词推送不良反应!!!");
+        Session session = null;
+        StatementResult result = null;
+        String query = "";
+        try {
+            session = driver.session(AccessMode.WRITE);
+            logger.info("session 为: " + session);
+            query = propertiesUtil.getProperty("serchCollect").replace("fildList", fildList.toString());
+            result = session.run(query);
+            while (result.hasNext()) {
+                Record record = result.next();
+                String fild = record.get("fild").toString();
+                List<Object> typeCollect = record.get("typeCollect").asList();
+                //如果不包含诊断依据就找它的同义词,否则就要这个词
+                if ("近义词".equals(typeCollect.get(0)) && typeCollect.size() == 1) {
+                    query = "match(l)-[r:近义词]->(h) where l.name=" + fild + " return h.name as js";
+                    StatementResult jinyiResult = session.run(query);
+                    while (jinyiResult.hasNext()) {
+                        Record next = jinyiResult.next();
+                        String js = next.get("js").toString();
+                        fildList.remove(fild);
+                        fildList.add(js);
+                    }
+                }
+            }
+            newList.addAll(fildList);
+            int i = 0;
+            while (newList.size() > 0) {
+                i++;
+                query = propertiesUtil.getProperty("searchCondition").replace("newList", newList.toString()).replace("fildList", fildList.toString());
+                result = session.run(query);
+                newList.clear();
+                while (result.hasNext()) {
+                    Record record = result.next();
+                    String condition = record.get("condition").toString();
+                    String jundgement = record.get("jundgement").toString();
+                    String label = record.get("label").toString();
+                    if ("TRUE".equals(jundgement)) {
+                        newList.add(condition);
+                        fildList.add(condition);
+                    }
+                }
+            }
+            query = propertiesUtil.getProperty("searchUe").replace("fildList", fildList.toString());
+            result = session.run(query);
+            while (result.hasNext()) {
+                Record record = result.next();
+                String indName = record.get("name").toString().replace("\"", "");
+                indSet.add(indName);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            CloseSession(session);
+            return indSet;
+        }
+    }
 
     /**
      * 指标推送
@@ -826,6 +894,7 @@ public class Neo4jAPI {
         }
     }
 
+
     /**
      * 新的诊断逻辑
      * 包含确诊和疑诊集合
@@ -1092,7 +1161,7 @@ public class Neo4jAPI {
      * @param filds   //     * @param sign 标志,2是平常诊断的治疗,0是复诊诊断的治疗,1是急诊
      * @return
      */
-    public Map<String, Filnlly> getMulDiseaseTreat_2(String disease, Integer diseaseType, Set<String> disSet,Map<String, List<String>> disUE, String filds) {
+    public Map<String, Filnlly> getMulDiseaseTreat_2(String disease, Integer diseaseType, Set<String> disSet,Map<String, List<String>> disUE,Set<String> ueSet, String filds) {
         Map<String, Filnlly> diagTreat = new HashMap<>();
         Session session = null;
         NumberFormat nf = NumberFormat.getPercentInstance();
@@ -1114,19 +1183,22 @@ public class Neo4jAPI {
             for (String yizhen : disSet) {
                 fildsList.add("\'" + yizhen + "\'");
             }
+            for (String h:ueSet) {
+                fildsList.add("\'" + h + "\'");
+            }
             for (int j = 0; j < diseaseList.size(); j++) {
                 if (i != j) {
                     fildsList.add("\'" + diseaseList.get(j) + "\'");
                 }
             }
-            //获取每个病的不良反应集合
+         /*   //获取每个病的不良反应集合
             List<String> ueList = disUE.get(diseaseList.get(i));
             if(ueList !=null && ueList.size()>0){
                 for (String ue:ueList) {
                     fildsList.add("\'"+ue+"\'");
                 }
             }
-
+*/
             diseFilds.put(diseaseList.get(i), fildsList);
         }
         try {
@@ -1300,15 +1372,14 @@ public class Neo4jAPI {
                             logger.info(diseaseName+"下面有"+stringList+"不良反应");
                             if(stringList !=null && stringList.size()>0){
                                 List<Indicators> indicatorsList1 = new ArrayList<>();
-                                Indicators indicators1 = getAdverse(stringList, "低血糖反应");
+                                Indicators indicators1 = getAdverse(ueSet, "低血糖反应");
                                 logger.info(disSet + "包含  低血糖反应");
-                                Indicators indicators2 = getAdverse(stringList, "胃肠道不良反应");
+                                Indicators indicators2 = getAdverse(ueSet, "胃肠道不良反应");
                                 logger.info(disSet + "包含  胃肠道不良反应");
                                 indicatorsList1.add(indicators1);
                                 indicatorsList1.add(indicators2);
                                 filnlly.setAdverseEvent(indicatorsList1);
                             }
-
                         }
                         filnlly.setTreatment(drugsList);
                         diagTreat.put(diseaseName, filnlly);
@@ -1610,7 +1681,7 @@ public class Neo4jAPI {
 
     }
 
-    public Indicators getAdverse(List<String> dis, String name) {
+    public Indicators getAdverse(Set<String> dis, String name) {
         List<Detail> detailList1 = new ArrayList<>();
         Indicators indicators1 = new Indicators();
         indicators1.setName(name);

+ 7 - 0
graph/src/main/resources/bolt.properties

@@ -49,6 +49,13 @@ where n.name=row\n \
 with distinct m,r\n \
 return m.name as name, labels(m)[0] as label,type(r) as relationType
 
+#\u67E5\u627E\u4E0D\u826F\u53CD\u5E94\u7684\u8BED\u53E5
+searchUe=with fildList  as data unwind data as row\n \
+match (n)-[r:\u786E\u8BCA|:\u62DF\u8BCA]->(m:UntowardEffect)\n \
+where n.name=row\n \
+with distinct m,r\n \
+return m.name as name, labels(m)[0] as label,type(r) as relationType
+
 #\u67E5\u627E\u4E00\u4E9B\u8BCD\u662F\u5426\u5728\u56FE\u8C31\u4E2D
 searchWords=match(d) where d.name in fildList return distinct d.name as name
 #\u6839\u636E\u75BE\u75C5\u67E5\u627E\u76F8\u5E94\u7684Lis Pacs