|
@@ -24,6 +24,7 @@ import com.diagbot.enums.LexiconEnum;
|
|
|
import com.diagbot.enums.MedicalAdviceEnum;
|
|
|
import com.diagbot.enums.PushRelationTypeEnum;
|
|
|
import com.diagbot.enums.RedisEnum;
|
|
|
+import com.diagbot.enums.RelationshipEnum;
|
|
|
import com.diagbot.enums.StandConvertEnum;
|
|
|
import com.diagbot.facade.CommonFacade;
|
|
|
import com.diagbot.facade.ConceptInfoFacade;
|
|
@@ -38,14 +39,18 @@ import com.diagbot.rule.GroupRule;
|
|
|
import com.diagbot.rule.LisRule;
|
|
|
import com.diagbot.rule.VitalRule;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.CoreUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.RedisUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.vo.DiagnoseVO;
|
|
|
import com.diagbot.vo.DiseaseItemVO;
|
|
|
import com.diagbot.vo.IcssVo;
|
|
|
import com.diagbot.vo.NeoPushVO;
|
|
|
import com.diagbot.vo.PushVO;
|
|
|
import com.diagbot.vo.ReverseVO;
|
|
|
+import com.diagbot.vo.StandConvert;
|
|
|
import com.diagbot.vo.neoPushEntity.Diag;
|
|
|
import com.diagbot.vo.neoPushEntity.DiagVo;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -354,40 +359,21 @@ public class PushProcess {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 6.0推送业务
|
|
|
+ * 反推
|
|
|
*
|
|
|
* @param pushVo
|
|
|
* @param standConvertMap
|
|
|
* @param wordCrfDTO
|
|
|
* @return
|
|
|
*/
|
|
|
- public PushDTO process(PushVO pushVo, Map<String, Map<String, String>> standConvertMap, WordCrfDTO wordCrfDTO) {
|
|
|
+ public PushDTO process(PushDTO pushDTO, PushVO pushVo, WordCrfDTO wordCrfDTO) {
|
|
|
int length = pushVo.getLength();
|
|
|
- // TODO 聚合诊断依据推送的诊断和大数据推送的可能诊断
|
|
|
- PushDTO pushDTO = pushDiagnose(wordCrfDTO);
|
|
|
+ // 需要获取的类型
|
|
|
List<String> ruleTypeList = Arrays.asList(pushVo.getFeatureType().split(","));
|
|
|
- Map<String, List<String>> typeWords = typeWords(standConvertMap);
|
|
|
-
|
|
|
+ // 界面过滤元素
|
|
|
+ Map<String, List<String>> typeWords = filterWords(wordCrfDTO);
|
|
|
// 根据诊断反推(根据性别和年龄过滤,并根据界面已有信息过滤,根据长度截取)
|
|
|
reversePushPackage(pushDTO, ruleTypeList, typeWords, wordCrfDTO, length);
|
|
|
-
|
|
|
- // if (ListUtil.isNotEmpty(push)) {
|
|
|
- // //先把所有疾病推出来
|
|
|
- // if (ruleTypeList.contains("7")) {
|
|
|
- // List<PushBaseDTO> diseeases = push.stream().map(x -> {
|
|
|
- // PushBaseDTO pushBaseDTO = new PushBaseDTO();
|
|
|
- // pushBaseDTO.setName(x);
|
|
|
- // return pushBaseDTO;
|
|
|
- // }).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;
|
|
|
}
|
|
|
|
|
@@ -520,19 +506,26 @@ public class PushProcess {
|
|
|
pushVO.setDiagVo(diagVo);
|
|
|
}
|
|
|
|
|
|
- public Map<String, List<String>> typeWords(Map<String, Map<String, String>> standConvertMap) {
|
|
|
+ /**
|
|
|
+ * 生成各个类型的界面过滤元素
|
|
|
+ *
|
|
|
+ * @param wordCrfDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, List<String>> filterWords(WordCrfDTO wordCrfDTO) {
|
|
|
Map<String, List<String>> typeWordsMap = new HashMap<>();
|
|
|
- for (Map.Entry<String, Map<String, String>> s : standConvertMap.entrySet()) {
|
|
|
- List<String> words = new ArrayList<>();
|
|
|
- String type = s.getKey();
|
|
|
- Map<String, String> value = s.getValue();
|
|
|
- value.forEach((name, standName) -> {
|
|
|
- words.add(name);
|
|
|
- words.add(standName);
|
|
|
- });
|
|
|
- typeWordsMap.put(type, new ArrayList<>(new LinkedHashSet<>(words)));
|
|
|
- }
|
|
|
-
|
|
|
+ // TODO 界面过滤元素
|
|
|
+ typeWordsMap.put(StandConvertEnum.lis.getName(), CoreUtil.getByPropertyName(wordCrfDTO.getLis(), "name", "uniqueName"));
|
|
|
+ // for (Map.Entry<String, Map<String, String>> s : standConvertMap.entrySet()) {
|
|
|
+ // List<String> words = new ArrayList<>();
|
|
|
+ // String type = s.getKey();
|
|
|
+ // Map<String, String> value = s.getValue();
|
|
|
+ // value.forEach((name, standName) -> {
|
|
|
+ // words.add(name);
|
|
|
+ // words.add(standName);
|
|
|
+ // });
|
|
|
+ // typeWordsMap.put(type, new ArrayList<>(new LinkedHashSet<>(words)));
|
|
|
+ // }
|
|
|
return typeWordsMap;
|
|
|
}
|
|
|
|
|
@@ -545,13 +538,170 @@ public class PushProcess {
|
|
|
* @param length
|
|
|
*/
|
|
|
private void reversePushPackage(PushDTO pushDTO, List<String> ruleTypeList, Map<String, List<String>> typeWords, WordCrfDTO wordCrfDTO, int length){
|
|
|
- // TODO 拼接查询数据的入参
|
|
|
- ReverseVO reverseVO = new ReverseVO();
|
|
|
-
|
|
|
- // TODO 查询数据
|
|
|
+ Map<String, List<PushBaseDTO>> dis = pushDTO.getDis();
|
|
|
+ // 生成反推的入参
|
|
|
+ ReverseVO reverseVO = generateReverseVO(wordCrfDTO, ruleTypeList, dis);
|
|
|
+ if (StringUtil.isEmpty(reverseVO.getLibName())) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ pushDTO.getDebug().put("反推依据诊断", reverseVO.getLibName());
|
|
|
+ // 查询数据
|
|
|
List<ReverseDTO> reverseDTOList = conceptInfoFacade.getReverseFac(reverseVO);
|
|
|
|
|
|
- // TODO 放到对应位置
|
|
|
+ // 设置其他推送信息
|
|
|
+ setPushItem(pushDTO, ruleTypeList, typeWords, reverseDTOList, length);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置其他推送信息
|
|
|
+ *
|
|
|
+ * @param pushDTO
|
|
|
+ * @param ruleTypeList
|
|
|
+ * @param typeWords
|
|
|
+ * @param reverseDTOList
|
|
|
+ */
|
|
|
+ public void setPushItem(PushDTO pushDTO, List<String> ruleTypeList, Map<String, List<String>> typeWords, List<ReverseDTO> reverseDTOList, int length) {
|
|
|
+ Map<String, List<PushBaseDTO>> dis = pushDTO.getDis();
|
|
|
+ Map<Integer, List<ReverseDTO>> map = EntityUtil.makeEntityListMap(reverseDTOList, "sonType");
|
|
|
+ // 症状
|
|
|
+ if (ruleTypeList.contains("1")) {
|
|
|
+ if (map.get(LexiconEnum.Symptom.getKey()) != null) {
|
|
|
+ List<String> list = map.get(LexiconEnum.Symptom.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
|
|
|
+ CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.symptom.toString())); // 过滤界面已有
|
|
|
+ pushDTO.setSymptom(getPushBaseDTO(list, length)); // 放入对象返回
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 查体结果
|
|
|
+ if (ruleTypeList.contains("4")) {
|
|
|
+ if (map.get(LexiconEnum.VitalResult.getKey()) != null) {
|
|
|
+ List<String> list = map.get(LexiconEnum.VitalResult.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
|
|
|
+ CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.vital.toString())); // 过滤界面已有
|
|
|
+ pushDTO.setVital(getPushBaseDTO(list, length)); // 放入对象返回
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 化验套餐
|
|
|
+ if (ruleTypeList.contains("5")) {
|
|
|
+ if (map.get(LexiconEnum.LisName.getKey()) != null) {
|
|
|
+ List<String> list = map.get(LexiconEnum.LisName.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
|
|
|
+ CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.lis.toString())); // 过滤界面已有
|
|
|
+ pushDTO.setLis(getPushBaseDTO(list, length)); // 放入对象返回
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 辅检项目
|
|
|
+ if (ruleTypeList.contains("6")) {
|
|
|
+ if (map.get(LexiconEnum.PacsName.getKey()) != null) {
|
|
|
+ List<String> list = map.get(LexiconEnum.PacsName.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
|
|
|
+ CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.pacs.toString())); // 过滤界面已有
|
|
|
+ pushDTO.setPacs(getPushBaseDTO(list, length)); // 放入对象返回
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 鉴别诊断, 注意这个类型与其他类型不一样
|
|
|
+ if (ruleTypeList.contains("7")) {
|
|
|
+ if (map.get(LexiconEnum.Disease.getKey()) != null) {
|
|
|
+ List<String> list = map.get(LexiconEnum.Disease.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
|
|
|
+ CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.disease.toString())); // 过滤界面已有
|
|
|
+ List<PushBaseDTO> pushBaseDTO = getPushBaseDTO(list, length);
|
|
|
+ if (ListUtil.isNotEmpty(pushBaseDTO)) {
|
|
|
+ dis.put(DiseaseTypeEnum.identify.getName(), pushBaseDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 药品
|
|
|
+ if (ruleTypeList.contains("8")) {
|
|
|
+ if (map.get(LexiconEnum.Medicine.getKey()) != null) {
|
|
|
+ List<String> list = map.get(LexiconEnum.Medicine.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
|
|
|
+ CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.drug.toString())); // 过滤界面已有
|
|
|
+ pushDTO.setMedicines(getPushBaseDTO(list, length)); // 放入对象返回
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 手术
|
|
|
+ if (ruleTypeList.contains("9")) {
|
|
|
+ if (map.get(LexiconEnum.Operation.getKey()) != null) {
|
|
|
+ List<String> list = map.get(LexiconEnum.Operation.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
|
|
|
+ CoreUtil.removeRepeat(list, typeWords.get(StandConvertEnum.operation.toString())); // 过滤界面已有
|
|
|
+ pushDTO.setOperations(getPushBaseDTO(list, length)); // 放入对象返回
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将名称列表生成推送返回类型
|
|
|
+ *
|
|
|
+ * @param nameList
|
|
|
+ * @param length 最长个数
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<PushBaseDTO> getPushBaseDTO(List<String> nameList, int length) {
|
|
|
+ List<PushBaseDTO> pushBaseDTOList = Lists.newArrayList();
|
|
|
+ if (ListUtil.isNotEmpty(nameList)) {
|
|
|
+ for (int i = 0; i < nameList.size(); i++) {
|
|
|
+ if (pushBaseDTOList.size() >= length) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ PushBaseDTO pushBaseDTO = new PushBaseDTO();
|
|
|
+ pushBaseDTO.setName(nameList.get(i));
|
|
|
+ pushBaseDTOList.add(pushBaseDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pushBaseDTOList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成反推的入参
|
|
|
+ *
|
|
|
+ * @param wordCrfDTO
|
|
|
+ * @param ruleTypeList
|
|
|
+ * @param dis
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ReverseVO generateReverseVO(WordCrfDTO wordCrfDTO, List<String> ruleTypeList, Map<String, List<PushBaseDTO>> dis) {
|
|
|
+ ReverseVO reverseVO = new ReverseVO();
|
|
|
+ reverseVO.setAge(wordCrfDTO.getAgeNum());
|
|
|
+ reverseVO.setSexType(wordCrfDTO.getSex());
|
|
|
+ reverseVO.setLibType(LexiconEnum.Disease.getKey());
|
|
|
+ String disName = "";
|
|
|
+ // 按以下顺序获取一个诊断: 下的诊断->确诊->拟诊->警惕->可能
|
|
|
+ if (ListUtil.isNotEmpty(wordCrfDTO.getDiag())) {
|
|
|
+ disName = wordCrfDTO.getDiag().get(0).getUniqueName();
|
|
|
+ } else if (dis != null) {
|
|
|
+ if (dis.get(DiagnoseTypeEnum.definite.getName()) != null) { // 确诊
|
|
|
+ disName = dis.get(DiagnoseTypeEnum.definite.getName()).get(0).getName();
|
|
|
+ } else if (dis.get(DiagnoseTypeEnum.protocol.getName()) != null) { // 拟诊
|
|
|
+ disName = dis.get(DiagnoseTypeEnum.protocol.getName()).get(0).getName();
|
|
|
+ } else if (dis.get(DiagnoseTypeEnum.vigilant.getName()) != null) { // 警惕
|
|
|
+ disName = dis.get(DiagnoseTypeEnum.vigilant.getName()).get(0).getName();
|
|
|
+ } else if (dis.get(DiseaseTypeEnum.possibleDis.getName()) != null) { // 可能
|
|
|
+ disName = dis.get(DiseaseTypeEnum.possibleDis.getName()).get(0).getName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reverseVO.setLibName(disName);
|
|
|
+
|
|
|
+ // 关联类型
|
|
|
+ List<Integer> relationType = new ArrayList<>();
|
|
|
+ if (ruleTypeList.contains("1")) {
|
|
|
+ relationType.add(RelationshipEnum.R501.getKey()); // 主症状
|
|
|
+ relationType.add(RelationshipEnum.R502.getKey()); // 次症状
|
|
|
+ }
|
|
|
+ if (ruleTypeList.contains("4")) {
|
|
|
+ relationType.add(RelationshipEnum.R503.getKey()); // 查体结果
|
|
|
+ }
|
|
|
+ if (ruleTypeList.contains("5")) {
|
|
|
+ relationType.add(RelationshipEnum.R504.getKey()); // 化验套餐
|
|
|
+ }
|
|
|
+ if (ruleTypeList.contains("6")) {
|
|
|
+ relationType.add(RelationshipEnum.R505.getKey()); // 辅助检查项目
|
|
|
+ }
|
|
|
+ if (ruleTypeList.contains("7")) {
|
|
|
+ relationType.add(RelationshipEnum.R508.getKey()); // 鉴别诊断
|
|
|
+ }
|
|
|
+ if (ruleTypeList.contains("8")) {
|
|
|
+ relationType.add(RelationshipEnum.R506.getKey()); // 药品
|
|
|
+ }
|
|
|
+ if (ruleTypeList.contains("9")) {
|
|
|
+ relationType.add(RelationshipEnum.R507.getKey()); // 手术
|
|
|
+ }
|
|
|
+ reverseVO.setRelationType(relationType);
|
|
|
+ return reverseVO;
|
|
|
}
|
|
|
|
|
|
private void reversePushPackage(int length, PushDTO pushDTO, List<String> ruleTypeList, Map<String, List<String>> typeWords, NeoPushVO pushVO, Map<String, List<PushBaseDTO>> dis) {
|