|
@@ -1171,7 +1171,8 @@ public class Neo4jAPI {
|
|
|
if (stringList != null && stringList.size() > 0) {
|
|
|
List<Indicators> indicatorsList1 = new ArrayList<>();
|
|
|
for (String de : stringList) {
|
|
|
- Indicators indicators1 = getAdverse(ueSet, de);
|
|
|
+// Indicators indicators1 = getAdverse(ueSet, de);
|
|
|
+ Indicators indicators1 = new Indicators();
|
|
|
logger.info(disSet + "包含 " + de);
|
|
|
indicatorsList1.add(indicators1);
|
|
|
}
|
|
@@ -1192,7 +1193,7 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public Map<String, Filnlly> getMulDiseaseTreat_new(String disName, String disease, Integer diseaseType, Set<String> disSet, Map<String, List<String>> disUE, Map<String,String> ueSet, String filds) {
|
|
|
+ public Map<String, Filnlly> getMulDiseaseTreat_new(String disName, String disease, Integer diseaseType, Set<String> disSet, Map<String, List<String>> disUE, Map<String,String> ueSet, String filds, Map<String, List<CrisisDetail>> crisisDetails) {
|
|
|
Map<String, Filnlly> newTret = new HashMap<>();
|
|
|
Session session = null;
|
|
|
Map<String, ArrayList> diseFilds = getdisFilds(disName, disease, disSet, ueSet, filds);
|
|
@@ -1206,102 +1207,30 @@ public class Neo4jAPI {
|
|
|
if (diseFilds != null && diseFilds.size() > 0) {
|
|
|
for (Map.Entry<String, ArrayList> df : diseFilds.entrySet()) {
|
|
|
//大对象集合
|
|
|
- ArrayList<Drugs> drugsList = new ArrayList<Drugs>();
|
|
|
-
|
|
|
+ List<Drugs> drugsList;
|
|
|
+ TreatCate treatCate = null;
|
|
|
Map<String, String> medicaton_ji = new HashMap<>();//药的忌用和慎用集合
|
|
|
Map<String, List<String>> medicatonMap = new LinkedHashMap<>();//全部的药集合
|
|
|
String diseaseName = df.getKey();//疾病
|
|
|
ArrayList value = df.getValue();//其他条件
|
|
|
- query = propertiesUtil.getProperty("searchTreat").replace("disName", "\'" + diseaseName + "\'").replace("filds", value.toString());
|
|
|
- logger.info("查找诊断对应的类和药物,包括类的排序,查找语句为:\n" + query);
|
|
|
- result = tx.run(query);
|
|
|
- while (result.hasNext()) {
|
|
|
- Record record = result.next();
|
|
|
- String big = record.get("big").toString().replace("\"", "");
|
|
|
- String sub = record.get("sub").toString().replace("\"", "");
|
|
|
- String med = record.get("med").toString().replace("\"", "");
|
|
|
- String ty = record.get("ty").toString().replace("\"", "");
|
|
|
- if ("NULL".equals(ty)) {
|
|
|
- if (medicatonMap.containsKey(big + "$" + sub)) {
|
|
|
- List<String> ml = medicatonMap.get(big + "$" + sub);
|
|
|
- ml.add(med);
|
|
|
- medicatonMap.put(big + "$" + sub, ml);
|
|
|
- } else {
|
|
|
- List<String> ml = new ArrayList<>();
|
|
|
- ml.add(med);
|
|
|
- medicatonMap.put(big + "$" + sub, ml);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (medicaton_ji.containsKey(med)) {
|
|
|
- if (medicaton_ji.get(med).equals("慎用") && ty.equals("忌用")) {
|
|
|
- medicaton_ji.put(med, "忌用");
|
|
|
- }
|
|
|
- } else {
|
|
|
- medicaton_ji.put(med, ty);
|
|
|
- }
|
|
|
- }
|
|
|
+ // TODO: 2019/11/12 处理规则判断的用药情况
|
|
|
+ JSONObject jsonObject = medicationRule(tx, medicaton_ji, medicatonMap,diseaseName,value);
|
|
|
+ drugsList = (List<Drugs>)jsonObject.get("drugs");
|
|
|
+ treatCate = (TreatCate)jsonObject.get("treatCate");
|
|
|
+ if(treatCate.getType() == null){
|
|
|
+ treatCate = null;
|
|
|
}
|
|
|
- if (medicatonMap != null && medicatonMap.size() > 0) {
|
|
|
- for (Map.Entry<String, List<String>> fd : medicatonMap.entrySet()) {
|
|
|
- int i = 0;
|
|
|
- String big = "", sub = "";
|
|
|
- String big_sub = fd.getKey();//大小类
|
|
|
- List<String> medications = fd.getValue();//药的集合
|
|
|
- String[] splits = big_sub.split("\\$");
|
|
|
- Drugs drugs = new Drugs();
|
|
|
- if (splits[0].equals(splits[1])) {
|
|
|
- sub = "";
|
|
|
- big = splits[0];
|
|
|
- } else {
|
|
|
- big = splits[0];
|
|
|
- sub = splits[1];
|
|
|
- }
|
|
|
- LinkedList<Medicition> mes = new LinkedList<>();
|
|
|
- if (medications != null && medications.size() > 0) {
|
|
|
- for (String m : medications) {
|
|
|
- Medicition medicition = new Medicition();
|
|
|
- medicition.setMedicitionName(m);
|
|
|
- if (medicaton_ji.containsKey(m)) {
|
|
|
- String s = medicaton_ji.get(m);
|
|
|
- if (s.equals("忌用")) {
|
|
|
- medicition.setForbidden(2);
|
|
|
- } else {
|
|
|
- medicition.setForbidden(1);
|
|
|
- }
|
|
|
- } else {
|
|
|
- medicition.setForbidden(0);
|
|
|
- }
|
|
|
- if (i < 3) {
|
|
|
- medicition.setIsShow(1);
|
|
|
- i++;
|
|
|
- } else {
|
|
|
- medicition.setIsShow(0);
|
|
|
- }
|
|
|
- mes.add(medicition);
|
|
|
- }
|
|
|
- }
|
|
|
- drugs.setBigdrugsName(big);
|
|
|
- drugs.setSubdrugsName(sub);
|
|
|
- drugs.setDrugsForbidden(0);
|
|
|
- drugs.setMedicitionsList(mes);
|
|
|
- drugsList.add(drugs);
|
|
|
- }
|
|
|
+ //规则不成立,返回全部用药
|
|
|
+ if(drugsList == null || drugsList.size() == 0){
|
|
|
+ drugsList = allMedication(tx,medicaton_ji, medicatonMap, diseaseName, value,1,null);
|
|
|
}
|
|
|
Filnlly filnlly = new Filnlly();
|
|
|
//显示不良反应
|
|
|
if (diseaseType != null && 1 == diseaseType) {
|
|
|
- List<String> stringList = disUE.get(diseaseName);
|
|
|
- logger.info(diseaseName + "下面有" + stringList + "不良反应");
|
|
|
- if (stringList != null && stringList.size() > 0) {
|
|
|
- List<Indicators> indicatorsList1 = new ArrayList<>();
|
|
|
- for (String de : stringList) {
|
|
|
- Indicators indicators1 = getAdverse(ueSet, de);
|
|
|
- logger.info(disSet + "包含 " + de);
|
|
|
- indicatorsList1.add(indicators1);
|
|
|
- }
|
|
|
- filnlly.setAdverseEvent(indicatorsList1);
|
|
|
- }
|
|
|
+ List<Indicators> indicators = sideEffect(diseaseName, disUE, ueSet, crisisDetails, disSet);
|
|
|
+ filnlly.setAdverseEvent(indicators);
|
|
|
}
|
|
|
+ filnlly.setTreatCate(treatCate);
|
|
|
filnlly.setTreatment(drugsList);
|
|
|
newTret.put(diseaseName, filnlly);
|
|
|
}
|
|
@@ -1317,6 +1246,177 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private List<Drugs> allMedication(Transaction tx, Map<String, String> medicaton_ji, Map<String, List<String>> medicatonMap, String diseaseName, ArrayList value,int sign,List<String> drugslist) {
|
|
|
+ List<Drugs> drugsList = new ArrayList<Drugs>();
|
|
|
+ String query = null;
|
|
|
+ StatementResult result;
|
|
|
+ if(sign == 1){
|
|
|
+ query = propertiesUtil.getProperty("searchTreat").replace("disName", "\'" + diseaseName + "\'").replace("filds", value.toString());
|
|
|
+ }else if(sign == 2){
|
|
|
+ query = propertiesUtil.getProperty("searchRuleMedicaton").replace("disName", "\'" + diseaseName + "\'").replace("filds", value.toString()).replace("drugsList",drugslist.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ logger.info("查找诊断对应的类和药物,包括类的排序,查找语句为:\n" + query);
|
|
|
+ result = tx.run(query);
|
|
|
+ while (result.hasNext()) {
|
|
|
+ Record record = result.next();
|
|
|
+ String big = record.get("big").toString().replace("\"", "");
|
|
|
+ String sub = record.get("sub").toString().replace("\"", "");
|
|
|
+ String med = record.get("med").toString().replace("\"", "");
|
|
|
+ String ty = record.get("ty").toString().replace("\"", "");
|
|
|
+ if ("NULL".equals(ty)) {
|
|
|
+ if (medicatonMap.containsKey(big + "$" + sub)) {
|
|
|
+ List<String> ml = medicatonMap.get(big + "$" + sub);
|
|
|
+ ml.add(med);
|
|
|
+ medicatonMap.put(big + "$" + sub, ml);
|
|
|
+ } else {
|
|
|
+ List<String> ml = new ArrayList<>();
|
|
|
+ ml.add(med);
|
|
|
+ medicatonMap.put(big + "$" + sub, ml);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (medicaton_ji.containsKey(med)) {
|
|
|
+ if (medicaton_ji.get(med).equals("慎用") && ty.equals("忌用")) {
|
|
|
+ medicaton_ji.put(med, "忌用");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ medicaton_ji.put(med, ty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (medicatonMap != null && medicatonMap.size() > 0) {
|
|
|
+ for (Map.Entry<String, List<String>> fd : medicatonMap.entrySet()) {
|
|
|
+ int i = 0;
|
|
|
+ String big = "", sub = "";
|
|
|
+ String big_sub = fd.getKey();//大小类
|
|
|
+ List<String> medications = fd.getValue();//药的集合
|
|
|
+ String[] splits = big_sub.split("\\$");
|
|
|
+ Drugs drugs = new Drugs();
|
|
|
+ if (splits[0].equals(splits[1])) {
|
|
|
+ sub = "";
|
|
|
+ big = splits[0];
|
|
|
+ } else {
|
|
|
+ big = splits[0];
|
|
|
+ sub = splits[1];
|
|
|
+ }
|
|
|
+ LinkedList<Medicition> mes = new LinkedList<>();
|
|
|
+ if (medications != null && medications.size() > 0) {
|
|
|
+ for (String m : medications) {
|
|
|
+ Medicition medicition = new Medicition();
|
|
|
+ medicition.setMedicitionName(m);
|
|
|
+ if (medicaton_ji.containsKey(m)) {
|
|
|
+ String s = medicaton_ji.get(m);
|
|
|
+ if (s.equals("忌用")) {
|
|
|
+ medicition.setForbidden(2);
|
|
|
+ } else {
|
|
|
+ medicition.setForbidden(1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ medicition.setForbidden(0);
|
|
|
+ }
|
|
|
+ if (i < 3) {
|
|
|
+ medicition.setIsShow(1);
|
|
|
+ i++;
|
|
|
+ } else {
|
|
|
+ medicition.setIsShow(0);
|
|
|
+ }
|
|
|
+ mes.add(medicition);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ drugs.setBigdrugsName(big);
|
|
|
+ drugs.setSubdrugsName(sub);
|
|
|
+ drugs.setDrugsForbidden(0);
|
|
|
+ drugs.setMedicitionsList(mes);
|
|
|
+ drugsList.add(drugs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return drugsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ //不良反应set
|
|
|
+ private List<Indicators> sideEffect(String diseaseName, Map<String, List<String>> disUE, Map<String, String> ueSet, Map<String, List<CrisisDetail>> crisisDetails, Set<String> disSet) {
|
|
|
+ List<Indicators> indicatorsList1 =null;
|
|
|
+ List<String> stringList = disUE.get(diseaseName);
|
|
|
+ logger.info(diseaseName + "下面有" + stringList + "不良反应");
|
|
|
+ if (stringList != null && stringList.size() > 0) {
|
|
|
+ indicatorsList1 = new ArrayList<>();
|
|
|
+ for (String de : stringList) {
|
|
|
+ Indicators indicators1 = getAdverse(ueSet, de,crisisDetails);
|
|
|
+ logger.info(disSet + "包含 " + de);
|
|
|
+ indicatorsList1.add(indicators1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return indicatorsList1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用药规则处理
|
|
|
+ * @param diseaseName
|
|
|
+ * @param
|
|
|
+ */
|
|
|
+ private JSONObject medicationRule(Transaction tx,Map<String, String> medicaton_ji, Map<String, List<String>> medicatonMap,String diseaseName, ArrayList value){
|
|
|
+ String query;
|
|
|
+ StatementResult result;
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ TreatCate treatCate = new TreatCate();
|
|
|
+ List<Drugs> drugs = new ArrayList<>();
|
|
|
+ // TODO: 2019/11/13 开始匹配规则
|
|
|
+ query=propertiesUtil.getProperty("medicationRule").replace("filds",value.toString());
|
|
|
+ result = tx.run(query);
|
|
|
+ int i=0;
|
|
|
+ List<String> collection =null;
|
|
|
+ while (result.hasNext()) {
|
|
|
+ Record record = result.next();
|
|
|
+ int j = record.get("design").asInt();
|
|
|
+ if(j>i){
|
|
|
+ i = j;
|
|
|
+ collection = (List) record.get("collection").asList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> medictionDrugs =null;
|
|
|
+ if(collection != null){
|
|
|
+ medictionDrugs = new ArrayList<>();
|
|
|
+ for (String drugsp:collection) {
|
|
|
+ String[] splits = drugsp.replace("\"", "").split("\\+");
|
|
|
+ for (String drug:splits) {
|
|
|
+ if(medictionDrugs.contains("'"+drug+"'")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ medictionDrugs.add("'"+drug+"'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //根据类找药
|
|
|
+ try {
|
|
|
+ drugs = allMedication(tx, medicaton_ji, medicatonMap, diseaseName, value, 2, medictionDrugs);
|
|
|
+ }catch (Exception e){
|
|
|
+ drugs = null;
|
|
|
+ }
|
|
|
+ treatCate.setType(switchType(i));
|
|
|
+ treatCate.setName(collection);
|
|
|
+ jsonObject.put("drugs",drugs);
|
|
|
+ jsonObject.put("treatCate",treatCate);
|
|
|
+ return jsonObject;
|
|
|
+
|
|
|
+ }
|
|
|
+ //单、双药、胰岛素药
|
|
|
+ private String switchType(int i) {
|
|
|
+ String type;
|
|
|
+ switch (i){
|
|
|
+ case 1:
|
|
|
+ type = "单药治疗";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ type = "双药治疗";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ type = "胰岛素治疗";
|
|
|
+ break;
|
|
|
+ default:type = null;
|
|
|
+ }
|
|
|
+ return type;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 治疗方案,取每个诊断对应的filds
|
|
|
*
|
|
@@ -1586,7 +1686,7 @@ public class Neo4jAPI {
|
|
|
|
|
|
public Map<String, JSONObject> procrssMange(Map<String, Map<String, List<String>>> zong, List<String> types,Map<String, List<CrisisDetail>> crisisDetails) {
|
|
|
Map<String, JSONObject> llo = new HashMap<>();
|
|
|
- Map<String, String> crisisDetailsMap = this.processCrisisDetails(crisisDetails);
|
|
|
+ Map<String, String> crisisDetailsMap = this.processCrisisDetails(crisisDetails,"11");
|
|
|
if (types != null && types.size() > 0) {
|
|
|
for (String type : types) {
|
|
|
JSONObject big = new JSONObject();
|
|
@@ -1628,11 +1728,11 @@ public class Neo4jAPI {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 处理风险因素评估
|
|
|
+ * 处理风险因素评估或不良反应
|
|
|
* @param crisisDetails
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String,String> processCrisisDetails(Map<String, List<CrisisDetail>> crisisDetails){
|
|
|
+ public Map<String,String> processCrisisDetails(Map<String, List<CrisisDetail>> crisisDetails,String sign){
|
|
|
Map<String,String> crisisMap = new HashMap<>();
|
|
|
if(crisisDetails != null && crisisDetails.size()>0 ){
|
|
|
for (Map.Entry<String, List<CrisisDetail>> crisis:crisisDetails.entrySet()
|
|
@@ -1640,9 +1740,20 @@ public class Neo4jAPI {
|
|
|
List<CrisisDetail> value = crisis.getValue();
|
|
|
if(value!=null && value.size()>0){
|
|
|
for (CrisisDetail crisisDetail:value) {
|
|
|
- if("11".equals(crisisDetail.getTypeId())){
|
|
|
- String[] crisisSplits = crisisDetail.getRemindText().split(":");
|
|
|
+ String[] crisisSplits = crisisDetail.getRemindText().split(":");
|
|
|
+ if(sign.equals(crisisDetail.getTypeId()) && !sign.equals("6")){
|
|
|
crisisMap.put(crisisSplits[0],crisisSplits[1]);
|
|
|
+ }else if(sign.equals(crisisDetail.getTypeId()) && sign.equals("6")){//不良反应
|
|
|
+ if(crisisMap.containsKey(crisisSplits[0])){
|
|
|
+ if("轻度".equals(crisisMap.get(crisisSplits[0])) && ("重度".equals(crisisSplits[1])||"中度".equals(crisisSplits[1]) )){
|
|
|
+ crisisMap.put(crisisSplits[0],crisisSplits[1]);
|
|
|
+ }
|
|
|
+ if("中度".equals(crisisMap.get(crisisSplits[0])) && "重度".equals(crisisSplits[1])){
|
|
|
+ crisisMap.put(crisisSplits[0],crisisSplits[1]);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ crisisMap.put(crisisSplits[0],crisisSplits[1]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1801,24 +1912,39 @@ public class Neo4jAPI {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public Indicators getAdverse(Map<String,String> dis, String name) {
|
|
|
+ public Indicators getAdverse(Map<String,String> dis, String name,Map<String, List<CrisisDetail>> crisisDetails) {
|
|
|
+ Map<String, String> crisisDetailsMap = this.processCrisisDetails(crisisDetails,"6");
|
|
|
+ if(crisisDetailsMap != null && dis != null){
|
|
|
+ for (Map.Entry<String,String> d:dis.entrySet()
|
|
|
+ ) {
|
|
|
+ if(!crisisDetailsMap.containsKey(d.getKey())){
|
|
|
+ crisisDetailsMap.put(d.getKey(),d.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
String[] item={"无","可能有","轻度","中度","重度"};
|
|
|
Indicators indicators = new Indicators();
|
|
|
indicators.setName(name);
|
|
|
indicators.setControlType(2);
|
|
|
List<Detail> detailList1 = new ArrayList<>();
|
|
|
for (String it:item) {
|
|
|
+ int value = 0;
|
|
|
Detail detail = new Detail();
|
|
|
detail.setName(it);
|
|
|
- if(dis != null && dis.size()>0){
|
|
|
- if(dis.containsKey(name) && dis.get(name).equals(it)){
|
|
|
- detail.setValue(1);
|
|
|
- }else {
|
|
|
- detail.setValue(0);
|
|
|
- }
|
|
|
- }else {
|
|
|
- detail.setValue(0);
|
|
|
- }
|
|
|
+ if(crisisDetailsMap != null && crisisDetailsMap.size()>0){
|
|
|
+ if(crisisDetailsMap.containsKey(name) ){
|
|
|
+ if(it.equals(crisisDetailsMap.get(name))){
|
|
|
+ value = 1;
|
|
|
+ detail.setValue(value);
|
|
|
+ }else {
|
|
|
+ detail.setValue(value);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ detail.setValue(value);
|
|
|
+
|
|
|
+ } }else {
|
|
|
+ detail.setValue(value);
|
|
|
+ }
|
|
|
detailList1.add(detail);
|
|
|
|
|
|
}
|