|
@@ -771,34 +771,100 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 鉴别诊断
|
|
|
- * @param mainDiag
|
|
|
+ * 新结构,包含关联词
|
|
|
+ * @param keys
|
|
|
+ * @param webDiag
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<String> getDifferentialDiagnose(String mainDiag){
|
|
|
- List<String> differentialDiagnoseList = new LinkedList<>();
|
|
|
+ public Map<String, Map<String,String>> getNewCondition(String[] keys,String webDiag) {
|
|
|
+ Map<String, Map<String,String>> diseaseCondition = new LinkedHashMap<>();
|
|
|
+ List<String> newList = new ArrayList<>();
|
|
|
+ List<String> fildList = new ArrayList<>();
|
|
|
+ List<String> startList = new ArrayList<>();
|
|
|
+ //输出确诊集合
|
|
|
+ Set<String> quezhen = new LinkedHashSet<>();
|
|
|
+ for (String fild : keys) {
|
|
|
+ fildList.add("\"" + fild.trim() + "\"");
|
|
|
+ }
|
|
|
+ logger.info("根据 " + fildList + " 这些词推送图谱诊断!!!");
|
|
|
Session session = null;
|
|
|
StatementResult result = null;
|
|
|
String query = "";
|
|
|
try {
|
|
|
session = driver.session(AccessMode.WRITE);
|
|
|
logger.info("session 为: " + session);
|
|
|
- query = propertiesUtil.getProperty("searchDifferentialDiagnose").replace("mainDis", mainDiag);
|
|
|
+ //第一步查询是否有组合的词
|
|
|
+ query = propertiesUtil.getProperty("searchNumColl").replace("startList", fildList.toString());
|
|
|
+ result = session.run(query);
|
|
|
+ while (result.hasNext()) {
|
|
|
+ Record next = result.next();
|
|
|
+ String v = next.get("v").toString();
|
|
|
+ startList.add(v);
|
|
|
+ }
|
|
|
+ newList.addAll(startList);
|
|
|
+ while (newList.size() > 0) {
|
|
|
+ query = propertiesUtil.getProperty("searchNewCondition").replace("newList", newList.toString()).replace("fildList", startList.toString());
|
|
|
+ result = session.run(query);
|
|
|
+ newList.clear();
|
|
|
+ while (result.hasNext()) {
|
|
|
+ Record record = result.next();
|
|
|
+ String condition = record.get("condition").toString();
|
|
|
+ String jundgement = record.get("jundgement").toString();
|
|
|
+ if ("TRUE".equals(jundgement)) {
|
|
|
+ newList.add(condition);
|
|
|
+ startList.add(condition);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //第三步查找确诊
|
|
|
+ query = propertiesUtil.getProperty("searchDis").replace("startList", startList.toString());
|
|
|
result = session.run(query);
|
|
|
while (result.hasNext()) {
|
|
|
Record record = result.next();
|
|
|
- List<Object> coll = record.get("coll").asList();
|
|
|
- if(coll != null && coll.size()>0){
|
|
|
- for (Object o:coll) {
|
|
|
- differentialDiagnoseList.add(o.toString().replace("\"",""));
|
|
|
+ String quezhenName = record.get("name").toString().replace("\"", "");
|
|
|
+ String conditionType = record.get("relationType").toString().replace("\"", "");
|
|
|
+ if ("确诊".equals(conditionType)) {
|
|
|
+ quezhen.add(quezhenName);
|
|
|
+ } else if ("拟诊".equals(conditionType)) {
|
|
|
+ quezhen.add(quezhenName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String qu : quezhen) {
|
|
|
+ Map<String, String> dis_res = new HashMap<>();
|
|
|
+ dis_res.put("确诊", "");
|
|
|
+// diseaseCondition.put(qu, JSON.toJSONString(dis_res));
|
|
|
+ diseaseCondition.put(qu,dis_res);
|
|
|
+ logger.info("图谱推出的诊断为: " + qu);
|
|
|
+ }
|
|
|
+ Set<String> queSets = diseaseCondition.keySet();
|
|
|
+ if(webDiag != null && webDiag.trim() != ""){
|
|
|
+ String[] webDiagSplits = webDiag.split(",");
|
|
|
+ String mainDiag = webDiagSplits[0];
|
|
|
+ query = propertiesUtil.getProperty("searchDifferentialDiagnose").replace("mainDis", mainDiag);
|
|
|
+ result = session.run(query);
|
|
|
+ while (result.hasNext()) {
|
|
|
+ Record record = result.next();
|
|
|
+ List<Object> coll = record.get("coll").asList();
|
|
|
+ if(coll != null && coll.size()>0){
|
|
|
+ for (Object o:coll) {
|
|
|
+ if(queSets.contains(o.toString().replace("\"",""))){
|
|
|
+ Map<String, String> stringStringMap = diseaseCondition.get(o.toString().replace("\"", ""));
|
|
|
+ stringStringMap.put("鉴别诊断","");
|
|
|
+ diseaseCondition.put(o.toString().replace("\"",""),stringStringMap);
|
|
|
+ }else {
|
|
|
+ Map<String, String> diffMap = new HashMap<>();
|
|
|
+ diffMap.put("鉴别诊断","");
|
|
|
+ diseaseCondition.put(o.toString().replace("\"",""),diffMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
+ } finally {
|
|
|
CloseSession(session);
|
|
|
- return differentialDiagnoseList;
|
|
|
+ return diseaseCondition;
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
@@ -942,73 +1008,6 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 新的诊断逻辑
|
|
|
- * 包含确诊和疑诊集合
|
|
|
- *
|
|
|
- * @param iputList
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Map<String, ArrayList> newConditionProcess(ArrayList<String> iputList) {
|
|
|
- Map<String, ArrayList> conditionMap = new HashMap<>();
|
|
|
- ArrayList<String> quezhenList = new ArrayList<>();
|
|
|
- ArrayList<String> yizhenList = new ArrayList<>();
|
|
|
- //处理原始输入
|
|
|
- List<String> arrayList = inputProcess(iputList);
|
|
|
- List<String> newList = new ArrayList<>();
|
|
|
- newList.addAll(arrayList);
|
|
|
- Session session = null;
|
|
|
- StatementResult stat = null;
|
|
|
- String query = "";
|
|
|
- try {
|
|
|
- session = driver.session(AccessMode.READ);
|
|
|
- while (newList.size() > 0) {
|
|
|
- //查找符合条件的判断节点
|
|
|
- query = "with " + newList + " as data unwind data as row\n" +
|
|
|
- "match (l)-[r:诊断依据]->(m)\n" +
|
|
|
- "where row.label in labels(l) and l.name=row.name\n" +
|
|
|
- "with m," + arrayList + " as data unwind data as row\n" +
|
|
|
- "match (n)-[r:诊断依据]->(m)\n" +
|
|
|
- "where row.label in labels(n) and n.name=row.name\n" +
|
|
|
- "return m.name as condition, count(distinct r)>=m.path as jundgement, labels(m)[0] as label";
|
|
|
- stat = session.run(query);
|
|
|
- newList.clear();
|
|
|
- while (stat.hasNext()) {
|
|
|
- Record record = stat.next();
|
|
|
- String condition = record.get("condition").toString();
|
|
|
- String jundgement = record.get("jundgement").toString();
|
|
|
- String label = record.get("label").toString();
|
|
|
- if ("TRUE".equals(jundgement)) {
|
|
|
- newList.add("{label:" + label + ",name:" + condition + "}");
|
|
|
- arrayList.add("{label:" + label + ",name:" + condition + "}");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //计算确诊,可能诊断
|
|
|
- query = "with " + arrayList + " as data unwind data as row\n" +
|
|
|
- "match (n)-[r:确诊|:可能诊断]->(m)\n" +
|
|
|
- "where row.label in labels(n) and n.name=row.name\n" +
|
|
|
- "with distinct m,r\n" +
|
|
|
- "return m.name as name, labels(m)[0] as label,type(r) as relationType";
|
|
|
- stat = session.run(query);
|
|
|
- while (stat.hasNext()) {
|
|
|
- Record record = stat.next();
|
|
|
- if ("\"确诊\"".equals(record.get("relationType").toString())) {
|
|
|
- quezhenList.add(record.get("name").toString().replaceAll("\"", ""));
|
|
|
- } else if ("\"可能诊断\"".equals(record.get("relationType").toString())) {
|
|
|
- yizhenList.add(record.get("name").toString().replaceAll("\"", ""));
|
|
|
- }
|
|
|
- }
|
|
|
- conditionMap.put("确诊", quezhenList);
|
|
|
- conditionMap.put("可能诊断", yizhenList);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- CloseSession(session);
|
|
|
- return conditionMap;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 多疾病下治疗方案
|
|
|
*
|
|
@@ -1240,14 +1239,7 @@ public class Neo4jAPI {
|
|
|
fildsList.add("\'" + diseaseList.get(j) + "\'");
|
|
|
}
|
|
|
}
|
|
|
- /* //获取每个病的不良反应集合
|
|
|
- List<String> ueList = disUE.get(diseaseList.get(i));
|
|
|
- if(ueList !=null && ueList.size()>0){
|
|
|
- for (String ue:ueList) {
|
|
|
- fildsList.add("\'"+ue+"\'");
|
|
|
- }
|
|
|
- }
|
|
|
-*/
|
|
|
+
|
|
|
diseFilds.put(diseaseList.get(i), fildsList);
|
|
|
}
|
|
|
try {
|
|
@@ -1421,13 +1413,19 @@ public class Neo4jAPI {
|
|
|
logger.info(diseaseName + "下面有" + stringList + "不良反应");
|
|
|
if (stringList != null && stringList.size() > 0) {
|
|
|
List<Indicators> indicatorsList1 = new ArrayList<>();
|
|
|
- Indicators indicators1 = getAdverse(ueSet, "低血糖反应");
|
|
|
- logger.info(disSet + "包含 低血糖反应");
|
|
|
- Indicators indicators2 = getAdverse(ueSet, "胃肠道不良反应");
|
|
|
- logger.info(disSet + "包含 胃肠道不良反应");
|
|
|
- indicatorsList1.add(indicators1);
|
|
|
- indicatorsList1.add(indicators2);
|
|
|
+ for (String de:stringList) {
|
|
|
+ Indicators indicators1 = getAdverse(ueSet, de);
|
|
|
+ logger.info(disSet + "包含 "+de);
|
|
|
+ indicatorsList1.add(indicators1);
|
|
|
+ }
|
|
|
filnlly.setAdverseEvent(indicatorsList1);
|
|
|
+// Indicators indicators1 = getAdverse(ueSet, "低血糖反应");
|
|
|
+// logger.info(disSet + "包含 低血糖反应");
|
|
|
+// Indicators indicators2 = getAdverse(ueSet, "胃肠道不良反应");
|
|
|
+// logger.info(disSet + "包含 胃肠道不良反应");
|
|
|
+// indicatorsList1.add(indicators1);
|
|
|
+// indicatorsList1.add(indicators2);
|
|
|
+// filnlly.setAdverseEvent(indicatorsList1);
|
|
|
}
|
|
|
}
|
|
|
filnlly.setTreatment(drugsList);
|
|
@@ -1788,82 +1786,6 @@ public class Neo4jAPI {
|
|
|
return indicators1;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 倒推实现
|
|
|
- *
|
|
|
- * @param diseaseName
|
|
|
- * @return
|
|
|
- */
|
|
|
- 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" };
|
|
|
- Session session = null;
|
|
|
- StatementResult result = null;
|
|
|
- String query = "";
|
|
|
- try {
|
|
|
- if (sign == 1) {
|
|
|
- session = driver.session(AccessMode.WRITE);
|
|
|
- for (String l : label) {
|
|
|
- query = "match (d1:Disease{name:'" + diseaseName + "'})-[r1]->(s1:" + l + ") return s1.name as symptom";
|
|
|
- result = session.run(query);
|
|
|
- while (result.hasNext()) {
|
|
|
- String symptom = result.next().get("symptom").toString().replaceAll("\"", "");
|
|
|
- if (backMap.containsKey(l)) {
|
|
|
- List symptomList = backMap.get(l);
|
|
|
- symptomList.add(symptom);
|
|
|
- backMap.put(l, symptomList);
|
|
|
- } else {
|
|
|
- List<String> sList = new ArrayList<>();
|
|
|
- sList.add(symptom);
|
|
|
- backMap.put(l, sList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- CloseSession(session);
|
|
|
- }
|
|
|
-
|
|
|
- return backMap;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 高危逻辑
|
|
|
- *
|
|
|
- * @param diseaseName
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Map<String, String> getHighRisk(String diseaseName) {
|
|
|
- String[] diseaseArray = diseaseName.split(",|,|、");
|
|
|
- List<String> diseaseList = new ArrayList<>();
|
|
|
- for (String di : diseaseArray) {
|
|
|
- diseaseList.add("'" + di + "'");
|
|
|
- }
|
|
|
- Map<String, String> riskMap = new HashMap<>();
|
|
|
- Session session = null;
|
|
|
- StatementResult result = null;
|
|
|
- String query = "match(d:Disease) where d.name in " + diseaseList + " return d.name as name, d.high_risk as risk";
|
|
|
- try {
|
|
|
- session = driver.session(AccessMode.WRITE);
|
|
|
- result = session.run(query);
|
|
|
- while (result.hasNext()) {
|
|
|
- Record next = result.next();
|
|
|
- String name = next.get("name").toString().replaceAll("\"", "");
|
|
|
- String risk = next.get("risk").toString();
|
|
|
- riskMap.put(name, risk);
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
-
|
|
|
- } finally {
|
|
|
- CloseSession(session);
|
|
|
- return riskMap;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 反推LIS,PACS
|
|
@@ -2142,36 +2064,6 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public List<String> getGrapWords(String[] keys) {
|
|
|
- List<String> graphWordsList = new ArrayList<>();
|
|
|
- ArrayList<String> fildList = new ArrayList<>();
|
|
|
- //输出确诊集合
|
|
|
- Set<String> quezhen = new HashSet<>();
|
|
|
- for (String fild : keys) {
|
|
|
- fildList.add("\"" + fild.trim() + "\"");
|
|
|
- }
|
|
|
- Session session = null;
|
|
|
- StatementResult result = null;
|
|
|
- String query = "";
|
|
|
- try {
|
|
|
- session = driver.session(AccessMode.WRITE);
|
|
|
- //判断是否有近义词
|
|
|
- query = "match(d) where d.name in " + fildList + " return distinct d.name as name";
|
|
|
- result = session.run(query);
|
|
|
- while (result.hasNext()) {
|
|
|
- Record next = result.next();
|
|
|
- String word = next.get("name").toString();
|
|
|
- graphWordsList.add(word);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- CloseSession(session);
|
|
|
- }
|
|
|
- return graphWordsList;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 根据是否需要计算调取相应返回量表的方法
|
|
|
*
|
|
@@ -2456,6 +2348,10 @@ public class Neo4jAPI {
|
|
|
if (!scaleStructure.containsKey("Calc")) {
|
|
|
scaleStructure.put("Calc", Integer.valueOf(calc));
|
|
|
}
|
|
|
+
|
|
|
+ if (group.contains("-")){
|
|
|
+ group = group.split("-")[0];
|
|
|
+ }
|
|
|
if (group.contains("计算方法")) {
|
|
|
String[] range = mutex.split("~|-");
|
|
|
String min = range[0];
|