ソースを参照

适配以诊断编码为主的规则匹配

0027005599 1 年間 前
コミット
188131be3c

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

@@ -96,6 +96,11 @@ public class MedicalInsRuleInfo implements Serializable {
     @ApiModelProperty(value = "调用场景;1=事前  2=事后  3=事前/事后 4=事中 5=事后/事中")
     @Dict(dicCode = "call_scenario")
     private java.lang.String callScenario;
+
+    /**
+     * 匹配类型;为空或者1:项目编码匹配,2:诊断编码匹配
+     */
+    private java.lang.String searchType;
 	/**状态*/
 	@Excel(name = "状态", width = 15)
     @ApiModelProperty(value = "状态")

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

@@ -152,6 +152,15 @@ public class RuleEngine {
 
     public static Set<Integer> daysRuleIdSet = new HashSet<>();
 
+    /**
+     * 配置了项目编码,但是是以诊断编码匹配的规则id列表
+     */
+    public static List<Integer> diagRuleIdList = new ArrayList<>();
+    /**
+     * 没有配置项目编码,只配置了诊断编码类的规则id列表
+     */
+    public static List<Integer> noProjectCodeDiagRuleIdList = new ArrayList<>();
+
     public void initMedicalInsRule() {
         log.info("进入初始化RuleEngine");
         List<MedicalInsRuleInfo> medicalInsRuleInfoList = medicalInsRuleInfoService.lambdaQuery().eq(MedicalInsRuleInfo::getState, Constant.EFF_STATE).list();
@@ -165,12 +174,25 @@ public class RuleEngine {
          */
         List<MedicalInsRuleInfo> midMedicalInsRuleInfoList = new ArrayList<>();
         for (MedicalInsRuleInfo medicalInsRuleInfo : medicalInsRuleInfoList) {
+            //诊断编码匹配
+            if (medicalInsRuleInfo.getSearchType().equals("2")) {
+                diagRuleIdList.add(medicalInsRuleInfo.getId());
+            }
             allMedicalMap.put(medicalInsRuleInfo.getId(), medicalInsRuleInfo);
             if (Constant.TREATMEN_TYPE_ADVANCE_WARNING.equals(medicalInsRuleInfo.getCallScenario())) {
                 advanceWaringRuleIdList.add(medicalInsRuleInfo.getId());
             } else {
                 midMedicalInsRuleInfoList.add(medicalInsRuleInfo);
             }
+            String selectedRoles = medicalInsRuleInfo.getSelectedRoles();
+            if (StringUtils.isNotBlank(selectedRoles)) {
+                String[] selectedRolesArr = selectedRoles.split(",");
+                boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
+                boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
+                if (diagnoseFlag && !projectCodeFlag) {
+                    noProjectCodeDiagRuleIdList.add(medicalInsRuleInfo.getId());
+                }
+            }
         }
 
         genItemCodeAndRuleIdMap(midMedicalInsRuleInfoList);
@@ -506,7 +528,7 @@ public class RuleEngine {
     }
 
 
-    public void dealAfterAdvance(AfterIncidentLog afterIncidentLog,Map<String,Object> paramMap, List<Integer> ruleIdList, List<Map<String, Object>> itemList) {
+    public void dealAfterAdvance(AfterIncidentLog afterIncidentLog, Map<String, Object> paramMap, List<Integer> ruleIdList, List<Map<String, Object>> itemList) {
         if (CollectionUtil.isEmpty(ruleIdList)) {
             log.error("事后提醒未配置对应的提醒规则");
             return;
@@ -793,31 +815,10 @@ public class RuleEngine {
 
             Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
             if (null != diagnose) {
+                List<String> diagnoseList = (List<String>) diagnose;
                 //获取诊断编码配置的规则ID,加入需要执行的规则
-                List<MedicalInsRuleProject> 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);
+                getAndSetDiagRule(diagnoseList, medicalInsRuleProjectList);
 
-                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"));
-                            boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
-                            if (diagnoseFlag && !projectCodeFlag) {
-                                medicalInsRuleProjectList.add(medicalInsRuleProject);
-                            }
-                        }
-                    }
-                }
             }
             if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                 log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出执行规则", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
@@ -853,6 +854,48 @@ public class RuleEngine {
 
     }
 
+    public void getAndSetDiagRule(List<String> diagnoseList, List<MedicalInsRuleProject> medicalInsRuleProjectList) {
+        if (CollectionUtil.isNotEmpty(diagRuleIdList)) {
+            List<MedicalInsRuleProjectDiagnose> projectDiagnoseList = medicalInsRuleProjectDiagnoseService.getRuleProjectByDiagCodeAndRuleId(diagRuleIdList, diagnoseList);
+            if (CollectionUtil.isNotEmpty(projectDiagnoseList)) {
+                List<String> projectCodeList = new ArrayList<>();
+                for (MedicalInsRuleProjectDiagnose medicalInsRuleProjectDiagnose : projectDiagnoseList) {
+                    projectCodeList.add(medicalInsRuleProjectDiagnose.getMedicalInsProjectCode());
+                }
+                List<MedicalInsRuleProject> medicalInsRuleProjectTempList = medicalInsRuleProjectService.lambdaQuery().in(MedicalInsRuleProject::getProjectCode)
+                        .in(MedicalInsRuleProject::getMedicalInsRuleInfoId, diagRuleIdList).list();
+                if (CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)) {
+                    Set<Integer> ruleIdSet = medicalInsRuleProjectTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
+                    log.error("有项目编码以诊断编码为主的诊断规则 诊断编码:{} 匹配的规则id:{} ", diagnoseList, ruleIdSet);
+                    for (MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectTempList) {
+                        medicalInsRuleProjectList.add(medicalInsRuleProject);
+                    }
+                }
+            }
+        }
+        if (CollectionUtil.isNotEmpty(noProjectCodeDiagRuleIdList)) {
+            List<MedicalInsRuleProjectDiagnose> projectDiagnoseList = medicalInsRuleProjectDiagnoseService.getRuleProjectByDiagCodeAndRuleId(noProjectCodeDiagRuleIdList, diagnoseList);
+            if (CollectionUtil.isNotEmpty(projectDiagnoseList)) {
+                Set<Integer> medicalRuleIdSet = projectDiagnoseList.stream().map(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId).collect(Collectors.toSet());
+                List<String> diagnoseCodeList = new ArrayList<>();
+                for (MedicalInsRuleProjectDiagnose medicalInsRuleProjectDiagnose : projectDiagnoseList) {
+                    diagnoseCodeList.add(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode());
+                }
+                List<MedicalInsRuleProject> medicalInsRuleProjectDiagTempList = medicalInsRuleProjectService.lambdaQuery().in(MedicalInsRuleProject::getMedicalDiagnoseCode, diagnoseCodeList).in(MedicalInsRuleProject::getMedicalInsRuleInfoId, medicalRuleIdSet).list();
+                if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagTempList)) {
+                    Set<Integer> ruleIdSet = medicalInsRuleProjectDiagTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
+                    log.error("无项目编码以诊断编码为主的诊断规则 诊断编码:{} 匹配的规则id:{} ", diagnoseList, ruleIdSet);
+                    for (MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectDiagTempList) {
+                        medicalInsRuleProjectList.add(medicalInsRuleProject);
+                    }
+                } else {
+                    log.error("无项目编码的诊断规则 诊断编码:{} 规则id:{} 在medical_ins_rule_project表数据缺失", diagnoseCodeList, medicalRuleIdSet);
+                }
+
+            }
+        }
+    }
+
     /**
      * 把当前明细记录的主单下的所有项目编码设置到当前项目记录
      */

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

@@ -16,9 +16,9 @@ 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> getRuleProjectByDiagCodeAndRuleId(List<Integer> medicalInsRuleInfoIdList, List<String> medicalDiagnoseCode);
 
-    List<MedicalInsRuleProjectDiagnose> getRuleProjectByMedicalDiagnoseCode(String medicalDiagnoseCode);
+    List<MedicalInsRuleProjectDiagnose> getRuleProjectByDiagnoseCodeAndProjectNull(List<String> medicalDiagnoseCode);
 //    boolean saveCorrelationDiagnose(List<String> medicalDiagnoseCode, Integer medicalInsRuleInfoId, String medicalInsProjectCode);
 
 }

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

@@ -1,14 +1,12 @@
 package org.jeecg.modules.medical.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import org.jeecg.modules.medical.Constant;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.medical.entity.MedicalInsRuleProjectDiagnose;
 import org.jeecg.modules.medical.mapper.MedicalInsRuleProjectDiagnoseMapper;
 import org.jeecg.modules.medical.service.IMedicalInsRuleProjectDiagnoseService;
 import org.springframework.stereotype.Service;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -24,13 +22,13 @@ public class MedicalInsRuleProjectDiagnoseServiceImpl extends ServiceImpl<Medica
 
 
     @Override
-    public boolean saveDiagnose(List<String> medicalDiagnoseCode,Integer projectCodeType, Integer medicalInsRuleInfoId, String projectCode) {
+    public boolean saveDiagnose(List<String> medicalDiagnoseCode, Integer projectCodeType, Integer medicalInsRuleInfoId, String projectCode) {
         List<MedicalInsRuleProjectDiagnose> diagnoseList = this.lambdaQuery().in(MedicalInsRuleProjectDiagnose::getMedicalDiagnoseCode, medicalDiagnoseCode)
                 .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, projectCodeType)
                 .eq(MedicalInsRuleProjectDiagnose::getMedicalInsProjectCode, projectCode)
                 .eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfoId).list();
         List<MedicalInsRuleProjectDiagnose> list = new ArrayList<>();
-        if(diagnoseList.size()>0){
+        if (diagnoseList.size() > 0) {
             List<String> collect = diagnoseList.stream().map(it -> it.getMedicalDiagnoseCode()).collect(Collectors.toList());
             medicalDiagnoseCode = medicalDiagnoseCode.stream().filter(item -> !collect.contains(item)).collect(Collectors.toList());
         }
@@ -64,23 +62,48 @@ public class MedicalInsRuleProjectDiagnoseServiceImpl extends ServiceImpl<Medica
     }
 
     @Override
-    public List<MedicalInsRuleProjectDiagnose> getRuleProjectByDiagCodeAndRuleId(List<Integer> medicalInsRuleInfoIdList, String medicalDiagnoseCode) {
+    public List<MedicalInsRuleProjectDiagnose> getRuleProjectByDiagCodeAndRuleId(List<Integer> medicalInsRuleInfoIdList, List<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  ");
+        StringBuffer lastSql = new StringBuffer(" and (");
+        for (int i = 0; i < medicalDiagnoseCode.size(); i++) {
+            String diagnose = medicalDiagnoseCode.get(i);
+            if (i == 0) {
+                lastSql.append("INSTR('").append(diagnose).append("',medical_diagnose_code)=1");
+            } else {
+                lastSql.append(" or INSTR('").append(diagnose).append("',medical_diagnose_code)=1");
+            }
+
+            if (i == medicalDiagnoseCode.size()-1) {
+                lastSql.append(")");
+            }
+        }
+
+        queryWrapper.last(lastSql.toString());
 
         return this.list(queryWrapper);
     }
 
 
     @Override
-    public List<MedicalInsRuleProjectDiagnose> getRuleProjectByMedicalDiagnoseCode(String medicalDiagnoseCode) {
+    public List<MedicalInsRuleProjectDiagnose> getRuleProjectByDiagnoseCodeAndProjectNull(List<String> medicalDiagnoseCodeList) {
         QueryWrapper<MedicalInsRuleProjectDiagnose> queryWrapper = new QueryWrapper<MedicalInsRuleProjectDiagnose>();
         queryWrapper.isNull("medical_ins_project_code");
-        queryWrapper.last(" and INSTR('"+medicalDiagnoseCode+"',medical_diagnose_code)=1  ");
+        StringBuffer lastSql = new StringBuffer(" and (");
+        for (int i = 0; i < medicalDiagnoseCodeList.size(); i++) {
+            String diagnose = medicalDiagnoseCodeList.get(i);
+            if (i == 0) {
+                lastSql.append("INSTR('").append(diagnose).append("',medical_diagnose_code)=1");
+            } else {
+                lastSql.append(" or INSTR('").append(diagnose).append("',medical_diagnose_code)=1");
+            }
 
+            if (i == medicalDiagnoseCodeList.size()-1) {
+                lastSql.append(")");
+            }
+        }
+
+        queryWrapper.last(lastSql.toString());
         return this.list(queryWrapper);
     }
-
 }

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

@@ -631,6 +631,7 @@ 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.isNull("search_type");
         queryWrapper.last(" and INSTR('"+medicalProjectCode+"',project_code)=1");
 
         return this.list(queryWrapper);
@@ -640,6 +641,7 @@ public class MedicalInsRuleProjectServiceImpl extends ServiceImpl<MedicalInsRule
     public List<MedicalInsRuleProject> getRuleProjectByRuleIdAndProjectCode(List<Integer> medicalInsRuleInfoIdList, String medicalProjectCode) {
         QueryWrapper<MedicalInsRuleProject> queryWrapper = new QueryWrapper<MedicalInsRuleProject>();
         queryWrapper.in("medical_ins_rule_info_id", medicalInsRuleInfoIdList);
+        queryWrapper.isNull("search_type");
         queryWrapper.eq("STATE", Constant.EFF_STATE);
         queryWrapper.last(" and INSTR('"+medicalProjectCode+"',project_code)=1  ");