Browse Source

Merge branch 'push-dev' of http://192.168.2.236:10080/louhr/push into push-dev

louhr 5 years ago
parent
commit
8f7447bb55

+ 15 - 26
bigdata-web/src/main/java/org/diagbot/bigdata/work/BigDataParamsProxy.java

@@ -8,9 +8,6 @@ import org.diagbot.nlp.feature.FeatureType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * @ClassName org.diagbot.bigdata.work.ParamsDataProxy
  * @Description TODO
@@ -33,7 +30,7 @@ public class BigDataParamsProxy {
      * @param searchData
      */
     public AlgorithmClassify[] createAlgorithmClassify(String sysCode, String[] featureTypes, SearchData searchData) {
-        List<AlgorithmClassify> algorithmClassifies = new ArrayList<>();
+        AlgorithmClassify[] classifies = new AlgorithmClassify[featureTypes.length];
         //下了诊断且其他信息全为空 反推标识
         boolean reverse = !StringUtils.isEmpty(searchData.getDiag()) && StringUtils.isEmpty(searchData.getSymptom());
         for (int i = 0; i < featureTypes.length; i++) {
@@ -42,64 +39,56 @@ public class BigDataParamsProxy {
                 switch (FeatureType.parse(featureTypes[i])) {
                     case SYMPTOM:
                         if (reverse) {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_DIAG_SYMPTOM);
+                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_SYMPTOM;
                         } else {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_SYMPTOM);
+                            classifies[i] = AlgorithmClassify.NEURAL_SYMPTOM;
                         }
                         break;
                     case DIAG:
                         if (reverse) {
-                            algorithmClassifies.add(null);
+                            classifies[i] = null;
                         } else {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_DIAG);
+                            classifies[i] = AlgorithmClassify.NEURAL_DIAG;
                         }
                         break;
                     case VITAL:
                         if (reverse) {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_DIAG_VITAL);
-
+                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_VITAL;
                         } else {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_VITAL);
-
+                            classifies[i] = AlgorithmClassify.NEURAL_VITAL;
                         }
                         break;
                     case LIS:
                         if (reverse) {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_DIAG_LIS);
-
+                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_LIS;
                         } else {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_LIS);
+                            classifies[i] = AlgorithmClassify.NEURAL_LIS;
                         }
                         break;
                     case PACS:
                         if (reverse) {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_DIAG_PACS);
+                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_PACS;
                         } else {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_PACS);
+                            classifies[i] = AlgorithmClassify.NEURAL_PACS;
                         }
                         break;
                     case TREAT:
                         if (reverse) {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_DIAG_TREAT);
-
+                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_TREAT;
                         } else {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_TREAT);
-
+                            classifies[i] = AlgorithmClassify.NEURAL_TREAT;
                         }
                         break;
                     case HISTORY:
                         if (reverse) {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_DIAG_HISTORY);
-
+                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_HISTORY;
                         } else {
-                            algorithmClassifies.add(AlgorithmClassify.NEURAL_HISTORY);
+                            classifies[i] = AlgorithmClassify.NEURAL_HISTORY;
                         }
                         break;
                 }
             }
         }
-        AlgorithmClassify[] classifies = new AlgorithmClassify[algorithmClassifies.size()];
-        algorithmClassifies.toArray(classifies);
         return classifies;
     }
 }

+ 9 - 0
common-push/src/main/java/org/diagbot/common/push/bean/SearchData.java

@@ -31,6 +31,7 @@ public class SearchData {
     protected String lis = "";
     protected String pacs = "";
     protected String diag = "";
+    private String diseaseName;
     protected String past = "";
     protected String other = "";
     //当前开单lis项目
@@ -311,4 +312,12 @@ public class SearchData {
     public void setRules(Map<String, List<Rule>> rules) {
         this.rules = rules;
     }
+
+    public String getDiseaseName() {
+        return diseaseName;
+    }
+
+    public void setDiseaseName(String diseaseName) {
+        this.diseaseName = diseaseName;
+    }
 }

+ 85 - 3
common-push/src/main/java/org/diagbot/common/push/filter/ClassifyDiag.java

@@ -5,6 +5,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.diagbot.common.push.bean.FeatureRate;
 import org.diagbot.common.push.bean.ResponseData;
 import org.diagbot.common.push.cache.CacheUtil;
+import org.diagbot.nlp.relation.module.Lis;
 
 import java.text.DecimalFormat;
 import java.util.*;
@@ -81,6 +82,7 @@ public class ClassifyDiag {
     public List<FeatureRate> diagClassify(List<FeatureRate> updateFeatures){
         List<FeatureRate> finalDiagList = new LinkedList<>();//最终返回
         List<String> highDiagList = new LinkedList<>();//警惕集合
+        List<String> diffDiagList = new LinkedList<>();//鉴别诊断集合
         List<String> queDiagList = new LinkedList<>();//确诊集合
         List<String> bigDiagList = new LinkedList<>();//可能诊断集合
         if(updateFeatures != null && updateFeatures.size()>0){
@@ -89,13 +91,21 @@ public class ClassifyDiag {
                 String desc = featureRate.getDesc();
                 Map<String,Object> d = new HashMap<>();
                 if(desc != null){
-                    JSONObject jsonObject = JSONObject.parseObject(desc);
+                   /* JSONObject jsonObject = JSONObject.parseObject(desc);
                     d = jsonObject;
                     if(d.keySet().size() == 1 && "警惕".equals(d.keySet().toArray()[0])){
                         highDiagList.add(featureName);
+                    }else if(d.keySet().size() == 1 && ("鉴别诊断".equals(d.keySet().toArray()[0])
+                            || "页面急诊".equals(d.keySet().toArray()[0])) || "急诊".equals(d.keySet().toArray()[0])){
+                        diffDiagList.add(featureName);
                     }else {
                         queDiagList.add(featureName);
-                    }
+                    }*/
+                   if(desc.contains("确诊") || desc.contains("拟诊")){
+                       queDiagList.add(featureName);
+                   }else {
+                       highDiagList.add(featureName);
+                   }
                 }else {
                     bigDiagList.add(featureName);
                 }
@@ -112,6 +122,17 @@ public class ClassifyDiag {
                 }
             }
         }
+        //再把鉴别诊断加进去
+        if(diffDiagList.size()>0){
+            for(int j =0;j<updateFeatures.size();j++){
+                FeatureRate featureRate = updateFeatures.get(j);
+                String featureName = featureRate.getFeatureName();
+                int i = diffDiagList.indexOf(featureName);
+                if(i >= 0){
+                    finalDiagList.add(featureRate);
+                }
+            }
+        }
         /**
          * 这里处理一下可能诊断剔除的功能
          * 如果图谱推出的诊断和可能诊断有层级关系,就把对应的可能诊断剔除
@@ -121,12 +142,16 @@ public class ClassifyDiag {
         System.out.println("图谱归一前数据 :"+queDiagList);
         if(queDiagList != null && queDiagList.size()>0){
             //图谱归一 ,图谱sign =0,大数据sign = 1
-            queSet = this.diagProcess(queDiagList,0);
+            List<String> que = this.processQue(updateFeatures, queDiagList);
+            queSet = this.diagProcess(que,0);
             System.out.println("图谱归一后的数据    :"+queSet);
             if(queSet != null && queSet.size()>0){
                 for (String queDis:queSet) {
                     if(queDiagList.indexOf(queDis)>=0){ //可以找到,就取出来,用原来的
                         FeatureRate feature = this.getFeature(updateFeatures, queDis);
+                        if(feature.getDesc().contains("拟诊")){
+                            feature.setDesc(feature.getDesc().replace("拟诊","确诊"));
+                        }
                         feature.setExtraProperty(diagDepartCache.get(queDis));
                         finalDiagList.add(feature);
                     }else {
@@ -527,5 +552,62 @@ public class ClassifyDiag {
         }
         return arrayList;
     }
+    //归一有确诊的诊断
+    public  List<String> processQue(List<FeatureRate> updateFeatures,List<String>queList){
+        List<String> finallyQue = new LinkedList<>();
+        List<String> que = new ArrayList<>();
+        List<String> ni = new ArrayList<>();
+        for (String qd:queList) {
+            for (FeatureRate f:updateFeatures) {
+                if("neo4j".equals(f.getSource()) && qd.equals(f.getFeatureName())){
+                    if(f.getDesc().contains("确诊")){
+                        que.add(qd);
+                    }else if(f.getDesc().contains("拟诊")) {
+                        ni.add(qd);
+                    }
+                }
+            }
+        }
+        if(que != null && que.size()>0){
+            for (String q:que) {
+                Set<String> classifySet = new HashSet<>();
+                String s = diagClassifyCache.get(q);
+                if(StringUtils.isNotEmpty(s)){
+                    classifySet.add(s);
+                    List<Object> key = this.getKey(diagClassifyCache, s);
+                    if(key != null && key.size()>0){
+                        for (Object o:key) {
+                            classifySet.add(o.toString());
+                            List<Object> key1 = this.getKey(diagClassifyCache, o.toString());
+                            if(key1 != null && key1.size()>0){
+                                for (Object f:key1
+                                     ) {
+                                    classifySet.add(f.toString());
+                                }
+                            }
+                        }
+                    }
+                }
+                List<Object> key = this.getKey(diagClassifyCache, q);
+                if(key != null && key.size()>0){
+                    for (Object o:key) {
+                        classifySet.add(o.toString());
+                    }
+                }
+                if(classifySet != null && classifySet.size()>0){
+                    for (String sq:classifySet
+                         ) {
+                        if(ni.indexOf(sq) >= 0){
+                            ni.remove(sq);
+                        }
+                    }
+                }
+            }
+        }
+        finallyQue.addAll(que);
+        finallyQue.addAll(ni);
+        return finallyQue;
+
+    }
 
 }

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

@@ -39,15 +39,14 @@ public class GraphCalculate {
 
         long starttime = System.currentTimeMillis();
         System.out.println("Start at: " + starttime);
-
         ResponseData responseData = new ResponseData();
 //        ParamsDataProxy paramsDataProxy = new ParamsDataProxy();
 //        paramsDataProxy.createSearchData(request, searchData);
         List<String> inputList = new ArrayList<>();
         int age = searchData.getAge();
         String sex = searchData.getSex();
+        String diseaseName = searchData.getDiseaseName();
         logger.info("前端传来的年龄为 :"+age+" 前端传来的性别为 :"+sex);
-
         Map<String, Map<String, String>> sexAgeCache = CacheUtil.getSexAgeCache();
         Map<String, Map<String, String>> inputs = searchData.getGraphInputs();
         Set<String> ss = new HashSet<>();
@@ -63,7 +62,6 @@ public class GraphCalculate {
         }
         logger.info("从分词系统接收到的词 :" + ss);
         System.out.println("Participle takes: " + (System.currentTimeMillis()-starttime)/1000d + 's');
-
         List<String> featureTypeList = Arrays.asList(searchData.getFeatureTypes());
         logger.info("featureTypeList : " + featureTypeList);
         inputList.addAll(ss);
@@ -73,39 +71,38 @@ public class GraphCalculate {
         logger.info("图谱开始推送诊断!!!!!!!!!!!");
         String webDiag = searchData.getDiag();
         logger.info("页面诊断为 :"+webDiag);
+        String[] webDiagList = webDiag.split(",|,|、|;|:|;");
         //计算诊断
-        Map<String, Map<String,String>> condition =null;
+        Map<String, Object> condition =null;
         Map<String, Map<String, String>> excludelist = null;
         if(featureTypeList.contains("2")){
             condition = neo4jAPI.getNewCondition((String[]) inputList.toArray(new String[inputList.size()]),webDiag );
-
             // 查找需要排除的诊断
             excludelist = neo4jAPI.getExcludeDiag(inputList);
             responseData.setExcludeDiag(Arrays.asList(excludelist.keySet().stream().toArray(String[]::new)));
         }
-
         List<FeatureRate> featureRates = new ArrayList<>();
         if(condition != null){
-            for (Map.Entry<String, Map<String,String>> d : condition.entrySet()) {
-                String dis = d.getKey();
-                Map<String, String> sexAgeMap = sexAgeCache.get(dis);
-                if(sexAgeMap != null){
-                    String sexType = sexAgeMap.get("sexType");
-                    Integer min_age = Integer.parseInt(sexAgeMap.get("min_age"));
-                    Integer max_age = Integer.parseInt(sexAgeMap.get("max_age"));
-
-                    if(("1".equals(sexType) &&sex.equals(sexType)) || ("2".equals(sexType) &&sex.equals(sexType)) || "3".equals(sexType)){
-                        if(min_age <age && age<=max_age){
-                            FeatureRate featureRate = new FeatureRate();
-                            featureRate.setFeatureName(dis);
-                            Map<String, String> value = d.getValue();
-                            String s = JSON.toJSONString(value);
-                            featureRate.setDesc(s);
-//                            featureRate.setRate("neo4j");
-                            featureRate.setSource("neo4j");
-                            featureRates.add(featureRate);
+            Map<String, Map<String,String>> allCondition = (Map<String, Map<String,String>>)condition.get("全部诊断");
+            if(allCondition != null && allCondition.size()>0){
+                for (Map.Entry<String, Map<String,String>> d : allCondition.entrySet()) {
+                    String dis = d.getKey();
+                    Map<String, String> sexAgeMap = sexAgeCache.get(dis);
+                    if(sexAgeMap != null){
+                        String sexType = sexAgeMap.get("sexType");
+                        Integer min_age = Integer.parseInt(sexAgeMap.get("min_age"));
+                        Integer max_age = Integer.parseInt(sexAgeMap.get("max_age"));
+                        if(("1".equals(sexType) &&sex.equals(sexType)) || ("2".equals(sexType) &&sex.equals(sexType)) || "3".equals(sexType)){
+                            if(min_age <age && age<=max_age){
+                                FeatureRate featureRate = new FeatureRate();
+                                featureRate.setFeatureName(dis);
+                                Map<String, String> value = d.getValue();
+                                String s = JSON.toJSONString(value);
+                                featureRate.setDesc(s);
+                                featureRate.setSource("neo4j");
+                                featureRates.add(featureRate);
+                            }
                         }
-
                     }
                 }
             }
@@ -132,33 +129,28 @@ public class GraphCalculate {
             }
         }
         logger.info("页面导入的所有化验项为 :" +lisSet);
-
         //走治疗
-        if (webDiag !=null && webDiag.trim() != null && webDiag.trim() != "" && featureTypeList.contains("6")) {
+        if (StringUtils.isNotEmpty(diseaseName) && featureTypeList.contains("6")) {
             // 查找页面诊断里是否有不良反应
-            String[] webDiagList = webDiag.split(",|,|、|;|:|;");
-            Map<String, List<String>> disUE = neo4jAPI.getDisUE(webDiagList, diseaseType);
+            Map<String, List<String>> disUE = neo4jAPI.getDisUE(diseaseName, 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));
+            Map<String, Filnlly> mulDiseaseTreat = neo4jAPI.getMulDiseaseTreat_2(diseaseName,webDiag, diseaseType, diseaseSet,disUE,ue,String.join(",", inputList));
             responseData.setTreat(mulDiseaseTreat);
         }
         //管理评估(慢病才有)
         if (featureTypeList.contains("11") && diseaseType == 1 && diseaseType != null) {
             logger.info("featureTypeList 包含11,走管理评估!!!");
             if(webDiag != null){
-                String[] webDiagsplits = webDiag.split(",|,|、|;|:|;");
-                MangementEvaluation mangementEvaluation = neo4jAPI.pushMe(webDiagsplits,lis_Result);
+                MangementEvaluation mangementEvaluation = neo4jAPI.pushMe(webDiagList,lis_Result);
                 Map<String, JSONObject> mangementEvaluation1 = mangementEvaluation.getMangementEvaluation();
                 responseData.setManagementEvaluation(mangementEvaluation1);
             }
         }
-        String pacsOrder = searchData.getPacsOrder();
         //指标推送
         if (featureTypeList.contains("22") ) {
             List<MedicalIndication> idns =new ArrayList<>();
-//            List<MedicalIndication> pacsMi = getPacsMi(pacsOrder, inputList,webDiag);
             Set<String> newindSet = new HashSet<>();
             Set<String> newindSet1 = new HashSet<>();
             //查找指标
@@ -172,8 +164,6 @@ public class GraphCalculate {
                     }
                 }
             }
-
-
             Map<String, String> indLiang =null;
             if(newindSet1 != null && newindSet1.size()>0){
                 indLiang =neo4jAPI.getIndLiang(newindSet1);
@@ -199,297 +189,18 @@ public class GraphCalculate {
                     if(indLiang != null){
                         jsonObject.put("name",indLiang.get(ind)); 
                     }
-                    
                     medicalIndicationDetail.setContent(jsonObject);
                     ds.add(medicalIndicationDetail);
                     medicalIndication.setDetails(ds);
                     idns.add(medicalIndication);
-
                 }
             }
             responseData.setMedicalIndications(idns);
-
         }
-
         //诊断推送
         responseData.setDis(featureRates);
         responseData.setInputs(searchData.getInputs());
-
         System.out.println("Total takes: " + (System.currentTimeMillis()-starttime)/1000d + 's');
         return responseData;
     }
-    public List<MedicalIndication> getPacsMi(String pacsOrder,List<String> inputList,String webDiag){
-        if(StringUtils.isNotEmpty(webDiag)){
-            String[] webDiagsplits = webDiag.split(",|,|、|;|:|;");
-            for (String wd:webDiagsplits
-                 ) {
-                inputList.add(wd);
-            }
-        }
-
-        List<MedicalIndication> pacsMi = new ArrayList<>();
-        Map<String, String> newInd = neo4jAPI.getNewInd((String[]) inputList.toArray(new String[inputList.size()]));
-        if(StringUtils.isNotEmpty(pacsOrder)){
-            String[] pacsOrders = pacsOrder.split(",|,");
-            for (String pacs:pacsOrders) {
-                if(newInd.containsKey(pacs)){
-                    String causes = newInd.get(pacs);
-                    MedicalIndication m = new MedicalIndication();
-                    List<MedicalIndicationDetail> mds = new ArrayList<>();
-                    MedicalIndicationDetail medicalIndicationDetail = new MedicalIndicationDetail();
-                    medicalIndicationDetail.setType(4);
-                    JSONObject jsonObject = new JSONObject();
-                    jsonObject.put("name", causes);
-                    jsonObject.put("controlType",2);
-                    medicalIndicationDetail.setContent(jsonObject);
-                    mds.add(medicalIndicationDetail);
-                    m.setName("不建议做:"+pacs);
-                    m.setDetails(mds);
-                    pacsMi.add(m);
-                }
-            }
-        }
-        return pacsMi;
-    }
-//    诊断过滤
-    public void filterDis(List<FeatureRate> graphFeatureRates,String sex,Integer age) throws Exception {
-        if(neo4jAPI == null){
-            neo4jAPI = new Neo4jAPI(DriverManager.newDrive());
-        }
-        List<String> disList = new ArrayList<>();
-        if(graphFeatureRates != null && graphFeatureRates.size()>0){
-            for (FeatureRate f:graphFeatureRates) {
-                disList.add("\""+f.getFeatureName()+"\"");
-            }
-        }
-//        第一步先过滤性别和年龄
-        Set<String> filterSexAgeList = neo4jAPI.filterDisFromSexAge(disList,sex,age);
-
-
-    }
-    /**
-     * 返回LIS,PACS
-     *
-     * @param searchData
-     */
-    public ResponseData getLisPacs(HttpServletRequest request, SearchData searchData) throws Exception {
-        ResponseData responseData = new ResponseData();
-        Neo4jAPI neo4jAPI = new Neo4jAPI(DriverManager.newDrive());
-        String webDiag = searchData.getDiag();
-        List<String> webDiagList = Arrays.asList(webDiag.split(",|,|、"));
-        List<FeatureRate> bigdataDiagFeature = searchData.getPushDiags();
-        List<String> bigdataDiagList = new LinkedList<>();
-        if (bigdataDiagFeature.size() > 0) {
-            for (FeatureRate fe : bigdataDiagFeature) {
-                if ("neo4j".equals(fe.getRate())) {
-                    bigdataDiagList.add(fe.getFeatureName());
-                    logger.info("图谱推出的诊断为: " + fe.getFeatureName());
-                } else {
-                    bigdataDiagList.add(fe.getFeatureName());
-                    logger.info("大数据推出的诊断为: " + fe.getFeatureName());
-                }
-            }
-        }
-        for (String web : webDiagList) {
-            for (int i = 0; i < bigdataDiagList.size(); i++) {
-                if (bigdataDiagList.get(i).equals(web)) {
-                    bigdataDiagList.remove(bigdataDiagList.get(i));
-                }
-            }
-        }
-        logger.info("界面诊断为: " + webDiagList);
-        logger.info("推出的诊断合并为: " + bigdataDiagList);
-        Map<String, Set<String>> weblisPacs1 = null;
-        Map<String, Set<String>> biglisPacs1 = null;
-        if (webDiagList != null && webDiagList.size() > 0) {
-            weblisPacs1 = neo4jAPI.getLisPacs(webDiagList);//界面诊断推出的LIS,PACS
-        }
-        if (bigdataDiagList != null && bigdataDiagList.size() > 0) {
-            biglisPacs1 = neo4jAPI.getLisPacs(bigdataDiagList);//大数据推得诊断
-        }
-        Set<String> lis = null;
-        Set<String> pacs = null;
-        //如果界面有诊断
-        if (weblisPacs1 != null && weblisPacs1.values().size() > 0) {
-            lis = weblisPacs1.get("LIS");
-            pacs = weblisPacs1.get("PACS");
-            logger.info("界面有诊断的情况下,界面诊断推出的lis为: " + lis);
-            logger.info("界面有诊断的情况下,界面诊断推出的pacs为: " + pacs);
-            if (biglisPacs1 != null && biglisPacs1.values().size() > 0) {
-                Set<String> bl = biglisPacs1.get("LIS");
-                Set<String> bp = biglisPacs1.get("PACS");
-                logger.info("界面有诊断的情况下,推出诊断的lis为: " + bl);
-                logger.info("界面有诊断的情况下,推出诊断的pacs为: " + bp);
-                lis.addAll(bl);
-                pacs.addAll(bp);
-            }
-        } else {
-            lis = biglisPacs1.get("LIS");
-            pacs = biglisPacs1.get("PACS");
-            logger.info("界面无诊断的情况下,推出诊断的lis为: " + lis);
-            logger.info("界面无诊断的情况下,推出诊断的lis为: " + pacs);
-        }
-        logger.info("推出的合并lis为: " + lis);
-        logger.info("推出的合并pacs为: " + pacs);
-        ArrayList<FeatureRate> lisFeature = new ArrayList<>();
-        ArrayList<FeatureRate> pacsFeature = new ArrayList<>();
-        for (String l : lis) {
-            FeatureRate featureRate = new FeatureRate();
-            featureRate.setFeatureName(l);
-            lisFeature.add(featureRate);
-        }
-        for (String p : pacs) {
-            FeatureRate featureRate = new FeatureRate();
-            featureRate.setFeatureName(p);
-            pacsFeature.add(featureRate);
-        }
-        responseData.setLabs(lisFeature);
-        responseData.setPacs(pacsFeature);
-        return responseData;
-    }
-
-
-    /**
-     * 对化验和检查的结果进行排序
-     *
-     * @param set
-     * @return List<FeatureRate>
-     */
-    public Set<String> processResult(Set<String> set) {
-        Set<String> frlist = new LinkedHashSet<>();
-        Map<String, String> sortval = new HashMap<>();
-        Map<String, String> items = new HashMap<>();
-        String name;
-        try {
-            if (set != null && set.size() > 0) {
-                for (String item : set) {
-                    if (sortval.get(item) == null) {
-                        sortval.put(item, "1");
-                    } else {
-                        sortval.put(item, String.valueOf(Integer.parseInt(sortval.get(item)) + 1));
-                    }
-                }
-                sortval = sortMapByValue(sortval);
-                for (String key : sortval.keySet()) {
-                    frlist.add(items.get(key));
-                }
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        } finally {
-            return frlist;
-        }
-    }
-
-
-    /**
-     * 使用 Map按value进行排序
-     *
-     * @param oriMap
-     * @return
-     */
-    public static Map<String, String> sortMapByValue(Map<String, String> oriMap) {
-        if (oriMap == null || oriMap.isEmpty()) {
-            return null;
-        }
-        Map<String, String> sortedMap = new LinkedHashMap<String, String>();
-        List<Map.Entry<String, String>> entryList = new ArrayList<Map.Entry<String, String>>(
-                oriMap.entrySet());
-        Collections.sort(entryList, new MapValueComparator());
-        Iterator<Map.Entry<String, String>> iter = entryList.iterator();
-        Map.Entry<String, String> tmpEntry = null;
-        while (iter.hasNext()) {
-            tmpEntry = iter.next();
-            sortedMap.put(tmpEntry.getKey(), tmpEntry.getValue());
-        }
-        return sortedMap;
-    }
-
-
-    public Map<String, Object> scaleCalcMethod(MedicalIndicationDetail medicalIndicationDetail) throws Exception {
-        Map<String, Object> scaleCalcResult = new HashMap<>();
-        Integer type = medicalIndicationDetail.getType();
-        if (type == 2) {
-            JSONObject content = medicalIndicationDetail.getContent();
-            JSONArray contentDetails = content.getJSONArray("details");
-            if ("肾小球滤过率".equals(content.get("name"))) {
-                int age = 0;
-                double scr = 0.00;
-                float k = 0.0f;
-                double a = 0.00;
-                double denger = 0.00;
-                for (int i = 0; i < contentDetails.size(); i++) {
-                    JSONObject detailSub = contentDetails.getJSONObject(i);
-                    if ("年龄".equals(detailSub.getString("name"))) {
-                        if ("".equals(detailSub.getString("value"))) {
-                            //如果拿到的年龄为空,
-                            break;
-                        } else {
-                            age = Integer.parseInt(detailSub.getString("value"));
-                        }
-                    } else if ("血肌酐".equals(detailSub.getString("name"))) {
-                        if ("".equals(detailSub.getString("value"))) {
-                            //如果给的value是空,给的2.2621是假数据
-                            break;
-                        } else {
-                            if ("umol/L".equals(detailSub.getString("value"))) {
-                                scr = Double.valueOf(detailSub.getString("value")) / 88.41;
-                            } else {
-                                scr = Double.valueOf(detailSub.getString("value"));
-                            }
-                        }
-                    } else if ("性别".equals(detailSub.getString("name"))) {
-                        JSONArray genderDetails = detailSub.getJSONArray("details");
-                        for (int j = 0; j < genderDetails.size(); j++) {
-                            JSONObject genderDetail = genderDetails.getJSONObject(j);
-                            //返回的数据结构性别暂时是写死(默认女性)
-                            if (genderDetail.getInteger("state") == 1) {
-                                if ("男".equals(genderDetail.getString("detailName"))) {
-                                    k = 0.9f;
-                                    denger = Double.parseDouble(genderDetail.getString("value"));
-                                    if (scr <= 0.90) {
-                                        a = -0.411;
-                                    } else {
-                                        a = -1.209;
-                                    }
-                                } else if ("女".equals(genderDetail.getString("detailName"))) {
-                                    k = 0.7f;
-                                    denger = Double.parseDouble(genderDetail.getString("value"));
-                                    if (scr <= 0.70) {
-                                        a = -0.329;
-                                    } else {
-                                        a = -1.209;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-                double eGFR3 = 141 * Math.pow((scr / k), a) * Math.pow(0.993, age) * denger;
-                String unit = "ml/min•1.73m2";
-                String text = null;
-                if (eGFR3 <= 0) {
-                    text = "指标值缺少";
-                } else if (eGFR3 > 0 && eGFR3 < 15) {
-                    text = "肾功能衰竭";
-                } else if (eGFR3 >= 15 && eGFR3 <= 29) {
-                    text = "重度下降";
-                } else if (eGFR3 > 29 && eGFR3 < 60) {
-                    text = "中度下降";
-                } else if (eGFR3 >= 60 && eGFR3 <= 89) {
-                    text = "轻度下降";
-                } else if (eGFR3 > 89) {
-                    text = "正常或肾损伤代偿期";
-                }
-
-                scaleCalcResult.put("text", text);
-                scaleCalcResult.put("unit", unit);
-                scaleCalcResult.put("value", eGFR3);
-                System.out.println("text:" + text + "\tunit:" + unit + "\tvalue:" + eGFR3);
-            }
-        }
-
-
-        return scaleCalcResult;
-    }
 }

+ 46 - 41
graph/src/main/java/org/diagbot/graph/jdbc/Neo4jAPI.java

@@ -789,7 +789,8 @@ public class Neo4jAPI {
      * @param webDiag
      * @return
      */
-    public Map<String, Map<String, String>> getNewCondition(String[] keys, String webDiag) {
+    public Map<String, Object> getNewCondition(String[] keys, String webDiag) {
+        Map<String, Object> conditionMap = new HashMap<>();
         Map<String, Map<String, String>> diseaseCondition = new LinkedHashMap<>();
         Map<String, Map<String, String>> diseaseCondition1 = new LinkedHashMap<>(16, 0.75f, true);
         Map<String,Map<String,String>> neoPushMap = new HashMap<>();
@@ -842,17 +843,15 @@ public class Neo4jAPI {
                 Record record = result.next();
                 String quezhenName = record.get("name").toString().replace("\"", "");
                 String conditionType = record.get("relationType").toString().replace("\"", "");
-                /*if("拟诊".equals(conditionType) || "确诊".equals(conditionType)){
-                    que = "确诊";
-                }else {
-                    que = conditionType;
-                }*/
                 que = conditionType;
                 Map<String, String> queMap = neoPushMap.get(quezhenName);
                 if(queMap != null && queMap.size()>0){
+                    if("拟诊".equals(que) &&queMap.keySet().contains("确诊") ){
+                        continue;
+                    }
                     if(queMap.keySet().contains("拟诊") && "确诊".equals(que) ){
                         queMap.remove("拟诊");
-                        queMap.put("确诊","");
+                        queMap.put(que,"");
                         neoPushMap.put(quezhenName,queMap);
                     }else if(que.equals("警惕")){
                         queMap.put("警惕","");
@@ -869,14 +868,7 @@ public class Neo4jAPI {
                     newMap.put(que,"");
                     neoPushMap.put(quezhenName,newMap);
                 }
-               /* if(queMap != null){
-                    queMap.put(que, "");
-                    neoPushMap.put(quezhenName,queMap);
-                }else {
-                    Map<String,String> newMap = new HashMap<>();
-                    newMap.put(que,"");
-                    neoPushMap.put(quezhenName,newMap);
-                }*/
+
             }
             Map<String,Map<String,String>> queHighMap = new HashMap<>();
             Map<String,Map<String,String>> highMap = new HashMap<>();
@@ -885,15 +877,7 @@ public class Neo4jAPI {
                 String dis = l.getKey();
                 Set<String> typeSet = l.getValue().keySet();
                 Map<String,String> con = new HashMap<>();
-                /*if(typeSet.size() == 2 && typeSet.contains("确诊") && typeSet.contains("警惕")){
-                    queHighMap.put(dis,new HashMap<>());
-                }
-                if(typeSet.size() == 1 && typeSet.contains("确诊")){
-                    quezhenMap.put(dis,new HashMap<>());
-                }
-                if(typeSet.size() == 1 && typeSet.contains("警惕")){
-                    highMap.put(dis,new HashMap<>());
-                }*/
+
                 if(typeSet.size() == 2){
                     for (String type:typeSet) {
                         con.put(type,"");
@@ -919,7 +903,6 @@ public class Neo4jAPI {
                     Map<String,String> k = new HashMap<>();
                     k.put("确诊","");
                     k.put("警惕","");
-//                    diseaseCondition.put(dis,k);
                     diseaseCondition.put(dis,queHighMap.get(dis));
                 }
                 if(quezhenMap != null && quezhenMap.size()>0){
@@ -927,7 +910,6 @@ public class Neo4jAPI {
                     for (String dis:queDis) {
                         Map<String,String> k = new HashMap<>();
                         k.put("确诊","");
-//                        diseaseCondition.put(dis,k);
                         diseaseCondition.put(dis,quezhenMap.get(dis));
                     }
                 }
@@ -937,7 +919,6 @@ public class Neo4jAPI {
                     for (String dis:queDis) {
                         Map<String,String> k = new HashMap<>();
                         k.put("确诊","");
-//                        diseaseCondition.put(dis,k);
                         diseaseCondition.put(dis,quezhenMap.get(dis));
                     }
                 }
@@ -946,7 +927,6 @@ public class Neo4jAPI {
                     for (String dis:highSet) {
                         Map<String,String> k = new HashMap<>();
                         k.put("警惕","");
-//                        diseaseCondition.put(dis,k);
                         diseaseCondition.put(dis,highMap.get(dis));
                     }
                 }
@@ -975,6 +955,28 @@ public class Neo4jAPI {
                         }
                     }
                 }
+                //查找是否有页面急诊
+                List<String> webDiagList = new ArrayList<>();
+               /* for (String wd:webDiagSplits) {
+                    webDiagList.add("\'"+wd+"\'");
+                }*/
+                webDiagList.add("\'"+webDiagSplits[0]+"\'");
+                query =propertiesUtil.getProperty("searchEmergency").replace("disList",webDiagList.toString());
+                result = session.run(query);
+                while (result.hasNext()) {
+                    Record record = result.next();
+                    String emDis = record.get("emDis").toString();
+                    int em = record.get("em").asInt();//急诊
+                    Map<String, String> stringStringMap = neoPushMap.get(emDis.replace("\"", ""));
+                    if( stringStringMap == null ){
+                        stringStringMap = new HashMap<>();
+                    }
+                    if(em == 1){
+                        stringStringMap.put("页面急诊", "");
+                        diseaseCondition.put(emDis.replace("\"", ""), stringStringMap);
+                    }
+
+                }
             }
             List<String> newDis = new ArrayList<>();
             //判断急诊
@@ -998,12 +1000,13 @@ public class Neo4jAPI {
                 }
                     diseaseCondition.put(emDis.replace("\"", ""), stringStringMap);
             }
-
+           /* Set<String> queset = new LinkedHashSet<>();
             Set<String> ll = new LinkedHashSet<>();
             Set<String> kk = new LinkedHashSet<>();
             for (Map.Entry<String,Map<String,String>> l:diseaseCondition.entrySet()) {
                 if(l.getValue().keySet().contains("确诊")){
                     ll.add(l.getKey());
+                    queset.add(l.getKey());
                 }else {
                     kk.add(l.getKey());
                 }
@@ -1018,14 +1021,15 @@ public class Neo4jAPI {
                         break;
                     }
                 }
-
                 diseaseCondition1.put(dis,stringStringMap);
             }
+            conditionMap.put("确诊",queset);*/
+            conditionMap.put("全部诊断",diseaseCondition);
         } catch (Exception e) {
             e.printStackTrace();
         } finally {
             CloseSession(session);
-            return diseaseCondition1;
+            return conditionMap;
         }
     }
 
@@ -1347,14 +1351,15 @@ public class Neo4jAPI {
     /**
      * 获取每个慢病对应的不良反应
      *
-     * @param webDiagArray
+     * @param
      * @param diseaseType
      * @return
      */
-    public Map<String, List<String>> getDisUE(String[] webDiagArray, Integer diseaseType) {
+    public Map<String, List<String>> getDisUE(String disName, Integer diseaseType) {
         Session session = null;
         Map<String, List<String>> disUE = new HashMap<>();
         List<String> webDiagList = new ArrayList<>();
+        String[] webDiagArray = disName.split(",");
         if (diseaseType != null && 1 == diseaseType) {
             for (String dis : webDiagArray) {
                 if (!"".equals(dis)) {
@@ -1396,7 +1401,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, Set<String> ueSet, String filds) {
+    public Map<String, Filnlly> getMulDiseaseTreat_2(String disName,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();
@@ -1409,7 +1414,7 @@ public class Neo4jAPI {
             diseaseList.add(diseaseArray[i]);
         }
         Map<String, ArrayList> diseFilds = new HashMap<>();
-        for (int i = 0; i < diseaseList.size(); i++) {
+//        for (int i = 0; i < diseaseList.size(); i++) {
             String[] fildsArray = filds.split(",");
             ArrayList<String> fildsList = new ArrayList<>();//其他条件数组
             for (String fild : fildsArray) {
@@ -1424,14 +1429,14 @@ public class Neo4jAPI {
             for (String h : ueSet) {
                 fildsList.add("\'" + h + "\'");
             }
-            for (int j = 0; j < diseaseList.size(); j++) {
+           /* for (int j = 0; j < diseaseList.size(); j++) {
                 if (i != j) {
                     fildsList.add("\'" + diseaseList.get(j) + "\'");
                 }
-            }
+            }*/
 
-            diseFilds.put(diseaseList.get(i), fildsList);
-        }
+            diseFilds.put(disName, fildsList);
+//        }
         try {
             session = driver.session(AccessMode.WRITE);
             Integer integer = session.writeTransaction(new TransactionWork<Integer>() {
@@ -2873,8 +2878,8 @@ public class Neo4jAPI {
         Map<String, Map<String, String>> diaglist = new HashMap<>();
         try{
             session = driver.session(AccessMode.READ);
-            String query = "unwind " + infostr + " as lis " +
-                    "match (ex)-[q:排除依据]-(c)-[r:排除]->(d:Disease) where ex.name = lis return d";
+
+            String query = propertiesUtil.getProperty("excludeDiag").replace("infostr",infostr);
             System.out.println(query);
             StatementResult dlist = session.run(query);
 

+ 2 - 1
graph/src/main/resources/bolt.properties

@@ -71,7 +71,8 @@ searchDis=match (n:Condition)-[r:\u786E\u8BCA|:\u62DF\u8BCA|:\u8B66\u60D5]->(m:D
 where n.name in startList\n \
 with distinct m,r\n \
 return m.name as name, labels(m)[0] as label,type(r) as relationType;
-
+#\u6392\u9664\u8BCA\u65AD
+excludeDiag=match (ex)-[q:\u6392\u9664\u4F9D\u636E]-(c)-[r:\u6392\u9664]->(d:Disease) where ex.name in infostr return d
 #\u6CBB\u7597\u5904\u7406
 #\u67E5\u627E\u8BCA\u65AD\u5BF9\u5E94\u7684\u7C7B\u548C\u836F,\u4EE5\u53CA\u4ED6\u4EEC\u7684\u6392\u5E8F
 searchDrugsMedic=match (d:Disease{name:diseaseName})-[r0:\u63A8\u8350]->(m:Drugs)-[:\u5305\u542B]->(n:Medicine),(d:Disease)-[r1:\u63A8\u8350]->(n)\n \