Browse Source

删除冗余方法

kongwz 6 years ago
parent
commit
a07e3aa498

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

@@ -52,7 +52,7 @@ public class GraphCalculate {
         Map<String, Map<String,String>> condition = neo4jAPI.getCondition((String[]) inputList.toArray(new String[inputList.size()]),webDiag );
         List<FeatureRate> featureRates = new ArrayList<>();
         for (Map.Entry<String, Map<String,String>> d : condition.entrySet()) {
-            if (!"低血糖反应".equals(d.getKey()) && !"胃肠道不良反应".equals(d.getKey())) {
+//            if (!"低血糖反应".equals(d.getKey()) && !"胃肠道不良反应".equals(d.getKey())) {
                 FeatureRate featureRate = new FeatureRate();
                 featureRate.setFeatureName(d.getKey());
                 featureRate.setExtraProperty("");
@@ -61,7 +61,7 @@ public class GraphCalculate {
                 featureRate.setDesc(s);
                 featureRate.setRate("neo4j");
                 featureRates.add(featureRate);
-            }
+//            }
         }
         Set<String> diseaseSet = condition.keySet();
         logger.info("diseaseSet :" + diseaseSet);
@@ -79,19 +79,13 @@ public class GraphCalculate {
             }
         }
         logger.info("页面导入的所有化验项为 :" +lisSet);
-        //鉴别诊断
-        /*if(webDiag != null && webDiag.trim() != ""){
-            String[] webDiagSplits = webDiag.split(",");
-            String mainDiag = webDiagSplits[0];
-            List<String> differentialDiagnose = neo4jAPI.getDifferentialDiagnose(mainDiag);
-            responseData.setDiffDiag(differentialDiagnose);
-        }*/
+
         //走治疗
         if (webDiag.trim() != null && webDiag.trim() != "" && featureTypeList.contains("8")) {
             // 查找页面诊断里是否有不良反应
             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,ue,String.join(",", inputList));
@@ -106,9 +100,6 @@ public class GraphCalculate {
                 Map<String, JSONObject> mangementEvaluation1 = mangementEvaluation.getMangementEvaluation();
                 responseData.setManagementEvaluation(mangementEvaluation1);
             }
-//            MangementEvaluation mangementEvaluation = this.getMangementEvaluation();
-//            Map<String, JSONObject> mangementEvaluation1 = mangementEvaluation.getMangementEvaluation();
-//            responseData.setManagementEvaluation(mangementEvaluation1);
         }
         int age = searchData.getAge();
         String sex = searchData.getSex();
@@ -117,12 +108,6 @@ public class GraphCalculate {
             //查找指标
             Set<String> indSet = neo4jAPI.getInd((String[]) inputList.toArray(new String[inputList.size()]));
             logger.info("featureTypeList 包含22,走指标推送!!!,图谱推出的指标为:" + indSet);
-            /*List<MedicalIndication> medicalIndicationList = new ArrayList<>();
-            MedicalIndication medicalIndication = this.getMedicalIndication(indSet,age,sex);
-            if (medicalIndication != null) {
-                medicalIndicationList.add(medicalIndication);
-            }
-            responseData.setMedicalIndications(medicalIndicationList);*/
             List<MedicalIndication> idn = neo4jAPI.getIdn(indSet, age, sex);
             responseData.setMedicalIndications(idn);
 
@@ -271,185 +256,6 @@ public class GraphCalculate {
         return sortedMap;
     }
 
-    /**
-     * 量表和指标
-     *
-     * @param idnSet
-     * @return
-     */
-    public MedicalIndication getMedicalIndication(Set idnSet,Integer age,String sex) throws Exception {
-        MedicalIndication medicalIndication = new MedicalIndication();
-        if (idnSet.contains("肾功能不全")) {
-            logger.info("diseaseSet中包含肾功能不全");
-            //推送指标
-            medicalIndication.setName("肾功能不全");
-            List<MedicalIndicationDetail> medicalIndicationDetailList = new ArrayList<>();
-            //量表
-            MedicalIndicationDetail medicalIndicationDetail1 = new MedicalIndicationDetail();
-            medicalIndicationDetail1.setType(1);
-            JSONObject liangJson = new JSONObject();
-            liangJson.put("name", "密西根糖尿病周围神经病评分(MDNS)");
-            medicalIndicationDetail1.setContent(liangJson);
-            //公式
-            MedicalIndicationDetail medicalIndicationDetail2 = new MedicalIndicationDetail();
-            medicalIndicationDetail2.setType(2);
-            JSONObject gongshiJson = new JSONObject();
-            gongshiJson.put("name", "肾小球滤过率");
-            List<JSONObject> detailList = new ArrayList<>();
-            JSONObject ageJsonObject = new JSONObject();
-            ageJsonObject.put("controlType", 2);
-            ageJsonObject.put("name", "年龄");
-            ageJsonObject.put("value", age);
-            ageJsonObject.put("uint", "");
-            ageJsonObject.put("details", new ArrayList<>());
-            JSONObject indicationJsonObject = new JSONObject();
-            indicationJsonObject.put("controlType", 2);
-            indicationJsonObject.put("name", "血肌酐");
-            indicationJsonObject.put("value", "");
-            indicationJsonObject.put("uint", "mg/dL");
-            indicationJsonObject.put("details", new ArrayList<>());
-            JSONObject sexJson = new JSONObject();
-            sexJson.put("controlType", 1);
-            sexJson.put("name", "性别");
-            sexJson.put("value", "");
-            sexJson.put("uint", "");
-            List<JSONObject> sexList = new ArrayList<>();
-            JSONObject manJson = new JSONObject();
-            manJson.put("detailName", "男");
-            manJson.put("value", 1);
-            manJson.put("state", 0);
-            if("M".equals(sex)){
-                manJson.put("state", 1);
-            }
-            JSONObject womanJson = new JSONObject();
-            womanJson.put("detailName", "女");
-            womanJson.put("value", 1.018);
-            womanJson.put("state", 0);
-            if("F".equals(sex)){
-                womanJson.put("state", 1);
-            }
-            sexList.add(manJson);
-            sexList.add(womanJson);
-            sexJson.put("details", sexList);
-            detailList.add(ageJsonObject);
-            detailList.add(indicationJsonObject);
-            detailList.add(sexJson);
-            gongshiJson.put("details", detailList);
-            medicalIndicationDetail2.setContent(gongshiJson);
-            //其他
-            MedicalIndicationDetail medicalIndicationDetail3 = new MedicalIndicationDetail();
-            medicalIndicationDetail3.setType(3);
-            JSONObject shiFouJson = new JSONObject();
-            shiFouJson.put("name", "是否");
-            shiFouJson.put("controlType", 0);
-            List<JSONObject> shiFouList = new ArrayList<>();
-            JSONObject shiJsonObject = new JSONObject();
-            shiJsonObject.put("detailName", "是");
-            shiJsonObject.put("state", 1);
-            JSONObject fouJsonObject = new JSONObject();
-            fouJsonObject.put("detailName", "否");
-            fouJsonObject.put("state", 0);
-            shiFouList.add(shiJsonObject);
-            shiFouList.add(fouJsonObject);
-            shiFouJson.put("details", shiFouList);
-            medicalIndicationDetail3.setContent(shiFouJson);
-            medicalIndicationDetailList.add(medicalIndicationDetail1);
-            //Map<String, Object> maps = scaleCalcMethod(medicalIndicationDetail2);
-            JSONObject resultJson = new JSONObject();
-            JSONArray resultList = new JSONArray();
-            JSONObject result = new JSONObject();
-            result.put("text", "");
-            result.put("name", "GFR值");
-            resultList.add(result);
-            result = new JSONObject();
-            result.put("text", "");
-            result.put("name", "评估结论");
-            resultList.add(result);
-            gongshiJson.put("result", resultList);
-            medicalIndicationDetail2.setContent(gongshiJson);
-            medicalIndicationDetailList.add(medicalIndicationDetail2);
-            medicalIndicationDetailList.add(medicalIndicationDetail3);
-            medicalIndication.setDetails(medicalIndicationDetailList);
-        } else {
-            medicalIndication = null;
-        }
-        return medicalIndication;
-    }
-
-    /**
-     * 管理评估
-     *
-     * @return
-     */
-    public MangementEvaluation getMangementEvaluation() {
-        MangementEvaluation mangementEvaluation = new MangementEvaluation();
-        Map<String, JSONObject> mangementMap = new HashMap<>();
-        JSONObject curativeJson = new JSONObject();
-        List<JSONObject> itemJson = new ArrayList<>();
-        JSONObject bloodPressure = new JSONObject();
-        bloodPressure.put("controltype", 0);
-        bloodPressure.put("name", "血压控制情况");
-        List<JSONObject> bloodPressureLevelList = new ArrayList<>();
-        String[] items = { "正常", "1级", "2级", "3级" };
-        for (String item : items) {
-            JSONObject iJson = new JSONObject();
-            iJson.put("detailName", item);
-            iJson.put("state", 0);
-            bloodPressureLevelList.add(iJson);
-        }
-        bloodPressure.put("details", bloodPressureLevelList);
-        itemJson.add(bloodPressure);
-
-        JSONObject bmiControl = new JSONObject();
-        bmiControl.put("controltype", 0);
-        bmiControl.put("name", "BMI控制情况");
-        List<JSONObject> bmiControlLevelList = new ArrayList<>();
-        String[] bmiControlitems = { "体重过低", "体重达标", "肥胖前期", "肥胖" };
-        for (String item : bmiControlitems) {
-            JSONObject iJson = new JSONObject();
-            iJson.put("detailName", item);
-            iJson.put("state", 0);
-            bmiControlLevelList.add(iJson);
-        }
-        bmiControl.put("details", bmiControlLevelList);
-        itemJson.add(bmiControl);
-
-        JSONObject bloodFatControl = new JSONObject();
-        bloodFatControl.put("controltype", 0);
-        bloodFatControl.put("name", "血脂控制情况");
-        List<JSONObject> bloodFatControlLevelList = new ArrayList<>();
-        String[] bloodFatControlitems = { "高血脂" };
-        for (String item : bloodFatControlitems) {
-            JSONObject iJson = new JSONObject();
-            iJson.put("detailName", item);
-            iJson.put("state", 0);
-            bloodFatControlLevelList.add(iJson);
-        }
-        bloodFatControl.put("details", bmiControlLevelList);
-        itemJson.add(bloodFatControl);
-        curativeJson.put("rows", itemJson);
-        //分级管理
-        JSONObject gradeJson = new JSONObject();
-        List<JSONObject> gradItemJson = new ArrayList<>();
-        JSONObject bigGrad = new JSONObject();
-        bigGrad.put("name", "血压控制情况");
-        bigGrad.put("controltype", 0);
-        List<JSONObject> gradItemJ = new ArrayList<>();
-        String[] gradItem = { "常规管理", "强化管理" };
-        for (String item : gradItem) {
-            JSONObject j = new JSONObject();
-            j.put("detailName", item);
-            j.put("state", 0);
-            gradItemJ.add(j);
-        }
-        bigGrad.put("details", gradItemJ);
-        gradItemJson.add(bigGrad);
-        gradeJson.put("rows", gradItemJson);
-        mangementMap.put("疗效评估", curativeJson);
-        mangementMap.put("糖尿病分级管理", gradeJson);
-        mangementEvaluation.setMangementEvaluation(mangementMap);
-        return mangementEvaluation;
-    }
 
     public Map<String, Object> scaleCalcMethod(MedicalIndicationDetail medicalIndicationDetail) throws Exception {
         Map<String, Object> scaleCalcResult = new HashMap<>();

+ 13 - 218
graph/src/main/java/org/diagbot/graph/jdbc/Neo4jAPI.java

@@ -770,37 +770,6 @@ public class Neo4jAPI {
         }
     }
 
-    /**
-     * 鉴别诊断
-     * @param mainDiag
-     * @return
-     */
-    public List<String> getDifferentialDiagnose(String mainDiag){
-        List<String> differentialDiagnoseList = new LinkedList<>();
-        Session session = null;
-        StatementResult result = null;
-        String query = "";
-        try {
-            session = driver.session(AccessMode.WRITE);
-            logger.info("session 为: " + session);
-            query = propertiesUtil.getProperty("searchDifferentialDiagnose").replace("mainDis", mainDiag);
-            result = session.run(query);
-            while (result.hasNext()) {
-                Record record = result.next();
-                List<Object> coll = record.get("coll").asList();
-                if(coll != null && coll.size()>0){
-                    for (Object o:coll) {
-                        differentialDiagnoseList.add(o.toString().replace("\"",""));
-                    }
-                }
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }finally {
-            CloseSession(session);
-            return differentialDiagnoseList;
-        }
-    }
     /**
      * 不良反应推送
      */
@@ -942,73 +911,6 @@ public class Neo4jAPI {
     }
 
 
-    /**
-     * 新的诊断逻辑
-     * 包含确诊和疑诊集合
-     *
-     * @param iputList
-     * @return
-     */
-    public Map<String, ArrayList> newConditionProcess(ArrayList<String> iputList) {
-        Map<String, ArrayList> conditionMap = new HashMap<>();
-        ArrayList<String> quezhenList = new ArrayList<>();
-        ArrayList<String> yizhenList = new ArrayList<>();
-        //处理原始输入
-        List<String> arrayList = inputProcess(iputList);
-        List<String> newList = new ArrayList<>();
-        newList.addAll(arrayList);
-        Session session = null;
-        StatementResult stat = null;
-        String query = "";
-        try {
-            session = driver.session(AccessMode.READ);
-            while (newList.size() > 0) {
-                //查找符合条件的判断节点
-                query = "with " + newList + " as data unwind data as row\n" +
-                        "match (l)-[r:诊断依据]->(m)\n" +
-                        "where row.label in labels(l) and l.name=row.name\n" +
-                        "with m," + arrayList + " as data unwind data as row\n" +
-                        "match (n)-[r:诊断依据]->(m)\n" +
-                        "where row.label in labels(n) and n.name=row.name\n" +
-                        "return m.name as condition, count(distinct r)>=m.path as jundgement, labels(m)[0] as label";
-                stat = session.run(query);
-                newList.clear();
-                while (stat.hasNext()) {
-                    Record record = stat.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("{label:" + label + ",name:" + condition + "}");
-                        arrayList.add("{label:" + label + ",name:" + condition + "}");
-                    }
-                }
-            }
-            //计算确诊,可能诊断
-            query = "with " + arrayList + " as data unwind data as row\n" +
-                    "match (n)-[r:确诊|:可能诊断]->(m)\n" +
-                    "where row.label in labels(n) and n.name=row.name\n" +
-                    "with distinct m,r\n" +
-                    "return m.name as name, labels(m)[0] as label,type(r) as relationType";
-            stat = session.run(query);
-            while (stat.hasNext()) {
-                Record record = stat.next();
-                if ("\"确诊\"".equals(record.get("relationType").toString())) {
-                    quezhenList.add(record.get("name").toString().replaceAll("\"", ""));
-                } else if ("\"可能诊断\"".equals(record.get("relationType").toString())) {
-                    yizhenList.add(record.get("name").toString().replaceAll("\"", ""));
-                }
-            }
-            conditionMap.put("确诊", quezhenList);
-            conditionMap.put("可能诊断", yizhenList);
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            CloseSession(session);
-            return conditionMap;
-        }
-    }
-
     /**
      * 多疾病下治疗方案
      *
@@ -1240,14 +1142,7 @@ public class Neo4jAPI {
                     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 {
@@ -1421,13 +1316,19 @@ public class Neo4jAPI {
                             logger.info(diseaseName + "下面有" + stringList + "不良反应");
                             if (stringList != null && stringList.size() > 0) {
                                 List<Indicators> indicatorsList1 = new ArrayList<>();
-                                Indicators indicators1 = getAdverse(ueSet, "低血糖反应");
-                                logger.info(disSet + "包含  低血糖反应");
-                                Indicators indicators2 = getAdverse(ueSet, "胃肠道不良反应");
-                                logger.info(disSet + "包含  胃肠道不良反应");
-                                indicatorsList1.add(indicators1);
-                                indicatorsList1.add(indicators2);
+                                for (String de:stringList) {
+                                    Indicators indicators1 = getAdverse(ueSet, de);
+                                    logger.info(disSet + "包含  "+de);
+                                    indicatorsList1.add(indicators1);
+                                }
                                 filnlly.setAdverseEvent(indicatorsList1);
+//                                Indicators indicators1 = getAdverse(ueSet, "低血糖反应");
+//                                logger.info(disSet + "包含  低血糖反应");
+//                                Indicators indicators2 = getAdverse(ueSet, "胃肠道不良反应");
+//                                logger.info(disSet + "包含  胃肠道不良反应");
+//                                indicatorsList1.add(indicators1);
+//                                indicatorsList1.add(indicators2);
+//                                filnlly.setAdverseEvent(indicatorsList1);
                             }
                         }
                         filnlly.setTreatment(drugsList);
@@ -1788,82 +1689,6 @@ public class Neo4jAPI {
         return indicators1;
     }
 
-    /**
-     * 倒推实现
-     *
-     * @param diseaseName
-     * @return
-     */
-    public Map<String, List> getPushBack(String diseaseName, int sign) {
-        //        Map<String, String> labelMap = new HashMap<>();
-        HashMap<String, List> backMap = new HashMap<>();
-        String[] label = { "Symptom", "Vital", "LIS", "PACS", "History" };
-        Session session = null;
-        StatementResult result = null;
-        String query = "";
-        try {
-            if (sign == 1) {
-                session = driver.session(AccessMode.WRITE);
-                for (String l : label) {
-                    query = "match (d1:Disease{name:'" + diseaseName + "'})-[r1]->(s1:" + l + ") return s1.name as symptom";
-                    result = session.run(query);
-                    while (result.hasNext()) {
-                        String symptom = result.next().get("symptom").toString().replaceAll("\"", "");
-                        if (backMap.containsKey(l)) {
-                            List symptomList = backMap.get(l);
-                            symptomList.add(symptom);
-                            backMap.put(l, symptomList);
-                        } else {
-                            List<String> sList = new ArrayList<>();
-                            sList.add(symptom);
-                            backMap.put(l, sList);
-                        }
-                    }
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            CloseSession(session);
-        }
-
-        return backMap;
-    }
-
-    /**
-     * 高危逻辑
-     *
-     * @param diseaseName
-     * @return
-     */
-    public Map<String, String> getHighRisk(String diseaseName) {
-        String[] diseaseArray = diseaseName.split(",|,|、");
-        List<String> diseaseList = new ArrayList<>();
-        for (String di : diseaseArray) {
-            diseaseList.add("'" + di + "'");
-        }
-        Map<String, String> riskMap = new HashMap<>();
-        Session session = null;
-        StatementResult result = null;
-        String query = "match(d:Disease) where d.name in " + diseaseList + " return d.name as name, d.high_risk as risk";
-        try {
-            session = driver.session(AccessMode.WRITE);
-            result = session.run(query);
-            while (result.hasNext()) {
-                Record next = result.next();
-                String name = next.get("name").toString().replaceAll("\"", "");
-                String risk = next.get("risk").toString();
-                riskMap.put(name, risk);
-            }
-
-        } catch (Exception e) {
-            e.printStackTrace();
-
-        } finally {
-            CloseSession(session);
-            return riskMap;
-        }
-    }
 
     /**
      * 反推LIS,PACS
@@ -2142,36 +1967,6 @@ public class Neo4jAPI {
         }
     }
 
-    public List<String> getGrapWords(String[] keys) {
-        List<String> graphWordsList = new ArrayList<>();
-        ArrayList<String> fildList = new ArrayList<>();
-        //输出确诊集合
-        Set<String> quezhen = new HashSet<>();
-        for (String fild : keys) {
-            fildList.add("\"" + fild.trim() + "\"");
-        }
-        Session session = null;
-        StatementResult result = null;
-        String query = "";
-        try {
-            session = driver.session(AccessMode.WRITE);
-            //判断是否有近义词
-            query = "match(d) where d.name in " + fildList + " return distinct d.name as name";
-            result = session.run(query);
-            while (result.hasNext()) {
-                Record next = result.next();
-                String word = next.get("name").toString();
-                graphWordsList.add(word);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            CloseSession(session);
-        }
-        return graphWordsList;
-    }
-
-
     /**
      * 根据是否需要计算调取相应返回量表的方法
      *