|
@@ -0,0 +1,888 @@
|
|
|
|
+package org.diagbot.graph.medicationProcess;
|
|
|
|
+
|
|
|
|
+import org.diagbot.common.push.bean.CrisisDetail;
|
|
|
|
+import org.diagbot.common.push.bean.neo4j.*;
|
|
|
|
+import org.diagbot.pub.utils.PropertiesUtil;
|
|
|
|
+import org.neo4j.driver.v1.*;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 治疗方案的推送
|
|
|
|
+ */
|
|
|
|
+public class PushTreat {
|
|
|
|
+ Logger logger = LoggerFactory.getLogger(PushTreat.class);
|
|
|
|
+ PropertiesUtil propertiesUtil_treat = new PropertiesUtil("pushTreat.properties");
|
|
|
|
+ PropertiesUtil propertiesUtil = new PropertiesUtil("bolt.properties");
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * @param disName 主诊断
|
|
|
|
+ * @param diseaseType 慢病为1
|
|
|
|
+ * @param driver
|
|
|
|
+ * @param keys 大数据的分词
|
|
|
|
+ * @param crisisDetails 规则返回结果
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ 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
|
|
|
|
+ //主诊断下的不良反应
|
|
|
|
+ Map<String, List<String>> disUE = this.getDisUE(disName, diseaseType, driver);
|
|
|
|
+ //根据分词推出的不良反应
|
|
|
|
+ Map<String, String> ueSet = this.getUe(keys, driver);//肾功能不全:可能有
|
|
|
|
+ //显示不良反应
|
|
|
|
+ if(diseaseType != null && 1 == diseaseType){
|
|
|
|
+ List<Indicators> indicators = sideEffect(disName, disUE, ueSet, crisisDetails);
|
|
|
|
+ treat.setAdverseEvent(indicators);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // TODO: 2019/11/20
|
|
|
|
+ //具体用药
|
|
|
|
+ List<TreatDetail> treatmentPlan = this.getTreatmentPlan(disName,webDiag, keys,exculdDiagFilds, crisisDetails,ueSet,driver);
|
|
|
|
+ treat.setTreatmentPlan(treatmentPlan);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return treat;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param webDiag 界面下的诊断
|
|
|
|
+ * @param
|
|
|
|
+ * @param inputList 分词
|
|
|
|
+ * @param crisisDetails 规则结果
|
|
|
|
+ * @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> allFilds = this.getAllFilds(webDiag, crisisDetails, inputList, ueSet);
|
|
|
|
+
|
|
|
|
+ // 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;
|
|
|
|
+
|
|
|
|
+ }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);
|
|
|
|
+ treatmentPlanList.addAll(treatDetailList);
|
|
|
|
+
|
|
|
|
+ return treatmentPlanList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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<>();
|
|
|
|
+ Set<String> disSet = new HashSet<>();
|
|
|
|
+ List<String> filds = new ArrayList<>();
|
|
|
|
+ if(inputList.length>0){
|
|
|
|
+ for (String fild:inputList) {
|
|
|
|
+ String s = "\'" + fild.trim() + "\'";
|
|
|
|
+ if(filds.indexOf(s)<0){
|
|
|
|
+ filds.add(s);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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",filds.toString());
|
|
|
|
+ logger.info("规则用药,查询语句为:\n" + query);
|
|
|
|
+ StatementResult result = tx.run(query);
|
|
|
|
+ while (result.hasNext()) {
|
|
|
|
+ searchDrugs(result, conditionDesign, disDrugs,disSet);
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ closeSession(session);
|
|
|
|
+ disTreatDetailList = this.processMedication_he(disDrugs, conditionDesign, allFilds, driver);
|
|
|
|
+
|
|
|
|
+ return disTreatDetailList;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 规则不匹配返回主诊断用药
|
|
|
|
+ * @param disName 主诊断
|
|
|
|
+ * @param allFilds 其他条件
|
|
|
|
+ * @param driver
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<TreatDetail> ordinaryMedicaton(String disName,List<String> allFilds,Driver driver){
|
|
|
|
+ List<TreatDetail> disTreatDetailList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ List<Drugs> dList = new ArrayList<>();
|
|
|
|
+ Map<String, String> medicaton_ji = new HashMap<>();
|
|
|
|
+ Map<String, List<String>> medicatonMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ Session session = driver.session(AccessMode.WRITE);
|
|
|
|
+ session.writeTransaction(new TransactionWork<Integer>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Integer execute(Transaction tx) {
|
|
|
|
+ String query = propertiesUtil_treat.getProperty("searchMedication").replace("disName", "\'" + disName + "\'").replace("filds", allFilds.toString());
|
|
|
|
+ logger.info("规则通过类找药:\n" + query);
|
|
|
|
+ StatementResult result = tx.run(query);
|
|
|
|
+ while (result.hasNext()) {
|
|
|
|
+ Record record = result.next();
|
|
|
|
+ searchAllMedication(record, medicatonMap, medicaton_ji);
|
|
|
|
+ }
|
|
|
|
+ medicationList(medicatonMap, medicaton_ji, dList);
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ closeSession(session);
|
|
|
|
+
|
|
|
|
+ TreatDetail treatDetail = new TreatDetail();
|
|
|
|
+ List<MeditionDetail> mList = new ArrayList<>();
|
|
|
|
+ MeditionDetail meditionDetail = new MeditionDetail();
|
|
|
|
+ meditionDetail.setDescription("");
|
|
|
|
+ meditionDetail.setTreatment(dList);
|
|
|
|
+ mList.add(meditionDetail);
|
|
|
|
+
|
|
|
|
+ treatDetail.setTitle(disName+"治疗方案");
|
|
|
|
+ treatDetail.setMeditionDetails(mList);
|
|
|
|
+ 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,disSet);
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ closeSession(session);
|
|
|
|
+ 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,Set<String> disSet) {
|
|
|
|
+ List<String> collection =null;
|
|
|
|
+ int i=0;
|
|
|
|
+ Record next = result.next();
|
|
|
|
+ String name = next.get("name").toString().replace("\"", "");
|
|
|
|
+ int design = next.get("design").asInt();
|
|
|
|
+ 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();
|
|
|
|
+ }
|
|
|
|
+ conditionDesign.put(name,i);
|
|
|
|
+ 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);
|
|
|
|
+ designHashMap.put("cate",cateList);
|
|
|
|
+ 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);
|
|
|
|
+ objectMap.put("cate",cate1);
|
|
|
|
+ List<String> dis1 = (List<String>)objectMap.get("dis");
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private List<TreatDetail> processMedication_he(Map<String,Map<String,Object>> disDrugs,Map<String,Integer> conditionDesign,List<String> allFilds,Driver driver){
|
|
|
|
+ List<TreatDetail> treatDetailList = new ArrayList<>();
|
|
|
|
+ Map<String,Set<String>> dis_Drugs =new HashMap<>();
|
|
|
|
+ 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("合并症")){
|
|
|
|
+ List<Integer> indexList = same(cateList, "合并症");
|
|
|
|
+ if(indexList.size()>0){
|
|
|
|
+ for (Integer i:indexList) {
|
|
|
|
+ String mainDis = disList.get(i);
|
|
|
|
+ List<String> o = (List<String>)collList.get(i);
|
|
|
|
+ List<String> yinhao = yinhao(o);
|
|
|
|
+ if(dis_Drugs.containsKey(mainDis)){
|
|
|
|
+ Set<String> strings = dis_Drugs.get(mainDis);
|
|
|
|
+ strings.addAll(yinhao);
|
|
|
|
+ dis_Drugs.put(mainDis,strings);
|
|
|
|
+ }else {
|
|
|
|
+ Set<String> strings = new HashSet<>();
|
|
|
|
+ strings.addAll(yinhao);
|
|
|
|
+ dis_Drugs.put(mainDis,strings);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(dis_Drugs != null && dis_Drugs.size()>0){
|
|
|
|
+ for (Map.Entry<String,Set<String>> dd:dis_Drugs.entrySet()) {
|
|
|
|
+ TreatDetail treatDetail = new TreatDetail();
|
|
|
|
+ String mainDis = dd.getKey();
|
|
|
|
+ Set<String> drugs = dd.getValue();
|
|
|
|
+ //根据类找药
|
|
|
|
+ List<Drugs> drugsList = searchMedication(new ArrayList<>(drugs),allFilds,driver);
|
|
|
|
+ List<MeditionDetail> meditionDetails = new ArrayList<>();
|
|
|
|
+ MeditionDetail meditionDetail = new MeditionDetail();
|
|
|
|
+ meditionDetail.setDescription("");
|
|
|
|
+ meditionDetail.setTreatment(drugsList);
|
|
|
|
+ meditionDetails.add(meditionDetail);
|
|
|
|
+ treatDetail.setTitle(mainDis);
|
|
|
|
+ treatDetail.setMeditionDetails(meditionDetails);
|
|
|
|
+ treatDetailList.add(treatDetail);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return treatDetailList;
|
|
|
|
+ }
|
|
|
|
+ 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();
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return treatDetailList;
|
|
|
|
+ }
|
|
|
|
+ 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<>();
|
|
|
|
+
|
|
|
|
+ Session session = driver.session(AccessMode.WRITE);
|
|
|
|
+ session.writeTransaction(new TransactionWork<Integer>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Integer execute(Transaction tx) {
|
|
|
|
+ String query = propertiesUtil_treat.getProperty("searchMedication_rule").replace("drugs",drugs.toString()).replace("filds",allFilds.toString());
|
|
|
|
+ logger.info("规则通过类找药:\n" + query);
|
|
|
|
+ StatementResult result = tx.run(query);
|
|
|
|
+ while (result.hasNext()) {
|
|
|
|
+ Record record = result.next();
|
|
|
|
+ searchAllMedication(record, medicatonMap, medicaton_ji);
|
|
|
|
+ }
|
|
|
|
+ medicationList(medicatonMap, medicaton_ji, dList);
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ closeSession(session);
|
|
|
|
+ return dList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void medicationList(Map<String, List<String>> medicatonMap, Map<String, String> medicaton_ji, List<Drugs> dList) {
|
|
|
|
+ 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];
|
|
|
|
+ sub = 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);
|
|
|
|
+ dList.add(drugs);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void searchAllMedication(Record record, Map<String, List<String>> medicatonMap, Map<String, String> medicaton_ji) {
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查找主诊断
|
|
|
|
+ private String mainDisease(String disName,Driver driver){
|
|
|
|
+ String main_dis = "";
|
|
|
|
+ List<String> disArray = new ArrayList<>();
|
|
|
|
+ Session session = null;
|
|
|
|
+ session = driver.session(AccessMode.WRITE);
|
|
|
|
+ session.writeTransaction(new TransactionWork<Integer>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Integer execute(Transaction tx) {
|
|
|
|
+ StatementResult result = null;
|
|
|
|
+ String query = propertiesUtil_treat.getProperty("mainDis").replace("disName",disName);
|
|
|
|
+ logger.info("判断主诊断,查询语句为:\n" + query);
|
|
|
|
+ result = tx.run(query);
|
|
|
|
+ while (result.hasNext()) {
|
|
|
|
+ Record next = result.next();
|
|
|
|
+ Integer sign = next.get("sign").asInt();//1:并发症 2:主诊断
|
|
|
|
+ Integer ksign = next.get("ksign").asInt();
|
|
|
|
+ String kname = next.get("kname").toString().replace("\"", "");
|
|
|
|
+ if(0 == sign){
|
|
|
|
+ disArray.add(disName);
|
|
|
|
+ }else {
|
|
|
|
+ disArray.add(kname);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ disArray.add(disName);
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ closeSession(session);
|
|
|
|
+ main_dis = disArray.size()>0 ? disArray.get(disArray.size()-1):"";
|
|
|
|
+ return main_dis;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<String> getAllFilds(String webDiag,Map<String, List<CrisisDetail>> crisisDetails,String[] inputList,Map<String, String> ueSet){
|
|
|
|
+ List<String> filds = new ArrayList<>();
|
|
|
|
+ Map<String, String> details = this.processCrisisDetails(crisisDetails, "6");
|
|
|
|
+ String[] diseaseArray = webDiag.split(",|,|、|;|:|;");
|
|
|
|
+ for(int i=0;i<diseaseArray.length;i++){
|
|
|
|
+ filds.add("\'"+diseaseArray[i]+"\'");
|
|
|
|
+ }
|
|
|
|
+ if(inputList.length>0){
|
|
|
|
+ for (String fild:inputList) {
|
|
|
|
+ filds.add("\'"+fild.trim()+"\'");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(details != null && details.size() >0){
|
|
|
|
+ for (Map.Entry<String,String> de:details.entrySet()) {
|
|
|
|
+ filds.add("\'"+de.getValue().trim()+de.getKey().trim()+"\'");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(ueSet != null && ueSet.size()>0){
|
|
|
|
+ for(Map.Entry<String, String> sd:ueSet.entrySet()){
|
|
|
|
+ filds.add("\'"+sd.getKey().trim()+"\'");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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
|
|
|
|
+ private List<Indicators> sideEffect(String diseaseName, Map<String, List<String>> disUE, Map<String, String> ueSet, Map<String, List<CrisisDetail>> crisisDetails) {
|
|
|
|
+ List<Indicators> indicatorsList =null;
|
|
|
|
+ List<String> stringList = disUE.get(diseaseName);
|
|
|
|
+ logger.info(diseaseName + "下面有" + stringList + "不良反应");
|
|
|
|
+ if (stringList != null && stringList.size() > 0) {
|
|
|
|
+ indicatorsList = new ArrayList<>();
|
|
|
|
+ for (String de : stringList) {
|
|
|
|
+ Indicators indicators = getAdverse(ueSet, de,crisisDetails);
|
|
|
|
+ indicatorsList.add(indicators);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return indicatorsList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 组装不良反应
|
|
|
|
+ * @param dis
|
|
|
|
+ * @param name
|
|
|
|
+ * @param crisisDetails
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private 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(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);
|
|
|
|
+ }
|
|
|
|
+ indicators.setDetails(detailList1);
|
|
|
|
+ return indicators;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 处理风险因素评估或不良反应
|
|
|
|
+ * @param crisisDetails
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ 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()
|
|
|
|
+ ) {
|
|
|
|
+ List<CrisisDetail> value = crisis.getValue();
|
|
|
|
+ if(value!=null && value.size()>0){
|
|
|
|
+ for (CrisisDetail crisisDetail:value) {
|
|
|
|
+ String[] crisisSplits = crisisDetail.getRemindText().split(":");
|
|
|
|
+ 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]);
|
|
|
|
+ }
|
|
|
|
+ /*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]);
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return crisisMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 只有主诊断才会有不良反应
|
|
|
|
+ * 查找主诊断的不良反应
|
|
|
|
+ * 获取每个慢病对应的不良反应
|
|
|
|
+ * @param disName 主诊断
|
|
|
|
+ * @param diseaseType 1为慢病
|
|
|
|
+ * @return 这个慢病对应的不良反应的组合
|
|
|
|
+ */
|
|
|
|
+ public Map<String, List<String>> getDisUE(String disName, Integer diseaseType,Driver driver) {
|
|
|
|
+ Map<String, List<String>> disUE = new HashMap<>();
|
|
|
|
+ if(diseaseType != null && 1 == diseaseType){
|
|
|
|
+ Session session = null;
|
|
|
|
+ session = driver.session(AccessMode.WRITE);
|
|
|
|
+ session.writeTransaction(new TransactionWork<Integer>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Integer execute(Transaction tx) {
|
|
|
|
+ StatementResult result = null;
|
|
|
|
+ String query = propertiesUtil_treat.getProperty("disUe").replace("disName",disName);
|
|
|
|
+ logger.info("根据页面诊断查询每个诊断所对应的不良反应集合,查询语句为:\n" + query);
|
|
|
|
+ result = tx.run(query);
|
|
|
|
+ while (result.hasNext()) {
|
|
|
|
+ Record next = result.next();
|
|
|
|
+ String dis = next.get("dis").toString().replace("\"", "");
|
|
|
|
+ List<Object> stringList = next.get("ueCollect").asList();
|
|
|
|
+ List<String> ueList = new ArrayList<>();
|
|
|
|
+ for (Object o : stringList) {
|
|
|
|
+ ueList.add(o.toString().replace("\"", ""));
|
|
|
|
+ }
|
|
|
|
+ disUE.put(dis, ueList);
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ closeSession(session);
|
|
|
|
+ }
|
|
|
|
+ return disUE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 不良反应推送
|
|
|
|
+ */
|
|
|
|
+ public Map<String,String> getUe(String[] keys,Driver driver) {
|
|
|
|
+ //查找不良反应推送
|
|
|
|
+ Map<String,String> indSet = new HashMap<>();
|
|
|
|
+ List<String> newList = new ArrayList<>();
|
|
|
|
+ List<String> fildList = new ArrayList<>();
|
|
|
|
+ List<String> startList = new ArrayList<>();
|
|
|
|
+ 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);
|
|
|
|
+ //第一步查询输入的词所在number
|
|
|
|
+ query = propertiesUtil.getProperty("searchNumColl").replace("startList", fildList.toString());
|
|
|
|
+ logger.info("查找词所在的number \n" + query);
|
|
|
|
+ result = session.run(query);
|
|
|
|
+ while (result.hasNext()) {
|
|
|
|
+ Record next = result.next();
|
|
|
|
+ String v = next.get("v").toString();
|
|
|
|
+ startList.add(v);
|
|
|
|
+ }
|
|
|
|
+ newList.addAll(startList);
|
|
|
|
+ int i = 1;
|
|
|
|
+ while (newList.size() > 0) {
|
|
|
|
+ query = propertiesUtil.getProperty("searchNewCondition").replace("newList", newList.toString()).replace("fildList", startList.toString());
|
|
|
|
+ logger.info("第" + i + "次查询conditon语句 \n" + query);
|
|
|
|
+ i++;
|
|
|
|
+ result = session.run(query);
|
|
|
|
+ newList.clear();
|
|
|
|
+ while (result.hasNext()) {
|
|
|
|
+ Record record = result.next();
|
|
|
|
+ String condition = record.get("condition").toString();
|
|
|
|
+ newList.add(condition);
|
|
|
|
+ startList.add(condition);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ query = propertiesUtil.getProperty("searchUe").replace("fildList", startList.toString());
|
|
|
|
+ logger.info("查找界面输入是否有不良反应,处理语句为:\n" + query);
|
|
|
|
+ result = session.run(query);
|
|
|
|
+ while (result.hasNext()) {
|
|
|
|
+ Record record = result.next();
|
|
|
|
+ String indName = record.get("name").toString().replace("\"", "");
|
|
|
|
+ String tr = record.get("tr").toString().replace("\"", "");//类型
|
|
|
|
+ indSet.put(indName,tr);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ closeSession(session);
|
|
|
|
+ return indSet;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //单、双药、胰岛素药
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void closeSession(Session session){
|
|
|
|
+ if(session != null){
|
|
|
|
+ session.close();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<String> yinhao(List<String> o){
|
|
|
|
+ List<String> yinhaoList = new ArrayList<>();
|
|
|
|
+ if(o != null && o.size()>0){
|
|
|
|
+ for (String sd:o
|
|
|
|
+ ) {
|
|
|
|
+ yinhaoList.add("\'"+sd+"\'");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return yinhaoList;
|
|
|
|
+ }
|
|
|
|
+ private List<String> processWebDiag(String disName,String webdiag){
|
|
|
|
+ List<String> diagList = new ArrayList<>();
|
|
|
|
+ String[] diseaseArray = webdiag.split(",|,|、|;|:|;");
|
|
|
|
+ for(int i=0;i<diseaseArray.length;i++){
|
|
|
|
+ diagList.add("\'"+diseaseArray[i]+"\'");
|
|
|
|
+ }
|
|
|
|
+ disName = "\'"+disName+"\'";
|
|
|
|
+ if(!diagList.contains(disName)){
|
|
|
|
+ diagList.add(disName);
|
|
|
|
+ }
|
|
|
|
+ return diagList;
|
|
|
|
+ }
|
|
|
|
+ public List<Integer> same(List<String> list,String input) {
|
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
|
+ String key = list.get(i);
|
|
|
|
+ String old = map.get(key);
|
|
|
|
+ if (old != null) {
|
|
|
|
+ map.put(key, old + "," + (i + 1));
|
|
|
|
+ } else {
|
|
|
|
+ map.put(key, "" + (i + 1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<Integer> indexList = new ArrayList<Integer>();
|
|
|
|
+ try {
|
|
|
|
+ String s = map.get(input);
|
|
|
|
+ String[] split = s.split(",");
|
|
|
|
+ for (String ds:split) {
|
|
|
|
+ indexList.add(Integer.parseInt(ds)-1);
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return indexList;
|
|
|
|
+ }
|
|
|
|
+}
|