|
@@ -8,9 +8,7 @@ import org.diagbot.nlp.rule.module.PreResult;
|
|
|
import org.diagbot.nlp.rule.pretreat.*;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -18,51 +16,105 @@ public class PretreatmentRule {
|
|
|
public void rule(SearchData searchData) throws java.io.IOException {
|
|
|
//患者基本信息 性别 年龄
|
|
|
if (!StringUtils.isEmpty(searchData.getNormal())) {
|
|
|
- searchData.setNormal(add2PreResultList(new PretreatmentNormal(), searchData.getNormal(), "normal", searchData));
|
|
|
+ add2PreResultList(new PretreatmentNormal(), searchData.getNormal(), "normal", searchData);
|
|
|
}
|
|
|
- //症状数据
|
|
|
- if (!StringUtils.isEmpty(searchData.getSymptom())) {
|
|
|
- searchData.setSymptom(add2PreResultList(new PretreatmentSymptom(), searchData.getSymptom(), "symptom", searchData));
|
|
|
+ //症状规则 主诉、现病史提取
|
|
|
+ if (!StringUtils.isEmpty(searchData.getChief())) {
|
|
|
+ searchData.setChief(add2PreResultList(new PretreatmentSymptom(), searchData.getChief(), "symptom", searchData));
|
|
|
}
|
|
|
- //体征数据
|
|
|
+ //体征数据 体征、现病史提取
|
|
|
if (!StringUtils.isEmpty(searchData.getVital())) {
|
|
|
searchData.setVital(add2PreResultList(new PretreatmentVital(), searchData.getVital(), "vital", searchData));
|
|
|
}
|
|
|
- //lis结构化信息
|
|
|
- if (searchData.getLisArr() != null && searchData.getLisArr().size() > 0) {
|
|
|
- List<PreResult> preResults = searchData.getLisArr();
|
|
|
+ //诊断数据 诊断信息(历史)、现病史、既往史(重要疾病史)
|
|
|
+ if (searchData.getDiag() != null && searchData.getDiag().size() > 0) {
|
|
|
+ List<PreResult> preResults = searchData.getDiag();
|
|
|
for (PreResult result : preResults) {
|
|
|
- result.setUniqueName("化验--" + result.getUniqueName());
|
|
|
+ result.setUniqueName("诊断--" + result.getUniqueName());
|
|
|
}
|
|
|
- searchData.setLis(add2PreResultList(searchData.getLisArr(), searchData.getLis(), "lis", searchData));
|
|
|
- } else if (!StringUtils.isEmpty(searchData.getLis())) {
|
|
|
- searchData.setLis(add2PreResultList(new PretreatmentLis(), searchData.getLis(), "lis", searchData));
|
|
|
+ searchData.setDiagString(add2PreResultList(searchData.getDiag(), searchData.getDiagString(), "diag", searchData));
|
|
|
+ add2PreResultList(new PretreatmentDiag(), searchData.getPasts(), "diag", searchData);
|
|
|
+ } else if (!StringUtils.isEmpty(searchData.getDiagString())) {
|
|
|
+ searchData.setDiagString(add2PreResultList(new PretreatmentDiag(), searchData.getDiagString(), "diag", searchData));
|
|
|
+ add2PreResultList(new PretreatmentDiag(), searchData.getPasts(), "diag", searchData);
|
|
|
}
|
|
|
- //pacs数据
|
|
|
- if (!StringUtils.isEmpty(searchData.getPacs())) {
|
|
|
- searchData.setPacs(add2PreResultList(new PretreatmentPacs(), searchData.getPacs(), "pacs", searchData));
|
|
|
+ //药品数据 药品信息(历史)、现病史、既往史
|
|
|
+ if (searchData.getDrug() != null && searchData.getDrug().size() > 0) {
|
|
|
+ List<PreResult> preResults = searchData.getDrug();
|
|
|
+ for (PreResult result : preResults) {
|
|
|
+ result.setUniqueName("药品--" + result.getUniqueName());
|
|
|
+ }
|
|
|
+ searchData.setDrugString(add2PreResultList(searchData.getDrug(), searchData.getDrugString(), "drug", searchData));
|
|
|
+ add2PreResultList(new PretreatmentDrug(), searchData.getPasts(), "drug", searchData);
|
|
|
+ } else if (!StringUtils.isEmpty(searchData.getDrugString())) {
|
|
|
+ searchData.setDrugString(add2PreResultList(new PretreatmentDrug(), searchData.getDrugString(), "drug", searchData));
|
|
|
+ add2PreResultList(new PretreatmentDrug(), searchData.getPasts(), "drug", searchData);
|
|
|
}
|
|
|
//既往史
|
|
|
if (!StringUtils.isEmpty(searchData.getPasts())) {
|
|
|
- searchData.setPasts(add2PreResultList(new PretreatmentPast(), searchData.getPasts(), "past", searchData));
|
|
|
+ add2PreResultList(new PretreatmentPast(), searchData.getPasts(), "pasts", searchData);
|
|
|
+ }
|
|
|
+ //手术外伤史 现病史、手术史
|
|
|
+ if (!StringUtils.isEmpty(searchData.getPasts())) {
|
|
|
+ add2PreResultList(new PretreatmentOperation(), searchData.getOperation(), "operation", searchData);
|
|
|
+ add2PreResultList(new PretreatmentOperation(), searchData.getSymptom(), "operation", searchData);
|
|
|
+ }
|
|
|
+ //过敏 现病史、过敏史
|
|
|
+ if (!StringUtils.isEmpty(searchData.getPasts())) {
|
|
|
+ add2PreResultList(new PretreatmentAllergy(), searchData.getAllergy(), "allergy", searchData);
|
|
|
+ add2PreResultList(new PretreatmentAllergy(), searchData.getSymptom(), "allergy", searchData);
|
|
|
+ }
|
|
|
+ //外伤 现病史、手术外伤史
|
|
|
+ if (!StringUtils.isEmpty(searchData.getPasts())) {
|
|
|
+ add2PreResultList(new PretreatmentWound(), searchData.getOperation(), "wound", searchData);
|
|
|
+ add2PreResultList(new PretreatmentWound(), searchData.getSymptom(), "wound", searchData);
|
|
|
+ }
|
|
|
+ //传染病 现病史、传染病史
|
|
|
+ if (!StringUtils.isEmpty(searchData.getPasts())) {
|
|
|
+ add2PreResultList(new PretreatmentInfectious(), searchData.getInfectious(), "infectious", searchData);
|
|
|
+ add2PreResultList(new PretreatmentInfectious(), searchData.getSymptom(), "infectious", searchData);
|
|
|
}
|
|
|
- //其他史
|
|
|
- if (!StringUtils.isEmpty(searchData.getOther())) {
|
|
|
- add2PreResultList(new PretreatmentOther(), searchData.getSymptom(), "symptom-other", searchData);
|
|
|
- searchData.setOther(add2PreResultList(new PretreatmentOther(), searchData.getOther(), "other", searchData));
|
|
|
+ //lis结构化信息
|
|
|
+ if (searchData.getLis() != null && searchData.getLis().size() > 0) {
|
|
|
+ List<PreResult> preResults = searchData.getLis();
|
|
|
+ for (PreResult result : preResults) {
|
|
|
+ result.setUniqueName("化验--" + result.getUniqueName());
|
|
|
+ }
|
|
|
+ searchData.setLisString(add2PreResultList(searchData.getLis(), searchData.getLisString(), "lis", searchData));
|
|
|
+ } else if (!StringUtils.isEmpty(searchData.getLisString())) {
|
|
|
+ searchData.setLisString(add2PreResultList(new PretreatmentLis(), searchData.getLisString(), "lis", searchData));
|
|
|
}
|
|
|
- //开具诊断
|
|
|
- if (!StringUtils.isEmpty(searchData.getDiag())) {
|
|
|
- add2PreResultList(new PretreatmentDiag(), searchData.getDiag(), "diag", searchData);
|
|
|
+ //pacs结构化信息
|
|
|
+ if (searchData.getPacs() != null && searchData.getPacs().size() > 0) {
|
|
|
+ List<PreResult> preResults = searchData.getPacs();
|
|
|
+ for (PreResult result : preResults) {
|
|
|
+ result.setUniqueName("检查--" + result.getUniqueName());
|
|
|
+ }
|
|
|
+ searchData.setPacsString(add2PreResultList(searchData.getPacs(), searchData.getPacsString(), "pacs", searchData));
|
|
|
+ } else if (!StringUtils.isEmpty(searchData.getPacsString())) {
|
|
|
+ searchData.setPacsString(add2PreResultList(new PretreatmentPacs(), searchData.getPacsString(), "pacs", searchData));
|
|
|
}
|
|
|
- //开具辅检化验
|
|
|
+
|
|
|
+ //开具 化验
|
|
|
if (!StringUtils.isEmpty(searchData.getLisOrder())) {
|
|
|
add2PreResultList(new PretreatmentMakeList(), searchData.getLisOrder(), "lisOrder", searchData);
|
|
|
}
|
|
|
- //开具辅检化验
|
|
|
+ //开具 检查
|
|
|
if (!StringUtils.isEmpty(searchData.getPacsOrder())) {
|
|
|
add2PreResultList(new PretreatmentMakeList(), searchData.getPacsOrder(), "pacsOrder", searchData);
|
|
|
}
|
|
|
+ //开具 诊断
|
|
|
+ if (!StringUtils.isEmpty(searchData.getDiagOrder())) {
|
|
|
+ add2PreResultList(new PretreatmentMakeList(), searchData.getDiagOrder(), "diagOrder", searchData);
|
|
|
+ }
|
|
|
+ //开具 药品
|
|
|
+ if (!StringUtils.isEmpty(searchData.getDrugOrder())) {
|
|
|
+ add2PreResultList(new PretreatmentMakeList(), searchData.getDrugOrder(), "drugOrder", searchData);
|
|
|
+ }
|
|
|
+ //开具 手术
|
|
|
+ if (!StringUtils.isEmpty(searchData.getOperationOrder())) {
|
|
|
+ add2PreResultList(new PretreatmentMakeList(), searchData.getOperationOrder(), "operationOrder", searchData);
|
|
|
+ }
|
|
|
|
|
|
// Map<String, List<Rule>> ruleMap = searchData.getRules();
|
|
|
// for (Map.Entry<String, List<Rule>> entry : ruleMap.entrySet()) {
|
|
@@ -72,12 +124,12 @@ public class PretreatmentRule {
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
- private String add2PreResultList(Pretreatment pretreatment, String content, String ruleType, SearchData searchData) throws java.io.IOException {
|
|
|
+ private String add2PreResultList(Pretreatment pretreatment, String content, String inputType, SearchData searchData) throws java.io.IOException {
|
|
|
List<PreResult> preResultList = pretreatment.analyze(content);
|
|
|
- return add2PreResultList(preResultList, content, ruleType, searchData);
|
|
|
+ return add2PreResultList(preResultList, content, inputType, searchData);
|
|
|
}
|
|
|
|
|
|
- private String add2PreResultList(List<PreResult> preResultList, String content, String ruleType, SearchData searchData) throws java.io.IOException {
|
|
|
+ private String add2PreResultList(List<PreResult> preResultList, String content, String inputType, SearchData searchData) throws java.io.IOException {
|
|
|
Map<String, List<Rule>> kl_rule_filter_map = ApplicationCacheUtil.getKl_rule_filter_map();
|
|
|
//符合条件的规则
|
|
|
Map<String, List<Rule>> accord_rule_map = searchData.getRules();
|
|
@@ -94,13 +146,13 @@ public class PretreatmentRule {
|
|
|
boolean isSuit = suitRule(result, rule, content);
|
|
|
if (isSuit) {
|
|
|
rule.setOriginText(result.getUniqueName() + ":" + result.getValue() + result.getUnits());
|
|
|
- if (accord_rule_map.get(ruleType) == null) {
|
|
|
+ if (accord_rule_map.get(inputType) == null) {
|
|
|
accord_rules = new ArrayList<>();
|
|
|
} else {
|
|
|
- accord_rules = accord_rule_map.get(ruleType);
|
|
|
+ accord_rules = accord_rule_map.get(inputType);
|
|
|
}
|
|
|
accord_rules.add(rule);
|
|
|
- accord_rule_map.put(ruleType, accord_rules);
|
|
|
+ accord_rule_map.put(inputType, accord_rules);
|
|
|
searchData.setRules(accord_rule_map);
|
|
|
|
|
|
content = content + (rule.getRemind() == null ? "" : rule.getSuffixInfo());
|