Bläddra i källkod

Merge branch 'master' of D:\Workspaces\push with conflicts.

hujing 6 år sedan
förälder
incheckning
026ee9e59c

+ 2 - 2
algorithm/src/main/resources/algorithm.properties

@@ -1,8 +1,8 @@
 ################################ model basic url ###################################
 
 #basicPath=E:/git/push/algorithm/src/main/models/model_version_replacement/model
-basicPath=/opt/models/dev/models/model_version_replacement/model
-#basicPath=E:/models/model_version_replacement/model
+#basicPath=/opt/models/dev/models/model_version_replacement/model
+basicPath=E:/models/model_version_replacement/model
 
 ############################### current model version ################################
 diagnosisPredict.version=outpatient_556_IOE_1

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

@@ -465,15 +465,15 @@ public class GraphCalculate {
                 String text = null;
                 if (eGFR3 <= 0) {
                     text = "指标值缺少";
-                } else if (eGFR3 > 0 && eGFR3 <= 15) {
+                } else if (eGFR3 > 0 && eGFR3 < 15) {
                     text = "肾功能衰竭";
-                } else if (eGFR3 > 15 && eGFR3 <= 29) {
+                } else if (eGFR3 >= 15 && eGFR3 <= 29) {
                     text = "重度下降";
-                } else if (eGFR3 > 30 && eGFR3 <= 59) {
+                } else if (eGFR3 > 29 && eGFR3 < 60) {
                     text = "中度下降";
-                } else if (eGFR3 > 60 && eGFR3 <= 89) {
+                } else if (eGFR3 >= 60 && eGFR3 <= 89) {
                     text = "轻度下降";
-                } else if (eGFR3 >= 90) {
+                } else if (eGFR3 > 89) {
                     text = "正常或肾损伤代偿期";
                 }
 

+ 36 - 88
graph/src/main/java/org/diagbot/graph/jdbc/Neo4jAPI.java

@@ -42,9 +42,7 @@ public class Neo4jAPI {
     public Neo4jAPI(Driver driver) {
         this.driver = driver;
     }
-    public Neo4jAPI() {
 
-    }
     /**
      * 获取所有标签名称
      *
@@ -645,7 +643,7 @@ public class Neo4jAPI {
      * @param keys
      * @return
      */
-    public Map<String, String> getCondition(String[] keys,Driver driver) {
+    public Map<String, String> getCondition(String[] keys) {
         Map<String, String> diseaseCondition = new LinkedHashMap<>();
         List<String> newList = new ArrayList<>();
         ArrayList<String> fildList = new ArrayList<>();
@@ -654,7 +652,7 @@ public class Neo4jAPI {
         for (String fild : keys) {
             fildList.add("\"" + fild.trim() + "\"");
         }
-        logger.info("根据 "+fildList+" 这些词推送图谱诊断!!!");
+        logger.info("根据 " + fildList + " 这些词推送图谱诊断!!!");
         Session session = null;
         StatementResult result = null;
         String query = "";
@@ -734,13 +732,12 @@ public class Neo4jAPI {
                 Map<String, String> dis_res = new HashMap<>();
                 dis_res.put("确诊", "");
                 diseaseCondition.put(qu, JSON.toJSONString(dis_res));
-                logger.info("图谱推出的诊断为: "+qu);
+                logger.info("图谱推出的诊断为: " + qu);
             }
         } catch (Exception e) {
             e.printStackTrace();
         } finally {
             CloseSession(session);
-            driver.close();
             return diseaseCondition;
         }
     }
@@ -969,7 +966,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, String filds,Driver driver) {
+    public Map<String, Filnlly> getMulDiseaseTreat_2(String disease, Integer diseaseType, Set<String> disSet, String filds) {
         Map<String, Filnlly> diagTreat = new HashMap<>();
         Session session = null;
         NumberFormat nf = NumberFormat.getPercentInstance();
@@ -988,7 +985,7 @@ public class Neo4jAPI {
             for (String fild : fildsArray) {
                 fildsList.add("\'" + fild + "\'");
             }
-            for (String yizhen:disSet) {
+            for (String yizhen : disSet) {
                 fildsList.add("\'" + yizhen + "\'");
             }
             for (int j = 0; j < diseaseList.size(); j++) {
@@ -1164,7 +1161,7 @@ public class Neo4jAPI {
                         }
                         Filnlly filnlly = new Filnlly();
                         //显示不良反应
-                        if(diseaseType !=null && 1 == diseaseType){
+                        if (diseaseType != null && 1 == diseaseType) {
                             List<Indicators> indicatorsList1 = new ArrayList<>();
                             Indicators indicators1 = getAdverse(disSet, "低血糖反应");
                             Indicators indicators2 = getAdverse(disSet, "胃肠道不良反应");
@@ -1182,11 +1179,11 @@ public class Neo4jAPI {
             e.printStackTrace();
         } finally {
             CloseSession(session);
-            driver.close();
             return diagTreat;
         }
     }
-    public Indicators getAdverse(Set<String> dis,String name){
+
+    public Indicators getAdverse(Set<String> dis, String name) {
         List<Detail> detailList1 = new ArrayList<>();
         Indicators indicators1 = new Indicators();
         indicators1.setName(name);
@@ -1197,7 +1194,7 @@ public class Neo4jAPI {
         Detail detail2 = new Detail();
         detail2.setName("是");
         detail2.setValue(0);
-        if(dis.contains(name)){
+        if (dis.contains(name)) {
             detail2.setValue(1);
         }
         Detail detail3 = new Detail();
@@ -1225,6 +1222,7 @@ public class Neo4jAPI {
         indicators1.setDetails(detailList1);
         return indicators1;
     }
+
     /**
      * 倒推实现
      *
@@ -1809,6 +1807,7 @@ public class Neo4jAPI {
 
     /**
      * 获取量表
+     *
      * @param scaleName
      * @return
      */
@@ -2090,24 +2089,34 @@ public class Neo4jAPI {
         String final_result = null;
         Map<String, Object> scaleCalc = getScaleCalc2(scaleName);
         for (String scaleItem : scaleItems) {
-            Object details = scaleCalc.get("rows");
-            //获取name
-            List<Map<String, Object>> content = (List<Map<String, Object>>) details;
-            for (Map<String, Object> map : content) {
-                String name = map.get("name").toString();
-                if (scaleItem.contains(name) || name.contains(scaleItem)) {
-                    List<Map<String, Object>> sub_detail = (List<Map<String, Object>>) map.get("details");
-                    for (Map<String, Object> sub_map : sub_detail) {
-                        String detailName = sub_map.get("detailName").toString();
-                        String score = sub_map.get("score").toString();
-                        if (scaleItem.contains(detailName)) {
-                            sum += Double.valueOf(score);
-                            sub_map.put("state", "1");
+            List<Map<String, Object>> groupList = (List<Map<String, Object>>) scaleCalc.get("group");
+            for (Map<String, Object> groupMap : groupList) {
+                int groupSum = 0;
+                JSONArray rowList = new JSONArray();
+                //获取name
+                rowList = JSONArray.parseArray(JSONObject.parseObject(groupMap.get("rows").toString()).get("row").toString());
+                for (int i = 0; i < rowList.size(); i++) {
+                    Map<String, Object> map = (Map<String, Object>) rowList.get(i);
+                    String name = map.get("name").toString();
+                    if (scaleItem.contains(name) || name.contains(scaleItem)) {
+                        List<Map<String, Object>> sub_detail = (List<Map<String, Object>>) map.get("details");
+                        for (Map<String, Object> sub_map : sub_detail) {
+                            String detailName = sub_map.get("detailName").toString();
+                            String score = sub_map.get("score").toString();
+                            if (scaleItem.contains(detailName)) {
+                                groupSum += Double.valueOf(score);
+                                sum += Double.valueOf(score);
+                                sub_map.put("state", 1);
+                                JSONObject details = new JSONObject();
+                                details.put(sub_map);
+                            }
                         }
+                    } else {
+                        continue;
                     }
-                } else {
-                    continue;
                 }
+                Map<String, Object> groupCalculate = (Map<String, Object>) groupMap.get("groupCalculate");
+                groupCalculate.put("score", String.valueOf(groupSum));
             }
         }
         System.out.println(sum);
@@ -2132,65 +2141,4 @@ public class Neo4jAPI {
         Map<String, Object> map = new HashMap<>();
         return map;
     }
-
-    public String scaleCalcMethod(String[] scaleItems, String scaleName) {
-        String result = null;
-        Map<String, Object> calcMap = calcMethod();
-        List<Map<String, Object>> calcTypes = (List<Map<String, Object>>) calcMap.get("details");
-        for (Map<String, Object> calcType : calcTypes) {
-            switch ((int) calcType.get("type")) {
-                case 1:
-                    result = scaleScoreCalc(scaleItems, scaleName).get("text").toString();
-                    break;
-                case 2:
-                    Map<String, Object> content = (Map<String, Object>) calcType.get("content");
-                    List<Map<String, Object>> details = (List<Map<String, Object>>) content.get("details");
-                    int age = 0;
-//                    double scr = 0.00;
-                    double scr = 2.2621;
-                    float k = 0.0f;
-                    double a = 0.00;
-                    double denger = 0.00;
-                    for (Map<String, Object> detailsMap : details) {
-                        if ("年龄".equals(detailsMap.get("name").toString())) {
-                            age = (int) detailsMap.get("value");
-                        } else if ("血肌酐".equals(detailsMap.get("name").toString())) {
-                            if ("umol/L".equals(detailsMap.get("uint"))) {
-                                scr = (double) detailsMap.get("value") * 88.41;
-                            } else {
-                                scr = (double) detailsMap.get("value");
-                            }
-                        } else if ("性别".equals(detailsMap.get("name").toString())) {
-                            List<Map<String, Object>> genderDetails = (List<Map<String, Object>>) detailsMap.get("details");
-                            for (Map<String, Object> genderDetail : genderDetails) {
-                                if ("男".equals(genderDetail.get("detailName").toString())) {
-                                    k = 0.9f;
-                                    denger = (double) genderDetail.get("value");
-                                    if (scr <= 0.90) {
-                                        a = -0.411;
-                                    } else {
-                                        a = -1.209;
-                                    }
-                                } else if ("女".equals(genderDetail.get("detailName").toString())) {
-                                    k = 0.7f;
-                                    denger = (double) genderDetail.get("value");
-                                    if (scr <= 0.70) {
-                                        a = -0.329;
-                                    } else {
-                                        a = -1.209;
-                                    }
-                                }
-                            }
-                        }
-                    }
-
-                    age = 20;
-                    double eGFR3 = 141 * Math.pow((scr / k), a) * Math.pow(0.993, age) * denger;
-                    System.out.println(eGFR3);
-            }
-        }
-
-        return result;
-    }
-
 }

+ 10 - 0
push-web/src/main/java/org/diagbot/push/controller/GraphController.java

@@ -101,6 +101,16 @@ public class GraphController extends BaseController {
         return scale;
     }
 
+    @RequestMapping(value = "/scaleTest", method = RequestMethod.POST)
+    @ResponseBody
+    public Map<String, Object> scaleTest(HttpServletRequest request, @RequestBody SearchData searchData) throws Exception {
+        Driver driver = DriverManager.newDrive("192.168.2.233", "neo4j", "root");
+        Neo4jAPI neo4jAPI = new Neo4jAPI(driver);
+
+        Map<String, Object> scale = neo4jAPI.getScaleCalc2( searchData.getScaleName());
+        return scale;
+    }
+
     @RequestMapping(value = "/scaleCalc", method = RequestMethod.POST)
     @ResponseBody
     public Map<String, Object> scaleCalc(HttpServletRequest request, @RequestBody SearchData searchData) throws Exception {