|
@@ -26,7 +26,7 @@ public class PushTreat {
|
|
|
* @param crisisDetails 规则返回结果
|
|
|
* @return
|
|
|
*/
|
|
|
- public Treat processTreat(String disName,String webDiag,Integer diseaseType,Driver driver,String[] keys,Map<String, List<CrisisDetail>> crisisDetails){
|
|
|
+ public Treat processTreat(String disName,String webDiag,Integer diseaseType,Driver driver,String[] keys,List<String> exculdDiagFilds,Map<String, List<CrisisDetail>> crisisDetails){
|
|
|
Treat treat =new Treat();
|
|
|
|
|
|
// TODO: 2019/11/20
|
|
@@ -42,7 +42,7 @@ public class PushTreat {
|
|
|
|
|
|
// TODO: 2019/11/20
|
|
|
//具体用药
|
|
|
- List<TreatDetail> treatmentPlan = this.getTreatmentPlan(disName,webDiag, keys, crisisDetails,ueSet,driver);
|
|
|
+ List<TreatDetail> treatmentPlan = this.getTreatmentPlan(disName,webDiag, keys,exculdDiagFilds, crisisDetails,ueSet,driver);
|
|
|
treat.setTreatmentPlan(treatmentPlan);
|
|
|
|
|
|
|
|
@@ -56,21 +56,36 @@ public class PushTreat {
|
|
|
* @param crisisDetails 规则结果
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<TreatDetail> getTreatmentPlan(String disName,String webDiag,String[] inputList,Map<String, List<CrisisDetail>> crisisDetails, Map<String, String> ueSet,Driver driver){
|
|
|
+ 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> allFilds = this.getAllFilds(webDiag, crisisDetails, inputList, ueSet);
|
|
|
+
|
|
|
// TODO: 2019/11/19 匹配规则用药,判断是否满足规则
|
|
|
- treatmentPlanList = this.ruleMedicaton(disName,webDiag,allFilds, driver);
|
|
|
+ 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;
|
|
|
+
|
|
|
+ }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/11/21 处理合并症 例如高热
|
|
|
List<TreatDetail> treatDetailList = this.complicationMedicaton(inputList, driver, allFilds);
|
|
|
- treatDetailList.addAll(treatmentPlanList);
|
|
|
+ treatmentPlanList.addAll(treatDetailList);
|
|
|
|
|
|
- return treatDetailList;
|
|
|
+ return treatmentPlanList;
|
|
|
}
|
|
|
|
|
|
private List<TreatDetail> complicationMedicaton(String[] inputList,Driver driver,List<String> allFilds){
|
|
@@ -79,6 +94,7 @@ public class PushTreat {
|
|
|
Map<String,Map<String,Object>> disDrugs = new HashMap<>();
|
|
|
Map<String, String> medicaton_ji = new HashMap<>();
|
|
|
Map<String, List<String>> medicatonMap = new HashMap<>();
|
|
|
+ Set<String> disSet = new HashSet<>();
|
|
|
List<String> filds = new ArrayList<>();
|
|
|
if(inputList.length>0){
|
|
|
for (String fild:inputList) {
|
|
@@ -96,7 +112,7 @@ public class PushTreat {
|
|
|
logger.info("规则用药,查询语句为:\n" + query);
|
|
|
StatementResult result = tx.run(query);
|
|
|
while (result.hasNext()) {
|
|
|
- searchDrugs(result, conditionDesign, disDrugs);
|
|
|
+ searchDrugs(result, conditionDesign, disDrugs,disSet);
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
@@ -149,30 +165,72 @@ public class PushTreat {
|
|
|
disTreatDetailList.add(treatDetail);
|
|
|
return disTreatDetailList;
|
|
|
}
|
|
|
+ //匹配规则,主症+其他+其他
|
|
|
+ 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<>();
|
|
|
+ Set<String> disSet = new HashSet<>();
|
|
|
+ excludeDiagFilds.add("'"+disName+"'");
|
|
|
+ Session session = driver.session(AccessMode.WRITE);
|
|
|
+ session.writeTransaction(new TransactionWork<Integer>() {
|
|
|
+ @Override
|
|
|
+ public Integer execute(Transaction tx) {
|
|
|
+ String query = propertiesUtil_treat.getProperty("medicationRule").replace("filds",excludeDiagFilds.toString());
|
|
|
+ logger.info("规则用药,查询语句为:\n" + query);
|
|
|
+ StatementResult result = tx.run(query);
|
|
|
+ while (result.hasNext()) {
|
|
|
+ searchDrugs(result, conditionDesign, disDrugs,disSet);
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ closeSession(session);
|
|
|
+ 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);
|
|
|
+
|
|
|
+// }
|
|
|
+
|
|
|
+ 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<>();
|
|
|
+ Set<String> disSet = new HashSet<>();
|
|
|
List<String> webDiagList = processWebDiag(disName,webDiag);
|
|
|
Session session = driver.session(AccessMode.WRITE);
|
|
|
session.writeTransaction(new TransactionWork<Integer>() {
|
|
|
@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);
|
|
|
+ searchDrugs(result, conditionDesign, disDrugs,disSet);
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
});
|
|
|
closeSession(session);
|
|
|
- List<TreatDetail> treatDetailList = this.processMedication(disDrugs, conditionDesign, allFilds, driver);
|
|
|
+ List<TreatDetail> treatDetailList =new ArrayList<>();
|
|
|
+ if(!disSet.contains(disName)){
|
|
|
+ //规则不匹配,返回主诊断治疗方案
|
|
|
+ treatDetailList = this.ordinaryMedicaton(disName,allFilds,driver);
|
|
|
+ }else {
|
|
|
+ treatDetailList = this.processMedication(disName,disDrugs, conditionDesign, allFilds, driver);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return treatDetailList;
|
|
|
}
|
|
|
|
|
|
- private void searchDrugs(StatementResult result, Map<String, Integer> conditionDesign, Map<String, Map<String, Object>> disDrugs) {
|
|
|
+ private void searchDrugs(StatementResult result, Map<String, Integer> conditionDesign, Map<String, Map<String, Object>> disDrugs,Set<String> disSet) {
|
|
|
List<String> collection =null;
|
|
|
int i=0;
|
|
|
Record next = result.next();
|
|
@@ -181,6 +239,7 @@ public class PushTreat {
|
|
|
String p = next.get("p").toString();
|
|
|
String category = next.get("category").toString().replace("\"","");
|
|
|
String disName = next.get("disName").toString().replace("\"","");
|
|
|
+ disSet.add(disName);
|
|
|
if(design >= i){
|
|
|
i = design;
|
|
|
collection = (List) next.get("collection").asList();
|
|
@@ -268,58 +327,116 @@ public class PushTreat {
|
|
|
}
|
|
|
return treatDetailList;
|
|
|
}
|
|
|
-
|
|
|
- private List<TreatDetail> processMedication(Map<String,Map<String,Object>> disDrugs,Map<String,Integer> conditionDesign,List<String> allFilds,Driver driver){
|
|
|
+ private List<TreatDetail> processMedication_otherrule(String disName,Map<String,Map<String,Object>> disDrugs,Map<String,Integer> conditionDesign,List<String> allFilds,Driver driver){
|
|
|
List<TreatDetail> treatDetailList = new ArrayList<>();
|
|
|
|
|
|
if(disDrugs != null && disDrugs.size()>0){
|
|
|
for (Map.Entry<String,Map<String,Object>> ds:disDrugs.entrySet()) {
|
|
|
String key = ds.getKey();
|
|
|
- Map<String, Object> values = ds.getValue();
|
|
|
- List<String> cateList = (List<String>) values.get("cate");
|
|
|
- List<String> disList = (List<String>)values.get("dis");
|
|
|
- List<Object> collList = (List<Object>)values.get("coll");
|
|
|
- if(cateList.contains("主症") && 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);
|
|
|
+ if(Arrays.asList(key.split("\\+")).contains(disName)){
|
|
|
+ Map<String, Object> values = ds.getValue();
|
|
|
+ List<String> cateList = (List<String>) values.get("cate");
|
|
|
+ List<String> disList = (List<String>)values.get("dis");
|
|
|
+ List<Object> collList = (List<Object>)values.get("coll");
|
|
|
+ if(cateList.size()==1 && cateList.contains("主症")){
|
|
|
+
|
|
|
+ TreatDetail treatDetail = new TreatDetail();
|
|
|
+ List<MeditionDetail> meditionDetails = new ArrayList<>();
|
|
|
+ int main = cateList.indexOf("主症");
|
|
|
+ String mainDis = disList.get(main);
|
|
|
+ treatDetail.setTitle(mainDis+"治疗方案");//糖尿病及其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);
|
|
|
+ treatDetail.setMeditionDetails(meditionDetails);
|
|
|
+
|
|
|
+ treatDetailList.add(treatDetail);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return treatDetailList;
|
|
|
+ }
|
|
|
+ private List<TreatDetail> processMedication(String disName,Map<String,Map<String,Object>> disDrugs,Map<String,Integer> conditionDesign,List<String> allFilds,Driver driver){
|
|
|
+ List<TreatDetail> treatDetailList = new ArrayList<>();
|
|
|
|
|
|
+ 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)){
|
|
|
+ Map<String, Object> values = ds.getValue();
|
|
|
+ List<String> cateList = (List<String>) values.get("cate");
|
|
|
+ List<String> disList = (List<String>)values.get("dis");
|
|
|
+ List<Object> collList = (List<Object>)values.get("coll");
|
|
|
+ if(cateList.contains("主症") && 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);
|
|
|
+ treatDetail.setMeditionDetails(meditionDetails);
|
|
|
|
|
|
- treatDetailList.add(treatDetail);
|
|
|
+ treatDetailList.add(treatDetail);
|
|
|
|
|
|
+ }
|
|
|
+ if(cateList.size()==1 && cateList.contains("主症")){
|
|
|
+
|
|
|
+ TreatDetail treatDetail = new TreatDetail();
|
|
|
+ List<MeditionDetail> meditionDetails = new ArrayList<>();
|
|
|
+ int main = cateList.indexOf("主症");
|
|
|
+ String mainDis = disList.get(main);
|
|
|
+ treatDetail.setTitle(mainDis+"治疗方案");//糖尿病及其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);
|
|
|
+ treatDetail.setMeditionDetails(meditionDetails);
|
|
|
+
|
|
|
+ treatDetailList.add(treatDetail);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -362,6 +479,7 @@ public class PushTreat {
|
|
|
if (splits[0].equals(splits[1])) {
|
|
|
sub = "";
|
|
|
big = splits[0];
|
|
|
+ sub = splits[0];
|
|
|
} else {
|
|
|
big = splits[0];
|
|
|
sub = splits[1];
|
|
@@ -483,6 +601,15 @@ public class PushTreat {
|
|
|
|
|
|
return filds;
|
|
|
}
|
|
|
+ private List<String> getAllFilds(String[] inputList){
|
|
|
+ List<String> filds = new ArrayList<>();
|
|
|
+ if(inputList.length>0){
|
|
|
+ for (String fild:inputList) {
|
|
|
+ filds.add("\'"+fild.trim()+"\'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return filds;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//不良反应set
|