|
@@ -4,6 +4,8 @@ import com.alibaba.druid.support.json.JSONUtils;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import io.netty.handler.codec.json.JsonObjectDecoder;
|
|
|
+import org.assertj.core.util.Lists;
|
|
|
import org.diagbot.common.javabean.*;
|
|
|
import org.diagbot.common.work.*;
|
|
|
import org.diagbot.pub.utils.PropertiesUtil;
|
|
@@ -1801,6 +1803,192 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取量表
|
|
|
+ * @param scaleName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> getScaleCalc2(String scaleName) {
|
|
|
+ Session session = driver.session(AccessMode.READ);
|
|
|
+ StatementResult Rset = null;
|
|
|
+ Record rec;
|
|
|
+ scaleName = scaleName.toUpperCase();
|
|
|
+
|
|
|
+ Map<String, Object> threeLevelItems = new LinkedHashMap<>();
|
|
|
+ //<<=44,0>
|
|
|
+
|
|
|
+ Map<String, Object> result = null;
|
|
|
+ Map<String, Object> title = new LinkedHashMap<>();
|
|
|
+ List<Map<String, Object>> results = new ArrayList<>();
|
|
|
+
|
|
|
+ //标题
|
|
|
+ List<Object> titles = new ArrayList<>();
|
|
|
+ title.put("name", "临床体格检查");
|
|
|
+ title.put("column", "name");
|
|
|
+ titles.add(title);
|
|
|
+ title = new LinkedHashMap<>();
|
|
|
+ title.put("name", "临床症状");
|
|
|
+ title.put("column", "detailName");
|
|
|
+ titles.add(title);
|
|
|
+ title = new LinkedHashMap<>();
|
|
|
+ title.put("name", "得分");
|
|
|
+ title.put("column", "score");
|
|
|
+ titles.add(title);
|
|
|
+ JSONObject titleJson = new JSONObject();
|
|
|
+ titleJson.put("columns", titles);
|
|
|
+ titleJson.put("isShow", 1);
|
|
|
+
|
|
|
+ //分组计算结果
|
|
|
+ JSONObject groupCalcJson = new JSONObject();
|
|
|
+ JSONObject groupCalcResult = new JSONObject();
|
|
|
+ groupCalcJson.put("value", "");
|
|
|
+ groupCalcJson.put("unit", "");
|
|
|
+ groupCalcJson.put("text", "");
|
|
|
+ groupCalcJson.put("isShow", 0);
|
|
|
+ groupCalcJson.put("result", groupCalcResult);
|
|
|
+
|
|
|
+ threeLevelItems.put("scaleType", 1);
|
|
|
+ threeLevelItems.put("scaleName", scaleName);
|
|
|
+ threeLevelItems.put("group", new JSONArray());
|
|
|
+
|
|
|
+ Map<String, Object> calculate = new HashMap<>();
|
|
|
+ Map<String, List<Map<String, String>>> nameDetails = new HashMap<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ String query = "match (m:Scale)-[r1]->(n1)-[r2]->(n2)-[r3]->(n3) WHERE m.name=~'.*" + scaleName + ".*' return n1.name, n1.method, r1.score, n2.name, r2.score,n2.type, r2.p,n3.name as n3name,r3.score as r3score, r3.p as r3p, n3.type as n3type order by toInt(r1.p), toInt(r2.p),n2.type,toInt(r3.p) \n" +
|
|
|
+ "union match (m:Scale)-[r1]->(n1)-[r2]->(n2) WHERE m.name=~'.*" + scaleName + ".*' return n1.name,n1.method, r1.score,n2.name,r2.score,n2.type,r2.p, null as n3name, null as r3score, null as r3p, null as n3type order by toInt(r1.p), toInt(r2.p), n2.type";
|
|
|
+
|
|
|
+ Rset = session.run(query);
|
|
|
+
|
|
|
+ String name = "";
|
|
|
+ String method = "";
|
|
|
+ String optionOrIndex = "";
|
|
|
+ String pacsResult = "";
|
|
|
+ String score1 = "";
|
|
|
+ String score2 = "";
|
|
|
+ String priority = "";
|
|
|
+
|
|
|
+ while (Rset.hasNext()) {
|
|
|
+ rec = Rset.next();
|
|
|
+ //分组名称
|
|
|
+ name = rec.get("n1.name").toString().replace("\"", "");
|
|
|
+ method = rec.get("n1.method").toString().replace("\"", "");
|
|
|
+ //项目名称
|
|
|
+ optionOrIndex = rec.get("n2.name").toString().replace("\"", "");
|
|
|
+ //指标结果
|
|
|
+ pacsResult = rec.get("n3name").toString().replace("\"", "");
|
|
|
+ //range区间
|
|
|
+ score1 = rec.get("r2.score").toString().replace("\"", "");
|
|
|
+ //得分
|
|
|
+ score2 = rec.get("r3score").toString().replace("\"", "");
|
|
|
+ //权重(排序)
|
|
|
+ priority = rec.get("r2.p").toString().replace("\"", "");
|
|
|
+
|
|
|
+ if (name.contains("计算方法")) {
|
|
|
+ String[] score = score1.split("~|-");
|
|
|
+ String min = score[0];
|
|
|
+ String max = score[1];
|
|
|
+ result = new TreeMap<>();
|
|
|
+ result.put("min", min);
|
|
|
+ result.put("max", max);
|
|
|
+ result.put("text", optionOrIndex);
|
|
|
+ result.put("priority", priority);
|
|
|
+ results.add(result);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //分组匹配
|
|
|
+ JSONObject groupItem = new JSONObject();
|
|
|
+ Boolean existGroup = false;
|
|
|
+ JSONArray groupList = (JSONArray) threeLevelItems.get("group");
|
|
|
+ if (groupList.size() > 0) {
|
|
|
+ for (int i = 0; i < groupList.size(); i++) {
|
|
|
+ if (groupList.getJSONObject(i).containsKey("groupName") && groupList.getJSONObject(i).get("groupName").equals(name)) {
|
|
|
+ groupItem = groupList.getJSONObject(i);
|
|
|
+ groupList.remove(i);
|
|
|
+ existGroup = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (groupList.size() == 0 || existGroup == false) {
|
|
|
+ groupItem.put("groupName", name);
|
|
|
+ groupItem.put("title", titleJson);
|
|
|
+ groupItem.put("groupCalculate", groupCalcJson);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject rows = new JSONObject();
|
|
|
+ JSONArray rowList = new JSONArray();
|
|
|
+ if (!groupItem.containsKey("rows") || groupItem.get("rows") == null) {
|
|
|
+ rows.put("metux", 0);
|
|
|
+ rows.put("required", 1);
|
|
|
+ groupItem.put("rows", rows);
|
|
|
+ } else {
|
|
|
+ if (JSONObject.parseObject(groupItem.get("rows").toString()).containsKey("row")) {
|
|
|
+ rowList = JSONArray.parseArray(JSONObject.parseObject(groupItem.get("rows").toString()).get("row").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Boolean existRow = false;
|
|
|
+ for (int i = 0; i < rowList.size(); i++) {
|
|
|
+ JSONObject row = rowList.getJSONObject(i);
|
|
|
+ if (row.containsKey("name") && row.get("name").equals(optionOrIndex)) {
|
|
|
+ JSONArray details = JSON.parseArray(row.get("details").toString());
|
|
|
+ if (!"NULL".equals(pacsResult)) {
|
|
|
+ JSONObject rowDetail = new JSONObject();
|
|
|
+ rowDetail.put("detailName", pacsResult);
|
|
|
+ rowDetail.put("score", score2);
|
|
|
+ rowDetail.put("state", 0);
|
|
|
+ details.add(rowDetail);
|
|
|
+ row.put("details", details);
|
|
|
+ }
|
|
|
+ rows.put("row", rowList);
|
|
|
+ existRow = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (rowList.size() == 0 || existRow == false) {
|
|
|
+ JSONObject row = new JSONObject();
|
|
|
+ row.put("name", optionOrIndex);
|
|
|
+ row.put("coefficent", 1);
|
|
|
+ row.put("constant", 0);
|
|
|
+ row.put("controlType", 0);
|
|
|
+ if (!"NULL".equals(pacsResult)) {
|
|
|
+ JSONObject rowDetail = new JSONObject();
|
|
|
+ rowDetail.put("detailName", pacsResult);
|
|
|
+ rowDetail.put("score", score2);
|
|
|
+ rowDetail.put("state", 0);
|
|
|
+ JSONArray details = new JSONArray();
|
|
|
+ details.add(rowDetail);
|
|
|
+ row.put("details", details);
|
|
|
+ }
|
|
|
+ rowList.add(row);
|
|
|
+ rows.put("row", rowList);
|
|
|
+ }
|
|
|
+ groupItem.put("rows", rows);
|
|
|
+ groupList.add(groupItem);
|
|
|
+ threeLevelItems.put("group", groupList);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map<String, Object> resMap : results) {
|
|
|
+ resMap.remove("priority");
|
|
|
+ }
|
|
|
+ calculate.put("range", results);
|
|
|
+ calculate.put("formula", "");
|
|
|
+ Map<String, String> calcResult = new HashMap<>();
|
|
|
+ calcResult.put("score", "");
|
|
|
+ calcResult.put("text", "");
|
|
|
+ calculate.put("result", calcResult);
|
|
|
+ threeLevelItems.put("calculate", calculate);
|
|
|
+
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ System.out.println("返回带得分需要计算的量表时出了问题!---->getScaleCalc");
|
|
|
+ } finally {
|
|
|
+ CloseSession(session);
|
|
|
+ return threeLevelItems;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 返回不带得分不需要计算的量表
|
|
|
*
|
|
@@ -1880,7 +2068,7 @@ public class Neo4jAPI {
|
|
|
|
|
|
int sum = 0;
|
|
|
String final_result = null;
|
|
|
- Map<String, Object> scaleCalc = getScaleCalc(scaleName);
|
|
|
+ Map<String, Object> scaleCalc = getScaleCalc2(scaleName);
|
|
|
for (String scaleItem : scaleItems) {
|
|
|
Object details = scaleCalc.get("rows");
|
|
|
//获取name
|