|
@@ -654,13 +654,13 @@ public class Neo4jAPI {
|
|
|
try {
|
|
|
session = driver.session(AccessMode.WRITE);
|
|
|
//第一步查询是否有组合的词
|
|
|
- query = propertiesUtil.getProperty("searchCollection").replace("fildList",fildList.toString());
|
|
|
+ query = propertiesUtil.getProperty("searchCollection").replace("fildList", fildList.toString());
|
|
|
result = session.run(query);
|
|
|
- while (result.hasNext()){
|
|
|
+ while (result.hasNext()) {
|
|
|
Record next = result.next();
|
|
|
String jundgement = next.get("jundgement").toString();
|
|
|
String standName = next.get("standName").toString();
|
|
|
- if ("TRUE".equals(jundgement)){
|
|
|
+ if ("TRUE".equals(jundgement)) {
|
|
|
fildList.add(standName);
|
|
|
}
|
|
|
}
|
|
@@ -681,22 +681,22 @@ public class Neo4jAPI {
|
|
|
fildList.add(js);
|
|
|
}
|
|
|
}
|
|
|
-// else {
|
|
|
-// fildList.add(fild);
|
|
|
-// query = "match(l)-[r:近义词]->(h) where l.name="+fild+" return h.name as js";
|
|
|
-// StatementResult run1 = session.run(query);
|
|
|
-// while (run1.hasNext()){
|
|
|
-// Record next = run1.next();
|
|
|
-// String js = next.get("js").toString();
|
|
|
-// fildList.add(js);
|
|
|
-// }
|
|
|
-// }
|
|
|
+ // else {
|
|
|
+ // fildList.add(fild);
|
|
|
+ // query = "match(l)-[r:近义词]->(h) where l.name="+fild+" return h.name as js";
|
|
|
+ // StatementResult run1 = session.run(query);
|
|
|
+ // while (run1.hasNext()){
|
|
|
+ // Record next = run1.next();
|
|
|
+ // String js = next.get("js").toString();
|
|
|
+ // fildList.add(js);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
newList.addAll(fildList);
|
|
|
int i = 0;
|
|
|
while (newList.size() > 0) {
|
|
|
i++;
|
|
|
- query = propertiesUtil.getProperty("searchCondition").replace("newList",newList.toString()).replace("fildList",fildList.toString());
|
|
|
+ query = propertiesUtil.getProperty("searchCondition").replace("newList", newList.toString()).replace("fildList", fildList.toString());
|
|
|
result = session.run(query);
|
|
|
newList.clear();
|
|
|
while (result.hasNext()) {
|
|
@@ -711,7 +711,7 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
}
|
|
|
//第三步查找确诊
|
|
|
- query = propertiesUtil.getProperty("searchQuezhen").replace("fildList",fildList.toString());
|
|
|
+ query = propertiesUtil.getProperty("searchQuezhen").replace("fildList", fildList.toString());
|
|
|
result = session.run(query);
|
|
|
while (result.hasNext()) {
|
|
|
Record record = result.next();
|
|
@@ -1636,137 +1636,124 @@ public class Neo4jAPI {
|
|
|
*/
|
|
|
public Map<String, Object> getScaleCalc(String scaleName) {
|
|
|
Session session = driver.session(AccessMode.READ);
|
|
|
- StatementResult Rset1 = null;
|
|
|
- StatementResult Rset2 = null;
|
|
|
+ StatementResult Rset = null;
|
|
|
Record rec;
|
|
|
scaleName = scaleName.toUpperCase();
|
|
|
|
|
|
Map<String, Object> threeLevelItems = new LinkedHashMap<>();
|
|
|
//<<=44,0>
|
|
|
|
|
|
- TreeMap<String, Object> result = null;
|
|
|
+ Map<String, Object> result = null;
|
|
|
Map<String, Object> title = new LinkedHashMap<>();
|
|
|
- List<TreeMap<String, Object>> results = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> results = new ArrayList<>();
|
|
|
|
|
|
List<Object> titles;
|
|
|
- Map<String,Object> calculate = new HashMap<>();
|
|
|
+ Map<String, Object> calculate = new HashMap<>();
|
|
|
+
|
|
|
+ Map<String, List<Map<String, String>>> nameDetails = new HashMap<>();
|
|
|
+
|
|
|
|
|
|
threeLevelItems.put("scaleType", "");
|
|
|
|
|
|
try {
|
|
|
- String query1 = "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 order by toInt(r2.p),n2.type";
|
|
|
+ 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(r2.p),n2.type " +
|
|
|
+ "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(r2.p),n2.type";
|
|
|
|
|
|
- String query2 = "match (m:Scale)-[r1]->(n1)-[r2]->(n2)-[r3]->(n3) WHERE m.name=~'.*" + scaleName + ".*' return n1.name,r1.score,n2.name," +
|
|
|
- "r2.score,r2.p,n3.name,r3.score,r3.p,n3.type order by toInt(r2.p),n2.type";
|
|
|
- writeLog(query1);
|
|
|
- Rset1 = session.run(query1);
|
|
|
- Rset2 = session.run(query2);
|
|
|
- writeLog(query2);
|
|
|
+ Rset = session.run(query);
|
|
|
|
|
|
- String item = "";
|
|
|
+ String name = "";
|
|
|
+ String method = "";
|
|
|
String optionOrIndex = "";
|
|
|
+ String pacsResult = "";
|
|
|
String score1 = "";
|
|
|
- String index = "";
|
|
|
String score2 = "";
|
|
|
- String priority1 = "";
|
|
|
- String priority2 = "";
|
|
|
+ String priority = "";
|
|
|
|
|
|
- while (Rset1.hasNext()) {
|
|
|
- rec = Rset1.next();
|
|
|
- item = rec.get("n1.name").toString().replace("\"", "");
|
|
|
+ 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("\"", "");
|
|
|
- priority1 = rec.get("r2.p").toString().replace("\"", "");
|
|
|
-
|
|
|
-
|
|
|
- if (!"NULL".equals(score1)) {
|
|
|
- if (item.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",priority1);
|
|
|
- results.add(result);
|
|
|
- }
|
|
|
+ //正常异常得分
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- titles = new ArrayList<>();
|
|
|
- title.put("name", item);
|
|
|
- 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);
|
|
|
-// title = new LinkedHashMap<>();
|
|
|
-// title.put("name", "推荐选项");
|
|
|
-// title.put("column", "state");
|
|
|
-// titles.add(title);
|
|
|
- threeLevelItems.put("title", titles);
|
|
|
+ titles = new ArrayList<>();
|
|
|
+ title.put("name", 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);
|
|
|
+ threeLevelItems.put("title", titles);
|
|
|
+
|
|
|
+ if ("NULL".equals(method) && !"NULL".equals(pacsResult)){
|
|
|
+ optionOrIndex = optionOrIndex + "_" + priority;
|
|
|
+
|
|
|
+ Map<String, String> detailInfo = new LinkedHashMap<>();
|
|
|
+ detailInfo.put("detailName", pacsResult);
|
|
|
+ detailInfo.put("score", score2);
|
|
|
+ detailInfo.put("state", "0");
|
|
|
+ detailInfo.put("priority", priority);
|
|
|
+
|
|
|
+ if (nameDetails.containsKey(optionOrIndex)) {
|
|
|
+ nameDetails.get(optionOrIndex).add(detailInfo);
|
|
|
+ } else {
|
|
|
+ nameDetails.put(optionOrIndex, new ArrayList<>());
|
|
|
+ nameDetails.get(optionOrIndex).add(detailInfo);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- Collections.sort(results, new Comparator<TreeMap<String, Object>>() {
|
|
|
+ Collections.sort(results, new Comparator<Map<String, Object>>() {
|
|
|
@Override
|
|
|
- public int compare(TreeMap<String, Object> o1, TreeMap<String, Object> o2) {
|
|
|
+ public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
Integer priorityo1 = Integer.valueOf(o1.get("priority").toString());
|
|
|
Integer priorityo2 = Integer.valueOf(o2.get("priority").toString());
|
|
|
return priorityo1.compareTo(priorityo2);
|
|
|
}
|
|
|
});
|
|
|
- for (TreeMap<String, Object> resMap:results) {
|
|
|
+ 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);
|
|
|
-
|
|
|
- Map<String, List<Map<String, String>>> nameDetails = new HashMap<>();
|
|
|
- List<TreeMap<String, Object>> finalResult = new ArrayList<>();
|
|
|
- while (Rset2.hasNext()) {
|
|
|
- rec = Rset2.next();
|
|
|
- item = rec.get("n1.name").toString().replace("\"", "");
|
|
|
- //左拇指震动觉、右拇指振动觉
|
|
|
- optionOrIndex = rec.get("n2.name").toString().replace("\"", "");
|
|
|
- //正常、存在、消失
|
|
|
- index = rec.get("n3.name").toString().replace("\"", "");
|
|
|
- //score
|
|
|
- score2 = rec.get("r3.score").toString().replace("\"", "");
|
|
|
- priority1 = rec.get("r2.p").toString().replace("\"", "");
|
|
|
- priority2 = rec.get("r3.p").toString().replace("\"", "");
|
|
|
-
|
|
|
- optionOrIndex = optionOrIndex + "_" + priority1;
|
|
|
-
|
|
|
- Map<String, String> detailInfo = new LinkedHashMap<>();
|
|
|
- detailInfo.put("detailName", index);
|
|
|
- detailInfo.put("score", score2);
|
|
|
- detailInfo.put("state","0");
|
|
|
- detailInfo.put("priority",priority2);
|
|
|
-
|
|
|
- if (nameDetails.containsKey(optionOrIndex)){
|
|
|
- nameDetails.get(optionOrIndex).add(detailInfo);
|
|
|
- }else{
|
|
|
- nameDetails.put(optionOrIndex, new ArrayList<>());
|
|
|
- nameDetails.get(optionOrIndex).add(detailInfo);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (Map.Entry<String, List<Map<String, String>>> nameDetailEntry: nameDetails.entrySet()){
|
|
|
+ calculate.put("formula", "");
|
|
|
+ Map<String, String> calcResult = new HashMap<>();
|
|
|
+ calcResult.put("score", "");
|
|
|
+ calcResult.put("text", "");
|
|
|
+ calculate.put("result", calcResult);
|
|
|
+ threeLevelItems.put("calculate", calculate);
|
|
|
+
|
|
|
+ List<Map<String, Object>> finalResult = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<Map<String, String>>> nameDetailEntry : nameDetails.entrySet()) {
|
|
|
String key = nameDetailEntry.getKey();
|
|
|
List<Map<String, String>> value = nameDetailEntry.getValue();
|
|
|
- TreeMap<String, Object> detailsResult = new TreeMap<>();
|
|
|
+ Map<String, Object> detailsResult = new TreeMap<>();
|
|
|
|
|
|
Collections.sort(value, new Comparator<Map<String, String>>() {
|
|
|
@Override
|
|
@@ -1777,26 +1764,25 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- for (Map<String, String> map:value){
|
|
|
+ for (Map<String, String> map : value) {
|
|
|
map.remove("priority");
|
|
|
}
|
|
|
|
|
|
detailsResult.put("name", key.split("_")[0]);
|
|
|
detailsResult.put("details", value);
|
|
|
- detailsResult.put("controltype",0);
|
|
|
- detailsResult.put("priority",key.split("_")[1]);
|
|
|
+ detailsResult.put("controltype", 0);
|
|
|
+ detailsResult.put("priority", key.split("_")[1]);
|
|
|
finalResult.add(detailsResult);
|
|
|
}
|
|
|
- Collections.sort(finalResult, new Comparator<TreeMap<String,Object>>() {
|
|
|
-
|
|
|
+ Collections.sort(finalResult, new Comparator<Map<String, Object>>() {
|
|
|
@Override
|
|
|
- public int compare(TreeMap<String, Object> o1, TreeMap<String, Object> o2) {
|
|
|
+ public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
Integer priorityo1 = Integer.valueOf(o1.get("priority").toString());
|
|
|
Integer priorityo2 = Integer.valueOf(o2.get("priority").toString());
|
|
|
return priorityo1.compareTo(priorityo2);
|
|
|
}
|
|
|
});
|
|
|
- for (TreeMap<String, Object> map:finalResult) {
|
|
|
+ for (Map<String, Object> map : finalResult) {
|
|
|
map.remove("priority");
|
|
|
}
|
|
|
threeLevelItems.put("rows", finalResult);
|
|
@@ -1884,12 +1870,12 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public Map<String, Object> scaleScoreCalc(String[] scaleItems,String scaleName,Neo4jAPI neo4jAPI){
|
|
|
+ public Map<String, Object> scaleScoreCalc(String[] scaleItems, String scaleName) {
|
|
|
|
|
|
int sum = 0;
|
|
|
String final_result = null;
|
|
|
- Map<String, Object> scaleCalc = neo4jAPI.getScaleCalc(scaleName);
|
|
|
- for (String scaleItem:scaleItems) {
|
|
|
+ Map<String, Object> scaleCalc = getScaleCalc(scaleName);
|
|
|
+ for (String scaleItem : scaleItems) {
|
|
|
Object details = scaleCalc.get("rows");
|
|
|
//获取name
|
|
|
List<Map<String, Object>> content = (List<Map<String, Object>>) details;
|
|
@@ -1900,9 +1886,9 @@ public class Neo4jAPI {
|
|
|
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)){
|
|
|
+ if (scaleItem.contains(detailName)) {
|
|
|
sum += Double.valueOf(score);
|
|
|
- sub_map.put("state","1");
|
|
|
+ sub_map.put("state", "1");
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -1913,18 +1899,18 @@ public class Neo4jAPI {
|
|
|
System.out.println(sum);
|
|
|
Map<String, Object> calculate = (Map<String, Object>) scaleCalc.get("calculate");
|
|
|
List<Map<String, String>> range = (List<Map<String, String>>) calculate.get("range");
|
|
|
- for (Map<String, String> range_map:range) {
|
|
|
+ for (Map<String, String> range_map : range) {
|
|
|
Integer min = Integer.valueOf(range_map.get("min"));
|
|
|
Integer max = Integer.valueOf(range_map.get("max"));
|
|
|
String text = range_map.get("text");
|
|
|
- if (sum >= min && sum <= max){
|
|
|
+ if (sum >= min && sum <= max) {
|
|
|
final_result = text;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
Map<String, String> result = (Map<String, String>) calculate.get("result");
|
|
|
- result.put("score",String.valueOf(sum));
|
|
|
- result.put("text",(final_result));
|
|
|
+ result.put("score", String.valueOf(sum));
|
|
|
+ result.put("text", final_result);
|
|
|
return scaleCalc;
|
|
|
}
|
|
|
|