liusheng
8 天以前 b087e507b04b30ae4069d688ddfc9ba4889cd63e
南华附一数据采集修改
已修改3个文件
224 ■■■■ 文件已修改
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java 77 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java 145 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/ServiceSLTDHealthcareRecordServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -368,43 +368,43 @@
                    log.info("【dealHisData】省立同德“入院”結束采集数据,院区:{}", cid);
                    // 门急诊分页采集:每页1000条,直到无数据为止(南华附一的先不采门急诊数据)
                    if (active.trim().equals("sltd")) {
                        log.info("【dealHisData】省立同德“门急诊”开始分页采集数据,院区:{}", cid);
                        serviceSLTDInhospReqVO.setStartHeadTime(null);
                        serviceSLTDInhospReqVO.setStartTailTime(null);
                        serviceSLTDInhospReqVO.setEncounterTimeStart(nowTime);
                        serviceSLTDInhospReqVO.setEncounterTimeEnd(nowTime);
                        if (active.trim().equals("nhfy")) {
                            serviceSLTDInhospReqVO.setEncounterTimeStart(yesterdayZero.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
                            serviceSLTDInhospReqVO.setEncounterTimeEnd(todayZero.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
                        }
                        serviceSLTDInhospReqVO.setStatusList(null);
                        List<String> list1 = new ArrayList<>();
                        list1.add("FH0108.01");
                        list1.add("FH0108.03");
                        serviceSLTDInhospReqVO.setHealthcareRecordTypeList(list1);
                        long outpPage = 1L;
                        final long OUTP_PAGE_SIZE = 1000L;
                        while (true) {
                            serviceSLTDInhospReqVO.setCurrent(outpPage);
                            serviceSLTDInhospReqVO.setSize(OUTP_PAGE_SIZE);
                            log.info("【dealHisData】省立同德“门急诊”采集第{}页数据,院区:{}", outpPage, cid);
                            List<ServiceSLTDInhospResDTO> outpResult = serviceSLTDHealthcareRecordService.queryHealthcareRecordList(serviceSLTDInhospReqVO);
                            if (CollectionUtils.isEmpty(outpResult)) {
                                log.info("【dealHisData】省立同德“门急诊”第{}页无数据,采集结束,院区:{}", outpPage, cid);
                                break;
                            }
                            log.info("【dealHisData】省立同德“门急诊”第{}页采集{}条,院区:{}", outpPage, outpResult.size(), cid);
                            if (outpResult.size() < OUTP_PAGE_SIZE) {
                                break;
                            }
                            outpPage++;
                        }
                        // 清除分页参数,避免影响后续出入院查询
                        serviceSLTDInhospReqVO.setCurrent(null);
                        serviceSLTDInhospReqVO.setSize(null);
                        log.info("【dealHisData】省立同德“门急诊”分页采集完成,院区:{}", cid);
                    }
//                    if (active.trim().equals("sltd")) {
//                        log.info("【dealHisData】省立同德“门急诊”开始分页采集数据,院区:{}", cid);
//                        serviceSLTDInhospReqVO.setStartHeadTime(null);
//                        serviceSLTDInhospReqVO.setStartTailTime(null);
//                        serviceSLTDInhospReqVO.setEncounterTimeStart(nowTime);
//                        serviceSLTDInhospReqVO.setEncounterTimeEnd(nowTime);
//                        if (active.trim().equals("nhfy")) {
//                            serviceSLTDInhospReqVO.setEncounterTimeStart(yesterdayZero.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//                            serviceSLTDInhospReqVO.setEncounterTimeEnd(todayZero.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//                        }
//                        serviceSLTDInhospReqVO.setStatusList(null);
//                        List<String> list1 = new ArrayList<>();
//                        list1.add("FH0108.01");
//                        list1.add("FH0108.03");
//                        serviceSLTDInhospReqVO.setHealthcareRecordTypeList(list1);
//                        long outpPage = 1L;
//                        final long OUTP_PAGE_SIZE = 1000L;
//                        while (true) {
//                            serviceSLTDInhospReqVO.setCurrent(outpPage);
//                            serviceSLTDInhospReqVO.setSize(OUTP_PAGE_SIZE);
//                            log.info("【dealHisData】省立同德“门急诊”采集第{}页数据,院区:{}", outpPage, cid);
//                            List<ServiceSLTDInhospResDTO> outpResult = serviceSLTDHealthcareRecordService.queryHealthcareRecordList(serviceSLTDInhospReqVO);
//                            if (CollectionUtils.isEmpty(outpResult)) {
//                                log.info("【dealHisData】省立同德“门急诊”第{}页无数据,采集结束,院区:{}", outpPage, cid);
//                                break;
//                            }
//                            log.info("【dealHisData】省立同德“门急诊”第{}页采集{}条,院区:{}", outpPage, outpResult.size(), cid);
//                            if (outpResult.size() < OUTP_PAGE_SIZE) {
//                                break;
//                            }
//                            outpPage++;
//                        }
//                        // 清除分页参数,避免影响后续出入院查询
//                        serviceSLTDInhospReqVO.setCurrent(null);
//                        serviceSLTDInhospReqVO.setSize(null);
//                        log.info("【dealHisData】省立同德“门急诊”分页采集完成,院区:{}", cid);
//                    }
                    log.info("【dealHisData】省立同德“出院”开始采集数据,院区:{}", cid);
                    serviceSLTDInhospReqVO.setStartHeadTime(null);
@@ -420,7 +420,10 @@
                    serviceSLTDInhospReqVO.setHealthcareRecordTypeList(null);
                    List<String> list2 = new ArrayList<>();
//                    list2.add("FH0108.02");
                    //出院
                    list2.add("FH0109.27");
                    //预出院
                    list2.add("FH0109.25");
                    serviceSLTDInhospReqVO.setStatusList(list2);
                    log.info("【dealHisData】省立同德“出院”采集数据入参:{}", serviceSLTDInhospReqVO);
                    serviceSLTDHealthcareRecordService.queryHealthcareRecordList(serviceSLTDInhospReqVO);
smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
@@ -699,7 +699,7 @@
                    i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
                    addServiceSubtaskPreachform(serviceSubtask, null);
                }
            } else if (serviceSubtask.getTaskSituation() == 6) {
            } else if (serviceSubtask.getTaskSituation() != null && serviceSubtask.getTaskSituation() == 6) {
                //说明该患者是被过滤的,不用再执行了
                serviceSubtask.setCreateBy(serviceTask.getCreateBy());
                serviceSubtask.setCreateTime(new Date());
@@ -1432,6 +1432,40 @@
    }
    /**
     * 统一更新pat_med_inhosp的check_flag
     *
     * @param patMedInhosp 患者住院记录
     * @param type         1=deptcheck_flag, 2=wardcheck_flag, 3=diagcheck_flag, 4=inDeptcheck_flag, 5=inWardcheck_flag
     * @param flagValue    要设置的值
     * @param remark       备注信息
     */
    private void updateCheckFlag(PatMedInhosp patMedInhosp, Integer type, String flagValue, String remark) {
        PatMedInhosp updateObj = new PatMedInhosp();
        updateObj.setInhospid(patMedInhosp.getInhospid());
        switch (type) {
            case 1:
                updateObj.setDeptcheckFlag(flagValue);
                break;
            case 2:
                updateObj.setWardcheckFlag(flagValue);
                break;
            case 3:
                updateObj.setDiagcheckFlag(flagValue);
                break;
            case 4:
                updateObj.setInDeptcheckFlag(flagValue);
                break;
            case 5:
                updateObj.setInWardcheckFlag(flagValue);
                break;
        }
        if (StringUtils.isNotEmpty(remark)) {
            updateObj.setRemark(remark + " (type=" + type + ")");
        }
        patMedInhospMapper.updatePatMedInhosp(updateObj);
    }
    /**
     * 基于规则的任务生成方法
     * 根据患者离院科室或病区查询service_task_rule,获取deptRule、wradRule、diagRule
     * 根据规则值决定调用哪个方法生成随访任务
@@ -1474,47 +1508,108 @@
                    // 有规则,按规则执行
                    log.info("【基于规则】患者{}查询到规则:deptRule={}, wradRule={}, diagRule={}", patMedInhosp1.getInhospid(), rule.getDeptRule(), rule.getWradRule(), rule.getDiagRule());
                    // 判断是否有规则为"1"(首先执行)
                    boolean hasPrimaryRule = "1".equals(rule.getDeptRule()) || "1".equals(rule.getWradRule()) || "1".equals(rule.getDiagRule());
                    boolean deptIsPrimary = "1".equals(rule.getDeptRule());
                    boolean wardIsPrimary = "1".equals(rule.getWradRule());
                    boolean diagIsPrimary = "1".equals(rule.getDiagRule());
                    boolean deptIsSecondary = "2".equals(rule.getDeptRule());
                    boolean wardIsSecondary = "2".equals(rule.getWradRule());
                    boolean diagIsSecondary = "2".equals(rule.getDiagRule());
                    boolean hasPrimaryRule = deptIsPrimary || wardIsPrimary || diagIsPrimary;
                    if (hasPrimaryRule) {
                        // 有首要规则,只执行首要规则对应的方法
                        int generatedCount = 0;
                        // 第一步:执行所有规则=1的方法,每个独立记录成功/失败
                        int deptGenCount = 0;
                        int wardGenCount = 0;
                        int diagGenCount = 0;
                        // 按顺序:科室 -> 病区 -> 疾病
                        if ("1".equals(rule.getDeptRule())) {
                        if (deptIsPrimary) {
                            log.info("【基于规则】执行科室首要规则");
                            generatedCount += addDeptSubTaskForPatient(patMedInhosp1, patArchive, config);
                            deptGenCount = addDeptSubTaskForPatient(patMedInhosp1, patArchive, config);
                        }
                        if (!active.equals("xh")) {
                            if ("1".equals(rule.getWradRule())) {
                            if (wardIsPrimary) {
                                log.info("【基于规则】执行病区首要规则");
                                generatedCount += addWardSubTaskForPatient(patMedInhosp1, patArchive, config);
                                wardGenCount = addWardSubTaskForPatient(patMedInhosp1, patArchive, config);
                            }
                            if ("1".equals(rule.getDiagRule())) {
                            if (diagIsPrimary) {
                                log.info("【基于规则】执行疾病首要规则");
                                generatedCount += addIcd10SubTaskForPatient(patMedInhosp1, patArchive, config);
                                diagGenCount = addIcd10SubTaskForPatient(patMedInhosp1, patArchive, config);
                            }
                        }
                        // 如果首要规则生成的子任务为空,则调用其他次要规则的方法
                        if (generatedCount == 0) {
                            log.info("【基于规则】首要规则未生成子任务,开始执行次要规则");
                        int primaryGeneratedCount = deptGenCount + wardGenCount + diagGenCount;
                        log.info("【基于规则】首要规则执行结果: deptGen={}, wardGen={}, diagGen={}, total={}", deptGenCount, wardGenCount, diagGenCount, primaryGeneratedCount);
                            if (!"1".equals(rule.getDeptRule()) && StringUtils.isNotEmpty(rule.getDeptRule())) {
                        // 第二步:判断首要规则是否有任意一个生成成功
                        if (primaryGeneratedCount > 0) {
                            // 至少有一个首要规则生成成功
                            // —— 将=2的次要规则对应flag设为"2"(跳过)
                            log.info("【基于规则】首要规则有成功(count={}),将次要规则对应flag设为2", primaryGeneratedCount);
                            if (deptIsSecondary) {
                                updateCheckFlag(patMedInhosp1, 1, "2", "首要规则已生成,次要规则跳过");
                            }
                            if (!active.equals("xh")) {
                                if (wardIsSecondary) {
                                    updateCheckFlag(patMedInhosp1, 2, "2", "首要规则已生成,次要规则跳过");
                                }
                                if (diagIsSecondary) {
                                    updateCheckFlag(patMedInhosp1, 3, "2", "首要规则已生成,次要规则跳过");
                                }
                            }
                            // —— 对于=1且生成成功的,将其对应flag设为"1"
                            if (deptIsPrimary && deptGenCount > 0) {
                                updateCheckFlag(patMedInhosp1, 1, "1", "科室首要规则生成成功");
                            }
                            if (!active.equals("xh")) {
                                if (wardIsPrimary && wardGenCount > 0) {
                                    updateCheckFlag(patMedInhosp1, 2, "1", "病区首要规则生成成功");
                                }
                                if (diagIsPrimary && diagGenCount > 0) {
                                    updateCheckFlag(patMedInhosp1, 3, "1", "疾病首要规则生成成功");
                                }
                            }
                            // —— 对于=1但生成失败的,将其对应flag设为"2"
                            if (deptIsPrimary && deptGenCount == 0) {
                                updateCheckFlag(patMedInhosp1, 1, "2", "科室首要规则生成失败");
                            }
                            if (!active.equals("xh")) {
                                if (wardIsPrimary && wardGenCount == 0) {
                                    updateCheckFlag(patMedInhosp1, 2, "2", "病区首要规则生成失败");
                                }
                                if (diagIsPrimary && diagGenCount == 0) {
                                    updateCheckFlag(patMedInhosp1, 3, "2", "疾病首要规则生成失败");
                                }
                            }
                        } else {
                            // 所有首要规则全部失败,将=1的flag设为"2",然后执行=2的方法
                            log.info("【基于规则】首要规则全部失败,将=1的flag设为2,开始执行次要规则");
                            if (deptIsPrimary) {
                                updateCheckFlag(patMedInhosp1, 1, "2", "科室首要规则全部失败");
                            }
                            if (!active.equals("xh")) {
                                if (wardIsPrimary) {
                                    updateCheckFlag(patMedInhosp1, 2, "2", "病区首要规则全部失败");
                                }
                                if (diagIsPrimary) {
                                    updateCheckFlag(patMedInhosp1, 3, "2", "疾病首要规则全部失败");
                                }
                            }
                            // 执行次要规则(=2)的方法
                            if (deptIsSecondary) {
                                log.info("【基于规则】执行科室次要规则");
                                addDeptSubTaskForPatient(patMedInhosp1, patArchive, config);
                            }
                            if (!active.equals("xh")) {
                                if (!"1".equals(rule.getWradRule()) && StringUtils.isNotEmpty(rule.getWradRule())) {
                                if (wardIsSecondary) {
                                    log.info("【基于规则】执行病区次要规则");
                                    addWardSubTaskForPatient(patMedInhosp1, patArchive, config);
                                }
                                if (!"1".equals(rule.getDiagRule()) && StringUtils.isNotEmpty(rule.getDiagRule())) {
                                if (diagIsSecondary) {
                                    log.info("【基于规则】执行疾病次要规则");
                                    addIcd10SubTaskForPatient(patMedInhosp1, patArchive, config);
                                }
@@ -1606,6 +1701,8 @@
            if (StringUtils.isNotEmpty(errorreason)) {
                PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid());
                patMedInhosp1.setWardcheckFlag("2");
                patMedInhosp1.setDeptcheckFlag(patMedInhosp.getDeptcheckFlag());
                patMedInhosp1.setDiagcheckFlag(patMedInhosp.getDiagcheckFlag());
                patMedInhosp1.setLongTaskReason(StringUtils.isNotEmpty(patMedInhosp.getLongTaskReason()) ? patMedInhosp.getLongTaskReason() + errorreason : errorreason);
                patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
            } else {
@@ -1656,9 +1753,9 @@
            if (CollectionUtils.isEmpty(serviceTaskdiags)) {
                PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid());
                patMedInhosp1.setDiagcheckFlag("2");
                patMedInhosp1.setLongTaskReason("该患者所患疾病未配置长期任务;");
                patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
                patMedInhosp.setDiagcheckFlag("2");
                patMedInhosp.setLongTaskReason("该患者所患疾病未配置长期任务;");
                patMedInhospMapper.updatePatMedInhosp(patMedInhosp);
            } else {
                int flag = 0;
                for (ServiceTaskdiag serviceTaskdiag1 : serviceTaskdiags) {
@@ -1675,9 +1772,9 @@
                if (flag == 0) {
                    log.error("该科室或病区对于患者所患疾病未配置长期任务,患者:{}", patMedInhosp1.getInhospid());
                    PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid());
                    patMedInhosp1.setDiagcheckFlag("2");
                    patMedInhosp1.setLongTaskReason("该科室或病区对于患者所患疾病未配置长期任务;");
                    patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
                    patMedInhosp.setDiagcheckFlag("2");
                    patMedInhosp.setLongTaskReason("该科室或病区对于患者所患疾病未配置长期任务;");
                    patMedInhospMapper.updatePatMedInhosp(patMedInhosp);
                }
            }
        } catch (Exception e) {
smartor/src/main/java/com/smartor/service/impl/ServiceSLTDHealthcareRecordServiceImpl.java
@@ -781,6 +781,8 @@
        patMedInhosp.setDelFlag("0");
        patMedInhosp.setOrgid(dto.getOrgId());
        patMedInhosp.setCampusid(dto.getCampusId());
        if(StringUtils.isNotEmpty(dto.getHealthcareRecordStatus())&&dto.getHealthcareRecordStatus().equals("FH0109.25"))
            patMedInhosp.setRemark("预出院");
        return patMedInhosp;
    }