|
@@ -68,6 +68,9 @@ public class PushTreat {
|
|
|
List<TreatDetail> treatmentPlanList_otherrule = this.otherRuleMedicaton(disName, exculdDiagFilds, allFilds, driver);
|
|
|
treatmentPlanList.addAll(treatmentPlanList_otherrule);
|
|
|
|
|
|
+ // TODO: 2019/12/4 合并规则,多个相同的治疗合并成一个
|
|
|
+ this.mergerRules(treatmentPlanList);
|
|
|
+
|
|
|
// TODO: 2019/11/19 规则不满足的情况下,返回主诊断的用药情况
|
|
|
if(treatmentPlanList.size() == 0){
|
|
|
treatmentPlanList = this.ordinaryMedicaton(disName,allFilds,driver);
|
|
@@ -80,6 +83,189 @@ public class PushTreat {
|
|
|
return 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();
|
|
|
+ for (MeditionDetail m:meditionDetails) {
|
|
|
+ String description = m.getDescription();
|
|
|
+ List<Drugs> treatment = m.getTreatment();
|
|
|
+ kk.put(description,treatment);
|
|
|
+ }
|
|
|
+ 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<>();
|
|
@@ -352,7 +538,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");
|
|
@@ -378,6 +565,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);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|