|
@@ -1,5 +1,6 @@
|
|
|
package org.diagbot.graph.medicationProcess;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.diagbot.common.push.bean.CrisisDetail;
|
|
|
import org.diagbot.common.push.bean.neo4j.*;
|
|
|
import org.diagbot.pub.utils.PropertiesUtil;
|
|
@@ -57,30 +58,32 @@ public class PushTreat {
|
|
|
* @return
|
|
|
*/
|
|
|
private List<TreatDetail> getTreatmentPlan(String disName,String webDiag,String[] inputList,List<String> exculdDiagFilds,Map<String, List<CrisisDetail>> crisisDetails, Map<String, String> ueSet,Driver driver){
|
|
|
+
|
|
|
List<TreatDetail> treatmentPlanList = new ArrayList<>();
|
|
|
+ List<String> typeList = this.judgeDiseaseType(disName, driver);
|
|
|
+ String sign = typeList.size()>0? typeList.get(0):"NULL";
|
|
|
//获取全部字段
|
|
|
List<String> allFilds = this.getAllFilds(webDiag, crisisDetails, inputList, ueSet);
|
|
|
+ if("NULL".equals(sign) || "2".equals(sign)|| "3".equals(sign)){
|
|
|
+ treatmentPlanList = this.ordinaryMedicaton(disName,allFilds,driver);
|
|
|
+ }else if("1".equals(sign)){
|
|
|
+ // TODO: 2019/11/19 匹配规则用药,判断是否满足规则
|
|
|
+ treatmentPlanList= this.ruleMedicaton(disName, webDiag, allFilds, driver);
|
|
|
|
|
|
- // TODO: 2019/11/19 匹配规则用药,判断是否满足规则
|
|
|
- List<TreatDetail> treatDetailList_rule = this.ruleMedicaton(disName, webDiag, allFilds, driver);
|
|
|
- String name = treatDetailList_rule.get(0).getTitle().substring(0, treatDetailList_rule.get(0).getTitle().indexOf("治疗方案"));
|
|
|
- if(treatDetailList_rule.size() == 1 && disName.equals(name)){
|
|
|
// TODO: 2019/11/28 匹配主症+其他+其他
|
|
|
-// List<TreatDetail> treatmentPlanList_otherrule = this.otherRuleMedicaton(disName, exculdDiagFilds, allFilds, driver);
|
|
|
-// treatmentPlanList = treatmentPlanList_otherrule;
|
|
|
+ List<TreatDetail> treatmentPlanList_otherrule = this.otherRuleMedicaton(disName, exculdDiagFilds, allFilds, driver);
|
|
|
+ treatmentPlanList.addAll(treatmentPlanList_otherrule);
|
|
|
|
|
|
- }else if(treatDetailList_rule.size() == 1 && !disName.equals(name)){
|
|
|
- treatmentPlanList =treatDetailList_rule;
|
|
|
- }else {
|
|
|
- treatmentPlanList = treatDetailList_rule;
|
|
|
- }
|
|
|
- // TODO: 2019/11/28 匹配主症+其他+其他
|
|
|
- List<TreatDetail> treatmentPlanList_otherrule = this.otherRuleMedicaton(disName, exculdDiagFilds, allFilds, driver);
|
|
|
- treatmentPlanList.addAll(treatmentPlanList_otherrule);
|
|
|
- // TODO: 2019/11/19 规则不满足的情况下,返回主诊断的用药情况
|
|
|
- if(treatmentPlanList.size() == 0){
|
|
|
- treatmentPlanList = this.ordinaryMedicaton(disName,allFilds,driver);
|
|
|
+ // TODO: 2019/12/4 合并规则,多个相同的治疗合并成一个
|
|
|
+ this.mergerRules(treatmentPlanList);
|
|
|
+
|
|
|
+ // TODO: 2019/11/19 规则不满足的情况下,返回主诊断的用药情况
|
|
|
+ if(treatmentPlanList.size() == 0){
|
|
|
+ treatmentPlanList = this.ordinaryMedicaton(disName,allFilds,driver);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
// TODO: 2019/11/21 处理合并症 例如高热
|
|
|
List<TreatDetail> treatDetailList = this.complicationMedicaton(inputList, driver, allFilds);
|
|
|
treatmentPlanList.addAll(treatDetailList);
|
|
@@ -88,12 +91,239 @@ public class PushTreat {
|
|
|
return treatmentPlanList;
|
|
|
}
|
|
|
|
|
|
+ private List<String> judgeDiseaseType(String disName, Driver driver){
|
|
|
+ List<String> signList = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotEmpty(disName)){
|
|
|
+ Session session = driver.session(AccessMode.WRITE);
|
|
|
+ session.writeTransaction(new TransactionWork<Integer>() {
|
|
|
+ @Override
|
|
|
+ public Integer execute(Transaction tx) {
|
|
|
+ String query = propertiesUtil_treat.getProperty("judgeDiseaseType").replace("disName",disName.toString());
|
|
|
+ logger.info("规则用药,查询语句为:\n" + query);
|
|
|
+ StatementResult result = tx.run(query);
|
|
|
+ while (result.hasNext()) {
|
|
|
+ Record next = result.next();
|
|
|
+ String sign = next.get("design").toString();
|
|
|
+ signList.add(sign);
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ closeSession(session);
|
|
|
+ }
|
|
|
+ return signList;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 合并规则
|
|
|
+ * @param treatmentPlanList
|
|
|
+ */
|
|
|
+ private void mergerRules(List<TreatDetail> treatmentPlanList) {
|
|
|
+ int i = 0;
|
|
|
+ Map<List<String>,LinkedHashMap<String,List<Drugs>>> fi = new HashMap<>();
|
|
|
+ Map<List<String>,LinkedHashMap<String,List<Drugs>>> fi_second = new HashMap<>();
|
|
|
+ if(treatmentPlanList.size()>0){
|
|
|
+ for (TreatDetail td:treatmentPlanList) {
|
|
|
+ List<String> disList = new ArrayList<>();
|
|
|
+ String title = td.getTitle();
|
|
|
+ String startTitle, subTitle = "";
|
|
|
+ if(title.contains("及其")){
|
|
|
+ startTitle = title.substring(0,title.indexOf("及其"));
|
|
|
+ subTitle = title.substring(startTitle.length()+2,title.length());
|
|
|
+ subTitle = subTitle.substring(0,subTitle.indexOf("治疗方案"));
|
|
|
+ disList.add(startTitle);
|
|
|
+ disList.add(subTitle);
|
|
|
+ }else {
|
|
|
+ startTitle = title.substring(0,title.indexOf("治疗方案"));
|
|
|
+ disList.add(startTitle);
|
|
|
+ }
|
|
|
+ LinkedHashMap<String,List<Drugs>> kk = new LinkedHashMap<>();
|
|
|
+ List<MeditionDetail> meditionDetails = td.getMeditionDetails();
|
|
|
+ String description ="";
|
|
|
+ for (MeditionDetail m:meditionDetails) {
|
|
|
+ description = m.getDescription();
|
|
|
+ List<Drugs> treatment = m.getTreatment();
|
|
|
+ kk.put(description,treatment);
|
|
|
+ }
|
|
|
+ if(fi.containsKey(disList)){
|
|
|
+ LinkedHashMap<String, List<Drugs>> jj = fi.get(disList);
|
|
|
+ Map.Entry<String, List<Drugs>> next = jj.entrySet().iterator().next();
|
|
|
+ String key = next.getKey();
|
|
|
+ String key1 = meditionDetails.get(0).getDescription();
|
|
|
+ if(!key.equals(key1)){
|
|
|
+ int type = getType(key.split(":")[0]);//原来的
|
|
|
+ int type1 = getType(key1.split(":")[0]);//新来的
|
|
|
+ if(type>type1){
|
|
|
+ continue;
|
|
|
+ }else if(type<type1){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fi.put(disList,kk);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(fi.size()>0){
|
|
|
+ for (Map.Entry<List<String>,LinkedHashMap<String,List<Drugs>>> d:fi.entrySet()) { //遍历原始的
|
|
|
+ List<String> key_dis = d.getKey(); // [糖尿病,糖尿病肾病]
|
|
|
+ String s = key_dis.get(0);//糖尿病
|
|
|
+ List<String> otherDis_1 = new ArrayList<>();
|
|
|
+ if(key_dis.size()>1){
|
|
|
+ for(int j = 1;j<key_dis.size();j++){
|
|
|
+ otherDis_1.add(key_dis.get(j));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //otherDis_1为[糖尿病肾病]
|
|
|
+ LinkedHashMap<String, List<Drugs>> dValue = d.getValue();
|
|
|
+ //"单药治疗:双胍类、格列奈类、SGLT-2抑制剂、磺脲类、DDP-4抑制剂" -> " size = 5"
|
|
|
+ //"糖尿病肾病" -> " size = 1"
|
|
|
+ Map.Entry<String, List<Drugs>> first = dValue.entrySet().iterator().next();//"单药治疗:双胍类、格列奈类、SGLT-2抑制剂、磺脲类、DDP-4抑制剂" -> " size = 5"
|
|
|
+ String key_first = first.getKey();//单药治疗:双胍类、格列奈类、SGLT-2抑制剂、磺脲类、DDP-4抑制剂
|
|
|
+ if(fi_second.keySet().size() == 0){
|
|
|
+ fi_second.put(key_dis,dValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map.Entry<List<String>,LinkedHashMap<String,List<Drugs>>> d_sec:fi_second.entrySet()) {
|
|
|
+ List<String> key = d_sec.getKey();// [1型糖尿病,糖尿病肾病]
|
|
|
+ LinkedHashMap<String, List<Drugs>> value = d_sec.getValue();
|
|
|
+ Map.Entry<String, List<Drugs>> next = value.entrySet().iterator().next();
|
|
|
+ String key_next = next.getKey();//"胰岛素治疗:中长效胰岛素、预混胰岛素"
|
|
|
+ String s_next = key.get(0);//1型糖尿病
|
|
|
+ List<String> otherDis = new ArrayList<>();
|
|
|
+ if(key.size()>1){
|
|
|
+ for(int j = 1;j<key.size();j++){
|
|
|
+ otherDis.add(key.get(j));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //otherDis为[糖尿病肾病]
|
|
|
+ if(s_next.equals(s)){ //1型糖尿病 == 1型糖尿病
|
|
|
+ if(key_first.equals(key_next)){ //"胰岛素治疗:中长效胰岛素、预混胰岛素" == "胰岛素治疗:中长效胰岛素、预混胰岛素"
|
|
|
+ if(otherDis_1.size()>0){
|
|
|
+ for (String dis:otherDis_1) {
|
|
|
+ if(!otherDis.contains(dis)){
|
|
|
+ otherDis.add(dis);
|
|
|
+ List<Drugs> drugsList = dValue.get(dis);
|
|
|
+ value.put(dis,drugsList);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fi_second.remove(key);
|
|
|
+ otherDis.add(0,s_next);
|
|
|
+ fi_second.put(otherDis,value);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ String[] split = key_first.split(":");
|
|
|
+ String[] split1 = key_next.split(":");
|
|
|
+ int type_first = getType(split[0]);
|
|
|
+ int type_next = getType(split1[0]);
|
|
|
+ if(type_first>type_next){
|
|
|
+ value.remove(key_next);
|
|
|
+ LinkedHashMap<String, List<Drugs>> value_new = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, List<Drugs>> value_new2 = new LinkedHashMap<>();
|
|
|
+ if(value.size()>0){
|
|
|
+ for (Map.Entry<String, List<Drugs>> dg:value.entrySet()
|
|
|
+ ) {
|
|
|
+ value_new.put(dg.getKey(),dg.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ value_new2.put(key_first,first.getValue());
|
|
|
+ if(value_new.size()>0){
|
|
|
+ for (Map.Entry<String, List<Drugs>> dg:value_new.entrySet()
|
|
|
+ ) {
|
|
|
+ value_new2.put(dg.getKey(),dg.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(otherDis_1.size()>0){
|
|
|
+ for (String dis:otherDis_1) {
|
|
|
+ if(!otherDis.contains(dis)){
|
|
|
+ otherDis.add(dis);
|
|
|
+ List<Drugs> drugsList = dValue.get(dis);
|
|
|
+ value_new2.put(dis,drugsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fi_second.remove(key);
|
|
|
+ otherDis.add(0,s_next);
|
|
|
+ fi_second.put(otherDis,value_new2);
|
|
|
+ }else if(type_first == type_next) {
|
|
|
+ System.out.println("hh");
|
|
|
+ fi_second.put(key_dis,dValue);
|
|
|
+ } else {
|
|
|
+ if(otherDis_1.size()>0){
|
|
|
+ for (String dis:otherDis_1) {
|
|
|
+ if(!otherDis.contains(dis)){
|
|
|
+ otherDis.add(dis);
|
|
|
+ List<Drugs> drugsList = dValue.get(dis);
|
|
|
+ value.put(dis,drugsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fi_second.remove(key);
|
|
|
+ otherDis.add(0,s_next);
|
|
|
+ fi_second.put(otherDis,value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(fi_second.size()>0){
|
|
|
+ treatmentPlanList.clear();
|
|
|
+ for (Map.Entry<List<String>,LinkedHashMap<String,List<Drugs>>> jfd:fi_second.entrySet()
|
|
|
+ ) {
|
|
|
+ TreatDetail treatDetail = new TreatDetail();
|
|
|
+ List<String> key = jfd.getKey();
|
|
|
+ LinkedHashMap<String, List<Drugs>> value = jfd.getValue();
|
|
|
+ String title="";
|
|
|
+ title = key.toString().replace("[","").replace("]","")+"治疗方案";
|
|
|
+ List<MeditionDetail> dda = new ArrayList<>();
|
|
|
+ if(value.size()>0){
|
|
|
+ for (Map.Entry<String, List<Drugs>> ds:value.entrySet()) {
|
|
|
+ String desc = ds.getKey();
|
|
|
+ List<Drugs> value1 = ds.getValue();
|
|
|
+ MeditionDetail meditionDetail = new MeditionDetail();
|
|
|
+ meditionDetail.setDescription(desc);
|
|
|
+ meditionDetail.setTreatment(value1);
|
|
|
+ dda.add(meditionDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ treatDetail.setTitle(title);
|
|
|
+ treatDetail.setMeditionDetails(dda);
|
|
|
+ treatmentPlanList.add(treatDetail);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ private int getType(String type){
|
|
|
+ int i = 0;
|
|
|
+ if(type.equals("单药治疗")){
|
|
|
+ i = 1;
|
|
|
+ }else if(type.equals("双药治疗")){
|
|
|
+ i = 2;
|
|
|
+ }else if(type.equals("胰岛素治疗")){
|
|
|
+ i = 3;
|
|
|
+ }
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+
|
|
|
private List<TreatDetail> complicationMedicaton(String[] inputList,Driver driver,List<String> allFilds){
|
|
|
List<TreatDetail> disTreatDetailList = new ArrayList<>();
|
|
|
Map<String,Integer> conditionDesign = new HashMap<>();
|
|
|
Map<String,Map<String,Object>> disDrugs = new HashMap<>();
|
|
|
Map<String, String> medicaton_ji = new HashMap<>();
|
|
|
Map<String, List<String>> medicatonMap = new HashMap<>();
|
|
|
+ Map<String,List<String>> condiTypedis = new HashMap<>();
|
|
|
Set<String> disSet = new HashSet<>();
|
|
|
List<String> filds = new ArrayList<>();
|
|
|
if(inputList.length>0){
|
|
@@ -112,14 +342,14 @@ public class PushTreat {
|
|
|
logger.info("规则用药,查询语句为:\n" + query);
|
|
|
StatementResult result = tx.run(query);
|
|
|
while (result.hasNext()) {
|
|
|
- searchDrugs(result, conditionDesign, disDrugs,disSet);
|
|
|
+ searchDrugs(condiTypedis,result, conditionDesign, disDrugs,disSet);
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
});
|
|
|
closeSession(session);
|
|
|
+ addColl(condiTypedis,disDrugs);
|
|
|
disTreatDetailList = this.processMedication_he(disDrugs, conditionDesign, allFilds, driver);
|
|
|
-
|
|
|
return disTreatDetailList;
|
|
|
}
|
|
|
/**
|
|
@@ -134,7 +364,7 @@ public class PushTreat {
|
|
|
|
|
|
List<Drugs> dList = new ArrayList<>();
|
|
|
Map<String, String> medicaton_ji = new HashMap<>();
|
|
|
- Map<String, List<String>> medicatonMap = new HashMap<>();
|
|
|
+ Map<String, List<String>> medicatonMap = new LinkedHashMap<>();
|
|
|
|
|
|
Session session = driver.session(AccessMode.WRITE);
|
|
|
session.writeTransaction(new TransactionWork<Integer>() {
|
|
@@ -169,6 +399,7 @@ public class PushTreat {
|
|
|
private List<TreatDetail> otherRuleMedicaton(String disName,List<String> excludeDiagFilds,List<String> allFilds,Driver driver){
|
|
|
Map<String,Integer> conditionDesign = new HashMap<>();
|
|
|
Map<String,Map<String,Object>> disDrugs = new HashMap<>();
|
|
|
+ Map<String,List<String>> condiTypedis = new HashMap<>();
|
|
|
Set<String> disSet = new HashSet<>();
|
|
|
excludeDiagFilds.add("'"+disName+"'");
|
|
|
Session session = driver.session(AccessMode.WRITE);
|
|
@@ -179,28 +410,23 @@ public class PushTreat {
|
|
|
logger.info("规则用药,查询语句为:\n" + query);
|
|
|
StatementResult result = tx.run(query);
|
|
|
while (result.hasNext()) {
|
|
|
- searchDrugs(result, conditionDesign, disDrugs,disSet);
|
|
|
+ searchDrugs(condiTypedis,result, conditionDesign, disDrugs,disSet);
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
});
|
|
|
closeSession(session);
|
|
|
+ addColl(condiTypedis,disDrugs);
|
|
|
List<TreatDetail> treatDetailList =new ArrayList<>();
|
|
|
-// if(!disSet.contains(disName)){
|
|
|
-// //规则不匹配,返回主诊断治疗方案
|
|
|
-// treatDetailList = this.ordinaryMedicaton(disName,allFilds,driver);
|
|
|
-// }else {
|
|
|
- treatDetailList = this.processMedication_otherrule(disName,disDrugs, conditionDesign, allFilds, driver);
|
|
|
-
|
|
|
-// }
|
|
|
-
|
|
|
+ treatDetailList = this.processMedication_otherrule(disName,disDrugs, conditionDesign, allFilds, driver);
|
|
|
return treatDetailList;
|
|
|
}
|
|
|
|
|
|
//匹配规则,推荐用药
|
|
|
private List<TreatDetail> ruleMedicaton(String disName,String webDiag,List<String> allFilds,Driver driver){
|
|
|
Map<String,Integer> conditionDesign = new HashMap<>();
|
|
|
- Map<String,Map<String,Object>> disDrugs = new HashMap<>();
|
|
|
+ Map<String,Map<String,Object>> disDrugs = new LinkedHashMap<>();
|
|
|
+ Map<String,List<String>> condiTypedis = new HashMap<>();
|
|
|
Set<String> disSet = new HashSet<>();
|
|
|
List<String> webDiagList = processWebDiag(disName,webDiag);
|
|
|
Session session = driver.session(AccessMode.WRITE);
|
|
@@ -208,30 +434,53 @@ public class PushTreat {
|
|
|
@Override
|
|
|
public Integer execute(Transaction tx) {
|
|
|
String query = propertiesUtil_treat.getProperty("medicationRule").replace("filds",webDiagList.toString());
|
|
|
-// String query = propertiesUtil_treat.getProperty("medicationRule").replace("filds",allFilds.toString());
|
|
|
logger.info("规则用药,查询语句为:\n" + query);
|
|
|
StatementResult result = tx.run(query);
|
|
|
while (result.hasNext()) {
|
|
|
- searchDrugs(result, conditionDesign, disDrugs,disSet);
|
|
|
+ searchDrugs(condiTypedis,result, conditionDesign, disDrugs,disSet);
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
});
|
|
|
closeSession(session);
|
|
|
+ addColl(condiTypedis,disDrugs);
|
|
|
List<TreatDetail> treatDetailList =new ArrayList<>();
|
|
|
- if(!disSet.contains(disName)){
|
|
|
- //规则不匹配,返回主诊断治疗方案
|
|
|
- treatDetailList = this.ordinaryMedicaton(disName,allFilds,driver);
|
|
|
- }else {
|
|
|
- treatDetailList = this.processMedication(disName,disDrugs, conditionDesign, allFilds, driver);
|
|
|
+ treatDetailList = this.processMedication(disName,disDrugs, conditionDesign, allFilds, driver);
|
|
|
+ return treatDetailList;
|
|
|
+ }
|
|
|
+ private void addColl(Map<String,List<String>> condiTypedis,Map<String,Map<String,Object>> disDrugs){
|
|
|
+ if(condiTypedis!= null &&condiTypedis.size()>0){
|
|
|
+ for (Map.Entry<String,List<String>> ctd:condiTypedis.entrySet()) {
|
|
|
+ String name = ctd.getKey().split("&")[1];
|
|
|
+ String type = ctd.getKey().split("&")[0];//主症或并发症
|
|
|
+ if(disDrugs.containsKey(name)){
|
|
|
|
|
|
+ Map<String, Object> objectMap = disDrugs.get(name);
|
|
|
+ List<String> cateList = (List<String>) objectMap.get("cate");
|
|
|
+ int index = cateList.indexOf(type);
|
|
|
+ if(objectMap.containsKey("coll")){
|
|
|
+ List<Object> list = (List<Object>) objectMap.get("coll");
|
|
|
+ List<String> v = new ArrayList<>();
|
|
|
+ v.addAll(ctd.getValue());
|
|
|
+ list.add(index,v);
|
|
|
+ objectMap.put("coll",list);
|
|
|
+ }else {
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ List<String> v = new ArrayList<>();
|
|
|
+ v.addAll(ctd.getValue());
|
|
|
+ list.add(v);
|
|
|
+ objectMap.put("coll",list);
|
|
|
+ }
|
|
|
+ disDrugs.put(name,objectMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- return treatDetailList;
|
|
|
- }
|
|
|
|
|
|
- private void searchDrugs(StatementResult result, Map<String, Integer> conditionDesign, Map<String, Map<String, Object>> disDrugs,Set<String> disSet) {
|
|
|
- List<String> collection =null;
|
|
|
+ }
|
|
|
+ private void searchDrugs(Map<String,List<String>> condiTypedis,StatementResult result, Map<String, Integer> conditionDesign, Map<String, Map<String, Object>> disDrugs,Set<String> disSet) {
|
|
|
+ String collection =null;
|
|
|
int i=0;
|
|
|
Record next = result.next();
|
|
|
String name = next.get("name").toString().replace("\"", "");
|
|
@@ -242,38 +491,45 @@ public class PushTreat {
|
|
|
disSet.add(disName);
|
|
|
if(design >= i){
|
|
|
i = design;
|
|
|
- collection = (List) next.get("collection").asList();
|
|
|
+ collection = next.get("collection").toString().replace("\"", "");
|
|
|
}
|
|
|
conditionDesign.put(name,i);
|
|
|
+ String ncd =category+"&"+ name + "&" + disName;
|
|
|
+ if(condiTypedis.containsKey(ncd)){
|
|
|
+ List<String> list = condiTypedis.get(ncd);
|
|
|
+ list.add(collection);
|
|
|
+ condiTypedis.put(ncd,list);
|
|
|
+ }else {
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ list.add(collection);
|
|
|
+ condiTypedis.put(ncd,list);
|
|
|
+ }
|
|
|
+
|
|
|
if(!disDrugs.containsKey(name)){
|
|
|
Map<String, Object> designHashMap = new HashMap<>();
|
|
|
- List<String> pList = new ArrayList<>();
|
|
|
List<String> cateList = new ArrayList<>();
|
|
|
List<String> disList = new ArrayList<>();
|
|
|
- List<Object> collList = new ArrayList<>();
|
|
|
- pList.add(p);
|
|
|
- designHashMap.put("p",pList);
|
|
|
- cateList.add(category);
|
|
|
+ if(!cateList.contains(category)){
|
|
|
+ cateList.add(category);
|
|
|
+ }
|
|
|
designHashMap.put("cate",cateList);
|
|
|
- disList.add(disName);
|
|
|
+ if(!disList.contains(disName)){
|
|
|
+ disList.add(disName);
|
|
|
+ }
|
|
|
designHashMap.put("dis",disList);
|
|
|
- collList.add(collection);
|
|
|
- designHashMap.put("coll",collList);
|
|
|
disDrugs.put(name,designHashMap);
|
|
|
}else {
|
|
|
Map<String, Object> objectMap = disDrugs.get(name);
|
|
|
- List<String> p1 = (List<String>)objectMap.get("p");
|
|
|
- p1.add(p);
|
|
|
- objectMap.put("p",p1);
|
|
|
List<String> cate1 = (List<String>)objectMap.get("cate");
|
|
|
- cate1.add(category);
|
|
|
+ if(!cate1.contains(category)){
|
|
|
+ cate1.add(category);
|
|
|
+ }
|
|
|
objectMap.put("cate",cate1);
|
|
|
List<String> dis1 = (List<String>)objectMap.get("dis");
|
|
|
- dis1.add(disName);
|
|
|
+ if(!dis1.contains(disName)){
|
|
|
+ dis1.add(disName);
|
|
|
+ }
|
|
|
objectMap.put("dis",dis1);
|
|
|
- List<Object> coll1 = (List<Object>)objectMap.get("coll");
|
|
|
- coll1.add(collection);
|
|
|
- objectMap.put("coll",coll1);
|
|
|
disDrugs.put(name,objectMap);
|
|
|
}
|
|
|
}
|
|
@@ -333,7 +589,8 @@ public class PushTreat {
|
|
|
if(disDrugs != null && disDrugs.size()>0){
|
|
|
for (Map.Entry<String,Map<String,Object>> ds:disDrugs.entrySet()) {
|
|
|
String key = ds.getKey();
|
|
|
- if(Arrays.asList(key.split("\\+")).contains(disName)){
|
|
|
+ List<String> asList = Arrays.asList(key.split("\\+"));
|
|
|
+ if(asList.contains(disName)){
|
|
|
Map<String, Object> values = ds.getValue();
|
|
|
List<String> cateList = (List<String>) values.get("cate");
|
|
|
List<String> disList = (List<String>)values.get("dis");
|
|
@@ -359,6 +616,46 @@ public class PushTreat {
|
|
|
|
|
|
treatDetailList.add(treatDetail);
|
|
|
}
|
|
|
+ if(asList.size()>2 && cateList.contains("并发症")){
|
|
|
+ TreatDetail treatDetail = new TreatDetail();
|
|
|
+ List<MeditionDetail> meditionDetails = new ArrayList<>();
|
|
|
+ int main = cateList.indexOf("主症");
|
|
|
+ String mainDis = disList.get(main);
|
|
|
+ List<String> dds= new ArrayList<>();
|
|
|
+ for(String s:disList){
|
|
|
+ if(!s.equals(mainDis)){
|
|
|
+ dds.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ treatDetail.setTitle(mainDis+"及其"+String.join("、",dds)+"治疗方案");//糖尿病及其2型糖尿病治疗方案
|
|
|
+ Integer da = conditionDesign.get(key);
|
|
|
+ String s = switchType(da);
|
|
|
+ MeditionDetail meditionDetail_main = new MeditionDetail();//主诊断的
|
|
|
+ List<String> o = (List<String>)collList.get(main);
|
|
|
+ List<String> yinhao = yinhao(o);
|
|
|
+ //根据类找药
|
|
|
+ List<Drugs> drugs = searchMedication(yinhao,allFilds,driver);
|
|
|
+ meditionDetail_main.setDescription(s+":"+String.join("、",o));//单药治疗:双胍类
|
|
|
+ meditionDetail_main.setTreatment(drugs);
|
|
|
+ meditionDetails.add(meditionDetail_main);
|
|
|
+
|
|
|
+ //并发症用药
|
|
|
+ for (String dis:dds) {
|
|
|
+ MeditionDetail meditionDetail_bing = new MeditionDetail();//并发症的
|
|
|
+ int i = disList.indexOf(dis);
|
|
|
+ List<String> ol = (List<String>)collList.get(i);
|
|
|
+ List<String> yinhaol = yinhao(ol);
|
|
|
+ List<Drugs> drugs1 = searchMedication(yinhaol,allFilds,driver);
|
|
|
+ meditionDetail_bing.setDescription(dis);//单药治疗:双胍类
|
|
|
+ meditionDetail_bing.setTreatment(drugs1);
|
|
|
+ meditionDetails.add(meditionDetail_bing);
|
|
|
+ }
|
|
|
+
|
|
|
+ treatDetail.setMeditionDetails(meditionDetails);
|
|
|
+
|
|
|
+ treatDetailList.add(treatDetail);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -446,7 +743,7 @@ public class PushTreat {
|
|
|
private List<Drugs> searchMedication(List<String> drugs,List<String> allFilds,Driver driver){
|
|
|
List<Drugs> dList = new ArrayList<>();
|
|
|
Map<String, String> medicaton_ji = new HashMap<>();
|
|
|
- Map<String, List<String>> medicatonMap = new HashMap<>();
|
|
|
+ Map<String, List<String>> medicatonMap = new LinkedHashMap<>();
|
|
|
|
|
|
Session session = driver.session(AccessMode.WRITE);
|
|
|
session.writeTransaction(new TransactionWork<Integer>() {
|