|
@@ -9,9 +9,7 @@ import org.diagbot.entity.node.Disease;
|
|
|
import org.diagbot.entity.node.base.BaseNode;
|
|
|
import org.apache.commons.collections4.IteratorUtils;
|
|
|
import org.diagbot.repository.*;
|
|
|
-import org.diagbot.vo.domain.FeatureRate;
|
|
|
-import org.diagbot.vo.domain.ResponseData;
|
|
|
-import org.diagbot.vo.domain.SearchData;
|
|
|
+import org.diagbot.vo.domain.*;
|
|
|
import org.neo4j.driver.v1.types.Node;
|
|
|
import org.neo4j.driver.v1.types.Path;
|
|
|
import org.slf4j.Logger;
|
|
@@ -272,10 +270,10 @@ public class KnowledgeServiceImpl implements KnowledgeService {
|
|
|
}
|
|
|
}
|
|
|
String webDiag = searchData.getDiag();
|
|
|
- if(webDiag.trim()!=null && Arrays.asList(searchData.getFeatureTypes()).contains("8")){
|
|
|
- processTreat(featureRates,webDiag,ss);
|
|
|
+ if(webDiag.trim()!=null){
|
|
|
+ Map<String, Filnlly> mulDiseaseTreat = processTreat(webDiag, ss);
|
|
|
+ responseData.setTreat(mulDiseaseTreat);
|
|
|
}
|
|
|
-
|
|
|
responseData.setDis(featureRates);
|
|
|
return responseData;
|
|
|
}
|
|
@@ -378,20 +376,204 @@ public class KnowledgeServiceImpl implements KnowledgeService {
|
|
|
|
|
|
/**
|
|
|
* 处理治疗
|
|
|
- * @param featureRateList
|
|
|
+ * @param
|
|
|
*/
|
|
|
- public void processTreat(List<FeatureRate> featureRateList,String webDisease,Set inputFilds){
|
|
|
+ public Map<String, Filnlly> processTreat(String webDisease,Set<String> inputFilds){
|
|
|
+ Map<String, Filnlly> diagTreat = new HashMap<>();
|
|
|
NumberFormat nf = NumberFormat.getPercentInstance();
|
|
|
nf.setMinimumFractionDigits(0);//设置该百分比数字,保留2位小数;
|
|
|
nf.setRoundingMode(RoundingMode.HALF_UP); //设置满5向上进位,即四舍五入;
|
|
|
String[] diseaseArray = webDisease.split(",|,|、|;|:|;");
|
|
|
List<String> diseaseList = Arrays.asList(diseaseArray);
|
|
|
- Map<String, ArrayList> diseFilds = new HashMap<>();
|
|
|
+ Map<String, List> diseFilds = new HashMap<>();
|
|
|
for(int i=0;i<diseaseList.size();i++){
|
|
|
List<String> fildsList = new ArrayList<>();//其他条件数组
|
|
|
-
|
|
|
+ for (String fild:inputFilds) {
|
|
|
+ fildsList.add(fild);
|
|
|
+ }
|
|
|
+ for (int j = 0; j < diseaseList.size(); j++) {
|
|
|
+ if (i != j) {
|
|
|
+ fildsList.add(diseaseList.get(j));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ diseFilds.put(diseaseList.get(i), fildsList);
|
|
|
}
|
|
|
-
|
|
|
+ for (Map.Entry<String, List> disFild:diseFilds.entrySet()) {
|
|
|
+ //获取诊断的药类和用药(排序好的)
|
|
|
+ List<Map<String, Object>> treatMedicaton = baseNodeRepository.getTreatMedicaton(disFild.getKey());
|
|
|
+ Map<String, LinkedHashMap<String, String>> contentMap = new LinkedHashMap<>();
|
|
|
+ if(treatMedicaton != null && treatMedicaton.size()>0){
|
|
|
+ for (Map<String, Object> tm:treatMedicaton) {
|
|
|
+ String drugs = tm.get("drugs").toString();
|
|
|
+ String medication = tm.get("medication").toString();
|
|
|
+ String rate = tm.get("rate").toString();
|
|
|
+ if (contentMap.containsKey(drugs)) {
|
|
|
+ LinkedHashMap<String, String> drugsMedicationLinkedHashMap = contentMap.get(drugs);
|
|
|
+ drugsMedicationLinkedHashMap.put(medication,rate);
|
|
|
+ contentMap.put(drugs,drugsMedicationLinkedHashMap);
|
|
|
+ }else {
|
|
|
+ LinkedHashMap<String, String> sa = new LinkedHashMap<>();
|
|
|
+ sa.put(medication,rate);
|
|
|
+ contentMap.put(drugs,sa);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //药所属类型的大小类合并
|
|
|
+ Map<String, String> shortLargeMap = new HashMap<>();
|
|
|
+ List<Map<String, Object>> shortLarge = baseNodeRepository.getShortLarge(disFild.getKey());
|
|
|
+ if(shortLarge != null && shortLarge.size()>0){
|
|
|
+ for (Map<String, Object> sl:shortLarge) {
|
|
|
+ String aShort = sl.get("short").toString();
|
|
|
+ String large = sl.get("large").toString();
|
|
|
+ shortLargeMap.put(aShort,large+"("+aShort+")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //小类替换成大类
|
|
|
+ Map<String, LinkedHashMap<String, String>> shortLargeMapConcat = new LinkedHashMap<>();
|
|
|
+ for (Map.Entry<String, LinkedHashMap<String, String>> f : contentMap.entrySet()) {
|
|
|
+ String drugs = f.getKey();
|
|
|
+ if (shortLargeMap.get(drugs) != null) {
|
|
|
+ shortLargeMapConcat.put(shortLargeMap.get(drugs), contentMap.get(drugs));
|
|
|
+ } else {
|
|
|
+ shortLargeMapConcat.put(drugs, contentMap.get(drugs));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理慎用,忌用
|
|
|
+ Map<String, String> medicationUseMap = new HashMap<>();//key:药名 value:禁忌(慎用)
|
|
|
+ List<Map<String, Object>> shenJi = baseNodeRepository.getShenJiDrugsMedication(disFild.getKey(), disFild.getValue());
|
|
|
+ if(shenJi != null && shenJi.size()>0){
|
|
|
+ for (Map<String, Object> sj:shenJi) {
|
|
|
+ String name = sj.get("name").toString();
|
|
|
+ String type = sj.get("type").toString();
|
|
|
+ medicationUseMap.put(name,type);//(名字,禁用/慎用)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //大对象集合
|
|
|
+ ArrayList<Drugs> drugsList = new ArrayList<Drugs>();
|
|
|
+ DrugsPattern drugsPattern = new DrugsPattern();
|
|
|
+ for (Map.Entry<String, LinkedHashMap<String, String>> w : shortLargeMapConcat.entrySet()) {
|
|
|
+ int i = 0;
|
|
|
+ int forbidden = 0;
|
|
|
+ Drugs drugs = new Drugs();
|
|
|
+ String drugsName = w.getKey();
|
|
|
+ Map<String, String> bigSubDrugs = drugsPattern.bigSubDrugs(drugsName);
|
|
|
+ drugs.setBigdrugsName(bigSubDrugs.get("big"));
|
|
|
+ drugs.setSubdrugsName(bigSubDrugs.get("sub"));
|
|
|
+ LinkedList<Medicition> medicitionsList = new LinkedList<>();
|
|
|
+ LinkedHashMap<String, String> meditionRate = w.getValue();
|
|
|
+ if ("忌用".equals(medicationUseMap.get(bigSubDrugs.get("big"))) || "忌用".equals(medicationUseMap.get(bigSubDrugs.get("sub")))) {
|
|
|
+ drugs.setDrugsForbidden(2);
|
|
|
+ for (Map.Entry<String, String> g : meditionRate.entrySet()) {
|
|
|
+ Medicition medicition = new Medicition();
|
|
|
+ String meditionName = g.getKey().trim();//药名
|
|
|
+ String rate = nf.format(Double.parseDouble(g.getValue().trim()));//百分比
|
|
|
+ medicition.setMedicitionName(meditionName);
|
|
|
+ medicition.setRate(rate);
|
|
|
+ if (i < 3) {
|
|
|
+ medicition.setIsShow(1);
|
|
|
+ i++;
|
|
|
+ } else {
|
|
|
+ medicition.setIsShow(0);
|
|
|
+ }
|
|
|
+ medicition.setForbidden(2);
|
|
|
+ medicitionsList.add(medicition);
|
|
|
+ }
|
|
|
+ }else if("慎用".equals(medicationUseMap.get(bigSubDrugs.get("big"))) || "慎用".equals(medicationUseMap.get(bigSubDrugs.get("sub")))){
|
|
|
+ drugs.setDrugsForbidden(1);
|
|
|
+ for (Map.Entry<String, String> g : meditionRate.entrySet()) {
|
|
|
+ Medicition medicition = new Medicition();
|
|
|
+ String meditionName = g.getKey().trim();//药名
|
|
|
+ String rate = nf.format(Double.parseDouble(g.getValue().trim()));//百分比
|
|
|
+ medicition.setMedicitionName(meditionName);
|
|
|
+ medicition.setRate(rate);
|
|
|
+ if (i < 3) {
|
|
|
+ medicition.setIsShow(1);
|
|
|
+ i++;
|
|
|
+ } else {
|
|
|
+ medicition.setIsShow(0);
|
|
|
+ }
|
|
|
+ medicition.setForbidden(1);
|
|
|
+ medicitionsList.add(medicition);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ drugs.setDrugsForbidden(0);
|
|
|
+ for (Map.Entry<String, String> g : meditionRate.entrySet()) {
|
|
|
+ Medicition medicition = new Medicition();
|
|
|
+ String meditionName = g.getKey().trim();//药名
|
|
|
+ String rate = nf.format(Double.parseDouble(g.getValue().trim()));//百分比
|
|
|
+ medicition.setMedicitionName(meditionName);
|
|
|
+ medicition.setRate(rate);
|
|
|
+ if (i < 3) {
|
|
|
+ medicition.setIsShow(1);
|
|
|
+ i++;
|
|
|
+ } else {
|
|
|
+ medicition.setIsShow(0);
|
|
|
+ }
|
|
|
+ if ("忌用".equals(medicationUseMap.get(meditionName))) {
|
|
|
+ medicition.setForbidden(2);
|
|
|
+ } else if ("慎用".equals(medicationUseMap.get(meditionName))) {
|
|
|
+ medicition.setForbidden(1);
|
|
|
+ } else {
|
|
|
+ medicition.setForbidden(0);
|
|
|
+ }
|
|
|
+ medicitionsList.add(medicition);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ drugs.setMedicitionsList(medicitionsList);
|
|
|
+ drugsList.add(drugs);
|
|
|
+ }
|
|
|
+ Filnlly filnlly = new Filnlly();
|
|
|
+ List<Indicators> indicatorsList1 = new ArrayList<>();
|
|
|
+ List<Detail> detailList1 = new ArrayList<>();
|
|
|
+ Detail detail1 = new Detail();
|
|
|
+ detail1.setName("无");
|
|
|
+ detail1.setValue(0);
|
|
|
+ Detail detail2 = new Detail();
|
|
|
+ detail2.setName("偶尔");
|
|
|
+ detail2.setValue(0);
|
|
|
+ Detail detail3 = new Detail();
|
|
|
+ detail3.setName("频");
|
|
|
+ detail3.setValue(0);
|
|
|
+ detailList1.add(detail1);
|
|
|
+ detailList1.add(detail2);
|
|
|
+ detailList1.add(detail3);
|
|
|
+ Indicators indicators1 = new Indicators();
|
|
|
+ indicators1.setName("低血糖反应");
|
|
|
+ indicators1.setControlType(2);
|
|
|
+ indicators1.setDetails(detailList1);
|
|
|
+ indicatorsList1.add(indicators1);
|
|
|
+
|
|
|
+ List<Detail> detailList2 = new ArrayList<>();
|
|
|
+ Detail detail11 = new Detail();
|
|
|
+ detail11.setName("腹胀");
|
|
|
+ detail11.setValue(0);
|
|
|
+ Detail detail12 = new Detail();
|
|
|
+ detail12.setName("厌食");
|
|
|
+ detail12.setValue(0);
|
|
|
+ Detail detail13 = new Detail();
|
|
|
+ detail13.setName("嗳气");
|
|
|
+ detail13.setValue(0);
|
|
|
+ Detail detail14 = new Detail();
|
|
|
+ detail14.setName("恶心");
|
|
|
+ detail14.setValue(0);
|
|
|
+ Detail detail15 = new Detail();
|
|
|
+ detail15.setName("呕吐");
|
|
|
+ detail15.setValue(0);
|
|
|
+ detailList2.add(detail11);
|
|
|
+ detailList2.add(detail12);
|
|
|
+ detailList2.add(detail13);
|
|
|
+ detailList2.add(detail14);
|
|
|
+ detailList2.add(detail15);
|
|
|
+ Indicators indicators11 = new Indicators();
|
|
|
+ indicators11.setName("胃肠道不良反应");
|
|
|
+ indicators11.setControlType(2);
|
|
|
+ indicators11.setDetails(detailList2);
|
|
|
+ indicatorsList1.add(indicators11);
|
|
|
+ filnlly.setAdverseEvent(indicatorsList1);
|
|
|
+ filnlly.setTreatment(drugsList);
|
|
|
+ diagTreat.put(disFild.getKey(),filnlly);
|
|
|
+ }
|
|
|
+ return diagTreat;
|
|
|
}
|
|
|
|
|
|
@Override
|