|
@@ -1,9 +1,12 @@
|
|
|
package org.diagbot.graphWeb.work;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import org.diagbot.graph.jdbc.DriverManager;
|
|
|
import org.diagbot.graph.jdbc.Neo4jAPI;
|
|
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -14,50 +17,84 @@ import java.util.Map;
|
|
|
* @Date: 2019/4/9 14:33
|
|
|
*/
|
|
|
public class ScaleCalculate {
|
|
|
- public String scaleScoreCalc(String[] scaleItems,String scaleName){
|
|
|
- Neo4jAPI neo4jAPI = null;
|
|
|
- try {
|
|
|
-// neo4jAPI = new Neo4jAPI(DriverManager.newDrive("192.168.2.233","neo4j","root"));
|
|
|
- neo4jAPI = new Neo4jAPI(DriverManager.newDrive());
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("Neo4j连接出错!");
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- int sum = 0;
|
|
|
- String final_result = null;
|
|
|
- Map<String, Object> scaleCalc = neo4jAPI.getScaleCalc2(scaleName);
|
|
|
- for (String scaleItem:scaleItems) {
|
|
|
- Object details = scaleCalc.get("details");
|
|
|
- //获取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);
|
|
|
+ public Map<String, Object> scaleScoreCalc(JSONObject jsonObject) {
|
|
|
+ Map<String, Object> scaleCalcResult = new HashMap<>();
|
|
|
+ Map<String, Object> groupResults = null;
|
|
|
+ List<Map<String, Object>> groupLists = new ArrayList<>();
|
|
|
+ double sum = 0;
|
|
|
+ Map<String, Object> data = (Map<String, Object>) jsonObject.get("data");
|
|
|
+ String scaleName = data.get("scaleName").toString();
|
|
|
+ List<Map<String, Object>> groupList = (List<Map<String, Object>>) data.get("group");
|
|
|
+ for (Map<String, Object> group : groupList) {
|
|
|
+ double groupSum = 0;
|
|
|
+ groupResults = new HashMap<>();
|
|
|
+ String groupName = group.get("groupName").toString();
|
|
|
+ List<Map<String, Object>> rowsList = (List<Map<String, Object>>) group.get("rows");
|
|
|
+ for (Map<String, Object> rows : rowsList) {
|
|
|
+ List<Map<String, Object>> rowList = (List<Map<String, Object>>) rows.get("row");
|
|
|
+ for (Map<String, Object> row : rowList) {
|
|
|
+ List<Map<String, Object>> detailsList = (List<Map<String, Object>>) row.get("details");
|
|
|
+ for (Map<String, Object> details : detailsList) {
|
|
|
+ if (Integer.valueOf(details.get("select").toString()) == 1) {
|
|
|
+ Double score = Double.valueOf(details.get("score").toString());
|
|
|
+ groupSum += score;
|
|
|
+ sum += score;
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- continue;
|
|
|
}
|
|
|
}
|
|
|
+ // String text = scaleResultText(groupSum);
|
|
|
+ JSONObject groupCalculate = new JSONObject();
|
|
|
+ JSONObject groupResult = new JSONObject();
|
|
|
+ groupResult.put("text", "");
|
|
|
+ groupResult.put("value", groupSum);
|
|
|
+
|
|
|
+ groupCalculate.put("result", groupResult);
|
|
|
+ groupCalculate.put("isShow", 0);
|
|
|
+
|
|
|
+ groupResults.put("groupName", groupName);
|
|
|
+ groupResults.put("groupCalculate", groupCalculate);
|
|
|
+
|
|
|
+ groupLists.add(groupResults);
|
|
|
+
|
|
|
}
|
|
|
- System.out.println(sum);
|
|
|
- List<Map<String, String>> result = (List<Map<String, String>>) scaleCalc.get("result");
|
|
|
- for (Map<String, String> result_map:result) {
|
|
|
- Integer min = Integer.valueOf(result_map.get("min"));
|
|
|
- Integer max = Integer.valueOf(result_map.get("max"));
|
|
|
- String text = result_map.get("text");
|
|
|
+ String text = null;
|
|
|
+ Map<String, Object> calculate = (Map<String, Object>) data.get("calculate");
|
|
|
+ List<Map<String, Object>> rangeList = (List<Map<String, Object>>) calculate.get("range");
|
|
|
+ for (Map<String, Object> range:rangeList) {
|
|
|
+ Double max = Double.valueOf(range.get("max").toString());
|
|
|
+ Double min = Double.valueOf(range.get("min").toString());
|
|
|
if (sum >= min && sum <= max){
|
|
|
- final_result = text;
|
|
|
+ text = range.get("text").toString();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- return final_result;
|
|
|
+
|
|
|
+ scaleCalcResult.put("scaleName", scaleName);
|
|
|
+ scaleCalcResult.put("group", groupLists);
|
|
|
+
|
|
|
+ JSONObject calcalculate = new JSONObject();
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("text", text);
|
|
|
+ //TODO 根据数字类型给出结果
|
|
|
+ result.put("value", sum);
|
|
|
+ calcalculate.put("result", result);
|
|
|
+ scaleCalcResult.put("calcalculate", calcalculate);
|
|
|
+ return scaleCalcResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String scaleResultText(int sum) {
|
|
|
+ String text = null;
|
|
|
+ if (sum >= 0 && sum <= 6) {
|
|
|
+ text = "无";
|
|
|
+ } else if (sum >= 7 && sum <= 12) {
|
|
|
+ text = "轻度";
|
|
|
+ } else if (sum >= 13 && sum <= 29) {
|
|
|
+ text = "中度";
|
|
|
+ } else if (sum >= 30 && sum <= 46) {
|
|
|
+ text = "重度";
|
|
|
+ }
|
|
|
+ return text;
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> scaleCalcMethod(JSONObject jsonObject) throws Exception {
|
|
@@ -136,10 +173,19 @@ public class ScaleCalculate {
|
|
|
} else if (eGFR3 > 89) {
|
|
|
text = "正常或肾损伤代偿期";
|
|
|
}
|
|
|
-
|
|
|
- scaleCalcResult.put("text", text);
|
|
|
- scaleCalcResult.put("unit", unit);
|
|
|
- scaleCalcResult.put("value", eGFR3);
|
|
|
+ JSONObject valueResult = new JSONObject();
|
|
|
+ JSONObject nameResult = new JSONObject();
|
|
|
+ valueResult.put("name","GFR值");
|
|
|
+ valueResult.put("text",new DecimalFormat("#.00").format(eGFR3)+" " + unit);
|
|
|
+ nameResult.put("name","评估结论");
|
|
|
+ nameResult.put("text",text);
|
|
|
+// scaleCalcResult.put("text", text);
|
|
|
+// scaleCalcResult.put("unit", unit);
|
|
|
+// scaleCalcResult.put("value", new DecimalFormat("#.00").format(eGFR3));
|
|
|
+ JSONArray result = new JSONArray();
|
|
|
+ result.add(valueResult);
|
|
|
+ result.add(nameResult);
|
|
|
+ scaleCalcResult.put("result",result);
|
|
|
System.out.println("text:" + text + "\tunit:" + unit + "\tvalue:" + eGFR3);
|
|
|
}
|
|
|
}
|