|
@@ -58,6 +58,11 @@ import org.jeecg.modules.medical.service.IRuleFactorRelaService;
|
|
|
import org.jeecg.modules.medical.service.ITreatmentItemsService;
|
|
|
import org.jeecg.modules.message.websocket.WebSocket;
|
|
|
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.stereotype.Component;
|
|
|
|
|
@@ -128,15 +133,20 @@ public class RuleEngine {
|
|
|
IMedicalInsuranceDrugsService medicalInsuranceDrugsService;
|
|
|
@Autowired
|
|
|
IDiagnoseItemsService diagnoseItemsService;
|
|
|
+ @Value("${cache.auto:false}")
|
|
|
+ private Boolean cacheAutoInit;
|
|
|
|
|
|
public static ThreadLocal<MidIncidentWarningVO> midIncidentWarningVOThreadLocal = new ThreadLocal<>();
|
|
|
|
|
|
public static Map<String, List<RuleAttr>> interfRuleAttrList = new HashMap<>();
|
|
|
public static List<Integer> advanceWaringRuleIdList = new ArrayList<>();
|
|
|
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() {
|
|
|
+ log.info("进入初始化RuleEngine");
|
|
|
List<MedicalInsRuleInfo> medicalInsRuleInfoList = medicalInsRuleInfoService.lambdaQuery().eq(MedicalInsRuleInfo::getState, Constant.EFF_STATE).list();
|
|
|
if (!CollectionUtil.isNotEmpty(medicalInsRuleInfoList)) {
|
|
|
log.error("规则配置表没有有效的规则");
|
|
@@ -152,10 +162,7 @@ public class RuleEngine {
|
|
|
medicalMap.put(medicalInsRuleInfo.getId(), medicalInsRuleInfo);
|
|
|
if (Constant.TREATMEN_TYPE_ADVANCE_WARNING.equals(medicalInsRuleInfo.getCallScenario())) {
|
|
|
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);
|
|
|
}
|
|
|
}
|
|
@@ -163,6 +170,26 @@ public class RuleEngine {
|
|
|
genItemCodeAndRuleIdMap(midMedicalInsRuleInfoList);
|
|
|
List<RuleAttr> ruleAttrList = ruleAttrService.list();
|
|
|
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 {
|
|
|
List<Integer> ruleIdList = medicalInsRuleInfoList.stream().map(MedicalInsRuleInfo::getId).collect(Collectors.toList());
|
|
|
List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.lambdaQuery().in(MedicalInsRuleProject::getMedicalInsRuleInfoId, ruleIdList).list();
|
|
|
- if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
|
|
|
+ if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
|
|
|
return;
|
|
|
}
|
|
|
Map<Integer, List<MedicalInsRuleProject>> ruleIdAndMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
|
|
@@ -937,17 +964,20 @@ public class RuleEngine {
|
|
|
log.error("未有对应的规则,接口数据:{}", paramMap);
|
|
|
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()) {
|
|
|
String auditDetailKeyStr = paramMap.get(Constant.MEDICAL_PROJECT_NAME_KEY) + "_" + medicalRuleInsInfoId;
|
|
|
if (auditDetailSet.contains(auditDetailKeyStr)) {
|
|
@@ -982,17 +1012,21 @@ public class RuleEngine {
|
|
|
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);
|
|
|
+// 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;
|
|
|
- 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()) {
|
|
|
String auditDetailKeyStr = paramMap.get(Constant.MEDICAL_PROJECT_NAME_KEY) + "_" + medicalRuleInsInfoId;
|
|
|
if (auditDetailSet.contains(auditDetailKeyStr)) {
|