|
@@ -58,6 +58,11 @@ import org.jeecg.modules.medical.service.IRuleFactorRelaService;
|
|
import org.jeecg.modules.medical.service.ITreatmentItemsService;
|
|
import org.jeecg.modules.medical.service.ITreatmentItemsService;
|
|
import org.jeecg.modules.message.websocket.WebSocket;
|
|
import org.jeecg.modules.message.websocket.WebSocket;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
+import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
|
|
|
+import org.springframework.context.annotation.Conditional;
|
|
|
|
+import org.springframework.context.annotation.Profile;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@@ -128,15 +133,20 @@ public class RuleEngine {
|
|
IMedicalInsuranceDrugsService medicalInsuranceDrugsService;
|
|
IMedicalInsuranceDrugsService medicalInsuranceDrugsService;
|
|
@Autowired
|
|
@Autowired
|
|
IDiagnoseItemsService diagnoseItemsService;
|
|
IDiagnoseItemsService diagnoseItemsService;
|
|
|
|
+ @Value("${cache.auto:false}")
|
|
|
|
+ private Boolean cacheAutoInit;
|
|
|
|
|
|
public static ThreadLocal<MidIncidentWarningVO> midIncidentWarningVOThreadLocal = new ThreadLocal<>();
|
|
public static ThreadLocal<MidIncidentWarningVO> midIncidentWarningVOThreadLocal = new ThreadLocal<>();
|
|
|
|
|
|
public static Map<String, List<RuleAttr>> interfRuleAttrList = new HashMap<>();
|
|
public static Map<String, List<RuleAttr>> interfRuleAttrList = new HashMap<>();
|
|
public static List<Integer> advanceWaringRuleIdList = new ArrayList<>();
|
|
public static List<Integer> advanceWaringRuleIdList = new ArrayList<>();
|
|
public static Map<String, Set<Integer>> itemCodeAndRuleIdMap = new HashMap<>();
|
|
public static Map<String, Set<Integer>> itemCodeAndRuleIdMap = new HashMap<>();
|
|
|
|
+ public static Map<Integer, List<RuleFactorRela>> ruleIdAndFatorEnchanceIdMap = new HashMap<>();
|
|
|
|
+ public static Map<Integer, List<FactorEnchance>> allEnchanceTypeMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
|
|
-// @PostConstruct
|
|
|
|
public void initMedicalInsRule() {
|
|
public void initMedicalInsRule() {
|
|
|
|
+ log.info("进入初始化RuleEngine");
|
|
List<MedicalInsRuleInfo> medicalInsRuleInfoList = medicalInsRuleInfoService.lambdaQuery().eq(MedicalInsRuleInfo::getState, Constant.EFF_STATE).list();
|
|
List<MedicalInsRuleInfo> medicalInsRuleInfoList = medicalInsRuleInfoService.lambdaQuery().eq(MedicalInsRuleInfo::getState, Constant.EFF_STATE).list();
|
|
if (!CollectionUtil.isNotEmpty(medicalInsRuleInfoList)) {
|
|
if (!CollectionUtil.isNotEmpty(medicalInsRuleInfoList)) {
|
|
log.error("规则配置表没有有效的规则");
|
|
log.error("规则配置表没有有效的规则");
|
|
@@ -152,10 +162,7 @@ public class RuleEngine {
|
|
medicalMap.put(medicalInsRuleInfo.getId(), medicalInsRuleInfo);
|
|
medicalMap.put(medicalInsRuleInfo.getId(), medicalInsRuleInfo);
|
|
if (Constant.TREATMEN_TYPE_ADVANCE_WARNING.equals(medicalInsRuleInfo.getCallScenario())) {
|
|
if (Constant.TREATMEN_TYPE_ADVANCE_WARNING.equals(medicalInsRuleInfo.getCallScenario())) {
|
|
advanceWaringRuleIdList.add(medicalInsRuleInfo.getId());
|
|
advanceWaringRuleIdList.add(medicalInsRuleInfo.getId());
|
|
- } else
|
|
|
|
-// if (Constant.TREATMEN_TYPE_MID_INCIDENT_WARNING.equals(medicalInsRuleInfo.getCallScenario())
|
|
|
|
-// || Constant.TREATMEN_TYPE_MID_EX_POST_SUPERVISION.equals(medicalInsRuleInfo.getCallScenario()))
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
midMedicalInsRuleInfoList.add(medicalInsRuleInfo);
|
|
midMedicalInsRuleInfoList.add(medicalInsRuleInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -163,6 +170,26 @@ public class RuleEngine {
|
|
genItemCodeAndRuleIdMap(midMedicalInsRuleInfoList);
|
|
genItemCodeAndRuleIdMap(midMedicalInsRuleInfoList);
|
|
List<RuleAttr> ruleAttrList = ruleAttrService.list();
|
|
List<RuleAttr> ruleAttrList = ruleAttrService.list();
|
|
interfRuleAttrList = ruleAttrList.stream().collect(Collectors.groupingBy(RuleAttr::getInterfName));
|
|
interfRuleAttrList = ruleAttrList.stream().collect(Collectors.groupingBy(RuleAttr::getInterfName));
|
|
|
|
+ initFactor();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostConstruct
|
|
|
|
+ public void initMedicalInsRuleAuto() {
|
|
|
|
+ if(cacheAutoInit) {
|
|
|
|
+ initMedicalInsRule();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void initFactor(){
|
|
|
|
+ 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);
|
|
|
|
+ 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);
|
|
|
|
+ allEnchanceTypeMap = factorEnchanceList.stream().collect(Collectors.groupingBy(FactorEnchance::getFactorCatalog));
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -274,7 +301,7 @@ public class RuleEngine {
|
|
try {
|
|
try {
|
|
List<Integer> ruleIdList = medicalInsRuleInfoList.stream().map(MedicalInsRuleInfo::getId).collect(Collectors.toList());
|
|
List<Integer> ruleIdList = medicalInsRuleInfoList.stream().map(MedicalInsRuleInfo::getId).collect(Collectors.toList());
|
|
List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.lambdaQuery().in(MedicalInsRuleProject::getMedicalInsRuleInfoId, ruleIdList).list();
|
|
List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.lambdaQuery().in(MedicalInsRuleProject::getMedicalInsRuleInfoId, ruleIdList).list();
|
|
- if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
|
|
|
|
|
|
+ if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
Map<Integer, List<MedicalInsRuleProject>> ruleIdAndMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
|
|
Map<Integer, List<MedicalInsRuleProject>> ruleIdAndMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
|
|
@@ -937,17 +964,20 @@ public class RuleEngine {
|
|
log.error("未有对应的规则,接口数据:{}", paramMap);
|
|
log.error("未有对应的规则,接口数据:{}", paramMap);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- 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);
|
|
|
|
-
|
|
|
|
- if (CollectionUtil.isNotEmpty(ruleFactorRelaList)) {
|
|
|
|
- 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));
|
|
|
|
|
|
+// 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));
|
|
|
|
+ }
|
|
|
|
+ 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()) {
|
|
for (Integer medicalRuleInsInfoId : enchanceTypeMap.keySet()) {
|
|
String auditDetailKeyStr = paramMap.get(Constant.MEDICAL_PROJECT_NAME_KEY) + "_" + medicalRuleInsInfoId;
|
|
String auditDetailKeyStr = paramMap.get(Constant.MEDICAL_PROJECT_NAME_KEY) + "_" + medicalRuleInsInfoId;
|
|
if (auditDetailSet.contains(auditDetailKeyStr)) {
|
|
if (auditDetailSet.contains(auditDetailKeyStr)) {
|
|
@@ -982,17 +1012,21 @@ public class RuleEngine {
|
|
log.error("未有对应的规则,接口数据:{}", paramMap);
|
|
log.error("未有对应的规则,接口数据:{}", paramMap);
|
|
return false;
|
|
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);
|
|
|
|
|
|
+// 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));
|
|
|
|
+ }
|
|
boolean auditFlag = false;
|
|
boolean auditFlag = false;
|
|
- if (CollectionUtil.isNotEmpty(ruleFactorRelaList)) {
|
|
|
|
- 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));
|
|
|
|
|
|
+ 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()) {
|
|
for (Integer medicalRuleInsInfoId : enchanceTypeMap.keySet()) {
|
|
String auditDetailKeyStr = paramMap.get(Constant.MEDICAL_PROJECT_NAME_KEY) + "_" + medicalRuleInsInfoId;
|
|
String auditDetailKeyStr = paramMap.get(Constant.MEDICAL_PROJECT_NAME_KEY) + "_" + medicalRuleInsInfoId;
|
|
if (auditDetailSet.contains(auditDetailKeyStr)) {
|
|
if (auditDetailSet.contains(auditDetailKeyStr)) {
|