陈昶聿
19 小时以前 b73334e984e391cb2ea6b2651e77bf008e127459
smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
@@ -319,7 +319,6 @@
        //获取未处理在院的数据(如果刚刚出院的患者数据的出院时间,在下面查询出的入院时间之前,那之前的出院患者的数据,也得停掉,因为又入院了)
        PatMedInhosp patMedInhosp = new PatMedInhosp();
        //获取需要出院部门随访,未处理的数据
        patMedInhosp.setDeptcheckFlag("0");
        patMedInhosp.setInhospstate("0");
        List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp);
@@ -703,6 +702,7 @@
                //说明该患者是被过滤的,不用再执行了
                serviceSubtask.setCreateBy(serviceTask.getCreateBy());
                serviceSubtask.setCreateTime(new Date());
                serviceSubtask.setSendstate(4L);
                i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
            } else {
                if (StringUtils.isEmpty(serviceSubtask.getPhone())) {
@@ -849,6 +849,7 @@
                //说明该患者是被过滤的,不用再执行了
                serviceSubtask.setCreateBy(serviceTask.getCreateBy());
                serviceSubtask.setCreateTime(new Date());
                serviceSubtask.setSendstate(4L);
                i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
            } else {
                if (StringUtils.isEmpty(serviceSubtask.getPhone())) {
@@ -1205,7 +1206,7 @@
                e.printStackTrace();
                log.error("人员手术处理出异常了:{}", e.getMessage());
                opItem.setOpercheckFlag("2");
                opItem.setLongTaskReason("人员手术处理异常:" + e.getMessage());
                opItem.setLongTaskReason("人员手术处理异常");
                patMedOperationItemMapper.updatePatMedOperationItem(opItem);
            }
        }
@@ -1296,7 +1297,7 @@
                e.printStackTrace();
                log.error("人员疾病处理出异常了:{}", e.getMessage());
                pmiJB.setDiagcheckFlag("2");
                pmiJB.setLongTaskReason("人员疾病处理异常:" + e.getMessage());
                pmiJB.setLongTaskReason("人员疾病处理异常");
                patMedInhospMapper.updatePatMedInhosp(pmiJB);
            }
        }
@@ -1365,7 +1366,7 @@
                e.printStackTrace();
                log.error("人员病区处理出异常了:{}", e.getMessage());
                pmiBQ1.setWardcheckFlag("2");
                pmiBQ1.setLongTaskReason("人员病区处理异常:" + e.getMessage());
                pmiBQ1.setLongTaskReason("人员病区处理异常");
                patMedInhospMapper.updatePatMedInhosp(pmiBQ1);
            }
        }
@@ -1425,7 +1426,7 @@
                e.printStackTrace();
                log.error("人员科室处理出异常了:{}", e.getMessage());
                patMedInhosp1.setDeptcheckFlag("2");
                patMedInhosp1.setLongTaskReason("人员科室处理异常:" + e.getMessage());
                patMedInhosp1.setLongTaskReason("人员科室处理异常");
                patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
            }
        }
@@ -1543,58 +1544,59 @@
                        int primaryGeneratedCount = deptGenCount + wardGenCount + diagGenCount;
                        log.info("【基于规则】首要规则执行结果: deptGen={}, wardGen={}, diagGen={}, total={}", deptGenCount, wardGenCount, diagGenCount, primaryGeneratedCount);
                        String remark = patMedInhosp1.getRemark();
                        // 第二步:判断首要规则是否有任意一个生成成功
                        if (primaryGeneratedCount > 0) {
                            // 至少有一个首要规则生成成功
                            // —— 将=2的次要规则对应flag设为"2"(跳过)
                            log.info("【基于规则】首要规则有成功(count={}),将次要规则对应flag设为2", primaryGeneratedCount);
                            if (deptIsSecondary) {
                                updateCheckFlag(patMedInhosp1, 1, "2", "首要规则已生成,次要规则跳过");
                                updateCheckFlag(patMedInhosp1, 1, "2", StringUtils.isNotEmpty(remark)?remark+";首要规则已生成,次要规则跳过":"首要规则已生成,次要规则跳过");
                            }
                            if (!active.equals("xh")) {
                                if (wardIsSecondary) {
                                    updateCheckFlag(patMedInhosp1, 2, "2", "首要规则已生成,次要规则跳过");
                                    updateCheckFlag(patMedInhosp1, 2, "2", StringUtils.isNotEmpty(remark)?remark+";首要规则已生成,次要规则跳过":"首要规则已生成,次要规则跳过");
                                }
                                if (diagIsSecondary) {
                                    updateCheckFlag(patMedInhosp1, 3, "2", "首要规则已生成,次要规则跳过");
                                    updateCheckFlag(patMedInhosp1, 3, "2", StringUtils.isNotEmpty(remark)?remark+";首要规则已生成,次要规则跳过":"首要规则已生成,次要规则跳过");
                                }
                            }
                            // —— 对于=1且生成成功的,将其对应flag设为"1"
                            if (deptIsPrimary && deptGenCount > 0) {
                                updateCheckFlag(patMedInhosp1, 1, "1", "科室首要规则生成成功");
                                updateCheckFlag(patMedInhosp1, 1, "1", StringUtils.isNotEmpty(remark)?remark+";科室首要规则生成成功":"科室首要规则生成成功");
                            }
                            if (!active.equals("xh")) {
                                if (wardIsPrimary && wardGenCount > 0) {
                                    updateCheckFlag(patMedInhosp1, 2, "1", "病区首要规则生成成功");
                                    updateCheckFlag(patMedInhosp1, 2, "1", StringUtils.isNotEmpty(remark)?remark+";病区首要规则生成成功":"病区首要规则生成成功");
                                }
                                if (diagIsPrimary && diagGenCount > 0) {
                                    updateCheckFlag(patMedInhosp1, 3, "1", "疾病首要规则生成成功");
                                    updateCheckFlag(patMedInhosp1, 3, "1", StringUtils.isNotEmpty(remark)?remark+";疾病首要规则生成成功":"疾病首要规则生成成功");
                                }
                            }
                            // —— 对于=1但生成失败的,将其对应flag设为"2"
                            if (deptIsPrimary && deptGenCount == 0) {
                                updateCheckFlag(patMedInhosp1, 1, "2", "科室首要规则生成失败");
                                updateCheckFlag(patMedInhosp1, 1, "2", StringUtils.isNotEmpty(remark)?remark+";科室首要规则生成失败":"科室首要规则生成失败");
                            }
                            if (!active.equals("xh")) {
                                if (wardIsPrimary && wardGenCount == 0) {
                                    updateCheckFlag(patMedInhosp1, 2, "2", "病区首要规则生成失败");
                                    updateCheckFlag(patMedInhosp1, 2, "2", StringUtils.isNotEmpty(remark)?remark+";病区首要规则生成失败":"病区首要规则生成失败");
                                }
                                if (diagIsPrimary && diagGenCount == 0) {
                                    updateCheckFlag(patMedInhosp1, 3, "2", "疾病首要规则生成失败");
                                    updateCheckFlag(patMedInhosp1, 3, "2", StringUtils.isNotEmpty(remark)?remark+";疾病首要规则生成失败":"疾病首要规则生成失败");
                                }
                            }
                        } else {
                            // 所有首要规则全部失败,将=1的flag设为"2",然后执行=2的方法
                            log.info("【基于规则】首要规则全部失败,将=1的flag设为2,开始执行次要规则");
                            if (deptIsPrimary) {
                                updateCheckFlag(patMedInhosp1, 1, "2", "科室首要规则全部失败");
                                updateCheckFlag(patMedInhosp1, 1, "2", StringUtils.isNotEmpty(remark)?remark+";科室首要规则全部失败":"科室首要规则全部失败");
                            }
                            if (!active.equals("xh")) {
                                if (wardIsPrimary) {
                                    updateCheckFlag(patMedInhosp1, 2, "2", "病区首要规则全部失败");
                                    updateCheckFlag(patMedInhosp1, 2, "2", StringUtils.isNotEmpty(remark)?remark+";病区首要规则全部失败":"病区首要规则全部失败");
                                }
                                if (diagIsPrimary) {
                                    updateCheckFlag(patMedInhosp1, 3, "2", "疾病首要规则全部失败");
                                    updateCheckFlag(patMedInhosp1, 3, "2", StringUtils.isNotEmpty(remark)?remark+";疾病首要规则全部失败":"疾病首要规则全部失败");
                                }
                            }
                            // 执行次要规则(=2)的方法
@@ -1629,7 +1631,7 @@
                e.printStackTrace();
                log.error("【基于规则】患者{}处理异常:{}", patMedInhosp1.getInhospid(), e.getMessage());
                patMedInhosp1.setDeptcheckFlag("2");
                patMedInhosp1.setLongTaskReason("基于规则处理异常:" + e.getMessage());
                patMedInhosp1.setLongTaskReason("基于规则处理异常");
                patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
            }
        }
@@ -1655,6 +1657,8 @@
            if (CollectionUtils.isEmpty(serviceTaskdepts)) {
                PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid());
                patMedInhosp1.setDeptcheckFlag("2");
                patMedInhosp1.setWardcheckFlag(patMedInhosp.getWardcheckFlag());
                patMedInhosp1.setDiagcheckFlag(patMedInhosp.getDiagcheckFlag());
                patMedInhosp1.setLongTaskReason(patMedInhosp.getLongTaskReason() + "该患者所在科室未配置离院长期任务;");
                patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
            } else {
@@ -1667,7 +1671,7 @@
            e.printStackTrace();
            log.error("【科室任务】患者{}处理异常:{}", patMedInhosp1.getInhospid(), e.getMessage());
            patMedInhosp1.setDeptcheckFlag("2");
            patMedInhosp1.setLongTaskReason("科室任务处理异常:" + e.getMessage());
            patMedInhosp1.setLongTaskReason("科室任务处理异常");
            patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
        }
        return generatedCount;
@@ -1715,7 +1719,7 @@
            e.printStackTrace();
            log.error("【病区任务】患者{}处理异常:{}", patMedInhosp1.getInhospid(), e.getMessage());
            patMedInhosp1.setWardcheckFlag("2");
            patMedInhosp1.setLongTaskReason("病区任务处理异常:" + e.getMessage());
            patMedInhosp1.setLongTaskReason("病区任务处理异常");
            patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
        }
        return generatedCount;
@@ -1781,7 +1785,7 @@
            e.printStackTrace();
            log.error("【疾病任务】患者{}处理异常:{}", patMedInhosp1.getInhospid(), e.getMessage());
            patMedInhosp1.setDiagcheckFlag("2");
            patMedInhosp1.setLongTaskReason("疾病任务处理异常:" + e.getMessage());
            patMedInhosp1.setLongTaskReason("疾病任务处理异常");
            patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
        }
        return generatedCount;