| | |
| | | private PatMedOperationMapper patMedOperationMapper; |
| | | @Autowired |
| | | private PatMedOperationItemMapper patMedOperationItemMapper; |
| | | @Autowired |
| | | private ServiceTaskRuleMapper serviceTaskRuleMapper; |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String active; |
| | |
| | | } |
| | | } |
| | | |
| | | //2.出院随访 |
| | | String generationRule = iSysConfigService.selectConfigByKey("multitask.generation.rule"); |
| | | //generationRule 0:所有服务都生成; 1:专病任务优先 |
| | | if ("0".equals(generationRule)) { |
| | | //科室任务新增 |
| | | addDeptSubTask(config, generationRule); |
| | | //根据患者所在病区,获取该病区的长期任务,新华医院可以先不用根据病区和疾病来做 |
| | | if (!active.equals("xh")) { |
| | | addWardSubTask(config, generationRule); |
| | | addIcd10SubTask(config, generationRule); |
| | | addOperationSubTask(config, generationRule); |
| | | } |
| | | //2.出院随访 - 基于规则的任务生成 |
| | | addSubTaskByRule(config); |
| | | //根据患者所在病区,获取该病区的长期任务,新华医院可以先不用根据病区和疾病来做 |
| | | if (!active.equals("xh")) { |
| | | addOperationSubTask(config); |
| | | } |
| | | |
| | | //丽水的特殊要求(需要先执行疾病,如果疾病为空,则执行科室和病区) |
| | | if ("1".equals(generationRule)) { |
| | | addIcd10SubTask(config, generationRule); |
| | | //科室任务新增 |
| | | addDeptSubTask(config, generationRule); |
| | | addWardSubTask(config, generationRule); |
| | | } |
| | | |
| | | //获取未处理在院的数据(如果刚刚出院的患者数据的出院时间,在下面查询出的入院时间之前,那之前的出院患者的数据,也得停掉,因为又入院了) |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void addOperationSubTask(String config, String generationRule) { |
| | | private void addOperationSubTask(String config) { |
| | | // 手术随访 |
| | | PatMedOperationItem pmoi = new PatMedOperationItem(); |
| | | //获取需要出院疾病随访,未处理的数据 |
| | |
| | | } |
| | | } |
| | | |
| | | private void addIcd10SubTask(String config, String generationRule) { |
| | | private void addIcd10SubTask(String config) { |
| | | PatMedInhosp pmjb = new PatMedInhosp(); |
| | | //获取需要出院疾病随访,未处理的数据 |
| | | pmjb.setDiagcheckFlag("0"); |
| | |
| | | } |
| | | } |
| | | |
| | | private void addWardSubTask(String config, String generationRule) { |
| | | private void addWardSubTask(String config) { |
| | | PatMedInhosp pmbq = new PatMedInhosp(); |
| | | //获取需要出院部门随访,未处理的数据 |
| | | pmbq.setWardcheckFlag("0"); |
| | |
| | | } |
| | | } |
| | | |
| | | private void addDeptSubTask(String config, String generationRule) { |
| | | private void addDeptSubTask(String config) { |
| | | //获取需要出院部门随访,未处理的数据 |
| | | PatMedInhosp pmks = new PatMedInhosp(); |
| | | pmks.setDeptcheckFlag("0"); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 基于规则的任务生成方法 |
| | | * 根据患者离院科室或病区查询service_task_rule,获取deptRule、wradRule、diagRule |
| | | * 根据规则值决定调用哪个方法生成随访任务 |
| | | */ |
| | | private void addSubTaskByRule(String config) { |
| | | // 获取所有需要处理的出院患者(科室维度未处理) |
| | | PatMedInhosp pmks = new PatMedInhosp(); |
| | | pmks.setDeptcheckFlag("0"); |
| | | pmks.setInhospstate("1"); |
| | | pmks.setFuflag("1"); |
| | | List<PatMedInhosp> patMedInhosps = patMedInhospMapper.selectPatMedInhospList(pmks); |
| | | log.info("【基于规则】需要处理的出院患者信息:{}", CollectionUtils.isNotEmpty(patMedInhosps) ? patMedInhosps.size() : null); |
| | | |
| | | for (PatMedInhosp patMedInhosp1 : patMedInhosps) { |
| | | // 获取患者基本信息 |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedInhosp1.getPatid()); |
| | | if (Objects.isNull(patArchive)) { |
| | | patMedInhosp1.setDeptcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("患者基本信息为空"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | continue; |
| | | } |
| | | |
| | | try { |
| | | // 查询规则:根据离院科室或病区 |
| | | ServiceTaskRule ruleQuery = new ServiceTaskRule(); |
| | | ruleQuery.setDeptcode(patMedInhosp1.getLeaveldeptcode()); |
| | | ruleQuery.setWardcode(patMedInhosp1.getLeavehospitaldistrictcode()); |
| | | ServiceTaskRule rule = serviceTaskRuleMapper.selectServiceTaskRuleByDeptOrWard(ruleQuery); |
| | | |
| | | if (rule == null) { |
| | | // 规则为空,全部生成 |
| | | log.info("【基于规则】患者{}未配置规则,执行全部生成逻辑", patMedInhosp1.getInhospid()); |
| | | addDeptSubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | if (!active.equals("xh")) { |
| | | addWardSubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | addIcd10SubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | } |
| | | } else { |
| | | // 有规则,按规则执行 |
| | | 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()); |
| | | |
| | | if (hasPrimaryRule) { |
| | | // 有首要规则,只执行首要规则对应的方法 |
| | | int generatedCount = 0; |
| | | |
| | | // 按顺序:科室 -> 病区 -> 疾病 |
| | | if ("1".equals(rule.getDeptRule())) { |
| | | log.info("【基于规则】执行科室首要规则"); |
| | | generatedCount += addDeptSubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | } |
| | | |
| | | if (!active.equals("xh")) { |
| | | if ("1".equals(rule.getWradRule())) { |
| | | log.info("【基于规则】执行病区首要规则"); |
| | | generatedCount += addWardSubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | } |
| | | |
| | | if ("1".equals(rule.getDiagRule())) { |
| | | log.info("【基于规则】执行疾病首要规则"); |
| | | generatedCount += addIcd10SubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | } |
| | | } |
| | | |
| | | // 如果首要规则生成的子任务为空,则调用其他次要规则的方法 |
| | | if (generatedCount == 0) { |
| | | log.info("【基于规则】首要规则未生成子任务,开始执行次要规则"); |
| | | |
| | | if (!"1".equals(rule.getDeptRule()) && StringUtils.isNotEmpty(rule.getDeptRule())) { |
| | | log.info("【基于规则】执行科室次要规则"); |
| | | addDeptSubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | } |
| | | |
| | | if (!active.equals("xh")) { |
| | | if (!"1".equals(rule.getWradRule()) && StringUtils.isNotEmpty(rule.getWradRule())) { |
| | | log.info("【基于规则】执行病区次要规则"); |
| | | addWardSubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | } |
| | | |
| | | if (!"1".equals(rule.getDiagRule()) && StringUtils.isNotEmpty(rule.getDiagRule())) { |
| | | log.info("【基于规则】执行疾病次要规则"); |
| | | addIcd10SubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | // 没有首要规则(都是"2"或其他),全部生成 |
| | | log.info("【基于规则】无首要规则,执行全部生成逻辑"); |
| | | addDeptSubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | if (!active.equals("xh")) { |
| | | addWardSubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | addIcd10SubTaskForPatient(patMedInhosp1, patArchive, config); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("【基于规则】患者{}处理异常:{}", patMedInhosp1.getInhospid(), e.getMessage()); |
| | | patMedInhosp1.setDeptcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("基于规则处理异常:" + e.getMessage()); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 为单个患者生成科室维度的子任务 |
| | | * |
| | | * @return 生成的子任务数量 |
| | | */ |
| | | private int addDeptSubTaskForPatient(PatMedInhosp patMedInhosp1, PatArchive patArchive, String config) { |
| | | int generatedCount = 0; |
| | | try { |
| | | //根据患者所在科室,获取该科室的长期任务 |
| | | ServiceTaskdept serviceTaskdept = new ServiceTaskdept(); |
| | | serviceTaskdept.setLongtask(1L); |
| | | serviceTaskdept.setDeptCode(patMedInhosp1.getLeaveldeptcode()); |
| | | serviceTaskdept.setDeptType("1"); |
| | | serviceTaskdept.setServiceType("2"); |
| | | serviceTaskdept.setOrgid(patMedInhosp1.getOrgid()); |
| | | List<ServiceTaskdept> serviceTaskdepts = serviceTaskdeptMapper.selectServiceTaskdeptList(serviceTaskdept); |
| | | |
| | | if (CollectionUtils.isEmpty(serviceTaskdepts)) { |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid()); |
| | | patMedInhosp1.setDeptcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason(patMedInhosp.getLongTaskReason() + "该患者所在科室未配置离院长期任务;"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } else { |
| | | for (ServiceTaskdept serviceTaskdept1 : serviceTaskdepts) { |
| | | writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedInhosp1, patArchive, 1, config); |
| | | generatedCount++; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("【科室任务】患者{}处理异常:{}", patMedInhosp1.getInhospid(), e.getMessage()); |
| | | patMedInhosp1.setDeptcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("科室任务处理异常:" + e.getMessage()); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } |
| | | return generatedCount; |
| | | } |
| | | |
| | | /** |
| | | * 为单个患者生成病区维度的子任务 |
| | | * |
| | | * @return 生成的子任务数量 |
| | | */ |
| | | private int addWardSubTaskForPatient(PatMedInhosp patMedInhosp1, PatArchive patArchive, String config) { |
| | | int generatedCount = 0; |
| | | try { |
| | | String errorreason = null; |
| | | List<ServiceTaskdept> serviceTaskdeptList = null; |
| | | if (!StringUtils.isEmpty(patMedInhosp1.getLeavehospitaldistrictcode())) { |
| | | ServiceTaskdept serviceTaskdept = new ServiceTaskdept(); |
| | | serviceTaskdept.setLongtask(1L); |
| | | serviceTaskdept.setDeptCode(patMedInhosp1.getLeavehospitaldistrictcode()); |
| | | serviceTaskdept.setDeptType("2"); |
| | | serviceTaskdept.setServiceType("2"); |
| | | serviceTaskdept.setOrgid(patMedInhosp1.getOrgid()); |
| | | serviceTaskdeptList = serviceTaskdeptMapper.selectServiceTaskdeptList(serviceTaskdept); |
| | | if (CollectionUtils.isEmpty(serviceTaskdeptList)) { |
| | | errorreason = "该患者所在病区未配置长期任务;"; |
| | | } |
| | | } else { |
| | | errorreason = "离院病区为空;"; |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(errorreason)) { |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid()); |
| | | patMedInhosp1.setWardcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason(StringUtils.isNotEmpty(patMedInhosp.getLongTaskReason()) ? patMedInhosp.getLongTaskReason() + errorreason : errorreason); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } else { |
| | | for (ServiceTaskdept serviceTaskdept1 : serviceTaskdeptList) { |
| | | writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedInhosp1, patArchive, 2, config); |
| | | generatedCount++; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("【病区任务】患者{}处理异常:{}", patMedInhosp1.getInhospid(), e.getMessage()); |
| | | patMedInhosp1.setWardcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("病区任务处理异常:" + e.getMessage()); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } |
| | | return generatedCount; |
| | | } |
| | | |
| | | /** |
| | | * 为单个患者生成疾病维度的子任务 |
| | | * |
| | | * @return 生成的子任务数量 |
| | | */ |
| | | private int addIcd10SubTaskForPatient(PatMedInhosp patMedInhosp1, PatArchive patArchive, String config) { |
| | | int generatedCount = 0; |
| | | try { |
| | | if (StringUtils.isEmpty(patMedInhosp1.getLeaveicd10code())) { |
| | | return 0; |
| | | } |
| | | |
| | | ServiceTaskdiag serviceTaskdiag = new ServiceTaskdiag(); |
| | | serviceTaskdiag.setLongtask(1L); |
| | | serviceTaskdiag.setServiceType("2"); |
| | | if (active.equals("nhfy")) { |
| | | serviceTaskdiag.setIcd10name(patMedInhosp1.getLeavediagname()); |
| | | if (StringUtils.isEmpty(patMedInhosp1.getLeavediagname())) { |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid()); |
| | | patMedInhosp1.setDiagcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("该患者主诊断名称为空;"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | return 0; |
| | | } |
| | | } else { |
| | | serviceTaskdiag.setIcd10code(patMedInhosp1.getLeaveicd10code()); |
| | | } |
| | | serviceTaskdiag.setOrgid(patMedInhosp1.getOrgid()); |
| | | List<ServiceTaskdiag> serviceTaskdiags = serviceTaskdiagMapper.selectServiceTaskdiagListByIcdName(serviceTaskdiag); |
| | | |
| | | if (CollectionUtils.isEmpty(serviceTaskdiags)) { |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid()); |
| | | patMedInhosp1.setDiagcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("该患者所患疾病未配置长期任务;"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } else { |
| | | int flag = 0; |
| | | for (ServiceTaskdiag serviceTaskdiag1 : serviceTaskdiags) { |
| | | if (StringUtils.isNotEmpty(serviceTaskdiag1.getDeptCode()) && serviceTaskdiag1.getDeptCode().equals(patMedInhosp1.getLeaveldeptcode())) { |
| | | writeInSubTask(serviceTaskdiag1.getTaskId(), true, patMedInhosp1, patArchive, 3, config); |
| | | generatedCount++; |
| | | flag = 1; |
| | | } else if (StringUtils.isNotEmpty(serviceTaskdiag1.getWardCode()) && serviceTaskdiag1.getWardCode().equals(patMedInhosp1.getLeavehospitaldistrictcode())) { |
| | | writeInSubTask(serviceTaskdiag1.getTaskId(), true, patMedInhosp1, patArchive, 3, config); |
| | | generatedCount++; |
| | | flag = 1; |
| | | } |
| | | } |
| | | if (flag == 0) { |
| | | log.error("该科室或病区对于患者所患疾病未配置长期任务,患者:{}", patMedInhosp1.getInhospid()); |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid()); |
| | | patMedInhosp1.setDiagcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("该科室或病区对于患者所患疾病未配置长期任务;"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("【疾病任务】患者{}处理异常:{}", patMedInhosp1.getInhospid(), e.getMessage()); |
| | | patMedInhosp1.setDiagcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("疾病任务处理异常:" + e.getMessage()); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } |
| | | return generatedCount; |
| | | } |
| | | |
| | | |
| | | } |