Browse Source

取计算公式的肾功能不全结果到不良反应

kongwz 5 years ago
parent
commit
08c7d5ea12

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

@@ -110,6 +110,11 @@ public class GraphCalculate {
         starttime = System.currentTimeMillis();
         starttime = System.currentTimeMillis();
         //走治疗
         //走治疗
         if (StringUtils.isNotEmpty(diseaseName) && featureTypeList.contains(Constants.feature_type_treat)) {
         if (StringUtils.isNotEmpty(diseaseName) && featureTypeList.contains(Constants.feature_type_treat)) {
+            List<MedicalIndication> medicalIndications = responseData.getMedicalIndications();
+            CrisisDetail shenGong = getShenGong(medicalIndications);
+            List<CrisisDetail> crisis = crisisDetails.get("crisis");
+            crisis.add(shenGong);
+            crisisDetails.put("crisis",crisis);
             PushTreat pushTreat = new PushTreat();
             PushTreat pushTreat = new PushTreat();
             Treat treat = pushTreat.processTreat(diseaseName,webDiag,diseaseType, driver, (String[]) inputList.toArray(new String[inputList.size()]),exculdDiagFilds, crisisDetails);
             Treat treat = pushTreat.processTreat(diseaseName,webDiag,diseaseType, driver, (String[]) inputList.toArray(new String[inputList.size()]),exculdDiagFilds, crisisDetails);
             responseData.setTreat(treat);
             responseData.setTreat(treat);
@@ -156,7 +161,7 @@ public class GraphCalculate {
                     idns.addAll(idn);
                     idns.addAll(idn);
                 }
                 }
             }
             }
-            newindSet1 = mergerIndex(newindSet1, mergeMap);
+//            newindSet1 = mergerIndex(newindSet1, mergeMap);
             if(newindSet1 != null && newindSet1.size()>0){
             if(newindSet1 != null && newindSet1.size()>0){
                 for (String ind:newindSet1
                 for (String ind:newindSet1
                      ) {
                      ) {
@@ -184,26 +189,84 @@ public class GraphCalculate {
         System.out.println("Total takes: " + (System.currentTimeMillis()-starttime)/1000d + 's');
         System.out.println("Total takes: " + (System.currentTimeMillis()-starttime)/1000d + 's');
         return responseData;
         return responseData;
     }
     }
+
+   private CrisisDetail getShenGong(List<MedicalIndication> medicalIndications){
+       CrisisDetail crisisDetail = new CrisisDetail();
+       if(medicalIndications != null && medicalIndications.size()>0){
+           for (MedicalIndication m:medicalIndications) {
+               String name = m.getName();
+               if("肾功能不全".equals(name)){
+                   List<MedicalIndicationDetail> details = m.getDetails();
+                   if(details != null && details.size()>0){
+                       for (MedicalIndicationDetail med:details) {
+                           Integer type = med.getType();
+                           if(type == 2){
+                               JSONObject content = med.getContent();
+                               if(content!= null){
+                                   List<JSONObject> results = (List<JSONObject>) content.get("result");
+                                   if(results != null && results.size()>0){
+                                       for (JSONObject j:results) {
+                                           String pr = j.getString("评估结论");
+                                           if(StringUtils.isNotEmpty(pr)){
+                                               if("重度肾功能不全".equals(pr)){
+                                                   pr = "肾功能不全:重度";
+                                               }else if("中度肾功能不全".equals(pr)){
+                                                   pr = "肾功能不全:中度";
+                                               }else if("轻度肾功能不全".equals(pr)){
+                                                   pr = "肾功能不全:轻度";
+                                               }else if("肾功能正常".equals(pr)){
+                                                   pr = "肾功能:正常";
+                                               }
+                                               crisisDetail.setRemindText(pr);
+                                               crisisDetail.setTypeId("4");
+
+                                           }
+
+                                       }
+                                   }
+                               }
+                           }
+                       }
+                   }
+               }
+           }
+       }
+
+       return crisisDetail;
+   }
     /**
     /**
      * 合并指标
      * 合并指标
      * @param newindSet
      * @param newindSet
      * @return
      * @return
      */
      */
     private Set<String> mergerIndex(Set<String> newindSet,Map<String,List<String>> merge){
     private Set<String> mergerIndex(Set<String> newindSet,Map<String,List<String>> merge){
+        Set<String> newindSetResult = new HashSet<>();
         Map<String, List<String>> mergeInit = mergeInit(merge);
         Map<String, List<String>> mergeInit = mergeInit(merge);
         if(newindSet != null && newindSet.size()>0){
         if(newindSet != null && newindSet.size()>0){
             for (Map.Entry<String, List<String>> ds:mergeInit.entrySet()) {
             for (Map.Entry<String, List<String>> ds:mergeInit.entrySet()) {
                 String key = ds.getKey();
                 String key = ds.getKey();
                 List<String> values = ds.getValue();
                 List<String> values = ds.getValue();
-                boolean b = newindSet.retainAll(values);
-                if(newindSet.contains(key) && b ){
-                    newindSet.remove(key);
+                if(newindSet.contains(key)){
+                    Iterator<String> iterator = newindSet.iterator();
+                    while (iterator.hasNext()){
+                        String next = iterator.next();
+                        // values   ["2型糖尿病","1型糖尿病","成人迟发性自身免疫糖尿病"]
+                        // newindSet ["糖尿病","糖尿病足"]
+                        if(values.contains(next)){
+                            newindSetResult.add(next);
+                        }else {
+                            if(!mergeInit.containsKey(next)){
 
 
+                            }
+                        }
+
+                    }
                 }
                 }
+
             }
             }
 
 
         }
         }
-        return newindSet;
+        return newindSetResult;
     }
     }
     private Map<String,List<String>> mergeInit(Map<String,List<String>> merge){
     private Map<String,List<String>> mergeInit(Map<String,List<String>> merge){
         if(merge == null){
         if(merge == null){