|
@@ -0,0 +1,144 @@
|
|
|
|
+package com.diagbot.facade;
|
|
|
|
+
|
|
|
|
+import com.diagbot.dto.BaseRegulationDTO;
|
|
|
|
+import com.diagbot.dto.RegulationDTO;
|
|
|
|
+import com.diagbot.dto.RuleBaseDTO;
|
|
|
|
+import com.diagbot.dto.WordCrfDTO;
|
|
|
|
+import com.diagbot.enums.BaseDiagnoseTypeEnum;
|
|
|
|
+import com.diagbot.enums.LexiconEnum;
|
|
|
|
+import com.diagbot.enums.RedisEnum;
|
|
|
|
+import com.diagbot.model.entity.Clinical;
|
|
|
|
+import com.diagbot.rule.AgeRule;
|
|
|
|
+import com.diagbot.rule.CommonRule;
|
|
|
|
+import com.diagbot.rule.GroupRule;
|
|
|
|
+import com.diagbot.rule.LisRule;
|
|
|
|
+import com.diagbot.rule.VitalRule;
|
|
|
|
+import com.diagbot.service.impl.KlRegulationBaseServiceImpl;
|
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
|
+import com.diagbot.util.RedisUtil;
|
|
|
|
+import com.diagbot.vo.PushVO;
|
|
|
|
+import com.diagbot.vo.RegulationVO;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Description:
|
|
|
|
+ * @author: zhoutg
|
|
|
|
+ * @time: 2021/3/15 10:58
|
|
|
|
+ */
|
|
|
|
+@Component
|
|
|
|
+public class KlRegulationBaseFacade extends KlRegulationBaseServiceImpl {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ RedisUtil redisUtil;
|
|
|
|
+ @Autowired
|
|
|
|
+ CommonFacade commonFacade;
|
|
|
|
+ @Autowired
|
|
|
|
+ CommonRule commonRule;
|
|
|
|
+ @Autowired
|
|
|
|
+ VitalRule vitalRule;
|
|
|
|
+ @Autowired
|
|
|
|
+ GroupRule groupRule;
|
|
|
|
+ @Autowired
|
|
|
|
+ LisRule lisRule;
|
|
|
|
+ @Autowired
|
|
|
|
+ AgeRule ageRule;
|
|
|
|
+ @Autowired
|
|
|
|
+ KlRegulationFacade klRegulationFacade;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 匹配规则
|
|
|
|
+ *
|
|
|
|
+ * @param pushVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<String> process(PushVO pushVO) {
|
|
|
|
+ List<String> codeList = Lists.newArrayList();
|
|
|
|
+ // 读取所有的基础规则——已去重
|
|
|
|
+ List<BaseRegulationDTO> baseRegulationDTOList = redisUtil.get(RedisEnum.allBaseRegulation.getName());
|
|
|
|
+ if (ListUtil.isEmpty(baseRegulationDTOList)) {
|
|
|
|
+ return codeList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // CRF模型处理
|
|
|
|
+ WordCrfDTO wordCrfDTO = commonFacade.crf_process(pushVO, false);
|
|
|
|
+
|
|
|
|
+ // 同义词转换
|
|
|
|
+ commonFacade.wordStandConvert(wordCrfDTO);
|
|
|
|
+
|
|
|
|
+ // 匹配的基础规则
|
|
|
|
+ List<Long> baseIdList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ /**---------------------------数据统一处理开始--------------------------------- */
|
|
|
|
+ // 【临床表现数据来源】(主诉、现病史)
|
|
|
|
+ List<Clinical> clinicals = commonFacade.getClinicalSource(wordCrfDTO);
|
|
|
|
+ /**---------------------------数据统一处理结束--------------------------------- */
|
|
|
|
+
|
|
|
|
+ // 规则处理
|
|
|
|
+ for (BaseRegulationDTO base : baseRegulationDTOList) {
|
|
|
|
+ RuleBaseDTO ruleBaseDTO = new RuleBaseDTO();
|
|
|
|
+ BeanUtil.copyProperties(base, ruleBaseDTO);
|
|
|
|
+ String baseIds = base.getIds();
|
|
|
|
+ switch (BaseDiagnoseTypeEnum.getEnum(base.getBaseType())) {
|
|
|
|
+ case equals: // 等于术语本身
|
|
|
|
+ switch (LexiconEnum.getEnum(base.getBaseLibType())) {
|
|
|
|
+ case Symptom: // 症状
|
|
|
|
+ commonRule.compareNameWithPush(clinicals, ruleBaseDTO, baseIdList, baseIds);
|
|
|
|
+ break;
|
|
|
|
+ case Disease: // 疾病【病史】
|
|
|
|
+ commonRule.compareNameWithPush(wordCrfDTO.getPastLabel().getDiags(), ruleBaseDTO, baseIdList, baseIds);
|
|
|
|
+ break;
|
|
|
|
+ case VitalResult: // 体格检查结果
|
|
|
|
+ vitalRule.push(wordCrfDTO.getVitalLabel(), ruleBaseDTO, baseIdList, baseIds);
|
|
|
|
+ break;
|
|
|
|
+ case Group: // 人群
|
|
|
|
+ groupRule.push(wordCrfDTO, ruleBaseDTO, baseIdList, baseIds);
|
|
|
|
+ break;
|
|
|
|
+ case PacsResult: // 辅助检查结果
|
|
|
|
+ commonRule.compareItemWithPush(wordCrfDTO.getPacsLabel().getRes(), ruleBaseDTO, baseIdList, baseIds);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case compare: // 比较
|
|
|
|
+ switch (LexiconEnum.getEnum(base.getBaseLibType())) {
|
|
|
|
+ case LisSubName: // 化验
|
|
|
|
+ lisRule.push(wordCrfDTO.getLis(), ruleBaseDTO, baseIdList, baseIds);
|
|
|
|
+ break;
|
|
|
|
+ case Age: // 年龄
|
|
|
|
+ ageRule.push(wordCrfDTO, ruleBaseDTO, baseIdList, baseIds);
|
|
|
|
+ break;
|
|
|
|
+ case Vital: // 体格检查项目
|
|
|
|
+ vitalRule.push(wordCrfDTO.getVitalLabel(), ruleBaseDTO, baseIdList, baseIds);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case regexChiefSymptom: // 主诉现病史正则
|
|
|
|
+ commonRule.getRegexResPush(wordCrfDTO.getChief() + wordCrfDTO.getSymptom(),
|
|
|
|
+ base.getBaseEqValue(), baseIdList, baseIds);
|
|
|
|
+ break;
|
|
|
|
+ case regexPast: // 既往史正则
|
|
|
|
+ commonRule.getRegexResPush(wordCrfDTO.getPasts() + wordCrfDTO.getPersonal() + wordCrfDTO.getMenstrual() + wordCrfDTO.getMarital() + wordCrfDTO.getFamily(),
|
|
|
|
+ base.getBaseEqValue(), baseIdList, baseIds);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Collections.sort(baseIdList); // id排序,方便调试查看
|
|
|
|
+
|
|
|
|
+ if (ListUtil.isNotEmpty(baseIdList)) {
|
|
|
|
+ RegulationVO regulationVO = new RegulationVO();
|
|
|
|
+ regulationVO.setIds(baseIdList);
|
|
|
|
+ List<RegulationDTO> regulationDTOList = klRegulationFacade.getRegulationByIds(regulationVO);
|
|
|
|
+ if (ListUtil.isNotEmpty(regulationDTOList)) {
|
|
|
|
+ codeList = regulationDTOList.stream().map(r -> r.getCode()).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return codeList;
|
|
|
|
+ }
|
|
|
|
+}
|