|
@@ -4,27 +4,44 @@ import com.diagbot.biz.push.entity.Item;
|
|
|
import com.diagbot.biz.push.entity.Lis;
|
|
|
import com.diagbot.biz.push.entity.Pacs;
|
|
|
import com.diagbot.client.IcssPushServiceClient;
|
|
|
+import com.diagbot.dto.BaseDiagnoseDTO;
|
|
|
+import com.diagbot.dto.DiagnoseDTO;
|
|
|
import com.diagbot.dto.NeoPushDTO;
|
|
|
import com.diagbot.dto.PushBaseDTO;
|
|
|
import com.diagbot.dto.PushDTO;
|
|
|
-import com.diagbot.dto.PushDiagnoseDTO;
|
|
|
+import com.diagbot.dto.RuleBaseDTO;
|
|
|
import com.diagbot.dto.TreatDTO;
|
|
|
import com.diagbot.dto.WordCrfDTO;
|
|
|
import com.diagbot.dto.icss.FeatureRate;
|
|
|
import com.diagbot.dto.icss.Response;
|
|
|
import com.diagbot.dto.icss.ResponseData;
|
|
|
import com.diagbot.entity.PreResult;
|
|
|
+import com.diagbot.enums.BaseDiagnoseTypeEnum;
|
|
|
+import com.diagbot.enums.DiagnoseTypeEnum;
|
|
|
import com.diagbot.enums.DiseaseTypeEnum;
|
|
|
+import com.diagbot.enums.LexiconEnum;
|
|
|
import com.diagbot.enums.MedicalAdviceEnum;
|
|
|
import com.diagbot.enums.PushRelationTypeEnum;
|
|
|
import com.diagbot.enums.RedisEnum;
|
|
|
import com.diagbot.enums.StandConvertEnum;
|
|
|
import com.diagbot.facade.CommonFacade;
|
|
|
+import com.diagbot.facade.KlDiagnoseFacade;
|
|
|
import com.diagbot.facade.KlRelationFacade;
|
|
|
import com.diagbot.facade.NeoFacade;
|
|
|
import com.diagbot.facade.TranLisConfigIcssFacade;
|
|
|
+import com.diagbot.model.entity.Clinical;
|
|
|
+import com.diagbot.model.entity.Operation;
|
|
|
+import com.diagbot.model.label.ChiefLabel;
|
|
|
+import com.diagbot.model.label.PacsLabel;
|
|
|
+import com.diagbot.model.label.PastLabel;
|
|
|
+import com.diagbot.model.label.PresentLabel;
|
|
|
+import com.diagbot.rule.CommonRule;
|
|
|
+import com.diagbot.rule.LisRule;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.CoreUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.RedisUtil;
|
|
|
+import com.diagbot.vo.DiagnoseVO;
|
|
|
import com.diagbot.vo.DiseaseItemVO;
|
|
|
import com.diagbot.vo.IcssVo;
|
|
|
import com.diagbot.vo.NeoPushVO;
|
|
@@ -68,7 +85,14 @@ public class PushProcess {
|
|
|
@Autowired
|
|
|
RedisUtil redisUtil;
|
|
|
@Autowired
|
|
|
- private KlRelationFacade klRelationFacade;
|
|
|
+ KlRelationFacade klRelationFacade;
|
|
|
+ @Autowired
|
|
|
+ CommonRule commonRule;
|
|
|
+ @Autowired
|
|
|
+ LisRule lisRule;
|
|
|
+ @Autowired
|
|
|
+ KlDiagnoseFacade klDiagnoseFacade;
|
|
|
+
|
|
|
|
|
|
public PushDTO processIcss(PushVO pushVo) {
|
|
|
|
|
@@ -327,44 +351,161 @@ public class PushProcess {
|
|
|
public PushDTO process(PushVO pushVo, Map<String, Map<String, String>> standConvertMap, WordCrfDTO wordCrfDTO) {
|
|
|
int length = pushVo.getLength();
|
|
|
PushDTO pushDTO = new PushDTO();
|
|
|
-// List<String> ruleTypeList = Arrays.asList(pushVo.getFeatureType().split(","));
|
|
|
-// Map<String, List<String>> typeWords = typeWords(standConvertMap);
|
|
|
-// //生成push入参,供图谱调用
|
|
|
-// NeoPushVO pushVO = commonFacade.generatePushInput(wordCrfDTO);
|
|
|
-// Map<String, List<PushBaseDTO>> dis = new HashMap<>();
|
|
|
-// List<String> push = neoFacade.getPush(pushVO);
|
|
|
-// 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);
|
|
|
-// }
|
|
|
+ // 推送诊断
|
|
|
+ pushDiagnose(wordCrfDTO, pushDTO);
|
|
|
+ // List<String> ruleTypeList = Arrays.asList(pushVo.getFeatureType().split(","));
|
|
|
+ // Map<String, List<String>> typeWords = typeWords(standConvertMap);
|
|
|
+ // Map<String, List<PushBaseDTO>> dis = new HashMap<>();
|
|
|
+ // 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;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据诊断依据推送疾病
|
|
|
* @param wordCrfDTO
|
|
|
*/
|
|
|
- public PushDiagnoseDTO pushDiagnose(WordCrfDTO wordCrfDTO) {
|
|
|
- PushDiagnoseDTO pushDiagnoseDTO = new PushDiagnoseDTO();
|
|
|
- // TODO 读取所有的诊断依据规则
|
|
|
-
|
|
|
- // TODO 规则匹配
|
|
|
+ public void pushDiagnose(WordCrfDTO wordCrfDTO, PushDTO pushDTO) {
|
|
|
+ // 读取所有的诊断依据规则——已去重处理
|
|
|
+ List<BaseDiagnoseDTO> diagnoselist = redisUtil.get(RedisEnum.allBaseDiagnose.getName());
|
|
|
+ // 匹配的诊断依据规则
|
|
|
+ List<Long> baseIdList = new ArrayList<>();
|
|
|
+
|
|
|
+ /**---------------------------数据统一处理开始--------------------------------- */
|
|
|
+ ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel();
|
|
|
+ PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
|
|
|
+ PastLabel pastLabel = wordCrfDTO.getPastLabel();
|
|
|
+ // 【过敏药品数据来源】
|
|
|
+ List<Item> allergyMedicines = commonRule.getDrugAllergySource(wordCrfDTO);
|
|
|
+ // 【药品数据来源】(主诉、现病史、既往史、结构化药品)
|
|
|
+ List<Item> medicineAll = wordCrfDTO.getDrugSource();
|
|
|
+ // 【诊断数据来源】
|
|
|
+ List<Item> diags = wordCrfDTO.getDiagSource();
|
|
|
+ // 【辅检结果数据来源】
|
|
|
+ PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
|
|
|
+ List<Item> pacsDescList = pacsLabel.getRes();
|
|
|
+ // 【手术数据来源】
|
|
|
+ List<Operation> operations_all = new ArrayList<>();
|
|
|
+ List<Item> operation = wordCrfDTO.getOperation();
|
|
|
+ List<Operation> operationsItem = new ArrayList<>();
|
|
|
+ for (Item item : operation) {
|
|
|
+ Operation operaData = new Operation();
|
|
|
+ operaData.setName(item.getName());
|
|
|
+ operaData.setStandName(item.getUniqueName());
|
|
|
+ operationsItem.add(operaData);
|
|
|
+ }
|
|
|
+ CoreUtil.addList(operations_all, chiefLabel.getOperations()); // 主诉手术
|
|
|
+ CoreUtil.addList(operations_all, presentLabel.getOperations()); // 现病史手术
|
|
|
+ CoreUtil.addList(operations_all, pastLabel.getOperations()); // 既往史手术
|
|
|
+ CoreUtil.addList(operations_all, operationsItem); // 结构化手术
|
|
|
+ // 【临床表现数据来源】(主诉、现病史)
|
|
|
+ List<Clinical> clinicals = new ArrayList<>();
|
|
|
+ CoreUtil.addList(clinicals, chiefLabel.getClinicals()); // 主诉临床表现
|
|
|
+ CoreUtil.addList(clinicals, presentLabel.getClinicals()); // 现病史临床表现
|
|
|
+ /**---------------------------数据统一处理结束--------------------------------- */
|
|
|
+
|
|
|
+ // TODO 规则处理
|
|
|
+ for (BaseDiagnoseDTO base : diagnoselist) {
|
|
|
+ RuleBaseDTO ruleBaseDTO = new RuleBaseDTO();
|
|
|
+ BeanUtil.copyProperties(base, ruleBaseDTO);
|
|
|
+ String baseIds = base.getIds();
|
|
|
+ switch (BaseDiagnoseTypeEnum.getEnum(base.getBaseType())) {
|
|
|
+ case B1: // 等于术语本身
|
|
|
+ switch (LexiconEnum.getEnum(base.getBaseLibType())) {
|
|
|
+ case Symptom: // 症状
|
|
|
+ commonRule.compareNameWithPush(clinicals, ruleBaseDTO, baseIdList, baseIds);
|
|
|
+ break;
|
|
|
+ case VitalResult: // 体格检查结果
|
|
|
+ break;
|
|
|
+ case Disease: // 疾病
|
|
|
+ break;
|
|
|
+ case Group: // 人群
|
|
|
+ break;
|
|
|
+ case PacsResult: // 辅助检查结果
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case B2: // 比较
|
|
|
+ switch (LexiconEnum.getEnum(base.getBaseLibType())) {
|
|
|
+ case LisSubName: // 化验
|
|
|
+ lisRule.push(wordCrfDTO.getLis(), ruleBaseDTO, baseIdList, baseIds);
|
|
|
+ break;
|
|
|
+ case Age: // 年龄
|
|
|
+ break;
|
|
|
+ case VitalResult: // 体格检查结果
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case B3: // 主诉现病史正则
|
|
|
+ break;
|
|
|
+ case B4: // 既往史正则
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 根据诊断依据推送诊断
|
|
|
+ pushDTO.getDebug().put("诊断依据ID列表", StringUtils.join(baseIdList, ","));
|
|
|
+ Map<String, List<PushBaseDTO>> pushDiagnoseDTO = setPushDiagnose(wordCrfDTO, baseIdList);
|
|
|
+ pushDTO.setDis(pushDiagnoseDTO);
|
|
|
+ }
|
|
|
|
|
|
- // TODO 返回诊断
|
|
|
+ /**
|
|
|
+ * 根据诊断依据推送诊断
|
|
|
+ *
|
|
|
+ * @param wordCrfDTO
|
|
|
+ * @param baseIdList
|
|
|
+ */
|
|
|
+ public Map<String, List<PushBaseDTO>> setPushDiagnose(WordCrfDTO wordCrfDTO, List<Long> baseIdList) {
|
|
|
+ Map<String, List<PushBaseDTO>> pushDiagnoseDTO = new LinkedHashMap<>();
|
|
|
+ // 设置诊断
|
|
|
+ if (ListUtil.isNotEmpty(baseIdList)) {
|
|
|
+ DiagnoseVO diagnoseVO = new DiagnoseVO();
|
|
|
+ diagnoseVO.setAge(wordCrfDTO.getAgeNum());
|
|
|
+ diagnoseVO.setSexType(wordCrfDTO.getSex());
|
|
|
+ diagnoseVO.setIds(baseIdList);
|
|
|
+ List<DiagnoseDTO> diagnoseDTOList = klDiagnoseFacade.getDiagnoseByIds(diagnoseVO);
|
|
|
+ List<PushBaseDTO> protocolList = new ArrayList<>(); // 拟诊
|
|
|
+ List<PushBaseDTO> definiteList = new ArrayList<>(); // 确诊
|
|
|
+ List<PushBaseDTO> vigilantList = new ArrayList<>(); // 警惕
|
|
|
+ for (DiagnoseDTO diagnoseDTO : diagnoseDTOList) {
|
|
|
+ PushBaseDTO pushBaseDTO = new PushBaseDTO();
|
|
|
+ pushBaseDTO.setName(diagnoseDTO.getLibName());
|
|
|
+ switch (DiagnoseTypeEnum.getEnum(diagnoseDTO.getConditionType())) {
|
|
|
+ case protocol: // 拟诊
|
|
|
+ protocolList.add(pushBaseDTO);
|
|
|
+ break;
|
|
|
+ case definite: // 确诊
|
|
|
+ definiteList.add(pushBaseDTO);
|
|
|
+ break;
|
|
|
+ case vigilant: // 警惕
|
|
|
+ vigilantList.add(pushBaseDTO);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(protocolList)) {
|
|
|
+ pushDiagnoseDTO.put("拟诊", protocolList);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(definiteList)) {
|
|
|
+ pushDiagnoseDTO.put("确诊", definiteList);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(vigilantList)) {
|
|
|
+ pushDiagnoseDTO.put("警惕", vigilantList);
|
|
|
+ }
|
|
|
+ }
|
|
|
return pushDiagnoseDTO;
|
|
|
}
|
|
|
|