|
@@ -64,6 +64,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat
|
|
|
import org.springframework.context.annotation.Conditional;
|
|
|
import org.springframework.context.annotation.Profile;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
@@ -517,7 +518,6 @@ public class RuleEngine {
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public Result dealMidInterfaceEngin(String intefName, MidIncidentWarningVO midIncidentWarningVO, String ipStr) {
|
|
|
midIncidentWarningVOThreadLocal.set(midIncidentWarningVO);
|
|
|
JSONObject sendJson = new JSONObject();
|
|
@@ -534,27 +534,76 @@ public class RuleEngine {
|
|
|
MidIncidentAudit midIncidentAudit = insertMidWarning(midIncidentWarningVO);
|
|
|
insertLog(midIncidentWarningVO);
|
|
|
midIncidentAudit.setInterfName(intefName);
|
|
|
- Set<String> auditDetailSet = new HashSet<>();
|
|
|
+
|
|
|
boolean sendFlag = false;
|
|
|
for (Map<String, Object> itemMap : itemList) {
|
|
|
Set<Integer> medicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ List<MedicalInsRuleProject> medicalInsRuleProjectList = null;
|
|
|
if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
|
|
|
- log.error("项目编码未匹配到对应的医保规则:{}", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
- continue;
|
|
|
+ log.error("项目编码未匹配到对应的医保规则:{} 再次从数据库检索", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
|
|
|
+ if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
|
|
|
+ log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ }else {
|
|
|
+ medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
|
|
|
+ log.info("数据库检索到匹配规则ID列表:{}", medicalInsRuleInfoIdList);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndProjectCode(new ArrayList<>(medicalInsRuleInfoIdList), itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
|
|
|
}
|
|
|
+
|
|
|
Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
|
|
|
if (null != diagnose) {
|
|
|
- List<Object> diagnoseList = (List<Object>) diagnose;
|
|
|
//获取诊断编码配置的规则ID,加入需要执行的规则
|
|
|
- for (Object diagnoseObject : diagnoseList) {
|
|
|
- Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnoseObject.toString());
|
|
|
- if (CollectionUtil.isNotEmpty(diagnoseMedicalInsRuleInfoIdList)) {
|
|
|
- medicalInsRuleInfoIdList.addAll(diagnoseMedicalInsRuleInfoIdList);
|
|
|
+ Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnose.toString());
|
|
|
+ List<MedicalInsRuleProject> medicalInsRuleProjectTempList = null;
|
|
|
+ if (CollectionUtil.isEmpty(diagnoseMedicalInsRuleInfoIdList)) {
|
|
|
+ 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);
|
|
|
+ }else{
|
|
|
+ medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndDiagCode(new ArrayList<>(diagnoseMedicalInsRuleInfoIdList), diagnose.toString());
|
|
|
+ }
|
|
|
+ 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"));
|
|
|
+ if(diagnoseFlag){
|
|
|
+ medicalInsRuleProjectList.add(medicalInsRuleProject);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
|
|
|
+ log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<Integer,List<MedicalInsRuleProject>> ruleAndProjectMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
|
|
|
paramMap.put(SystemEventAttrConstant.ADVICE_DETAILS_LIST_KEY, itemList);
|
|
|
- sendFlag = runMidEngine(auditDetailSet, itemMap, medicalInsRuleInfoIdList, midIncidentAudit, itemList);
|
|
|
+ for(Integer medicalInsRuleInfoId : ruleAndProjectMap.keySet()){
|
|
|
+ List<String> medicalInsCorrProjectCodeList = ruleAndProjectMap.get(medicalInsRuleInfoId).stream().map(MedicalInsRuleProject::getCorrelationProjectCode).collect(Collectors.toList());
|
|
|
+ MedicalInsRuleProject medicalInsRuleProject = ruleAndProjectMap.get(medicalInsRuleInfoId).get(0);
|
|
|
+ setProjectToLocalMap(itemMap, medicalInsRuleProject);
|
|
|
+ itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, medicalInsCorrProjectCodeList);
|
|
|
+ setItemCodeListToItemMap(itemList, itemMap);
|
|
|
+ boolean sendFlagTemp = false;
|
|
|
+ try {
|
|
|
+ sendFlagTemp = runMidEngine(itemMap, medicalInsRuleInfoId, midIncidentAudit, itemList);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ sendFlag = sendFlagTemp || sendFlag;
|
|
|
+ }
|
|
|
}
|
|
|
sendJson.put("id", midIncidentAudit.getId());
|
|
|
sendJson.put("violationFlag", sendFlag);
|
|
@@ -586,27 +635,75 @@ public class RuleEngine {
|
|
|
MidIncidentAudit midIncidentAudit = insertMidWarning(midIncidentWarningVO);
|
|
|
insertLog(midIncidentWarningVO);
|
|
|
midIncidentAudit.setInterfName(intefName);
|
|
|
- Set<String> auditDetailSet = new HashSet<>();
|
|
|
+
|
|
|
boolean sendFlag = false;
|
|
|
for (Map<String, Object> itemMap : itemList) {
|
|
|
Set<Integer> medicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ List<MedicalInsRuleProject> medicalInsRuleProjectList = null;
|
|
|
if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
|
|
|
- log.error("项目编码未匹配到对应的医保规则:{}", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
- continue;
|
|
|
+ log.error("项目编码未匹配到对应的医保规则:{} 再次从数据库检索", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
|
|
|
+ if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
|
|
|
+ log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ }else {
|
|
|
+ medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
|
|
|
+ log.info("数据库检索到匹配规则ID列表:{}", medicalInsRuleInfoIdList);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndProjectCode(new ArrayList<>(medicalInsRuleInfoIdList), itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
|
|
|
}
|
|
|
Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
|
|
|
if (null != diagnose) {
|
|
|
- List<Object> diagnoseList = (List<Object>) diagnose;
|
|
|
//获取诊断编码配置的规则ID,加入需要执行的规则
|
|
|
- for (Object diagnoseObject : diagnoseList) {
|
|
|
- Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnoseObject.toString());
|
|
|
- if (CollectionUtil.isNotEmpty(diagnoseMedicalInsRuleInfoIdList)) {
|
|
|
- medicalInsRuleInfoIdList.addAll(diagnoseMedicalInsRuleInfoIdList);
|
|
|
+ Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnose.toString());
|
|
|
+ List<MedicalInsRuleProject> medicalInsRuleProjectTempList = null;
|
|
|
+ if (CollectionUtil.isEmpty(diagnoseMedicalInsRuleInfoIdList)) {
|
|
|
+ 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);
|
|
|
+ }else{
|
|
|
+ medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndDiagCode(new ArrayList<>(diagnoseMedicalInsRuleInfoIdList), diagnose.toString());
|
|
|
+ }
|
|
|
+ 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"));
|
|
|
+ if(diagnoseFlag){
|
|
|
+ medicalInsRuleProjectList.add(medicalInsRuleProject);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
|
|
|
+ log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<Integer,List<MedicalInsRuleProject>> ruleAndProjectMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
|
|
|
paramMap.put(SystemEventAttrConstant.ADVICE_DETAILS_LIST_KEY, itemList);
|
|
|
- sendFlag = runMidEngine(auditDetailSet, itemMap, medicalInsRuleInfoIdList, midIncidentAudit, itemList);
|
|
|
+ for(Integer medicalInsRuleInfoId : ruleAndProjectMap.keySet()){
|
|
|
+ List<String> medicalInsCorrProjectCodeList = ruleAndProjectMap.get(medicalInsRuleInfoId).stream().map(MedicalInsRuleProject::getCorrelationProjectCode).collect(Collectors.toList());
|
|
|
+ MedicalInsRuleProject medicalInsRuleProject = ruleAndProjectMap.get(medicalInsRuleInfoId).get(0);
|
|
|
+ setProjectToLocalMap(itemMap, medicalInsRuleProject);
|
|
|
+ itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, medicalInsCorrProjectCodeList);
|
|
|
+ setItemCodeListToItemMap(itemList, itemMap);
|
|
|
+ boolean sendFlagTemp = false;
|
|
|
+ try {
|
|
|
+ sendFlagTemp = runMidEngine(itemMap, medicalInsRuleInfoId, midIncidentAudit, itemList);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ sendFlag = sendFlagTemp || sendFlag;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (sendFlag) {
|
|
@@ -634,25 +731,22 @@ public class RuleEngine {
|
|
|
* @param afterIncidentDetailLog
|
|
|
*/
|
|
|
public void dealAfterInterfaceEngin(AfterwardsAudit afterwardsAudit, AfterIncidentDetailLog afterIncidentDetailLog, List<Map<String, Object>> itemList) {
|
|
|
-
|
|
|
try {
|
|
|
dictUtil.transferAfterIncidentWarning(afterIncidentDetailLog);
|
|
|
String jsonStr = JSON.toJSONString(afterIncidentDetailLog);
|
|
|
log.info("事后处理日志:{}", jsonStr);
|
|
|
JSONObject itemMap = JSON.parseObject(jsonStr);
|
|
|
-
|
|
|
- Set<String> auditDetailSet = new HashSet<>();
|
|
|
Set<Integer> medicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
List<MedicalInsRuleProject> medicalInsRuleProjectList = null;
|
|
|
if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
|
|
|
log.error("项目编码未匹配到对应的医保规则:{} 再次从数据库检索", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
|
|
|
if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
|
|
|
- log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
- return;
|
|
|
+ log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ }else {
|
|
|
+ medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
|
|
|
+ log.info("数据库检索到匹配规则ID列表:{}", medicalInsRuleInfoIdList);
|
|
|
}
|
|
|
- medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
|
|
|
- log.info("数据库检索到匹配规则ID列表:{}", medicalInsRuleInfoIdList);
|
|
|
}else{
|
|
|
medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndProjectCode(new ArrayList<>(medicalInsRuleInfoIdList), itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
|
|
|
}
|
|
@@ -661,31 +755,46 @@ public class RuleEngine {
|
|
|
//获取诊断编码配置的规则ID,加入需要执行的规则
|
|
|
Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnose.toString());
|
|
|
List<MedicalInsRuleProject> medicalInsRuleProjectTempList = null;
|
|
|
- if (CollectionUtil.isNotEmpty(diagnoseMedicalInsRuleInfoIdList)) {
|
|
|
+ if (CollectionUtil.isEmpty(diagnoseMedicalInsRuleInfoIdList)) {
|
|
|
medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByDiagCode(diagnose.toString());
|
|
|
if(CollectionUtil.isEmpty(medicalInsRuleProjectTempList)){
|
|
|
log.info("诊断编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", diagnose);
|
|
|
}
|
|
|
- Set<Integer> medicalInsRuleInfoIdDiagSet = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
|
|
|
+ Set<Integer> medicalInsRuleInfoIdDiagSet = medicalInsRuleProjectTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
|
|
|
log.info("数据库检索到匹配规则ID列表:{} 诊断编码为:{}", medicalInsRuleInfoIdDiagSet, diagnose);
|
|
|
}else{
|
|
|
- medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndDiagCode(new ArrayList<>(medicalInsRuleInfoIdList), diagnose.toString());
|
|
|
+ medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndDiagCode(new ArrayList<>(diagnoseMedicalInsRuleInfoIdList), diagnose.toString());
|
|
|
}
|
|
|
if(CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)){
|
|
|
- if(CollectionUtil.isNotEmpty(medicalInsRuleProjectList)){
|
|
|
- medicalInsRuleProjectList.addAll(medicalInsRuleProjectTempList);
|
|
|
- }else {
|
|
|
- medicalInsRuleProjectList = 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"));
|
|
|
+ if(diagnoseFlag){
|
|
|
+ medicalInsRuleProjectList.add(medicalInsRuleProject);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
|
|
|
- log.error("医保规则对象被误删,请联系管理员");
|
|
|
+ log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出执行规则", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
return;
|
|
|
}
|
|
|
- for(MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectList) {
|
|
|
+ Map<Integer,List<MedicalInsRuleProject>> ruleAndProjectMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
|
|
|
+ log.info("明细记录ID:{} 匹配到规则:{}", afterIncidentDetailLog.getId(), ruleAndProjectMap.keySet());
|
|
|
+ for(Integer medicalInsRuleInfoId : ruleAndProjectMap.keySet()){
|
|
|
+ List<String> medicalInsCorrProjectCodeList = ruleAndProjectMap.get(medicalInsRuleInfoId).stream().map(MedicalInsRuleProject::getCorrelationProjectCode).collect(Collectors.toList());
|
|
|
+ MedicalInsRuleProject medicalInsRuleProject = ruleAndProjectMap.get(medicalInsRuleInfoId).get(0);
|
|
|
setProjectToLocalMap(itemMap, medicalInsRuleProject);
|
|
|
- runAfterEngine(itemMap, medicalInsRuleProject.getMedicalInsRuleInfoId(), afterwardsAudit, itemList);
|
|
|
+ itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, medicalInsCorrProjectCodeList);
|
|
|
+ setItemCodeListToItemMap(itemList, itemMap);
|
|
|
+ runAfterEngine(itemMap, medicalInsRuleInfoId, afterwardsAudit, itemList);
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
@@ -694,6 +803,21 @@ public class RuleEngine {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 把当前明细记录的主单下的所有项目编码设置到当前项目记录
|
|
|
+ */
|
|
|
+ public void setItemCodeListToItemMap(List<Map<String,Object>> itemList, Map<String,Object> itemMap){
|
|
|
+ List<String> medicalProjectCodeList = new ArrayList<>();
|
|
|
+ for(Map<String,Object> itemTempMap : itemList){
|
|
|
+ Object medicalProjectCode = itemTempMap.get(SystemEventAttrConstant.MEDICAL_PROJECT_CODE_KEY);
|
|
|
+ if(null != medicalProjectCode){
|
|
|
+ medicalProjectCodeList.add(medicalProjectCode.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itemMap.put(SystemEventAttrConstant.MEDICAL_PROJECT_CODE_LSIT, medicalProjectCodeList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param itemMap
|
|
@@ -904,13 +1028,12 @@ public class RuleEngine {
|
|
|
afterwardsAuditService.save(afterwardsAudit);
|
|
|
if (StringUtils.isNotBlank(afterIncidentLog.getDiagnoses())) {
|
|
|
List<String> diagonseCodeList = Arrays.asList(afterIncidentLog.getDiagnoses().split(","));
|
|
|
-// List<String> diagonseNameList = Arrays.asList(afterIncidentDetailLog.getDiagnose_desc().split(","));
|
|
|
List<AfterwardsIncidentAuditDiagnose> afterIncidentAuditDiagnoseList = new ArrayList<>();
|
|
|
for (int i = 0; i < diagonseCodeList.size(); i++) {
|
|
|
String diagonseCode = diagonseCodeList.get(i);
|
|
|
// String diagonseName = diagonseNameList.get(i);
|
|
|
// Object value = redisTemplate.opsForHash().get(Constant.HIS_MEDICAL_DICT_KEY, afterIncidentDetailLog.getDiagnose_code());
|
|
|
- String medicalDiagonseCode = dictUtil.getMedicalDiagnoseCode(diagonseCode);
|
|
|
+ String medicalDiagonseCode = dictUtil.getMedicalDiagnoseCode(diagonseCode.trim());
|
|
|
String medicalDiagnoseName = dictUtil.getMedicalDiagnoseName(medicalDiagonseCode);
|
|
|
AfterwardsIncidentAuditDiagnose afterIncidentAuditDiagnose = new AfterwardsIncidentAuditDiagnose();
|
|
|
afterIncidentAuditDiagnose.setAfterwardsAuditId(afterwardsAudit.getId());
|
|
@@ -953,12 +1076,16 @@ public class RuleEngine {
|
|
|
List<FactorEnchance> factorEnchanceList = factorEnchanceService.listByIds(factorEnchangeIdList);
|
|
|
Map<Integer, List<FactorEnchance>> enchanceTypeMap = factorEnchanceList.stream().collect(Collectors.groupingBy(FactorEnchance::getFactorCatalog));
|
|
|
for (Integer medicalRuleInsInfoId : enchanceTypeMap.keySet()) {
|
|
|
- List<FactorEnchance> factorEnchanceListTemp = enchanceTypeMap.get(medicalRuleInsInfoId);
|
|
|
- paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
|
|
|
- paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_CODE, medicalInsRuleInfo.getRuleCode());
|
|
|
- paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_NAME, medicalInsRuleInfo.getRuleName());
|
|
|
- paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_DESC, medicalInsRuleInfo.getDescription());
|
|
|
- factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, audit, paramMap, ruleFactorRelaList, factorEnchanceListTemp, null);
|
|
|
+ try {
|
|
|
+ List<FactorEnchance> factorEnchanceListTemp = enchanceTypeMap.get(medicalRuleInsInfoId);
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_CODE, medicalInsRuleInfo.getRuleCode());
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_NAME, medicalInsRuleInfo.getRuleName());
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_DESC, medicalInsRuleInfo.getDescription());
|
|
|
+ factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, audit, paramMap, ruleFactorRelaList, factorEnchanceListTemp, null);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -984,15 +1111,18 @@ public class RuleEngine {
|
|
|
List<FactorEnchance> factorEnchanceList = factorEnchanceService.listByIds(factorEnchangeIdList);
|
|
|
Map<Integer, List<FactorEnchance>> enchanceTypeMap = factorEnchanceList.stream().collect(Collectors.groupingBy(FactorEnchance::getFactorCatalog));
|
|
|
for (Integer medicalRuleInsInfoId : enchanceTypeMap.keySet()) {
|
|
|
-
|
|
|
- List<FactorEnchance> factorEnchanceListTemp = enchanceTypeMap.get(medicalRuleInsInfoId);
|
|
|
- paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
|
|
|
- paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_CODE, medicalInsRuleInfo.getRuleCode());
|
|
|
- paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_NAME, medicalInsRuleInfo.getRuleName());
|
|
|
- boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, null, paramMap, ruleFactorRelaList, factorEnchanceListTemp, null);
|
|
|
- if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
|
|
|
- log.error("事后统计数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
|
|
|
- return;
|
|
|
+ try {
|
|
|
+ List<FactorEnchance> factorEnchanceListTemp = enchanceTypeMap.get(medicalRuleInsInfoId);
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_CODE, medicalInsRuleInfo.getRuleCode());
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_NAME, medicalInsRuleInfo.getRuleName());
|
|
|
+ boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, null, paramMap, ruleFactorRelaList, factorEnchanceListTemp, null);
|
|
|
+ if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
|
|
|
+ log.error("事后统计数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1004,7 +1134,7 @@ public class RuleEngine {
|
|
|
*
|
|
|
* @param paramMap
|
|
|
*/
|
|
|
- public void runAfterEngine(Map<String, Object> paramMap, Integer medicalRuleInsInfoId, AfterwardsAudit afterIncidentAudit, List<Map<String, Object>> itemList) {
|
|
|
+ public void runAfterEngine(Map<String, Object> paramMap, Integer medicalRuleInsInfoId, AfterwardsAudit afterIncidentAudit, List<Map<String, Object>> itemList) throws Exception {
|
|
|
if (null == medicalRuleInsInfoId) {
|
|
|
log.error("未有对应的规则,接口数据:{}", paramMap);
|
|
|
return;
|
|
@@ -1033,46 +1163,29 @@ public class RuleEngine {
|
|
|
*
|
|
|
* @param paramMap
|
|
|
*/
|
|
|
- public boolean runMidEngine(Set<String> auditDetailSet, Map<String, Object> paramMap, Set<Integer> medicalInsRuleInfoIdList, MidIncidentAudit midIncidentAudit, List<Map<String, Object>> itemList) {
|
|
|
- if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
|
|
|
+ @Async("commonTaskAsyncPool")
|
|
|
+ public boolean runMidEngine(Map<String, Object> paramMap, Integer medicalRuleInsInfoId, MidIncidentAudit midIncidentAudit, List<Map<String, Object>> itemList) throws Exception {
|
|
|
+ boolean auditFlag = false;
|
|
|
+ if (null == medicalRuleInsInfoId) {
|
|
|
log.error("未有对应的规则,接口数据:{}", paramMap);
|
|
|
- return false;
|
|
|
- }
|
|
|
-// LambdaQueryWrapper<RuleFactorRela> query = new LambdaQueryWrapper<RuleFactorRela>();
|
|
|
-// query.eq(RuleFactorRela::getDelFlag, CommonConstant.DEL_FLAG_0);
|
|
|
-// query.in(RuleFactorRela::getMedicalInsRuleInfoId, medicalInsRuleInfoIdList);
|
|
|
-// query.orderByAsc(RuleFactorRela::getSeqNum);
|
|
|
-// List<RuleFactorRela> ruleFactorRelaList = ruleFactorRelaService.list(query);
|
|
|
- Map<Integer, List<FactorEnchance>> enchanceTypeMap = new HashMap<>();
|
|
|
- for(Integer medicalRuleINfoId : medicalInsRuleInfoIdList){
|
|
|
- enchanceTypeMap.put(medicalRuleINfoId, allEnchanceTypeMap.get(medicalRuleINfoId));
|
|
|
+ return auditFlag;
|
|
|
}
|
|
|
- boolean auditFlag = false;
|
|
|
- if (CollectionUtil.isNotEmpty(enchanceTypeMap)) {
|
|
|
-// Map<Integer, List<RuleFactorRela>> ruleIdAndFatorEnchanceIdMap = ruleFactorRelaList.stream().collect(Collectors.groupingBy(RuleFactorRela::getMedicalInsRuleInfoId));
|
|
|
-// Set<Integer> factorEnchangeIdList = ruleFactorRelaList.stream().map(RuleFactorRela::getFactorEnhanceId).collect(Collectors.toSet());
|
|
|
-// List<FactorEnchance> factorEnchanceList = factorEnchanceService.listByIds(factorEnchangeIdList);
|
|
|
-// Map<Integer, List<FactorEnchance>> enchanceTypeMap = factorEnchanceList.stream().collect(Collectors.groupingBy(FactorEnchance::getFactorCatalog));
|
|
|
- for (Integer medicalRuleInsInfoId : enchanceTypeMap.keySet()) {
|
|
|
- String auditDetailKeyStr = paramMap.get(Constant.MEDICAL_PROJECT_NAME_KEY) + "_" + medicalRuleInsInfoId;
|
|
|
- if (auditDetailSet.contains(auditDetailKeyStr)) {
|
|
|
- log.error("项目编码:{} 规则ID:{} 已经执行过规则引擎,此次忽略", paramMap.get(Constant.MEDICAL_PROJECT_NAME_KEY), medicalRuleInsInfoId);
|
|
|
- continue;
|
|
|
- }
|
|
|
- auditDetailSet.add(auditDetailKeyStr);
|
|
|
- MedicalInsRuleInfo medicalInsRuleInfo = medicalInsRuleInfoService.getById(medicalRuleInsInfoId);
|
|
|
- List<FactorEnchance> factorEnchanceListTemp = enchanceTypeMap.get(medicalRuleInsInfoId);
|
|
|
- paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
|
|
|
- paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_CODE, medicalInsRuleInfo.getRuleCode());
|
|
|
- paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_NAME, medicalInsRuleInfo.getRuleName());
|
|
|
- List<RuleFactorRela> ruleFactorRelaSortList = ruleIdAndFatorEnchanceIdMap.get(medicalRuleInsInfoId);
|
|
|
- getRuleProjectIntoMap(medicalInsRuleInfo, paramMap);
|
|
|
- auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, midIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp, itemList);
|
|
|
- if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
|
|
|
- log.error("事中提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
|
|
|
- return auditFlag;
|
|
|
- }
|
|
|
+ if (allEnchanceTypeMap.containsKey(medicalRuleInsInfoId)) {
|
|
|
+ MedicalInsRuleInfo medicalInsRuleInfo = allMedicalMap.get(medicalRuleInsInfoId);
|
|
|
+ List<FactorEnchance> factorEnchanceListTemp = allEnchanceTypeMap.get(medicalRuleInsInfoId);
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_CODE, medicalInsRuleInfo.getRuleCode());
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_NAME, medicalInsRuleInfo.getRuleName());
|
|
|
+ List<RuleFactorRela> ruleFactorRelaSortList = ruleIdAndFatorEnchanceIdMap.get(medicalRuleInsInfoId);
|
|
|
+ getRuleProjectIntoMap(medicalInsRuleInfo, paramMap);
|
|
|
+ paramMap.put(SystemEventAttrConstant.ADVICE_DETAILS_LIST_KEY, itemList);
|
|
|
+ auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, midIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp, itemList);
|
|
|
+ if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
|
|
|
+ log.error("事后提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
|
|
|
+ return auditFlag;
|
|
|
}
|
|
|
+ }else{
|
|
|
+ log.error("该医保规则ID:{} 未有配置医保规则处理流程-请到规则配置页面进行配置", medicalRuleInsInfoId);
|
|
|
}
|
|
|
return auditFlag;
|
|
|
}
|