|
@@ -754,10 +754,11 @@ public class Neo4jAPI {
|
|
|
return diseaseCondition;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 指标推送
|
|
|
*/
|
|
|
- public Set<String> getInd(String[] keys){
|
|
|
+ public Set<String> getInd(String[] keys) {
|
|
|
//查找指标推送
|
|
|
Set<String> indSet = new HashSet<>();
|
|
|
List<String> newList = new ArrayList<>();
|
|
@@ -1271,39 +1272,40 @@ public class Neo4jAPI {
|
|
|
|
|
|
/**
|
|
|
* 推送指标
|
|
|
+ *
|
|
|
* @param idnSet 指标集
|
|
|
- * @param age 年龄
|
|
|
- * @param sex 性别
|
|
|
+ * @param age 年龄
|
|
|
+ * @param sex 性别
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<MedicalIndication> getIdn(Set<String> idnSet,Integer age,String sex){
|
|
|
- String query="";
|
|
|
+ public List<MedicalIndication> getIdn(Set<String> idnSet, Integer age, String sex) {
|
|
|
+ String query = "";
|
|
|
Session session = null;
|
|
|
StatementResult result = null;
|
|
|
List<MedicalIndication> medicalIndicationList = new ArrayList<>();
|
|
|
- if(idnSet !=null && idnSet.size()>0){
|
|
|
- for (String s:idnSet) {
|
|
|
+ if (idnSet != null && idnSet.size() > 0) {
|
|
|
+ for (String s : idnSet) {
|
|
|
MedicalIndication medicalIndication = new MedicalIndication();
|
|
|
List<MedicalIndicationDetail> medicalIndicationDetailList = new ArrayList<>();
|
|
|
medicalIndication.setName(s);
|
|
|
- MedicalIndicationDetail medicalIndicationDetail1 =null;
|
|
|
- MedicalIndicationDetail medicalIndicationDetail2 =null;
|
|
|
- MedicalIndicationDetail medicalIndicationDetail3 =null;
|
|
|
+ MedicalIndicationDetail medicalIndicationDetail1 = null;
|
|
|
+ MedicalIndicationDetail medicalIndicationDetail2 = null;
|
|
|
+ MedicalIndicationDetail medicalIndicationDetail3 = null;
|
|
|
JSONObject gongshiJson = null;
|
|
|
- List<JSONObject> detailList =null;
|
|
|
- List<JSONObject> resultList =null;
|
|
|
+ List<JSONObject> detailList = null;
|
|
|
+ List<JSONObject> resultList = null;
|
|
|
List<JSONObject> sexList = null;
|
|
|
- List<JSONObject> shiFouList =null;
|
|
|
+ List<JSONObject> shiFouList = null;
|
|
|
JSONObject shiFouJson = null;
|
|
|
Set<String> results = new HashSet<>();
|
|
|
- query="match(d:Indicators{name:'"+s+"'})-[r2:内容]->(n:Content) where r2.p=1 \n" +
|
|
|
+ query = "match(d:Indicators{name:'" + s + "'})-[r2:内容]->(n:Content) where r2.p=1 \n" +
|
|
|
"return r2.p as sort1 ,n.name as conten,null as sort2,null as item,null as controlType,null as state,null as value,null as uint,null as details\n" +
|
|
|
"union\n" +
|
|
|
- "match(d:Indicators{name:'"+s+"'})-[r2:内容]->(n:Content)-[r3:项目]->(i:Item) \n" +
|
|
|
+ "match(d:Indicators{name:'" + s + "'})-[r2:内容]->(n:Content)-[r3:项目]->(i:Item) \n" +
|
|
|
"return r2.p as sort1 ,n.name as conten,r3.p as sort2,i.name as item,i.controlType as controlType,i.state as state,i.value as value,i.uint as uint,i.details as details order by sort1,sort2";
|
|
|
session = driver.session(AccessMode.WRITE);
|
|
|
result = session.run(query);
|
|
|
- while (result.hasNext()){
|
|
|
+ while (result.hasNext()) {
|
|
|
Record next1 = result.next();
|
|
|
int sort1 = next1.get("sort1").asInt();
|
|
|
String conten = next1.get("conten").toString();
|
|
@@ -1315,56 +1317,55 @@ public class Neo4jAPI {
|
|
|
String uint = next1.get("uint").toString();
|
|
|
String details = next1.get("details").toString();
|
|
|
// System.out.println(sort1+"\t"+conten+"\t"+sort2+"\t"+item+"\t"+controlType+"\t"+value+"\t"+uint+"\t"+details);
|
|
|
- if(1==sort1){
|
|
|
- if(medicalIndicationDetail1 == null){
|
|
|
+ if (1 == sort1) {
|
|
|
+ if (medicalIndicationDetail1 == null) {
|
|
|
medicalIndicationDetail1 = new MedicalIndicationDetail();
|
|
|
}
|
|
|
medicalIndicationDetail1.setType(sort1);
|
|
|
JSONObject liangJson = new JSONObject();
|
|
|
- liangJson.put("name", conten.replace("\"",""));
|
|
|
+ liangJson.put("name", conten.replace("\"", ""));
|
|
|
medicalIndicationDetail1.setContent(liangJson);
|
|
|
- }
|
|
|
- else if(2==sort1){
|
|
|
- if(medicalIndicationDetail2 ==null){
|
|
|
+ } else if (2 == sort1) {
|
|
|
+ if (medicalIndicationDetail2 == null) {
|
|
|
medicalIndicationDetail2 = new MedicalIndicationDetail();
|
|
|
}
|
|
|
medicalIndicationDetail2.setType(2);
|
|
|
- if(gongshiJson == null){
|
|
|
+ if (gongshiJson == null) {
|
|
|
gongshiJson = new JSONObject();
|
|
|
}
|
|
|
- gongshiJson.put("name", conten.replace("\"",""));
|
|
|
- if(detailList == null){
|
|
|
+ gongshiJson.put("name", conten.replace("\"", ""));
|
|
|
+ if (detailList == null) {
|
|
|
detailList = new ArrayList<>();
|
|
|
}
|
|
|
JSONObject ageJsonObject = new JSONObject();
|
|
|
ageJsonObject.put("controlType", Integer.parseInt(controlType));
|
|
|
- ageJsonObject.put("name",item.replace("\"","") );
|
|
|
- ageJsonObject.put("value", value.replace("\"",""));
|
|
|
- ageJsonObject.put("uint", uint.replace("\"",""));
|
|
|
- if("年龄".equals(item.replace("\"",""))){
|
|
|
+ ageJsonObject.put("name", item.replace("\"", ""));
|
|
|
+ ageJsonObject.put("value", value.replace("\"", ""));
|
|
|
+ ageJsonObject.put("uint", uint.replace("\"", ""));
|
|
|
+ if ("年龄".equals(item.replace("\"", ""))) {
|
|
|
ageJsonObject.put("value", age);
|
|
|
}
|
|
|
- if(!"0".equals(controlType)){
|
|
|
- ageJsonObject.put("details", details.replace("\"",""));
|
|
|
- }else {
|
|
|
- String query1="match(i:Item)-[r:详细]->(d:Detail) where i.name="+item+"\n" +
|
|
|
+ if (!"0".equals(controlType)) {
|
|
|
+ ageJsonObject.put("details", details.replace("\"", ""));
|
|
|
+ } else {
|
|
|
+ String query1 = "match(i:Item)-[r:详细]->(d:Detail) where i.name=" + item + "\n" +
|
|
|
"return d.name as name,d.state as state,d.value as value order by r.p";
|
|
|
StatementResult run1 = session.run(query1);
|
|
|
- if(sexList == null){
|
|
|
+ if (sexList == null) {
|
|
|
sexList = new ArrayList<>();
|
|
|
}
|
|
|
- while (run1.hasNext()){
|
|
|
+ while (run1.hasNext()) {
|
|
|
Record next = run1.next();
|
|
|
String name = next.get("name").toString();
|
|
|
int state = next.get("state").asInt();
|
|
|
String value1 = next.get("value").toString();
|
|
|
JSONObject manJson = new JSONObject();
|
|
|
- manJson.put("detailName", name.replace("\"",""));
|
|
|
- manJson.put("value", value1.replace("\"",""));
|
|
|
+ manJson.put("detailName", name.replace("\"", ""));
|
|
|
+ manJson.put("value", value1.replace("\"", ""));
|
|
|
manJson.put("state", state);
|
|
|
- if( "男".equals(name.replace("\"",""))&&"M".equals(sex)){
|
|
|
+ if ("男".equals(name.replace("\"", "")) && "M".equals(sex)) {
|
|
|
manJson.put("state", 1);
|
|
|
- }else if("女".equals(name.replace("\"",""))&&"F".equals(sex)){
|
|
|
+ } else if ("女".equals(name.replace("\"", "")) && "F".equals(sex)) {
|
|
|
manJson.put("state", 1);
|
|
|
}
|
|
|
sexList.add(manJson);
|
|
@@ -1373,45 +1374,44 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
detailList.add(ageJsonObject);
|
|
|
gongshiJson.put("details", detailList);
|
|
|
- if(resultList == null){
|
|
|
+ if (resultList == null) {
|
|
|
resultList = new ArrayList<>();
|
|
|
}
|
|
|
- String query2 = "match(c:Content)-[r:结果]->(f:Result) where c.name="+conten+"\n" +
|
|
|
+ String query2 = "match(c:Content)-[r:结果]->(f:Result) where c.name=" + conten + "\n" +
|
|
|
"return f.name as name,f.text as text order by r.p";
|
|
|
StatementResult run1 = session.run(query2);
|
|
|
- while (run1.hasNext()){
|
|
|
+ while (run1.hasNext()) {
|
|
|
Record next = run1.next();
|
|
|
String name = next.get("name").toString();
|
|
|
String text = next.get("text").toString();
|
|
|
- results.add(name.replace("\"",""));
|
|
|
+ results.add(name.replace("\"", ""));
|
|
|
}
|
|
|
- }
|
|
|
- else if(3==sort1){
|
|
|
- if(medicalIndicationDetail3 ==null){
|
|
|
+ } else if (3 == sort1) {
|
|
|
+ if (medicalIndicationDetail3 == null) {
|
|
|
medicalIndicationDetail3 = new MedicalIndicationDetail();
|
|
|
}
|
|
|
medicalIndicationDetail3.setType(3);
|
|
|
- if(shiFouList == null){
|
|
|
+ if (shiFouList == null) {
|
|
|
shiFouList = new ArrayList<>();
|
|
|
}
|
|
|
- if(shiFouJson == null){
|
|
|
+ if (shiFouJson == null) {
|
|
|
shiFouJson = new JSONObject();
|
|
|
}
|
|
|
- shiFouJson.put("name", conten.replace("\"",""));
|
|
|
+ shiFouJson.put("name", conten.replace("\"", ""));
|
|
|
shiFouJson.put("controlType", 0);
|
|
|
JSONObject shiJsonObject = new JSONObject();
|
|
|
- shiJsonObject.put("detailName", item.replace("\"",""));
|
|
|
+ shiJsonObject.put("detailName", item.replace("\"", ""));
|
|
|
shiJsonObject.put("state", Integer.parseInt(state1));
|
|
|
shiFouList.add(shiJsonObject);
|
|
|
shiFouJson.put("details", shiFouList);
|
|
|
medicalIndicationDetail3.setContent(shiFouJson);
|
|
|
}
|
|
|
}
|
|
|
- for (String re: results
|
|
|
+ for (String re : results
|
|
|
) {
|
|
|
JSONObject result1 = new JSONObject();
|
|
|
- result1.put("name",re);
|
|
|
- result1.put("text","");
|
|
|
+ result1.put("name", re);
|
|
|
+ result1.put("text", "");
|
|
|
resultList.add(result1);
|
|
|
}
|
|
|
gongshiJson.put("result", resultList);
|
|
@@ -1422,31 +1422,137 @@ public class Neo4jAPI {
|
|
|
medicalIndication.setDetails(medicalIndicationDetailList);
|
|
|
medicalIndicationList.add(medicalIndication);
|
|
|
}
|
|
|
- }else {
|
|
|
- medicalIndicationList=null;
|
|
|
+ } else {
|
|
|
+ medicalIndicationList = null;
|
|
|
}
|
|
|
CloseSession(session);
|
|
|
return medicalIndicationList;
|
|
|
}
|
|
|
|
|
|
- public MangementEvaluation pushMe(String[] webDiagsplits){
|
|
|
+ public MangementEvaluation pushMe(String[] webDiagsplits, Map<String, Double> lis_Result) {
|
|
|
MangementEvaluation mangementEvaluation = new MangementEvaluation();
|
|
|
- String query="";
|
|
|
+ Map<String, JSONObject> mangementMap = new HashMap<>();
|
|
|
+ String query = "";
|
|
|
Session session = null;
|
|
|
StatementResult result = null;
|
|
|
- if(webDiagsplits != null && webDiagsplits.length>0){
|
|
|
+ if (webDiagsplits != null && webDiagsplits.length > 0) {
|
|
|
String diag = webDiagsplits[0];//慢病
|
|
|
- query="match(d:Disease)-[r1:管理评估]-(m:Management)-[r2:疗效评估]->(e:Effect)-[r3:结果]-(u:Result)\n" +
|
|
|
- "where d.name='"+diag+"'\n" +
|
|
|
- "return d.name,m.name,e.name,u.name order by r2.p,r3.p";
|
|
|
- session = driver.session(AccessMode.WRITE);
|
|
|
- result = session.run(query);
|
|
|
- while (result.hasNext()){
|
|
|
- Record next = result.next();
|
|
|
+ if ("糖尿病".equals(diag)) {
|
|
|
+ Map<String, LinkedList<String>> effCollect = new LinkedHashMap<>();
|
|
|
+ query = "match(d:Disease)-[r1:管理评估]-(m:Management)-[r2:疗效评估]->(e:Effect)-[r3:结果]-(u:Result)\n" +
|
|
|
+ "where d.name='" + diag + "'\n" +
|
|
|
+ "return d.name as dis,e.name as eff,u.name as res order by r2.p,r3.p";
|
|
|
+ System.out.println(query);
|
|
|
+ session = driver.session(AccessMode.WRITE);
|
|
|
+ result = session.run(query);
|
|
|
+ while (result.hasNext()) {
|
|
|
+ Record next = result.next();
|
|
|
+ String eff = next.get("eff").toString().replace("\"","");//疗效评估名
|
|
|
+ String res = next.get("res").toString().replace("\"","");//疗效评估结果
|
|
|
+// System.out.println(eff + "\t" + res);
|
|
|
+ if (effCollect.keySet().contains(eff)) {
|
|
|
+ if (!effCollect.get(eff).contains(res)) {
|
|
|
+ LinkedList<String> strings = effCollect.get(eff);
|
|
|
+ strings.add(res);
|
|
|
+ effCollect.put(eff, strings);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ LinkedList<String> strings = new LinkedList<>();
|
|
|
+ strings.add(res);
|
|
|
+ effCollect.put(eff, strings);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //effCollect 存的:(血脂控制情况 : 正常,轻度,中度,重度)
|
|
|
+ List<JSONObject> itemJson = new ArrayList<>();
|
|
|
+ JSONObject curativeJson = new JSONObject();
|
|
|
+ for (Map.Entry<String, LinkedList<String>> item : effCollect.entrySet()) {
|
|
|
+ String key = item.getKey();//血脂控制情况
|
|
|
+ LinkedList<String> value = item.getValue();//正常,轻度,中度,重度
|
|
|
+ JSONObject bloodPressure = new JSONObject();
|
|
|
+ bloodPressure.put("controltype", 0);
|
|
|
+ bloodPressure.put("name", key);
|
|
|
+ List<JSONObject> bloodPressureLevelList = new ArrayList<>();
|
|
|
+ for (String res : value) {
|
|
|
+ JSONObject iJson = new JSONObject();
|
|
|
+ iJson.put("detailName", res);
|
|
|
+ iJson.put("state", 0);
|
|
|
+ bloodPressureLevelList.add(iJson);
|
|
|
+ }
|
|
|
|
|
|
+ bloodPressure.put("details", bloodPressureLevelList);
|
|
|
+ if (bloodPressure.get("name").equals("血脂控制情况")) {
|
|
|
+ List<JSONObject> details = (List<JSONObject>) bloodPressure.get("details");
|
|
|
+ Map<String,String> idnRes = new HashMap<>();
|
|
|
+ //化验计算
|
|
|
+ String query1 = "match(e:Effect)-[r:指标]->(l:LIS)-[r1:计算结果]->(k:Result) where e.name='血脂控制情况'\n" +
|
|
|
+ "return l.name as name,r1.between as between ,k.name as res";
|
|
|
+ StatementResult result1 = session.run(query1);
|
|
|
+ while (result1.hasNext()) {
|
|
|
+ Record next = result1.next();
|
|
|
+ String name = next.get("name").toString().replace("\"", "");
|
|
|
+ String between = next.get("between").toString().replace("\"", "");
|
|
|
+ String[] betweenSplit = between.split(",");
|
|
|
+ double min = Double.parseDouble(betweenSplit[0].replace("[", ""));
|
|
|
+ double max = Double.parseDouble(betweenSplit[1].replace("]", ""));
|
|
|
+ String res1 = next.get("res").toString().replace("\"", "");
|
|
|
+ if (lis_Result.keySet().contains(name)) {
|
|
|
+ Double aDouble = lis_Result.get(name);
|
|
|
+ if (min < aDouble && aDouble <= max) {
|
|
|
+ idnRes.put(res1,"血脂控制情况");
|
|
|
+ } else {
|
|
|
+ idnRes.put("","血脂控制情况");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Collection<String> values = idnRes.keySet();
|
|
|
+ for (String s:values) {
|
|
|
+ int i =0;
|
|
|
+ if(!"".equals(s)){
|
|
|
+ for (i =0;i<details.size();i++) {
|
|
|
+ String detailName = (String) details.get(i).get("detailName");
|
|
|
+ if(detailName.equals(s)){
|
|
|
+ details.remove(i);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONObject k = new JSONObject();
|
|
|
+ k.put("detailName", s);
|
|
|
+ k.put("state",1);
|
|
|
+// details.add(k);
|
|
|
+ details.add(i,k);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bloodPressure.put("details",details);
|
|
|
+ }
|
|
|
+ itemJson.add(bloodPressure);
|
|
|
+ }
|
|
|
+ curativeJson.put("rows", itemJson);
|
|
|
+ //分级管理
|
|
|
+ JSONObject gradeJson = new JSONObject();
|
|
|
+ List<JSONObject> gradItemJson = new ArrayList<>();
|
|
|
+ JSONObject bigGrad = new JSONObject();
|
|
|
+ bigGrad.put("name", "糖尿病控制情况");
|
|
|
+ bigGrad.put("controltype", 0);
|
|
|
+ List<JSONObject> gradItemJ = new ArrayList<>();
|
|
|
+ String[] gradItem = {"常规管理", "强化管理"};
|
|
|
+ for (String item : gradItem) {
|
|
|
+ JSONObject j = new JSONObject();
|
|
|
+ j.put("detailName", item);
|
|
|
+ j.put("state", 0);
|
|
|
+ gradItemJ.add(j);
|
|
|
+ }
|
|
|
+ bigGrad.put("details", gradItemJ);
|
|
|
+ gradItemJson.add(bigGrad);
|
|
|
+ gradeJson.put("rows", gradItemJson);
|
|
|
+ mangementMap.put("疗效评估", curativeJson);
|
|
|
+ mangementMap.put("糖尿病分级管理", gradeJson);
|
|
|
+ mangementEvaluation.setMangementEvaluation(mangementMap);
|
|
|
}
|
|
|
}
|
|
|
+ CloseSession(session);
|
|
|
return mangementEvaluation;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public Indicators getAdverse(Set<String> dis, String name) {
|
|
@@ -1499,7 +1605,7 @@ public class Neo4jAPI {
|
|
|
public Map<String, List> getPushBack(String diseaseName, int sign) {
|
|
|
// Map<String, String> labelMap = new HashMap<>();
|
|
|
HashMap<String, List> backMap = new HashMap<>();
|
|
|
- String[] label = { "Symptom", "Vital", "LIS", "PACS", "History" };
|
|
|
+ String[] label = {"Symptom", "Vital", "LIS", "PACS", "History"};
|
|
|
Session session = null;
|
|
|
StatementResult result = null;
|
|
|
String query = "";
|