|
@@ -152,6 +152,15 @@ public class RuleEngine {
|
|
|
|
|
|
public static Set<Integer> daysRuleIdSet = new HashSet<>();
|
|
|
|
|
|
+ /**
|
|
|
+ * 配置了项目编码,但是是以诊断编码匹配的规则id列表
|
|
|
+ */
|
|
|
+ public static List<Integer> diagRuleIdList = new ArrayList<>();
|
|
|
+ /**
|
|
|
+ * 没有配置项目编码,只配置了诊断编码类的规则id列表
|
|
|
+ */
|
|
|
+ public static List<Integer> noProjectCodeDiagRuleIdList = new ArrayList<>();
|
|
|
+
|
|
|
public void initMedicalInsRule() {
|
|
|
log.info("进入初始化RuleEngine");
|
|
|
List<MedicalInsRuleInfo> medicalInsRuleInfoList = medicalInsRuleInfoService.lambdaQuery().eq(MedicalInsRuleInfo::getState, Constant.EFF_STATE).list();
|
|
@@ -165,12 +174,25 @@ public class RuleEngine {
|
|
|
*/
|
|
|
List<MedicalInsRuleInfo> midMedicalInsRuleInfoList = new ArrayList<>();
|
|
|
for (MedicalInsRuleInfo medicalInsRuleInfo : medicalInsRuleInfoList) {
|
|
|
+ //诊断编码匹配
|
|
|
+ if (medicalInsRuleInfo.getSearchType().equals("2")) {
|
|
|
+ diagRuleIdList.add(medicalInsRuleInfo.getId());
|
|
|
+ }
|
|
|
allMedicalMap.put(medicalInsRuleInfo.getId(), medicalInsRuleInfo);
|
|
|
if (Constant.TREATMEN_TYPE_ADVANCE_WARNING.equals(medicalInsRuleInfo.getCallScenario())) {
|
|
|
advanceWaringRuleIdList.add(medicalInsRuleInfo.getId());
|
|
|
} else {
|
|
|
midMedicalInsRuleInfoList.add(medicalInsRuleInfo);
|
|
|
}
|
|
|
+ String selectedRoles = medicalInsRuleInfo.getSelectedRoles();
|
|
|
+ if (StringUtils.isNotBlank(selectedRoles)) {
|
|
|
+ String[] selectedRolesArr = selectedRoles.split(",");
|
|
|
+ boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
|
|
|
+ boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
|
|
|
+ if (diagnoseFlag && !projectCodeFlag) {
|
|
|
+ noProjectCodeDiagRuleIdList.add(medicalInsRuleInfo.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
genItemCodeAndRuleIdMap(midMedicalInsRuleInfoList);
|
|
@@ -506,7 +528,7 @@ public class RuleEngine {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void dealAfterAdvance(AfterIncidentLog afterIncidentLog,Map<String,Object> paramMap, List<Integer> ruleIdList, List<Map<String, Object>> itemList) {
|
|
|
+ public void dealAfterAdvance(AfterIncidentLog afterIncidentLog, Map<String, Object> paramMap, List<Integer> ruleIdList, List<Map<String, Object>> itemList) {
|
|
|
if (CollectionUtil.isEmpty(ruleIdList)) {
|
|
|
log.error("事后提醒未配置对应的提醒规则");
|
|
|
return;
|
|
@@ -793,31 +815,10 @@ public class RuleEngine {
|
|
|
|
|
|
Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
|
|
|
if (null != diagnose) {
|
|
|
+ List<String> diagnoseList = (List<String>) diagnose;
|
|
|
//获取诊断编码配置的规则ID,加入需要执行的规则
|
|
|
- List<MedicalInsRuleProject> medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByDiagCode(diagnose.toString());
|
|
|
- if (CollectionUtil.isEmpty(medicalInsRuleProjectTempList)) {
|
|
|
- log.info("诊断编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", diagnose);
|
|
|
- }
|
|
|
- Set<Integer> medicalInsRuleInfoIdDiagSet = medicalInsRuleProjectTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
|
|
|
- log.info("数据库检索到匹配规则ID列表:{} 诊断编码为:{}", medicalInsRuleInfoIdDiagSet, diagnose);
|
|
|
+ getAndSetDiagRule(diagnoseList, medicalInsRuleProjectList);
|
|
|
|
|
|
- if (CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)) {
|
|
|
- if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
|
|
|
- medicalInsRuleProjectList = new ArrayList<>();
|
|
|
- }
|
|
|
- for (MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectTempList) {
|
|
|
- MedicalInsRuleInfo projectRuleInfo = allMedicalMap.get(medicalInsRuleProject.getMedicalInsRuleInfoId());
|
|
|
- String selectedRoles = projectRuleInfo.getSelectedRoles();
|
|
|
- if (StringUtils.isNotBlank(selectedRoles)) {
|
|
|
- String[] selectedRolesArr = selectedRoles.split(",");
|
|
|
- boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
|
|
|
- boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
|
|
|
- if (diagnoseFlag && !projectCodeFlag) {
|
|
|
- medicalInsRuleProjectList.add(medicalInsRuleProject);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
|
|
|
log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出执行规则", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
@@ -853,6 +854,48 @@ public class RuleEngine {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public void getAndSetDiagRule(List<String> diagnoseList, List<MedicalInsRuleProject> medicalInsRuleProjectList) {
|
|
|
+ if (CollectionUtil.isNotEmpty(diagRuleIdList)) {
|
|
|
+ List<MedicalInsRuleProjectDiagnose> projectDiagnoseList = medicalInsRuleProjectDiagnoseService.getRuleProjectByDiagCodeAndRuleId(diagRuleIdList, diagnoseList);
|
|
|
+ if (CollectionUtil.isNotEmpty(projectDiagnoseList)) {
|
|
|
+ List<String> projectCodeList = new ArrayList<>();
|
|
|
+ for (MedicalInsRuleProjectDiagnose medicalInsRuleProjectDiagnose : projectDiagnoseList) {
|
|
|
+ projectCodeList.add(medicalInsRuleProjectDiagnose.getMedicalInsProjectCode());
|
|
|
+ }
|
|
|
+ List<MedicalInsRuleProject> medicalInsRuleProjectTempList = medicalInsRuleProjectService.lambdaQuery().in(MedicalInsRuleProject::getProjectCode)
|
|
|
+ .in(MedicalInsRuleProject::getMedicalInsRuleInfoId, diagRuleIdList).list();
|
|
|
+ if (CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)) {
|
|
|
+ Set<Integer> ruleIdSet = medicalInsRuleProjectTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
|
|
|
+ log.error("有项目编码以诊断编码为主的诊断规则 诊断编码:{} 匹配的规则id:{} ", diagnoseList, ruleIdSet);
|
|
|
+ for (MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectTempList) {
|
|
|
+ medicalInsRuleProjectList.add(medicalInsRuleProject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(noProjectCodeDiagRuleIdList)) {
|
|
|
+ List<MedicalInsRuleProjectDiagnose> projectDiagnoseList = medicalInsRuleProjectDiagnoseService.getRuleProjectByDiagCodeAndRuleId(noProjectCodeDiagRuleIdList, diagnoseList);
|
|
|
+ if (CollectionUtil.isNotEmpty(projectDiagnoseList)) {
|
|
|
+ Set<Integer> medicalRuleIdSet = projectDiagnoseList.stream().map(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId).collect(Collectors.toSet());
|
|
|
+ List<String> diagnoseCodeList = new ArrayList<>();
|
|
|
+ for (MedicalInsRuleProjectDiagnose medicalInsRuleProjectDiagnose : projectDiagnoseList) {
|
|
|
+ diagnoseCodeList.add(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode());
|
|
|
+ }
|
|
|
+ List<MedicalInsRuleProject> medicalInsRuleProjectDiagTempList = medicalInsRuleProjectService.lambdaQuery().in(MedicalInsRuleProject::getMedicalDiagnoseCode, diagnoseCodeList).in(MedicalInsRuleProject::getMedicalInsRuleInfoId, medicalRuleIdSet).list();
|
|
|
+ if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagTempList)) {
|
|
|
+ Set<Integer> ruleIdSet = medicalInsRuleProjectDiagTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
|
|
|
+ log.error("无项目编码以诊断编码为主的诊断规则 诊断编码:{} 匹配的规则id:{} ", diagnoseList, ruleIdSet);
|
|
|
+ for (MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectDiagTempList) {
|
|
|
+ medicalInsRuleProjectList.add(medicalInsRuleProject);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("无项目编码的诊断规则 诊断编码:{} 规则id:{} 在medical_ins_rule_project表数据缺失", diagnoseCodeList, medicalRuleIdSet);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 把当前明细记录的主单下的所有项目编码设置到当前项目记录
|
|
|
*/
|