| | |
| | | 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()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 统一更新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 |
| | | * 根据规则值决定调用哪个方法生成随访任务 |
| | |
| | | // 有规则,按规则执行 |
| | | 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); |
| | | } |
| | |
| | | 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 { |
| | |
| | | |
| | | 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) { |
| | |
| | | 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) { |