|
@@ -1,7 +1,6 @@
|
|
|
package org.jeecg.modules.medical.ruleengine;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -13,7 +12,6 @@ import org.jeecg.modules.medical.EnchanceTypeEnum;
|
|
|
import org.jeecg.modules.medical.SystemEventAttrConstant;
|
|
|
import org.jeecg.modules.medical.entity.AdvanceWarningAudit;
|
|
|
import org.jeecg.modules.medical.entity.AdvanceWarningAuditDetail;
|
|
|
-import org.jeecg.modules.medical.entity.AfterIncidentDetailLog;
|
|
|
import org.jeecg.modules.medical.entity.AfterwardsAudit;
|
|
|
import org.jeecg.modules.medical.entity.AfterwardsAuditDetail;
|
|
|
import org.jeecg.modules.medical.entity.EventAttr;
|
|
@@ -95,6 +93,8 @@ public class FactorEnchangeFactory {
|
|
|
|
|
|
public Map<Integer, List<FactorAttrRela>> factorEnhanceIdAndListMap = new HashMap<>();
|
|
|
|
|
|
+ public static ThreadLocal<Map<String, Object>> currentThreadLocalMap = new ThreadLocal<>();
|
|
|
+
|
|
|
public void init() {
|
|
|
log.info("进入初始化FactorEnchangeFactory");
|
|
|
List<EventAttr> eventAttrList = eventAttrService.lambdaQuery().eq(EventAttr::getDelFlag, CommonConstant.DEL_FLAG_0).list();
|
|
@@ -119,62 +119,67 @@ public class FactorEnchangeFactory {
|
|
|
}
|
|
|
|
|
|
public boolean runFactorEnchange(Integer medicalInfoRuleInfoId, MedicalInsRuleInfo medicalInsRuleInfo, Object audit, Map<String, Object> localMap, List<RuleFactorRela> ruleFactorRelaList, List<FactorEnchance> factorEnchanceList, List<Map<String, Object>> itemList) throws Exception {
|
|
|
- if(CollectionUtil.isEmpty(factorEnchanceList)) {
|
|
|
+ if (CollectionUtil.isEmpty(factorEnchanceList)) {
|
|
|
log.error("工单记录:{} 匹配到的规则ID:{} 未配置处理流程-请到规则配置管理页面配置医保规则对应处理流程", audit, medicalInfoRuleInfoId);
|
|
|
return false;
|
|
|
}
|
|
|
Map<Integer, FactorEnchance> factorEnchanceMap = factorEnchanceList.stream().collect(Collectors.toMap(FactorEnchance::getId, v -> v, (v1, v2) -> v1));
|
|
|
boolean result = false;
|
|
|
- for (RuleFactorRela ruleFactorRela : ruleFactorRelaList) {
|
|
|
- Integer factorEnchanceId = ruleFactorRela.getFactorEnhanceId();
|
|
|
- FactorEnchance factorEnchance = factorEnchanceMap.get(factorEnchanceId);
|
|
|
- if (null == factorEnchance) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ try {
|
|
|
+ localMap.put(Constant.ADESC, localMap.getOrDefault(SystemEventAttrConstant.MEDICAL_PROJECT_NAME_KEY,""));
|
|
|
+ currentThreadLocalMap.set(localMap);
|
|
|
+ for (RuleFactorRela ruleFactorRela : ruleFactorRelaList) {
|
|
|
+ Integer factorEnchanceId = ruleFactorRela.getFactorEnhanceId();
|
|
|
+ FactorEnchance factorEnchance = factorEnchanceMap.get(factorEnchanceId);
|
|
|
+ if (null == factorEnchance) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- EnchanceTypeEnum enchanceTypeEnum = EnchanceTypeEnum.getType(factorEnchance.getEnhanceType());
|
|
|
- switch (enchanceTypeEnum) {
|
|
|
- case SQL:
|
|
|
- Map<Integer, List<FactorAttrRela>> ioTypeMap = getIoMap(factorEnchanceId);
|
|
|
- sqlUtil.setSqlResultByFactorEnchance(localMap, ioTypeMap, factorEnchance, medicalInfoRuleInfoId);
|
|
|
- break;
|
|
|
- case EXPRESSION:
|
|
|
+ EnchanceTypeEnum enchanceTypeEnum = EnchanceTypeEnum.getType(factorEnchance.getEnhanceType());
|
|
|
+ switch (enchanceTypeEnum) {
|
|
|
+ case SQL:
|
|
|
+ Map<Integer, List<FactorAttrRela>> ioTypeMap = getIoMap(factorEnchanceId);
|
|
|
+ sqlUtil.setSqlResultByFactorEnchance(localMap, ioTypeMap, factorEnchance, medicalInfoRuleInfoId);
|
|
|
+ break;
|
|
|
+ case EXPRESSION:
|
|
|
// setLogicalExpressionResultByFactorEnchance(localMap, ioTypeMap, factorEnchance, medicalInfoRuleInfoId);
|
|
|
- break;
|
|
|
- case DICT:
|
|
|
- dictUtil.transferData(localMap, factorEnchance, medicalInfoRuleInfoId);
|
|
|
- break;
|
|
|
- case PLUGIN:
|
|
|
- Map<Integer, List<FactorAttrRela>> ioTypeMap1 = getIoMap(factorEnchanceId);
|
|
|
- PluginInterface pluginInterface = (PluginInterface) SpringContextUtils.getBean(factorEnchance.getEnhanceValue());
|
|
|
- pluginInterface.plugin(localMap, ioTypeMap1, factorEnchance, medicalInfoRuleInfoId);
|
|
|
- break;
|
|
|
- case CONSTANT:
|
|
|
- localMap.put(getParamName(factorEnchance.getEventAttrId()), factorEnchance.getExtAttr1());
|
|
|
- break;
|
|
|
- case LOGICAL_EXPRESSION:
|
|
|
-// Map<Integer, List<FactorAttrRela>> ioTypeMap2 = getIoMap(factorEnchanceId);
|
|
|
- result = setLogicalExpressionResultByFactorEnchance(localMap, factorEnchance);
|
|
|
- if (Constant.WARING_EVENT_ATTR_ID == factorEnchance.getEventAttrId()) {
|
|
|
- if (result) {
|
|
|
- insertWarningDetail(localMap, medicalInsRuleInfo, audit, itemList);
|
|
|
+ break;
|
|
|
+ case DICT:
|
|
|
+ dictUtil.transferData(localMap, factorEnchance, medicalInfoRuleInfoId);
|
|
|
+ break;
|
|
|
+ case PLUGIN:
|
|
|
+ Map<Integer, List<FactorAttrRela>> ioTypeMap1 = getIoMap(factorEnchanceId);
|
|
|
+ PluginInterface pluginInterface = (PluginInterface) SpringContextUtils.getBean(factorEnchance.getEnhanceValue());
|
|
|
+ pluginInterface.plugin(localMap, ioTypeMap1, factorEnchance, medicalInfoRuleInfoId);
|
|
|
+ break;
|
|
|
+ case CONSTANT:
|
|
|
+ localMap.put(getParamName(factorEnchance.getEventAttrId()), factorEnchance.getExtAttr1());
|
|
|
+ break;
|
|
|
+ case LOGICAL_EXPRESSION:
|
|
|
+ result = setLogicalExpressionResultByFactorEnchance(localMap, factorEnchance);
|
|
|
+ if (Constant.WARING_EVENT_ATTR_ID == factorEnchance.getEventAttrId()) {
|
|
|
+ if (result) {
|
|
|
+ insertWarningDetail(localMap, medicalInsRuleInfo, audit, itemList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ localMap.put(getParamName(factorEnchance.getEventAttrId()), result);
|
|
|
}
|
|
|
- } else {
|
|
|
- localMap.put(getParamName(factorEnchance.getEventAttrId()), result);
|
|
|
- }
|
|
|
- break;
|
|
|
- case PROPERTIES:
|
|
|
- Object valueTemp = localMap.get(getParamName(Integer.parseInt(factorEnchance.getExtAttr1())));
|
|
|
- if (null == valueTemp) {
|
|
|
- log.error("要素提取:{} 规则ID:{} 常量赋值:{} 配置的属性:{}无值", factorEnchance.getId(), medicalInfoRuleInfoId, factorEnchance.getRuleEnchanceName(), factorEnchance.getExtAttr1());
|
|
|
- } else {
|
|
|
- localMap.put(getParamName(factorEnchance.getEventAttrId()), valueTemp);
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- log.error("有配置的未处理类型");
|
|
|
- break;
|
|
|
+ break;
|
|
|
+ case PROPERTIES:
|
|
|
+ Object valueTemp = localMap.get(getParamName(Integer.parseInt(factorEnchance.getExtAttr1())));
|
|
|
+ if (null == valueTemp) {
|
|
|
+ log.error("要素提取:{} 规则ID:{} 常量赋值:{} 配置的属性:{}无值", factorEnchance.getId(), medicalInfoRuleInfoId, factorEnchance.getRuleEnchanceName(), factorEnchance.getExtAttr1());
|
|
|
+ } else {
|
|
|
+ localMap.put(getParamName(factorEnchance.getEventAttrId()), valueTemp);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ log.error("有配置的未处理类型");
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ } finally {
|
|
|
+ currentThreadLocalMap.remove();
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -186,7 +191,7 @@ public class FactorEnchangeFactory {
|
|
|
List<FactorAttrRela> factorAttrRelaList = factorEnhanceIdAndListMap.get(factorEnchanceId);
|
|
|
// Map<Integer, List<FactorAttrRela>> ioTypeMap = new HashMap<>();
|
|
|
// if (CollectionUtil.isNotEmpty(factorAttrRelaList)) {
|
|
|
- if(CollectionUtil.isEmpty(factorAttrRelaList)){
|
|
|
+ if (CollectionUtil.isEmpty(factorAttrRelaList)) {
|
|
|
return new HashMap<>();
|
|
|
}
|
|
|
Map<Integer, List<FactorAttrRela>> ioTypeMap = factorAttrRelaList.stream().collect(Collectors.groupingBy(FactorAttrRela::getIoType));
|
|
@@ -231,6 +236,15 @@ public class FactorEnchangeFactory {
|
|
|
advanceWarningAuditDetailService.save(advanceWarningAuditDetail);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成违规描述
|
|
|
+ *
|
|
|
+ * @param itemMap
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+// public String genDescription(Map<String,Object> itemMap, String prescription){
|
|
|
+//
|
|
|
+// }
|
|
|
public void insertAfterWarningDetail(Map<String, Object> itemMap, MedicalInsRuleInfo medicalInsRuleInfo, AfterwardsAudit afterwardsAudit, List<Map<String, Object>> itemList) {
|
|
|
|
|
|
if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod())) {
|
|
@@ -259,7 +273,8 @@ public class FactorEnchangeFactory {
|
|
|
afterwardsAuditDetail.setMedicalInsRuleInfoCode(medicalInsRuleInfo.getRuleCode());
|
|
|
afterwardsAuditDetail.setMedicalInsRuleInfoId(medicalInsRuleInfo.getId());
|
|
|
afterwardsAuditDetail.setMedicalInsRuleInfoName(medicalInsRuleInfo.getRuleName());
|
|
|
- afterwardsAuditDetail.setDescription(medicalInsRuleInfo.getViolationDesc());
|
|
|
+ String desc = getDesc(medicalInsRuleInfo, itemMap);
|
|
|
+ afterwardsAuditDetail.setDescription(desc);
|
|
|
afterwardsAuditDetail.setOutpatientNumber(afterwardsAudit.getOutpatientNumber());
|
|
|
afterwardsAuditDetail.setPrescriptionNumber(afterwardsAudit.getPrescriptionNumber());
|
|
|
|
|
@@ -273,8 +288,8 @@ public class FactorEnchangeFactory {
|
|
|
afterwardsAuditDetail.setCreateBy("auto");
|
|
|
afterwardsAuditDetail.setQuantity(otherMap.get(SystemEventAttrConstant.QUANTITY) != null ? Integer.parseInt(otherMap.get(SystemEventAttrConstant.QUANTITY).toString()) : 1);
|
|
|
afterwardsAuditDetail.setMedicalInsuranceMark(otherMap.get(Constant.MEDICAL_INSURANCE_MARK_KEY) != null ? otherMap.get(Constant.MEDICAL_INSURANCE_MARK_KEY).toString() : "0");
|
|
|
- afterwardsAuditDetail.setAfterIncidentDetailLogId((Integer)itemMap.get(SystemEventAttrConstant.ITEMMAP_AFTER_INCIDENT_DETAIL_LOG_ID));
|
|
|
- afterwardsAuditDetail.setMedicalInsRuleInfoId((Integer)itemMap.get(SystemEventAttrConstant.MEDICAL_INS_RULE_PROJECT_ID));
|
|
|
+ afterwardsAuditDetail.setAfterIncidentDetailLogId((Integer) itemMap.get(SystemEventAttrConstant.ITEMMAP_AFTER_INCIDENT_DETAIL_LOG_ID));
|
|
|
+ afterwardsAuditDetail.setMedicalInsRuleInfoId((Integer) itemMap.get(SystemEventAttrConstant.MEDICAL_INS_RULE_PROJECT_ID));
|
|
|
afterwardsAuditDetailList.add(afterwardsAuditDetail);
|
|
|
|
|
|
}
|
|
@@ -302,7 +317,8 @@ public class FactorEnchangeFactory {
|
|
|
afterwardsAuditDetail.setMedicalInsRuleInfoCode(medicalInsRuleInfo.getRuleCode());
|
|
|
afterwardsAuditDetail.setMedicalInsRuleInfoId(medicalInsRuleInfo.getId());
|
|
|
afterwardsAuditDetail.setMedicalInsRuleInfoName(medicalInsRuleInfo.getRuleName());
|
|
|
- afterwardsAuditDetail.setDescription(medicalInsRuleInfo.getViolationDesc());
|
|
|
+ String desc = getDesc(medicalInsRuleInfo, itemMap);
|
|
|
+ afterwardsAuditDetail.setDescription(desc);
|
|
|
afterwardsAuditDetail.setOutpatientNumber(afterwardsAudit.getOutpatientNumber());
|
|
|
afterwardsAuditDetail.setPrescriptionNumber(afterwardsAudit.getPrescriptionNumber());
|
|
|
// afterwardsAuditDetail.setReminderLevel();
|
|
@@ -314,8 +330,8 @@ public class FactorEnchangeFactory {
|
|
|
afterwardsAuditDetail.setAfterwardsAuditId(afterwardsAudit.getId());
|
|
|
afterwardsAuditDetail.setMedicalInsuranceMark(itemMap.get(Constant.MEDICAL_INSURANCE_MARK_KEY) != null ? itemMap.get(Constant.MEDICAL_INSURANCE_MARK_KEY).toString() : "0");
|
|
|
afterwardsAuditDetail.setPrice(itemMap.get(SystemEventAttrConstant.PRICE) != null ? new BigDecimal(itemMap.get(SystemEventAttrConstant.PRICE).toString()) : null);
|
|
|
- afterwardsAuditDetail.setMedicalRuleProjectId((Integer)itemMap.get(SystemEventAttrConstant.MEDICAL_INS_RULE_PROJECT_ID));
|
|
|
- afterwardsAuditDetail.setAfterIncidentDetailLogId((Integer)itemMap.get(SystemEventAttrConstant.ITEMMAP_AFTER_INCIDENT_DETAIL_LOG_ID));
|
|
|
+ afterwardsAuditDetail.setMedicalRuleProjectId((Integer) itemMap.get(SystemEventAttrConstant.MEDICAL_INS_RULE_PROJECT_ID));
|
|
|
+ afterwardsAuditDetail.setAfterIncidentDetailLogId((Integer) itemMap.get(SystemEventAttrConstant.ITEMMAP_AFTER_INCIDENT_DETAIL_LOG_ID));
|
|
|
afterwardsAuditService.lambdaUpdate().setSql("amount = amount +" + amount.doubleValue()).eq(AfterwardsAudit::getId, afterwardsAudit.getId()).update();
|
|
|
afterwardsAuditDetailService.save(afterwardsAuditDetail);
|
|
|
}
|
|
@@ -347,17 +363,13 @@ public class FactorEnchangeFactory {
|
|
|
midIncidentAuditDetail.setMedicalInsRuleInfoCode(medicalInsRuleInfo.getRuleCode());
|
|
|
midIncidentAuditDetail.setMedicalInsRuleInfoId(medicalInsRuleInfo.getId());
|
|
|
midIncidentAuditDetail.setMedicalInsRuleInfoName(medicalInsRuleInfo.getRuleName());
|
|
|
- String desc = medicalInsRuleInfo.getViolationDesc();
|
|
|
+ String desc = getDesc(medicalInsRuleInfo, itemMap);
|
|
|
if (otherItemMap.containsKey(Constant.PROJECT_CODE_KEY)) {
|
|
|
midIncidentAuditDetail.setProejctCode(otherItemMap.get(Constant.PROJECT_CODE_KEY).toString());
|
|
|
midIncidentAuditDetail.setProejctName(otherItemMap.get(Constant.PROJECT_NAME_KEY).toString());
|
|
|
midIncidentAuditDetail.setMedicalProjectCode(otherItemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
|
|
|
midIncidentAuditDetail.setMedicalProjectName(otherItemMap.get(Constant.MEDICAL_PROJECT_NAME_KEY).toString());
|
|
|
midIncidentAuditDetail.setProjectType(otherItemMap.getOrDefault(Constant.PROJECT_TYPE_KEY, "default").toString());
|
|
|
- Object descObject = redisTemplate.opsForHash().get(Constant.PROJECT_VOLIDATION_DESC_KEY + medicalInsRuleInfo.getId(), otherItemMap.get(Constant.MEDICAL_PROJECT_NAME_KEY).toString());
|
|
|
- if (null != descObject) {
|
|
|
- desc = descObject.toString();
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
midIncidentAuditDetail.setDescription(desc);
|
|
@@ -401,7 +413,8 @@ public class FactorEnchangeFactory {
|
|
|
midIncidentAuditDetail.setMedicalInsRuleInfoCode(medicalInsRuleInfo.getRuleCode());
|
|
|
midIncidentAuditDetail.setMedicalInsRuleInfoId(medicalInsRuleInfo.getId());
|
|
|
midIncidentAuditDetail.setMedicalInsRuleInfoName(medicalInsRuleInfo.getRuleName());
|
|
|
- midIncidentAuditDetail.setDescription(medicalInsRuleInfo.getViolationDesc());
|
|
|
+ String desc = getDesc(medicalInsRuleInfo, itemMap);
|
|
|
+ midIncidentAuditDetail.setDescription(desc);
|
|
|
midIncidentAuditDetail.setOutpatientNumber(midIncidentAudit.getOutpatientNumber());
|
|
|
midIncidentAuditDetail.setPrescriptionNumber(midIncidentAudit.getPrescriptionNumber());
|
|
|
midIncidentAuditDetail.setViolationLevel(medicalInsRuleInfo.getViolationLevel());
|
|
@@ -430,6 +443,21 @@ public class FactorEnchangeFactory {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public String getDesc(MedicalInsRuleInfo medicalInsRuleInfo, Map<String, Object> itemMap) {
|
|
|
+ String desc = medicalInsRuleInfo.getViolationDesc();
|
|
|
+ Object descObject = redisTemplate.opsForHash().get(Constant.PROJECT_VOLIDATION_DESC_KEY + medicalInsRuleInfo.getId(), itemMap.get(Constant.MEDICAL_PROJECT_NAME_KEY).toString());
|
|
|
+ if (null != descObject) {
|
|
|
+ desc = descObject.toString();
|
|
|
+ }
|
|
|
+ if (null != desc && desc.contains("#")) {
|
|
|
+ Map<String,Object> itemMapTemp = currentThreadLocalMap.get();
|
|
|
+ Object descSpel = spelUtil.getExpressionStr(itemMapTemp, desc);
|
|
|
+ return descSpel.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ return desc;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 逻辑表达式
|
|
@@ -441,9 +469,9 @@ public class FactorEnchangeFactory {
|
|
|
if (StringUtils.isNotBlank(factorEnchance.getEnhanceValue())) {
|
|
|
List<FactorCondRela> factorCondRelaList = factorCondRelaMap.get(factorEnchance.getId());
|
|
|
Set<String> condStrParamName = new HashSet<>();
|
|
|
- for (FactorCondRela factorCondRela : factorCondRelaList){
|
|
|
+ for (FactorCondRela factorCondRela : factorCondRelaList) {
|
|
|
condStrParamName.add(enchanceAttrMap.get(factorCondRela.getEventAttrId()).getEnName());
|
|
|
- if(2 == factorCondRela.getRefAttrType()){
|
|
|
+ if (2 == factorCondRela.getRefAttrType()) {
|
|
|
condStrParamName.add(enchanceAttrMap.get(factorCondRela.getRefEventAttrId()).getEnName());
|
|
|
}
|
|
|
}
|
|
@@ -461,7 +489,7 @@ public class FactorEnchangeFactory {
|
|
|
for (FactorCondRela factorCondRela : factorCondRelaList) {
|
|
|
Set<String> condStrParamName = new HashSet<>();
|
|
|
condStrParamName.add(enchanceAttrMap.get(factorCondRela.getEventAttrId()).getEnName());
|
|
|
- if(2 == factorCondRela.getRefAttrType()){
|
|
|
+ if (2 == factorCondRela.getRefAttrType()) {
|
|
|
condStrParamName.add(enchanceAttrMap.get(factorCondRela.getRefEventAttrId()).getEnName());
|
|
|
}
|
|
|
if (!StringUtils.isNotBlank(factorCondRela.getCondStr())) {
|