Browse Source

Merge remote-tracking branch 'origin/push-dev' into push-dev-ruletype

Conflicts:
	graph-web/src/main/java/org/diagbot/graphWeb/work/GraphCalculate.java
	graph-web/src/main/java/org/diagbot/graphWeb/work/ScaleCalculate.java
louhr 5 năm trước cách đây
mục cha
commit
517218ea3a

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

@@ -34,6 +34,7 @@ public class GraphCalculate {
         }
     }
     private static Neo4jAPI neo4jAPI ;
+    private static Map<String,List<String>> mergeMap;
 
     /**
      * 返回诊断和治疗
@@ -51,14 +52,14 @@ public class GraphCalculate {
         List<String> inputList = new ArrayList<>();
         int age = searchData.getAge();
         String sex = searchData.getSex();
-        String diseaseName = searchData.getDiseaseName();
-        String webDiag = searchData.getDiag();
-        logger.info("页面诊断为 :"+webDiag);
-        String[] webDiagList = webDiag.split(",|,|、|;|:|;");
+        String diseaseName = "";
+        if (searchData.getDiseaseName() != null) {
+            diseaseName = searchData.getDiseaseName().getUniqueName();
+        }
         logger.info("前端传来的年龄为 :"+age+" 前端传来的性别为 :"+sex);
         Map<String, Map<String, String>> sexAgeCache = CacheUtil.getSexAgeCache();
         Map<String, Map<String, String>> inputs = searchData.getGraphInputs();
-        List<String> exculdDiagFilds = this.exculdDiagFilds(inputs,webDiagList,diseaseName);
+        List<String> exculdDiagFilds = this.exculdDiagFilds(inputs);
         //从大数据解析分词
         Set<String> ss = processParticiple(inputs);
         logger.info("从分词系统接收到的词 :" + ss);
@@ -71,9 +72,21 @@ public class GraphCalculate {
             neo4jAPI = new Neo4jAPI(driver);
         }
         logger.info("图谱开始推送诊断!!!!!!!!!!!");
+        String webDiag = "";
+        if(searchData.getDiagOrder() !=null){
+            for (PreResult preResult : searchData.getDiagOrder()) {
+                if (StringUtils.isEmpty(webDiag)) {
+                    webDiag = preResult.getValue();
+                } else {
+                    webDiag = webDiag + "," + preResult.getValue();
+                }
+            }
+        }
 
+        logger.info("页面诊断为 :"+webDiag);
+        String[] webDiagList = webDiag.split(",|,|、|;|:|;");
         //处理血肌酐
-        List<PreResult> lisArr = searchData.getLisArr();
+        List<PreResult> lisArr = searchData.getLis();
         String serumCreatinine = processSerumcreatinine(lisArr);
 
         //计算诊断
@@ -99,12 +112,6 @@ public class GraphCalculate {
         if (StringUtils.isNotEmpty(diseaseName) && featureTypeList.contains(Constants.feature_type_treat)) {
             PushTreat pushTreat = new PushTreat();
             Treat treat = pushTreat.processTreat(diseaseName,webDiag,diseaseType, driver, (String[]) inputList.toArray(new String[inputList.size()]),exculdDiagFilds, crisisDetails);
-//            Map<String, List<String>> disUE = pushTreat.getDisUE(diseaseName,1,driver);
-//            Map<String,String> ue = pushTreat.getUe((String[]) inputList.toArray(new String[inputList.size()]),driver);
-            //走平常诊断治疗
-//            Map<String, Filnlly> mulDiseaseTreat = neo4jAPI.getMulDiseaseTreat_2(diseaseName,webDiag, diseaseType, diseaseSet,disUE,ue,String.join(",", inputList));
-//            Map<String, Filnlly> mulDiseaseTreat_new = neo4jAPI.getMulDiseaseTreat_new(diseaseName,webDiag, diseaseType, diseaseSet,disUE,ue,String.join(",", inputList),crisisDetails);
-//            System.out.println("推送治疗消耗:"+(System.currentTimeMillis()-starttime)+"s");
             responseData.setTreat(treat);
         }
         //管理评估(慢病才有)
@@ -149,9 +156,10 @@ public class GraphCalculate {
                     idns.addAll(idn);
                 }
             }
+            newindSet1 = mergerIndex(newindSet1, mergeMap);
             if(newindSet1 != null && newindSet1.size()>0){
                 for (String ind:newindSet1
-                     ) {
+                        ) {
                     MedicalIndication medicalIndication= new MedicalIndication();
                     medicalIndication.setName(ind);
                     List<MedicalIndicationDetail> ds = new ArrayList<>();
@@ -159,7 +167,7 @@ public class GraphCalculate {
                     medicalIndicationDetail.setType(1);
                     JSONObject jsonObject = new JSONObject();
                     if(indLiang != null){
-                        jsonObject.put("name",indLiang.get(ind)); 
+                        jsonObject.put("name",indLiang.get(ind));
                     }
                     medicalIndicationDetail.setContent(jsonObject);
                     ds.add(medicalIndicationDetail);
@@ -177,6 +185,69 @@ public class GraphCalculate {
         return responseData;
     }
 
+    /**
+     * 合并指标
+     * @param newindSet
+     * @return
+     */
+    private Set<String> mergerIndex(Set<String> newindSet,Map<String,List<String>> merge){
+        Map<String,List<String>> disColl = new HashMap<>();
+        Set<String> newindSetResult = new HashSet<>();
+        Map<String, List<String>> mergeInit = mergeInit(merge);
+        if(newindSet != null && newindSet.size()>0){
+            for (Map.Entry<String, List<String>> ds:mergeInit.entrySet()) {
+                String key = ds.getKey();
+                if(newindSet.contains(key)){
+                    Iterator<String> iterator = newindSet.iterator();
+                    while (iterator.hasNext()){
+                        String next = iterator.next();
+                        // values   ["2型糖尿病","1型糖尿病","成人迟发性自身免疫糖尿病"]
+                        // newindSet ["糖尿病","糖尿病足"]
+                        if(key.equals(next)){
+                            List<String> disList = new ArrayList<>();
+                            for (String dis:newindSet) {
+                                if(!dis.equals(key)){
+                                    disList.add(dis);
+                                }
+                            }
+                            disColl.put(key,disList);
+                        }
+                    }
+                    if(disColl != null && disColl.size()>0){
+                        for (Map.Entry<String,List<String>> disList:disColl.entrySet()) {
+                            String key1 = disList.getKey();
+                            List<String> value = disList.getValue();
+                            if(value.size() == 0){
+                                newindSetResult.add(key1);
+                            }else {
+                                for (String dis:value
+                                        ) {
+                                    if(!dis.equals(key1)){
+                                        newindSetResult.add(dis);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }else {
+                    newindSetResult = newindSet;
+                }
+            }
+        }
+        return newindSetResult;
+    }
+    private Map<String,List<String>> mergeInit(Map<String,List<String>> merge){
+        if(merge == null){
+            merge = new HashMap<>();
+            List<String> otherIn = new ArrayList<>();
+            otherIn.add("2型糖尿病");
+            otherIn.add("1型糖尿病");
+            otherIn.add("成人迟发性自身免疫糖尿病");
+            merge.put("糖尿病",otherIn);
+        }
+        return merge;
+    }
+
     private Set<String> getQueNiDiagnose(Map<String, Object> condition) {
         Set<String> diseaseSet =new HashSet<>();
         if(condition != null){
@@ -270,11 +341,10 @@ public class GraphCalculate {
         }
         return sc;
     }
-    private List<String> exculdDiagFilds(Map<String, Map<String, String>> inputs,String[] webDiagList,String disName){
+    private List<String> exculdDiagFilds(Map<String, Map<String, String>> inputs){
         List<String> exculdDiagFilds = new ArrayList<>();
-        String fildName ="";
         if(inputs != null && inputs.size()>0){
-
+            String fildName ="";
             for (Map.Entry<String, Map<String, String>> fild:inputs.entrySet()) {
                 fildName = fild.getKey();
                 Map<String, String> value = fild.getValue();
@@ -290,22 +360,6 @@ public class GraphCalculate {
                 }
             }
         }
-        try{
-            if(webDiagList!=null && webDiagList.length>0){
-                for (String wd:webDiagList) {
-                    if(wd != null && !disName.equals(wd)){
-                        fildName = "'"+wd+"'";
-                        if(!exculdDiagFilds.contains(fildName)){
-                            exculdDiagFilds.add(fildName);
-                        }
-                    }
-
-                }
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-
         return exculdDiagFilds;
     }
 }

+ 7 - 11
graph-web/src/main/java/org/diagbot/graphWeb/work/ScaleCalculate.java

@@ -171,14 +171,12 @@ public class ScaleCalculate {
                     Map<String, Object> detailSub = mapList.get(i);
                     if ("年龄".equals(detailSub.get("name"))) {
                         if (StringUtils.isEmpty(detailSub.get("value").toString())) {
-                            //如果拿到的年龄为空,
                             break;
                         } else {
                             age = Integer.valueOf(detailSub.get("value").toString());
                         }
                     } else if ("血肌酐".equals(detailSub.get("name"))) {
                         if ("".equals(detailSub.get("value"))) {
-                            //如果给的value是空,给的2.2621是假数据
                             break;
                         } else {
                             if ("umol/L".equals(detailSub.get("uint"))) {
@@ -215,18 +213,16 @@ public class ScaleCalculate {
                     }
                 }
                 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 && eGFR3 < 15) {
-                    text = "肾功能衰竭";
-                } else if (eGFR3 >= 15 && eGFR3 <= 29) {
-                    text = "重度下降";
+                String unit = "min•1.73㎡";
+                String text = "";
+                if (eGFR3 > 0 && eGFR3 <= 29) {
+                    text = "重度肾功能不全";
                 } else if (eGFR3 > 29 && eGFR3 < 60) {
-                    text = "中度下降";
+                    text = "中度肾功能不全";
                 } else if (eGFR3 >= 60 && eGFR3 <= 89) {
-                    text = "轻度下降";
+                    text = "轻度肾功能不全";
                 } else if (eGFR3 > 89) {
-                    text = "正常或肾损伤代偿期";
+                    text = "肾功能正常";
                 }
 
                 valueResult.put("name", "GFR值");