|
@@ -11,6 +11,8 @@ import com.diagbot.enums.StandConvertEnum;
|
|
import com.diagbot.process.PushProcess;
|
|
import com.diagbot.process.PushProcess;
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.vo.*;
|
|
import com.diagbot.vo.*;
|
|
|
|
+import com.diagbot.vo.neoPushEntity.Diag;
|
|
|
|
+import com.diagbot.vo.neoPushEntity.DiagVo;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@@ -38,6 +40,7 @@ public class PushFacade {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public PushDTO pushFac(PushVO pushVo) {
|
|
public PushDTO pushFac(PushVO pushVo) {
|
|
|
|
+ int length = pushVo.getLength();
|
|
PushDTO pushDTO = new PushDTO();
|
|
PushDTO pushDTO = new PushDTO();
|
|
// 模型处理数据
|
|
// 模型处理数据
|
|
WordCrfDTO wordCrfDTO = commonFacade.crf_process(pushVo);
|
|
WordCrfDTO wordCrfDTO = commonFacade.crf_process(pushVo);
|
|
@@ -50,131 +53,153 @@ public class PushFacade {
|
|
Map<String, List<String>> typeWords = typeWords(standConvertMap);
|
|
Map<String, List<String>> typeWords = typeWords(standConvertMap);
|
|
//生成push入参,供图谱调用
|
|
//生成push入参,供图谱调用
|
|
NeoPushVO pushVO = commonFacade.generatePushInput(wordCrfDTO);
|
|
NeoPushVO pushVO = commonFacade.generatePushInput(wordCrfDTO);
|
|
- //图谱推送数据
|
|
|
|
- List<NeoPushDTO> push = neoFacade.getPush(pushVO);
|
|
|
|
- /* NeoPushDTO neoPushDTO1 = new NeoPushDTO();
|
|
|
|
- PushBaseDTO disease = new PushBaseDTO();
|
|
|
|
- disease.setName("急性胰腺炎");
|
|
|
|
- neoPushDTO1.setDisease(disease);
|
|
|
|
- List<PushBaseDTO> vitals = new ArrayList<>();
|
|
|
|
- PushBaseDTO vital1 = new PushBaseDTO();
|
|
|
|
- vital1.setName("心率快");
|
|
|
|
- vitals.add(vital1);
|
|
|
|
- PushBaseDTO vital2 = new PushBaseDTO();
|
|
|
|
- vital2.setName("淋巴肿大");
|
|
|
|
- vitals.add(vital2);
|
|
|
|
- neoPushDTO1.setVitals(vitals);
|
|
|
|
- push.add(neoPushDTO1);*/
|
|
|
|
|
|
+ Map<String, List<PushBaseDTO>> dis = new HashMap<>();
|
|
|
|
+ //如果下的诊断有数据就反推
|
|
|
|
+ if(pushVO.getDiagVo() != null && pushVO.getDiagVo().getDiags().size() > 0){
|
|
|
|
+ reversePushPackage(length, pushDTO, ruleTypeList, typeWords, pushVO,dis);
|
|
|
|
+ }else {
|
|
|
|
+ //正推
|
|
|
|
+ List<NeoPushDTO> push = neoFacade.getPush(pushVO);
|
|
|
|
+ if(ListUtil.isNotEmpty(push) && push.size() >0){
|
|
|
|
+ //先把所有疾病推出来
|
|
|
|
+ if(ruleTypeList.contains("7")){
|
|
|
|
+ List<PushBaseDTO> diseeases = push.stream().filter(x -> x.getDisease() != null).map(x -> x.getDisease()).collect(Collectors.toList());
|
|
|
|
+ diseeases = diseeases.subList(0, diseeases.size() >= length ? length : diseeases.size());
|
|
|
|
+ dis.put(DiseaseTypeEnum.possibleDis.getName(),diseeases);
|
|
|
|
+ pushDTO.setDis(dis);
|
|
|
|
+ }
|
|
|
|
+ //把第一个推送出来的诊断set到diagOrder中,再反推
|
|
|
|
+ setPushVo(pushVO, push);
|
|
|
|
+ //调用反推
|
|
|
|
+ reversePushPackage(length, pushDTO, ruleTypeList, typeWords, pushVO,dis);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ return pushDTO;
|
|
|
|
+ }
|
|
|
|
|
|
- int length = pushVo.getLength();
|
|
|
|
- if(ListUtil.isNotEmpty(push)){
|
|
|
|
- NeoPushDTO neoPushDTO = push.get(0);
|
|
|
|
- if(neoPushDTO != null){
|
|
|
|
- // 症状
|
|
|
|
- if (ruleTypeList.contains("1") && ListUtil.isNotEmpty(neoPushDTO.getSymptoms())) {
|
|
|
|
- List<PushBaseDTO> filterSymptoms = neoPushDTO.getSymptoms().stream().filter(x -> !typeWords.get(StandConvertEnum.symptom.getName()).contains(x.getName())).collect(Collectors.toList());
|
|
|
|
- pushDTO.setSymptom(filterSymptoms.subList(0, filterSymptoms.size() >= length ? length : filterSymptoms.size()));
|
|
|
|
|
|
+ private void setPushVo(NeoPushVO pushVO, List<NeoPushDTO> push) {
|
|
|
|
+ String firstDisease = push.get(0).getDisease().getName();
|
|
|
|
+ List<Diag> diags = new ArrayList<>();
|
|
|
|
+ Diag diag = new Diag();
|
|
|
|
+ diag.setName(firstDisease);
|
|
|
|
+ diags.add(diag);
|
|
|
|
+ DiagVo diagVo = new DiagVo();
|
|
|
|
+ diagVo.setDiags(diags);
|
|
|
|
+ pushVO.setDiagVo(diagVo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void reversePushPackage(int length, PushDTO pushDTO, List<String> ruleTypeList, Map<String, List<String>> typeWords, NeoPushVO pushVO,Map<String, List<PushBaseDTO>> dis) {
|
|
|
|
+ List<NeoPushDTO> reversePush = neoFacade.getReversePush(pushVO);
|
|
|
|
+ if(ListUtil.isNotEmpty(reversePush)){
|
|
|
|
+ // 症状
|
|
|
|
+ if (ruleTypeList.contains("1")) {
|
|
|
|
+ List<String> symptoms = new ArrayList<>();
|
|
|
|
+ reversePush.stream().filter(x -> ListUtil.isNotEmpty(x.getSymptoms())).forEach(x -> {
|
|
|
|
+ List<String> symptomList = x.getSymptoms().stream().map(y -> y.getName()).collect(Collectors.toList());
|
|
|
|
+ symptoms.removeAll(symptomList);
|
|
|
|
+ symptoms.addAll(symptomList);
|
|
|
|
+ });
|
|
|
|
+ if (symptoms.size() > 0) {
|
|
|
|
+ List<PushBaseDTO> filtervitals = getPackagePushBaseDTO(typeWords, symptoms, StandConvertEnum.symptom);
|
|
|
|
+ pushDTO.setSymptom(filtervitals.subList(0, filtervitals.size() >= length ? length : filtervitals.size()));
|
|
}
|
|
}
|
|
- // 查体
|
|
|
|
- if (ruleTypeList.contains("4") && ListUtil.isNotEmpty(neoPushDTO.getVitals())) {
|
|
|
|
- List<PushBaseDTO> filtervitals = neoPushDTO.getVitals().stream().filter(x -> !typeWords.get(StandConvertEnum.vital.getName()).contains(x.getName())).collect(Collectors.toList());
|
|
|
|
|
|
+ }
|
|
|
|
+ // 查体
|
|
|
|
+ if (ruleTypeList.contains("4")) {
|
|
|
|
+ List<String> vitals = new ArrayList<>();
|
|
|
|
+ reversePush.stream().filter(x -> ListUtil.isNotEmpty(x.getVitals())).forEach(x -> {
|
|
|
|
+ List<String> vitalList = x.getVitals().stream().map(y -> y.getName()).collect(Collectors.toList());
|
|
|
|
+ vitals.removeAll(vitalList);
|
|
|
|
+ vitals.addAll(vitalList);
|
|
|
|
+ });
|
|
|
|
+ if (vitals.size() > 0) {
|
|
|
|
+ List<PushBaseDTO> filtervitals = getPackagePushBaseDTO(typeWords, vitals, StandConvertEnum.vital);
|
|
pushDTO.setVital(filtervitals.subList(0, filtervitals.size() >= length ? length : filtervitals.size()));
|
|
pushDTO.setVital(filtervitals.subList(0, filtervitals.size() >= length ? length : filtervitals.size()));
|
|
}
|
|
}
|
|
- // 化验
|
|
|
|
- if (ruleTypeList.contains("5") && ListUtil.isNotEmpty(neoPushDTO.getLis())) {
|
|
|
|
- List<PushBaseDTO> filterlis = neoPushDTO.getLis().stream().filter(x -> !typeWords.get(StandConvertEnum.lis.getName()).contains(x.getName())).collect(Collectors.toList());
|
|
|
|
|
|
+ }
|
|
|
|
+ // 化验
|
|
|
|
+ if (ruleTypeList.contains("5")) {
|
|
|
|
+ List<String> lises = new ArrayList<>();
|
|
|
|
+ reversePush.stream().filter(x -> ListUtil.isNotEmpty(x.getLis())).forEach(x -> {
|
|
|
|
+ List<String> lisList = x.getLis().stream().map(y -> y.getName()).collect(Collectors.toList());
|
|
|
|
+ lises.removeAll(lisList);
|
|
|
|
+ lises.addAll(lisList);
|
|
|
|
+ });
|
|
|
|
+ if (lises.size() > 0) {
|
|
|
|
+ List<PushBaseDTO> filterlis = getPackagePushBaseDTO(typeWords, lises, StandConvertEnum.lis);
|
|
pushDTO.setLis(filterlis.subList(0, filterlis.size() >= length ? length : filterlis.size()));
|
|
pushDTO.setLis(filterlis.subList(0, filterlis.size() >= length ? length : filterlis.size()));
|
|
}
|
|
}
|
|
- // 辅检
|
|
|
|
- if (ruleTypeList.contains("6") && ListUtil.isNotEmpty(neoPushDTO.getPacs())) {
|
|
|
|
- List<PushBaseDTO> filterpacs = neoPushDTO.getPacs().stream().filter(x -> !typeWords.get(StandConvertEnum.pacs.getName()).contains(x.getName())).collect(Collectors.toList());
|
|
|
|
|
|
+ }
|
|
|
|
+ // 辅检
|
|
|
|
+ if (ruleTypeList.contains("6")) {
|
|
|
|
+ List<String> pacses = new ArrayList<>();
|
|
|
|
+ reversePush.stream().filter(x -> ListUtil.isNotEmpty(x.getPacs())).forEach(x -> {
|
|
|
|
+ List<String> pacsList = x.getPacs().stream().map(y -> y.getName()).collect(Collectors.toList());
|
|
|
|
+ pacses.removeAll(pacsList);
|
|
|
|
+ pacses.addAll(pacsList);
|
|
|
|
+ });
|
|
|
|
+ if (pacses.size() > 0) {
|
|
|
|
+ List<PushBaseDTO> filterpacs = getPackagePushBaseDTO(typeWords, pacses, StandConvertEnum.pacs);
|
|
pushDTO.setPacs(filterpacs.subList(0, filterpacs.size() >= length ? length : filterpacs.size()));
|
|
pushDTO.setPacs(filterpacs.subList(0, filterpacs.size() >= length ? length : filterpacs.size()));
|
|
}
|
|
}
|
|
- // 药品
|
|
|
|
- if (ruleTypeList.contains("8") && neoPushDTO.getTreat() != null && ListUtil.isNotEmpty(neoPushDTO.getTreat().get(MedicalAdviceEnum.drug.getName()))) {
|
|
|
|
- List<PushBaseDTO> pushMedicineBaseDTOS = neoPushDTO.getTreat().get(MedicalAdviceEnum.drug.getName());
|
|
|
|
- pushDTO.setMedicines(pushMedicineBaseDTOS.subList(0, pushMedicineBaseDTOS.size() >= length ? length : pushMedicineBaseDTOS.size()));
|
|
|
|
|
|
+ }
|
|
|
|
+ // 药品
|
|
|
|
+ if (ruleTypeList.contains("8")) {
|
|
|
|
+ List<String> drugs = new ArrayList<>();
|
|
|
|
+ reversePush.stream().filter(x ->x.getTreat() != null && ListUtil.isNotEmpty(x.getTreat().get(MedicalAdviceEnum.drug.getName())))
|
|
|
|
+ .forEach(x -> {
|
|
|
|
+ List<String> drugList = x.getTreat().get(MedicalAdviceEnum.drug.getName()).stream().map(y -> y.getName()).collect(Collectors.toList());
|
|
|
|
+ drugs.removeAll(drugList);
|
|
|
|
+ drugs.addAll(drugList);
|
|
|
|
+ });
|
|
|
|
+ if (drugs.size() > 0) {
|
|
|
|
+ List<PushBaseDTO> filterdrugs = getPackagePushBaseDTO(typeWords, drugs, StandConvertEnum.drug);
|
|
|
|
+ pushDTO.setMedicines(filterdrugs.subList(0, filterdrugs.size() >= length ? length : filterdrugs.size()));
|
|
}
|
|
}
|
|
- // 手术
|
|
|
|
- if (ruleTypeList.contains("9") && neoPushDTO.getTreat() != null && ListUtil.isNotEmpty(neoPushDTO.getTreat().get(MedicalAdviceEnum.operation.getName()))) {
|
|
|
|
- List<PushBaseDTO> pushOperationBaseDTOS = neoPushDTO.getTreat().get(MedicalAdviceEnum.operation.getName());
|
|
|
|
- pushDTO.setMedicines(pushOperationBaseDTOS.subList(0, pushOperationBaseDTOS.size() >= length ? length : pushOperationBaseDTOS.size()));
|
|
|
|
|
|
+ }
|
|
|
|
+ // 手术
|
|
|
|
+ if (ruleTypeList.contains("9")) {
|
|
|
|
+ List<String> operations = new ArrayList<>();
|
|
|
|
+ reversePush.stream().filter(x ->x.getTreat() != null && ListUtil.isNotEmpty(x.getTreat().get(MedicalAdviceEnum.operation.getName())))
|
|
|
|
+ .forEach(x -> {
|
|
|
|
+ List<String> operationList = x.getTreat().get(MedicalAdviceEnum.operation.getName()).stream().map(y -> y.getName()).collect(Collectors.toList());
|
|
|
|
+ operations.removeAll(operationList);
|
|
|
|
+ operations.addAll(operationList);
|
|
|
|
+ });
|
|
|
|
+ if (operations.size() > 0) {
|
|
|
|
+ List<PushBaseDTO> filteroperations = getPackagePushBaseDTO(typeWords, operations, StandConvertEnum.operation);
|
|
|
|
+ pushDTO.setOperations(filteroperations.subList(0, filteroperations.size() >= length ? length : filteroperations.size()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- Map<String, List<PushBaseDTO>> dis = new HashMap<>();
|
|
|
|
- //推送诊断
|
|
|
|
|
|
+ //反推,推鉴别诊断
|
|
if (ruleTypeList.contains("7")) {
|
|
if (ruleTypeList.contains("7")) {
|
|
- List<PushBaseDTO> fiterDiseases = push.stream().map(x -> x.getDisease()).filter(y -> !typeWords.get(StandConvertEnum.disease.getName()).contains(y.getName())).collect(Collectors.toList());
|
|
|
|
- List<PushBaseDTO> pushBaseDTOS = fiterDiseases.subList(0, fiterDiseases.size() >= length ? length : fiterDiseases.size());
|
|
|
|
- dis.put(DiseaseTypeEnum.possibleDis.getName(),pushBaseDTOS);
|
|
|
|
-
|
|
|
|
- List<List<String>> differenrDisList = push.stream().filter(x -> ListUtil.isNotEmpty(x.getDifferentialDis())).map(y -> y.getDifferentialDis().stream().map(
|
|
|
|
- z -> z.getName()).collect(Collectors.toList())).collect(Collectors.toList());
|
|
|
|
- List<String> differentDises = new ArrayList<>();
|
|
|
|
- differenrDisList.forEach(
|
|
|
|
- x ->{
|
|
|
|
- differentDises.removeAll(x);
|
|
|
|
- differentDises.addAll(x);
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- List<PushBaseDTO> filterDifferentDis = differentDises.subList(0, differentDises.size() >= length ? length : differentDises.size()).stream().map(x -> {
|
|
|
|
- PushBaseDTO pushBaseDTO = new PushBaseDTO();
|
|
|
|
- pushBaseDTO.setName(x);
|
|
|
|
- return pushBaseDTO;
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
- dis.put(DiseaseTypeEnum.identify.getName(),filterDifferentDis);
|
|
|
|
- }
|
|
|
|
- pushDTO.setDis(dis);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*if (wordCrfDTO.getDiagLabel() != null && ListUtil.isNotEmpty(wordCrfDTO.getDiagLabel().getDiags())) { // 有诊断
|
|
|
|
- List<String> diags = wordCrfDTO.getDiagLabel().getDiags().stream().map(r -> r.getStandName()).collect(Collectors.toList());
|
|
|
|
- PushNeoVO pushNeoVO = new PushNeoVO();
|
|
|
|
- pushNeoVO.setSex(pushVo.getSex());
|
|
|
|
- pushNeoVO.setAge(pushVo.getAge());
|
|
|
|
- pushNeoVO.setDiags(diags);
|
|
|
|
- Map<String, PushDTO> map = neoFacade.getInverse(pushNeoVO);
|
|
|
|
- // 获取第一个诊断
|
|
|
|
- String firstDisease = diags.get(0);
|
|
|
|
- PushDTO neoDto = map.get(firstDisease);
|
|
|
|
-
|
|
|
|
- if (neoDto != null) {
|
|
|
|
- int length = pushVo.getLength();
|
|
|
|
- // 症状
|
|
|
|
- if (ruleTypeList.contains("1") && ListUtil.isNotEmpty(neoDto.getSymptom())) {
|
|
|
|
- pushDTO.setSymptom(neoDto.getSymptom().subList(0, neoDto.getSymptom().size() >= length ? length : neoDto.getSymptom().size()));
|
|
|
|
|
|
+ List<String> differentDis = new ArrayList<>();
|
|
|
|
+ reversePush.stream().filter(x -> ListUtil.isNotEmpty(x.getDifferentialDis())).forEach(x -> {
|
|
|
|
+ List<String> differentList = x.getDifferentialDis().stream().map(y -> y.getName()).collect(Collectors.toList());
|
|
|
|
+ differentDis.removeAll(differentList);
|
|
|
|
+ differentDis.addAll(differentList);
|
|
|
|
+ });
|
|
|
|
+ if (differentDis.size() > 0) {
|
|
|
|
+ List<PushBaseDTO> filterpacs = getPackagePushBaseDTO(typeWords, differentDis, StandConvertEnum.disease);
|
|
|
|
+ List<PushBaseDTO> pushDiffBaseDTOS = filterpacs.subList(0, filterpacs.size() >= length ? length : filterpacs.size());
|
|
|
|
+ dis.put(DiseaseTypeEnum.identify.getName(),pushDiffBaseDTOS);
|
|
|
|
+ pushDTO.setDis(dis);
|
|
}
|
|
}
|
|
|
|
|
|
- // 查体
|
|
|
|
- if (ruleTypeList.contains("4") && ListUtil.isNotEmpty(neoDto.getVital())) {
|
|
|
|
- pushDTO.setVital(neoDto.getVital().subList(0, neoDto.getVital().size() >= length ? length : neoDto.getVital().size()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 化验
|
|
|
|
- if (ruleTypeList.contains("5") && ListUtil.isNotEmpty(neoDto.getLis())) {
|
|
|
|
- pushDTO.setLis(neoDto.getLis().subList(0, neoDto.getLis().size() >= length ? length : neoDto.getLis().size()));
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // 辅检
|
|
|
|
- if (ruleTypeList.contains("6") && ListUtil.isNotEmpty(neoDto.getPacs())) {
|
|
|
|
- pushDTO.setPacs(neoDto.getPacs().subList(0, neoDto.getPacs().size() >= length ? length : neoDto.getPacs().size()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 诊断
|
|
|
|
- if (ruleTypeList.contains("7") && neoDto.getDis() != null) {
|
|
|
|
- Map<String, List<PushBaseDTO>> disMap = neoDto.getDis();
|
|
|
|
- Map<String, List<PushBaseDTO>> resMap = new HashMap<>();
|
|
|
|
- for (String key : disMap.keySet()) {
|
|
|
|
- resMap.put(key, disMap.get(key).subList(0, disMap.get(key).size() >= length ? length : disMap.get(key).size()));
|
|
|
|
- }
|
|
|
|
- pushDTO.setDis(resMap);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+// return pushDTO;
|
|
|
|
+ }
|
|
|
|
|
|
- }*/
|
|
|
|
- return pushDTO;
|
|
|
|
|
|
+ private List<PushBaseDTO> getPackagePushBaseDTO(Map<String, List<String>> typeWords, List<String> symptoms, StandConvertEnum symptom) {
|
|
|
|
+ PushBaseDTO pushBaseDTO = new PushBaseDTO();
|
|
|
|
+ List<PushBaseDTO> symptomPush = symptoms.stream().map(x -> {
|
|
|
|
+ pushBaseDTO.setName(x);
|
|
|
|
+ return pushBaseDTO;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ return symptomPush.stream().filter(x -> !typeWords.get(symptom.getName()).contains(x.getName())).collect(Collectors.toList());
|
|
}
|
|
}
|
|
|
|
|
|
public BillNeoVO fillBillNeo(IndicationPushVO indicationPushVO) {
|
|
public BillNeoVO fillBillNeo(IndicationPushVO indicationPushVO) {
|