|
@@ -1,13 +1,19 @@
|
|
|
package com.diagbot.rule;
|
|
|
|
|
|
import com.diagbot.biz.push.entity.Pacs;
|
|
|
+import com.diagbot.dto.BaseDiagnoseDTO;
|
|
|
import com.diagbot.dto.BillMsg;
|
|
|
import com.diagbot.dto.RuleBaseDTO;
|
|
|
import com.diagbot.dto.RuleSimpleDTO;
|
|
|
import com.diagbot.dto.WordCrfDTO;
|
|
|
+import com.diagbot.enums.BaseDiagnoseTypeEnum;
|
|
|
import com.diagbot.enums.ConEnum;
|
|
|
+import com.diagbot.enums.LexiconEnum;
|
|
|
import com.diagbot.enums.TypeEnum;
|
|
|
+import com.diagbot.facade.CommonFacade;
|
|
|
+import com.diagbot.model.entity.Clinical;
|
|
|
import com.diagbot.model.entity.Negative;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.CatalogueUtil;
|
|
|
import com.diagbot.util.CoreUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
@@ -16,6 +22,7 @@ import com.diagbot.util.MsgUtil;
|
|
|
import com.diagbot.util.RegexUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
@@ -26,8 +33,6 @@ import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
-import java.util.concurrent.atomic.AtomicReference;
|
|
|
-import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
/**
|
|
|
* @description: 通用规则提取
|
|
@@ -37,6 +42,17 @@ import java.util.concurrent.locks.ReentrantLock;
|
|
|
@Component
|
|
|
public class CommonRule {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ CommonFacade commonFacade;
|
|
|
+ @Autowired
|
|
|
+ GroupRule groupRule;
|
|
|
+ @Autowired
|
|
|
+ VitalRule vitalRule;
|
|
|
+ @Autowired
|
|
|
+ AgeRule ageRule;
|
|
|
+ @Autowired
|
|
|
+ LisRule lisRule;
|
|
|
+
|
|
|
/**
|
|
|
* 比较阳性属性是否匹配
|
|
|
*
|
|
@@ -406,34 +422,71 @@ public class CommonRule {
|
|
|
highRiskList.add(billMsg);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据基础规则,通用
|
|
|
+ *
|
|
|
+ * @param wordCrfDTO
|
|
|
+ */
|
|
|
+ public List<Long> matchBase(WordCrfDTO wordCrfDTO, List<BaseDiagnoseDTO> baseList) {
|
|
|
+ List<Long> baseIdList = new ArrayList<>();
|
|
|
+ /**---------------------------数据统一处理开始--------------------------------- */
|
|
|
+ // 【临床表现数据来源】(主诉、现病史)
|
|
|
+ List<Clinical> clinicals = commonFacade.getClinicalSource(wordCrfDTO);
|
|
|
+ /**---------------------------数据统一处理结束--------------------------------- */
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- List<Pacs> pacsList = new ArrayList<>();
|
|
|
- Pacs pacs = new Pacs();
|
|
|
- pacs.setName("d1");
|
|
|
- pacs.setDateValue("2020-01-01");
|
|
|
- pacsList.add(pacs);
|
|
|
-
|
|
|
- Pacs pacs1 = new Pacs();
|
|
|
- pacs1.setName("d2");
|
|
|
- pacs1.setDateValue("2020-01-07");
|
|
|
- pacsList.add(pacs1);
|
|
|
-
|
|
|
- Pacs pacs3 = new Pacs();
|
|
|
- pacs3.setName("d3");
|
|
|
- pacs3.setDateValue("2020-01-09");
|
|
|
- pacsList.add(pacs3);
|
|
|
- CommonRule commonRule = new CommonRule();
|
|
|
- commonRule.sortByProperty(pacsList, "dateValue");
|
|
|
- for (Pacs bean : pacsList) {
|
|
|
- System.out.println(bean.getName());
|
|
|
+ // 规则处理
|
|
|
+ for (BaseDiagnoseDTO base : baseList) {
|
|
|
+ RuleBaseDTO ruleBaseDTO = new RuleBaseDTO();
|
|
|
+ BeanUtil.copyProperties(base, ruleBaseDTO);
|
|
|
+ String baseIds = base.getIds();
|
|
|
+ BaseDiagnoseTypeEnum baseEnum = BaseDiagnoseTypeEnum.getEnum(base.getBaseType());
|
|
|
+ if (baseEnum == null) { // 防止报空指针
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ switch (baseEnum) {
|
|
|
+ case equals: // 等于术语本身
|
|
|
+ switch (LexiconEnum.getEnum(base.getBaseLibType())) {
|
|
|
+ case Symptom: // 症状
|
|
|
+ compareNameWithPush(clinicals, ruleBaseDTO, baseIdList, baseIds);
|
|
|
+ break;
|
|
|
+ case Disease: // 疾病【病史】
|
|
|
+ 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: // 辅助检查结果
|
|
|
+ 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: // 主诉现病史正则
|
|
|
+ getRegexResPush(wordCrfDTO.getChief() + wordCrfDTO.getSymptom(),
|
|
|
+ base.getBaseEqValue(), baseIdList, baseIds);
|
|
|
+ break;
|
|
|
+ case regexPast: // 既往史正则
|
|
|
+ getRegexResPush(wordCrfDTO.getPasts() + wordCrfDTO.getPersonal() + wordCrfDTO.getMenstrual() + wordCrfDTO.getMarital() + wordCrfDTO.getFamily(),
|
|
|
+ base.getBaseEqValue(), baseIdList, baseIds);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- AtomicReference<Integer> integerAtomicReference = new AtomicReference<>(20);
|
|
|
- integerAtomicReference.set(1020);
|
|
|
- new ReentrantLock().lock();
|
|
|
+ Collections.sort(baseIdList); // id排序,方便调试查看
|
|
|
+ return baseIdList;
|
|
|
}
|
|
|
-
|
|
|
}
|