Selaa lähdekoodia

事后规则匹配优化

0027005599 1 vuosi sitten
vanhempi
säilyke
d2bf9ac606

+ 14 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/SystemEventAttrConstant.java

@@ -16,6 +16,8 @@ public class SystemEventAttrConstant {
      */
     public static String MEDICAL_INS_RULE_INFO_ID = "medical_ins_rule_info_id";
 
+
+
     /**
      * 医保规则名称 eventAttrId:996
      */
@@ -94,6 +96,12 @@ public class SystemEventAttrConstant {
      * 医疗收费项目类别 eventAttrId:981
      */
     public static final String CATEGORIES_ITEMS = "categories_items";
+
+    /**
+     * 医保规则项目ID eventAttrId:980
+     */
+    public static String MEDICAL_INS_RULE_INFO_PROJECT_ID = "medical_ins_rule_info_project_id";
+
     /**
      * 医保库诊断编码列表 eventAttrId:10028
      */
@@ -101,7 +109,7 @@ public class SystemEventAttrConstant {
 
 
     /**
-     * 医保库诊断编码列表 eventAttrId:10029
+     * 医保库关联诊断编码列表 eventAttrId:10029
      */
     public static final String MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE = "medical_ins_correlationMedicalDiagnoseCode";
 
@@ -110,6 +118,11 @@ public class SystemEventAttrConstant {
      */
     public static final String MEDICAL_INS_CORRELATIONPROJECTCODELIST = "medical_ins_correlationProjectCodeList";
 
+    /**
+     * 医保库诊断编码 eventAttrId:10052
+     */
+    public static final String MEDICAL_INS_MEDICALDIAGNOSECODE = "medical_ins_medicalDiagnoseCode";
+
     /**
      * 事前工单idkey
      */

+ 0 - 20
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/MedicalInsRuleProject.java

@@ -56,35 +56,30 @@ public class MedicalInsRuleProject implements Serializable {
      */
     @Excel(name = "项目编码", width = 15)
     @ApiModelProperty(value = "主数据表编码")
-    @TableField("project_code")
     private java.lang.String projectCode;
     /**
      * 项目名称
      */
     @Excel(name = "项目名称", width = 15)
     @ApiModelProperty(value = "项目名称")
-    @TableField("project_name")
     private java.lang.String projectName;
     /**
      * 主数据表ID
      */
     @Excel(name = "主数据表ID", width = 15)
     @ApiModelProperty(value = "主数据表ID")
-    @TableField("project_id")
     private java.lang.String projectId;
     /**
      * 关联项目编号
      */
     @Excel(name = "关联项目编号", width = 15)
     @ApiModelProperty(value = "关联项目编号")
-    @TableField("correlation_project_code")
     private java.lang.String correlationProjectCode;
     /**
      * 关联项目名称
      */
     @Excel(name = "关联项目名称", width = 15)
     @ApiModelProperty(value = "关联项目名称")
-    @TableField("correlation_project_name")
     private java.lang.String correlationProjectName;
 
 
@@ -95,7 +90,6 @@ public class MedicalInsRuleProject implements Serializable {
     @Excel(name = "收费项目等级", width = 15)
     @ApiModelProperty(value = "收费等级;01 甲类 02 乙类 03 丙类 04 可报丙类")
     @Dict(dicCode = "change_class")
-    @TableField("change_class")
     private java.lang.String changeClass;
 
     /**
@@ -107,7 +101,6 @@ public class MedicalInsRuleProject implements Serializable {
     @Excel(name = "关联收费项目等级", width = 15)
     @ApiModelProperty(value = "关联收费项目等级;01 甲类 02 乙类 03 丙类 04 可报丙类")
     @Dict(dicCode = "change_class")
-    @TableField("correlation_change_class")
     private java.lang.String correlationChangeClass;
     /**
      * 医疗收费项目类别
@@ -115,14 +108,12 @@ public class MedicalInsRuleProject implements Serializable {
     @Excel(name = "医疗收费项目类别", width = 15)
     @ApiModelProperty(value = "医疗收费项目类别;01\t床位费 02\t诊察费 03\t检查费 04\t化验费 05\t治疗费 06\t手术费 07\t护理费 08\t卫生材料费 09\t西药费 10\t中药饮片费 11\t中成药费 12\t一般诊疗费 13\t挂号费 14\t其他费 14012\t单病种除外内容 14013\t单病种超标准床位费 14014\t单病种定额标准费 1407\t救护车费 1408\tMRI费 1409\tCT费 1410\t彩超费 1411\t输氧费 1412\t输血费 1413\t麻醉费 1414\t麻醉相关项目费 1415\t其他医疗费")
     @Dict(dicCode = "categories_items")
-    @TableField("categories_items")
     private java.lang.String categoriesItems;
     /**
      * 年龄;
      */
     @Excel(name = "年龄", width = 15)
     @ApiModelProperty(value = "年龄;")
-    @TableField("age")
     private java.lang.Integer age;
 
     /**
@@ -130,14 +121,12 @@ public class MedicalInsRuleProject implements Serializable {
      */
     @Excel(name = "数量", width = 15)
     @ApiModelProperty(value = "数量;")
-    @TableField("quantity")
     private java.lang.Integer quantity;
     /**
      * 金额;
      */
     @Excel(name = "金额", width = 15)
     @ApiModelProperty(value = "金额;")
-    @TableField("amount")
     private java.lang.Double amount;
     /**
      * 性别;0 未知的性别 1 男性 2 女性 9 未说明性别s
@@ -145,7 +134,6 @@ public class MedicalInsRuleProject implements Serializable {
     @Excel(name = "性别", width = 15)
     @ApiModelProperty(value = "性别;0 未知的性别 1 男性 2 女性 9 未说明性别")
     @Dict(dicCode = "sex")
-    @TableField("gender")
     private java.lang.String gender;
     /**
      * 医疗机构等级;
@@ -153,7 +141,6 @@ public class MedicalInsRuleProject implements Serializable {
     @Excel(name = "医疗机构等级", width = 15)
     @ApiModelProperty(value = "医疗机构等级;")
     @Dict(dicCode = "medical_ins_level")
-    @TableField("medical_ins_level")
     private java.lang.String medicalInsLevel;
     /**
      * 医师级别;
@@ -161,48 +148,41 @@ public class MedicalInsRuleProject implements Serializable {
     @Excel(name = "医师级别", width = 15)
     @ApiModelProperty(value = "医师级别;")
     @Dict(dicCode = "doctor_level")
-    @TableField("doctor_level")
     private java.lang.String doctorLevel;
     /**
      * 参保类型;
      */
     @Excel(name = "参保类型", width = 15)
     @ApiModelProperty(value = "参保类型;")
-    @TableField("ins_type")
     private java.lang.String insType;
     /**
      * 科室;
      */
     @Excel(name = "科室", width = 15)
     @ApiModelProperty(value = "科室;")
-    @TableField("medical_dept_code")
     private java.lang.String medicalDeptCode;
     /**
      * 用药天数;
      */
     @Excel(name = "用药天数", width = 15)
     @ApiModelProperty(value = "用药天数;")
-    @TableField("dose_day")
     private java.lang.String doseDay;
     /**
      * 单价;
      */
     @Excel(name = "单价", width = 15)
     @ApiModelProperty(value = "单价;")
-    @TableField("price")
     private java.lang.Double price;
     /**
      * 状态
      */
     @Excel(name = "状态", width = 15)
     @ApiModelProperty(value = "状态")
-    @TableField("state")
     private java.lang.String state;
 
 
     @Excel(name = "诊断编码")
     @ApiModelProperty(value = "诊断编码")
-    @TableField("medical_diagnose_code")
     private String medicalDiagnoseCode;
 
     /**

+ 4 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/FactorEnchangeFactory.java

@@ -1,6 +1,7 @@
 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;
@@ -118,6 +119,7 @@ public class FactorEnchangeFactory {
         }
         Map<Integer, FactorEnchance> factorEnchanceMap = factorEnchanceList.stream().collect(Collectors.toMap(FactorEnchance::getId, v -> v, (v1, v2) -> v1));
         boolean result = false;
+        log.info("表达式执行执行map:{}", JSON.toJSONString(localMap));
         for (RuleFactorRela ruleFactorRela : ruleFactorRelaList) {
             Integer factorEnchanceId = ruleFactorRela.getFactorEnhanceId();
             FactorEnchance factorEnchance = factorEnchanceMap.get(factorEnchanceId);
@@ -271,14 +273,14 @@ public class FactorEnchangeFactory {
             }
             afterwardsAuditDetailService.saveBatch(afterwardsAuditDetailList);
         } else {
-            Double amount = (Double) itemMap.getOrDefault(Constant.AMOUNT_KEY, 0);
+            BigDecimal amount = (BigDecimal) itemMap.getOrDefault(Constant.AMOUNT_KEY, new BigDecimal(0));
             AfterwardsAuditDetail afterwardsAuditDetail = new AfterwardsAuditDetail();
             afterwardsAuditDetail.setProejctCode(itemMap.get(Constant.PROJECT_CODE_KEY).toString());
             afterwardsAuditDetail.setProejctName(itemMap.get(Constant.PROJECT_NAME_KEY).toString());
             afterwardsAuditDetail.setMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
             afterwardsAuditDetail.setMedicalProjectName(itemMap.get(Constant.MEDICAL_PROJECT_NAME_KEY).toString());
             afterwardsAuditDetail.setProjectType(itemMap.getOrDefault(Constant.PROJECT_TYPE_KEY, "default").toString());
-            afterwardsAuditDetail.setAmount(amount);
+            afterwardsAuditDetail.setAmount(amount.doubleValue());
 
             afterwardsAuditDetail.setMedicalDeptCode(afterwardsAudit.getMedicalDeptCode());
             afterwardsAuditDetail.setMedicalDeptName(afterwardsAudit.getMedicalDeptName());

+ 74 - 67
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/RuleEngine.java

@@ -144,7 +144,7 @@ public class RuleEngine {
     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<>();
-
+    public static Map<Integer, MedicalInsRuleInfo> allMedicalMap = new HashMap<>();
 
     public void initMedicalInsRule() {
         log.info("进入初始化RuleEngine");
@@ -158,9 +158,8 @@ public class RuleEngine {
          * 后续提醒通过redis加载id,把id传入规则引擎,迅速调用对应规则
          */
         List<MedicalInsRuleInfo> midMedicalInsRuleInfoList = new ArrayList<>();
-        Map<Integer, MedicalInsRuleInfo> medicalMap = new HashMap<>();
         for (MedicalInsRuleInfo medicalInsRuleInfo : medicalInsRuleInfoList) {
-            medicalMap.put(medicalInsRuleInfo.getId(), medicalInsRuleInfo);
+            allMedicalMap.put(medicalInsRuleInfo.getId(), medicalInsRuleInfo);
             if (Constant.TREATMEN_TYPE_ADVANCE_WARNING.equals(medicalInsRuleInfo.getCallScenario())) {
                 advanceWaringRuleIdList.add(medicalInsRuleInfo.getId());
             } else {
@@ -172,6 +171,7 @@ public class RuleEngine {
         List<RuleAttr> ruleAttrList = ruleAttrService.list();
         interfRuleAttrList = ruleAttrList.stream().collect(Collectors.groupingBy(RuleAttr::getInterfName));
         initFactor();
+
     }
 
     @PostConstruct
@@ -643,31 +643,69 @@ public class RuleEngine {
 
             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));
-                List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
+                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;
                 }
                 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) {
                 //获取诊断编码配置的规则ID,加入需要执行的规则
                 Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnose.toString());
+                List<MedicalInsRuleProject> medicalInsRuleProjectTempList = null;
                 if (CollectionUtil.isNotEmpty(diagnoseMedicalInsRuleInfoIdList)) {
-                    medicalInsRuleInfoIdList.addAll(diagnoseMedicalInsRuleInfoIdList);
+                    medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByDiagCode(diagnose.toString());
+                    if(CollectionUtil.isEmpty(medicalInsRuleProjectTempList)){
+                        log.info("诊断编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", diagnose);
+                    }
+                    Set<Integer> medicalInsRuleInfoIdDiagSet = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
+                    log.info("数据库检索到匹配规则ID列表:{} 诊断编码为:{}", medicalInsRuleInfoIdDiagSet, diagnose);
+                }else{
+                    medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndDiagCode(new ArrayList<>(medicalInsRuleInfoIdList), diagnose.toString());
                 }
+                if(CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)){
+                    if(CollectionUtil.isNotEmpty(medicalInsRuleProjectList)){
+                        medicalInsRuleProjectList.addAll(medicalInsRuleProjectTempList);
+                    }else {
+                        medicalInsRuleProjectList = medicalInsRuleProjectTempList;
+                    }
+                }
+            }
+            if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
+                log.error("医保规则对象被误删,请联系管理员");
+                return;
             }
-            runAfterEngine(auditDetailSet, itemMap, medicalInsRuleInfoIdList, afterwardsAudit, itemList);
+            for(MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectList) {
+                setProjectToLocalMap(itemMap, medicalInsRuleProject);
+                runAfterEngine(itemMap, medicalInsRuleProject.getMedicalInsRuleInfoId(), afterwardsAudit, itemList);
+            }
+
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
 
     }
 
+    /**
+     *
+     * @param itemMap
+     * @param medicalInsRuleProject
+     */
+    public void setProjectToLocalMap(Map<String,Object> itemMap, MedicalInsRuleProject medicalInsRuleProject){
+        String jsonStr = JSON.toJSONString(medicalInsRuleProject);
+        JSONObject jsonObject = JSONObject.parseObject(jsonStr);
+        Map<String,Object> transferMedicalMap = filterMap(jsonObject);
+        itemMap.putAll(transferMedicalMap);
+    }
+
 
     public void insertLog(MidIncidentWarningVO midIncidentWarningVO) {
         MidIncidentVisitLog midIncidentVisitLog = new MidIncidentVisitLog();
@@ -915,7 +953,6 @@ 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());
@@ -967,46 +1004,27 @@ public class RuleEngine {
      *
      * @param paramMap
      */
-    public void runAfterEngine(Set<String> auditDetailSet, Map<String, Object> paramMap, Set<Integer> medicalInsRuleInfoIdList, AfterwardsAudit afterIncidentAudit, List<Map<String, Object>> itemList) {
-        if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
+    public void runAfterEngine(Map<String, Object> paramMap, Integer medicalRuleInsInfoId, AfterwardsAudit afterIncidentAudit, List<Map<String, Object>> itemList) {
+        if (null == medicalRuleInsInfoId) {
             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);
-        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)) {
-                    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);
-                paramMap.put(SystemEventAttrConstant.ADVICE_DETAILS_LIST_KEY, itemList);
-                boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, afterIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp, itemList);
-                if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
-                    log.error("事后提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
-                    return;
-                }
+        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);
+            boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, afterIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp, itemList);
+            if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
+                log.error("事后提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
+                return;
             }
+        }else{
+            log.error("该医保规则ID:{} 未有配置医保规则处理流程-请到规则配置页面进行配置", medicalRuleInsInfoId);
         }
     }
 
@@ -1067,53 +1085,42 @@ public class RuleEngine {
             boolean correlationDiagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("correlationMedicalDiagnoseCode"));
             boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
             String projectCode = null;
-            if (projectCodeFlag && null != itemMap.get(Constant.PROJECT_CODE_KEY)) {
-                projectCode = itemMap.get(Constant.PROJECT_CODE_KEY).toString();
-            } else {
-                return;
+            if (projectCodeFlag && null != itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY)) {
+                projectCode = itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString();
             }
-            List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.lambdaQuery().eq(MedicalInsRuleProject::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
-                    .eq(projectCodeFlag, MedicalInsRuleProject::getProjectCode, projectCode).eq(MedicalInsRuleProject::getState, Constant.EFF_STATE).list();
-            List<String> correlationProjectCodeList = new ArrayList<>();
-            String collectionProjectCode = null;
-            if (CollectionUtil.isNotEmpty(medicalInsRuleProjectList)) {
-                if (medicalInsRuleProjectList.size() == 1) {
-                    String jsonStr = JSON.toJSONString(medicalInsRuleProjectList.get(0));
-                    collectionProjectCode = medicalInsRuleProjectList.get(0).getCorrelationProjectCode();
-                    JSONObject ruleProjectJSONObject = JSON.parseObject(jsonStr);
-                    Map<String, Object> filterMap = filterMap(ruleProjectJSONObject);
-                    itemMap.putAll(filterMap);
-                } else {
-                    correlationProjectCodeList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getProjectCode).collect(Collectors.toList());
-                    itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONPROJECTCODELIST, correlationProjectCodeList);
-                }
 
-            }
             if (diagnoseFlag) {
                 List<MedicalInsRuleProjectDiagnose> medicalInsRuleProjectDiagnoseList = null;
                 boolean conditionFlag = false;
                 if (StringUtils.isNotBlank(projectCode)) {
                     conditionFlag = true;
                 }
-                medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(conditionFlag, MedicalInsRuleProjectDiagnose::getMedicalInsProjectCode, projectCode).eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
-                        .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 1).list();
+                medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
+                        .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 1).last(conditionFlag, " and INSTR('"+projectCode+"', medical_ins_project_code)").list();
                 if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
                     List<String> medicalDiagnoseStrList = medicalInsRuleProjectDiagnoseList.stream().map(MedicalInsRuleProjectDiagnose::getMedicalDiagnoseCode).collect(Collectors.toList());
                     itemMap.put(SystemEventAttrConstant.MEDICAL_INS_MEDICALDIAGNOSECODELIST, medicalDiagnoseStrList);
+                }else{
+                    log.error("配置了诊断编码规则属性,但是具体规则参数未配置,请管理员尽快配置 医保规则:{}", medicalInsRuleInfo);
+                    itemMap.put(SystemEventAttrConstant.MEDICAL_INS_MEDICALDIAGNOSECODELIST, new ArrayList<>());
                 }
             }
 
             if (correlationDiagnoseFlag) {
                 List<MedicalInsRuleProjectDiagnose> medicalInsRuleProjectDiagnoseList = null;
                 boolean conditionFlag = false;
+                String collectionProjectCode = itemMap.getOrDefault(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE,"").toString();
                 if (StringUtils.isNotBlank(collectionProjectCode)) {
                     conditionFlag = true;
                 }
-                medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(conditionFlag, MedicalInsRuleProjectDiagnose::getMedicalInsProjectCode, collectionProjectCode).eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
-                        .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 2).list();
+                medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
+                        .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 2).last(conditionFlag, " and INSTR('"+projectCode+"', medical_ins_project_code)").list();
                 if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
                     List<String> medicalDiagnoseStrList = medicalInsRuleProjectDiagnoseList.stream().map(MedicalInsRuleProjectDiagnose::getMedicalDiagnoseCode).collect(Collectors.toList());
                     itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, medicalDiagnoseStrList);
+                }else{
+                    log.error("配置了关联诊断编码规则属性,但是具体规则参数未配置,请管理员尽快配置 医保规则:{}", medicalInsRuleInfo);
+                    itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, new ArrayList<>());
                 }
             }
 

+ 13 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/SPELUtil.java

@@ -312,6 +312,19 @@ public class SPELUtil {
         return false;
     }
 
+    public static Boolean isNotMemberListAndList(List<Object> lList, List<Object> rList) {
+        if (CollectionUtil.isEmpty(rList) || CollectionUtil.isEmpty(lList)) {
+            return true;
+        }
+        for (Object value : rList) {
+            boolean flag = isMemberLeftObject(value, lList);
+            if (flag) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     public static boolean isNumeric(String str) {
         Pattern pattern = Pattern.compile("[0-9]*");
         Matcher isNum = pattern.matcher(str.charAt(0) + "");

+ 4 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/IMedicalInsRuleProjectDiagnoseService.java

@@ -15,6 +15,10 @@ public interface IMedicalInsRuleProjectDiagnoseService extends IService<MedicalI
 
     boolean saveDiagnose(List<String> medicalDiagnoseCode,Integer projectCodeType, Integer medicalInsRuleInfoId, String projectCode);
     boolean updateDiagnose(List<String> medicalDiagnoseCode,Integer projectCodeType, Integer medicalInsRuleInfoId, String projectCode);
+
+    List<MedicalInsRuleProjectDiagnose> getRuleProjectByDiagCodeAndRuleId(List<Integer> medicalInsRuleInfoIdList, String medicalDiagnoseCode);
+
+    List<MedicalInsRuleProjectDiagnose> getRuleProjectByMedicalDiagnoseCode(String medicalDiagnoseCode);
 //    boolean saveCorrelationDiagnose(List<String> medicalDiagnoseCode, Integer medicalInsRuleInfoId, String medicalInsProjectCode);
 
 }

+ 9 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/IMedicalInsRuleProjectService.java

@@ -42,9 +42,15 @@ public interface IMedicalInsRuleProjectService extends IService<MedicalInsRulePr
     List<MedicalInsRuleProject> getRuleProjectByMedicalProjectCode(String medicalProjectCode);
 
     /**
-     * 根据诊断编码模糊匹配规则
-     * @param medicalDiagnoseCode
+     * 根据医保规则id和项目编码查询
+     * @param medicalInsRuleInfoIdList
+     * @param medicalProjectCode
      * @return
      */
-    List<MedicalInsRuleProject> getRuleProjectByMedicalDiagnoseCode(String medicalDiagnoseCode);
+    List<MedicalInsRuleProject> getRuleProjectByRuleIdAndProjectCode(List<Integer> medicalInsRuleInfoIdList, String medicalProjectCode);
+
+
+    List<MedicalInsRuleProject> getRuleProjectByDiagCode(String medicalDiagnoseCode);
+
+    List<MedicalInsRuleProject> getRuleProjectByRuleIdAndDiagCode(List<Integer> medicalInsRuleInfoIdList, String medicalDiagnoseCode);
 }

+ 22 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/impl/MedicalInsRuleProjectDiagnoseServiceImpl.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.medical.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.entity.MedicalInsRuleProjectDiagnose;
 import org.jeecg.modules.medical.mapper.MedicalInsRuleProjectDiagnoseMapper;
 import org.jeecg.modules.medical.service.IMedicalInsRuleProjectDiagnoseService;
@@ -61,4 +63,24 @@ public class MedicalInsRuleProjectDiagnoseServiceImpl extends ServiceImpl<Medica
 
     }
 
+    @Override
+    public List<MedicalInsRuleProjectDiagnose> getRuleProjectByDiagCodeAndRuleId(List<Integer> medicalInsRuleInfoIdList, String medicalDiagnoseCode) {
+        QueryWrapper<MedicalInsRuleProjectDiagnose> queryWrapper = new QueryWrapper<MedicalInsRuleProjectDiagnose>();
+        queryWrapper.in("medical_ins_rule_info_id", medicalInsRuleInfoIdList);
+        queryWrapper.isNull("medical_ins_project_code");
+        queryWrapper.last(" and INSTR('"+medicalDiagnoseCode+"',medical_diagnose_code)=1  ");
+
+        return this.list(queryWrapper);
+    }
+
+
+    @Override
+    public List<MedicalInsRuleProjectDiagnose> getRuleProjectByMedicalDiagnoseCode(String medicalDiagnoseCode) {
+        QueryWrapper<MedicalInsRuleProjectDiagnose> queryWrapper = new QueryWrapper<MedicalInsRuleProjectDiagnose>();
+        queryWrapper.isNull("medical_ins_project_code");
+        queryWrapper.last(" and INSTR('"+medicalDiagnoseCode+"',medical_diagnose_code)=1  ");
+
+        return this.list(queryWrapper);
+    }
+
 }

+ 26 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/impl/MedicalInsRuleProjectServiceImpl.java

@@ -631,20 +631,43 @@ public class MedicalInsRuleProjectServiceImpl extends ServiceImpl<MedicalInsRule
     public List<MedicalInsRuleProject> getRuleProjectByMedicalProjectCode(String medicalProjectCode) {
         QueryWrapper<MedicalInsRuleProject> queryWrapper = new QueryWrapper<MedicalInsRuleProject>();
         queryWrapper.eq("STATE", Constant.EFF_STATE);
-        queryWrapper.last(" and (INSTR('"+medicalProjectCode+"',project_code) or INSTR('"+medicalProjectCode+"',correlation_project_code)) ");
+        queryWrapper.last(" and (INSTR('"+medicalProjectCode+"',project_code)>0 or INSTR('"+medicalProjectCode+"',correlation_project_code)>0) ");
 
         return this.list(queryWrapper);
     }
 
     @Override
-    public List<MedicalInsRuleProject> getRuleProjectByMedicalDiagnoseCode(String medicalDiagnoseCode) {
+    public List<MedicalInsRuleProject> getRuleProjectByRuleIdAndProjectCode(List<Integer> medicalInsRuleInfoIdList, String medicalProjectCode) {
         QueryWrapper<MedicalInsRuleProject> queryWrapper = new QueryWrapper<MedicalInsRuleProject>();
+        queryWrapper.in("medical_ins_rule_info_id", medicalInsRuleInfoIdList);
         queryWrapper.eq("STATE", Constant.EFF_STATE);
-        queryWrapper.last(" and (INSTR('"+medicalDiagnoseCode+"',project_code) or INSTR('"+medicalDiagnoseCode+"',correlation_project_code)) ");
+        queryWrapper.last(" and (INSTR('"+medicalProjectCode+"',project_code)=1 or INSTR('"+medicalProjectCode+"',correlation_project_code)=1) ");
 
         return this.list(queryWrapper);
     }
 
+
+    @Override
+    public List<MedicalInsRuleProject> getRuleProjectByDiagCode(String medicalDiagnoseCode) {
+        QueryWrapper<MedicalInsRuleProject> queryWrapper = new QueryWrapper<MedicalInsRuleProject>();
+        queryWrapper.eq("STATE", Constant.EFF_STATE);
+        queryWrapper.last(" and (INSTR('"+medicalDiagnoseCode+"',project_code)=1 or INSTR('"+medicalDiagnoseCode+"',correlation_project_code)=1) ");
+
+        return this.list(queryWrapper);
+    }
+
+    @Override
+    public List<MedicalInsRuleProject> getRuleProjectByRuleIdAndDiagCode(List<Integer> medicalInsRuleInfoIdList, String medicalDiagnoseCode) {
+        QueryWrapper<MedicalInsRuleProject> queryWrapper = new QueryWrapper<MedicalInsRuleProject>();
+        queryWrapper.in("medical_ins_rule_info_id", medicalInsRuleInfoIdList);
+        queryWrapper.eq("STATE", Constant.EFF_STATE);
+        queryWrapper.last(" and (INSTR('"+medicalDiagnoseCode+"',medical_diagnose_code)=1 or INSTR('"+medicalDiagnoseCode+"',correlation_medical_diagnose_code)=1) ");
+
+        return this.list(queryWrapper);
+    }
+
+
+
     public static void main(String[] args) {
 //        String role = "a,b,c";
 //        System.out.println(role.indexOf("a") > -1);

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 33 - 28
jeecg-module-system/jeecg-system-start/src/test/java/org/jeecg/SpelTest.java


+ 8 - 2
jeecg-module-system/jeecg-system-start/src/test/java/org/jeecg/TestMain.java

@@ -9,6 +9,8 @@ import org.springframework.http.HttpMethod;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 
+import java.util.regex.Pattern;
+
 /**
  * @Description: TODO
  * @author: scott
@@ -34,8 +36,12 @@ public class TestMain {
 //            System.out.println("查询失败");
 //        }
 
-        AfterIncidentDetailLog incidentDetailLog = new AfterIncidentDetailLog();
-        System.out.println(JSONObject.toJSONString(incidentDetailLog));
+//        AfterIncidentDetailLog incidentDetailLog = new AfterIncidentDetailLog();
+//        System.out.println(JSONObject.toJSONString(incidentDetailLog));
+
+//        Pattern p=Pattern.compile("^ABC");
+//        p.pattern();//返回 \
+        System.out.println(Pattern.matches("^ABC.","ABCA"));
 
     }
     private static HttpHeaders getHeaders() {

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä