瀏覽代碼

区分事中,事后规则

0027005599 1 年之前
父節點
當前提交
6f1aa743ab

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

@@ -601,56 +601,24 @@ public class RuleEngine {
             MidIncidentAudit midIncidentAudit = insertMidWarning(midIncidentWarningVO);
             insertLog(midIncidentWarningVO);
             midIncidentAudit.setInterfName(intefName);
-
+            //callScenario 1=事前  2=事后  3=事前/事后 4=事中 5=事后/事中
+            List<String> callScenarioList = Arrays.asList("4", "5");
             boolean sendFlag = false;
             for (Map<String, Object> itemMap : itemList) {
-                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));
-                    medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
-                    if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
-                        log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
-                    } else {
-                        medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
-                        log.info("数据库检索到匹配规则ID列表:{}", medicalInsRuleInfoIdList);
-                    }
+                List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString(), callScenarioList);
+                if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
+                    log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
                 } else {
-                    medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndProjectCode(new ArrayList<>(medicalInsRuleInfoIdList), itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
+                    Set<Integer> medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
+                    log.info("项目编码:{} 数据库检索到匹配规则ID列表:{}", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY), medicalInsRuleInfoIdList);
                 }
 
                 Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
                 if (null != diagnose) {
+                    List<String> diagnoseList = (List<String>) diagnose;
                     //获取诊断编码配置的规则ID,加入需要执行的规则
-                    Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnose.toString());
-                    List<MedicalInsRuleProject> medicalInsRuleProjectTempList = null;
-                    if (CollectionUtil.isEmpty(diagnoseMedicalInsRuleInfoIdList)) {
-                        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);
-                    } else {
-                        medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndDiagCode(new ArrayList<>(diagnoseMedicalInsRuleInfoIdList), diagnose.toString());
-                    }
-                    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);
-                                }
-                            }
-                        }
-                    }
+                    getAndSetDiagRule(diagnoseList, medicalInsRuleProjectList);
+
                 }
                 if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                     log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
@@ -703,55 +671,24 @@ public class RuleEngine {
             MidIncidentAudit midIncidentAudit = insertMidWarning(midIncidentWarningVO);
             insertLog(midIncidentWarningVO);
             midIncidentAudit.setInterfName(intefName);
-
+            //callScenario 1=事前  2=事后  3=事前/事后 4=事中 5=事后/事中
+            List<String> callScenarioList = Arrays.asList("4", "5");
             boolean sendFlag = false;
             for (Map<String, Object> itemMap : itemList) {
-                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));
-                    medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
-                    if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
-                        log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
-                    } else {
-                        medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
-                        log.info("数据库检索到匹配规则ID列表:{}", medicalInsRuleInfoIdList);
-                    }
+                List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString(), callScenarioList);
+                if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
+                    log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
                 } else {
-                    medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndProjectCode(new ArrayList<>(medicalInsRuleInfoIdList), itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
+                    Set<Integer> medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
+                    log.info("项目编码:{} 数据库检索到匹配规则ID列表:{}", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY), medicalInsRuleInfoIdList);
                 }
+
                 Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
                 if (null != diagnose) {
+                    List<String> diagnoseList = (List<String>) diagnose;
                     //获取诊断编码配置的规则ID,加入需要执行的规则
-                    Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnose.toString());
-                    List<MedicalInsRuleProject> medicalInsRuleProjectTempList = null;
-                    if (CollectionUtil.isEmpty(diagnoseMedicalInsRuleInfoIdList)) {
-                        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);
-                    } else {
-                        medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndDiagCode(new ArrayList<>(diagnoseMedicalInsRuleInfoIdList), diagnose.toString());
-                    }
-                    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);
-                                }
-                            }
-                        }
-                    }
+                    getAndSetDiagRule(diagnoseList, medicalInsRuleProjectList);
+
                 }
                 if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                     log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
@@ -805,7 +742,9 @@ public class RuleEngine {
             String jsonStr = JSON.toJSONString(afterIncidentDetailLog);
             log.info("事后处理日志:{}", jsonStr);
             JSONObject itemMap = JSON.parseObject(jsonStr);
-            List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
+            //callScenario 1=事前  2=事后  3=事前/事后 4=事中 5=事后/事中
+            List<String> callScenarioList = Arrays.asList("2", "5", "3");
+            List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString(), callScenarioList);
             if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                 log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
             } else {

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

@@ -39,18 +39,6 @@ public interface IMedicalInsRuleProjectService extends IService<MedicalInsRulePr
      * @param medicalProjectCode
      * @return
      */
-    List<MedicalInsRuleProject> getRuleProjectByMedicalProjectCode(String medicalProjectCode);
+    List<MedicalInsRuleProject> getRuleProjectByMedicalProjectCode(String medicalProjectCode,List<String> callScenarioList);
 
-    /**
-     * 根据医保规则id和项目编码查询
-     * @param medicalInsRuleInfoIdList
-     * @param medicalProjectCode
-     * @return
-     */
-    List<MedicalInsRuleProject> getRuleProjectByRuleIdAndProjectCode(List<Integer> medicalInsRuleInfoIdList, String medicalProjectCode);
-
-
-    List<MedicalInsRuleProject> getRuleProjectByDiagCode(String medicalDiagnoseCode);
-
-    List<MedicalInsRuleProject> getRuleProjectByRuleIdAndDiagCode(List<Integer> medicalInsRuleInfoIdList, String medicalDiagnoseCode);
 }

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

@@ -1,14 +1,10 @@
 package org.jeecg.modules.medical.service.impl;
 
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.util.BiFunction;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import net.sf.saxon.expr.instruct.Copy;
-import net.sf.saxon.s9api.TeeDestination;
-import net.sf.saxon.value.IntegerValue;
-import org.apache.poi.ss.formula.functions.T;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.exception.JeecgBootException;
@@ -21,13 +17,10 @@ import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.common.ExcelImportUtilService;
 import org.jeecg.modules.medical.common.bo.ExportRuleFieldDTO;
 import org.jeecg.modules.medical.common.bo.ExportRuleTitleDTO;
-import org.jeecg.modules.medical.entity.MaterialItems;
 import org.jeecg.modules.medical.entity.MedicalInsRuleProject;
-import org.jeecg.modules.medical.entity.MedicalInsRuleProjectDiagnose;
 import org.jeecg.modules.medical.mapper.MedicalInsRuleProjectMapper;
 import org.jeecg.modules.medical.service.IMedicalInsRuleProjectDiagnoseService;
 import org.jeecg.modules.medical.service.IMedicalInsRuleProjectService;
-import org.jeecg.modules.system.service.ISysDataSourceService;
 import org.jeecg.modules.system.service.ISysDictService;
 import org.jeecg.modules.utils.DefaultExcelImportServer;
 import org.jeecg.modules.utils.DefaultExcelImportUtil;
@@ -37,13 +30,10 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.jeecgframework.poi.util.PoiPublicUtil;
-import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.ObjectUtils;
@@ -58,8 +48,16 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Field;
 import java.net.URLEncoder;
-import java.util.*;
-import java.util.function.Function;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.TreeSet;
 import java.util.stream.Collectors;
 
 /**
@@ -393,7 +391,7 @@ public class MedicalInsRuleProjectServiceImpl extends ServiceImpl<MedicalInsRule
                         }
                         generateDataRecords = generateDataRecords(codeList, relatedCodeList);
                         resultList.addAll(generateDataRecords);
-                    }else{
+                    } else {
                         resultList.add(item);
                     }
                 }
@@ -628,48 +626,17 @@ public class MedicalInsRuleProjectServiceImpl extends ServiceImpl<MedicalInsRule
     }
 
     @Override
-    public List<MedicalInsRuleProject> getRuleProjectByMedicalProjectCode(String medicalProjectCode) {
+    public List<MedicalInsRuleProject> getRuleProjectByMedicalProjectCode(String medicalProjectCode, List<String> callScenarioList) {
         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);
-    }
-
-    @Override
-    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  ");
+        queryWrapper.in("call_scenario", callScenarioList);
+        queryWrapper.last(" and INSTR('" + medicalProjectCode + "',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 ");
-
-        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 ");
-
-        return this.list(queryWrapper);
-    }
-
-
-
     public static void main(String[] args) {
 //        String role = "a,b,c";
 //        System.out.println(role.indexOf("a") > -1);

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

@@ -130,8 +130,8 @@ public class AfterwardsAuditDataTest {
 //    IMedicalInsRuleProjectService medicalInsRuleProjectService;
     @Test
     public void testProjectCode(){
-        List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode("C17040122300004123asfsdf");
-        System.out.println(medicalInsRuleProjectList);
+//        List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode("C17040122300004123asfsdf");
+//        System.out.println(medicalInsRuleProjectList);
     }
 
     @Test