| | |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 多维度随访 |
| | | * @param config |
| | | * @return |
| | | */ |
| | | public int dealOutHospInfoByDimension(String config) { |
| | | // 一次性查出所有需要处理的出院患者(三个维度任意一个未完成) |
| | | List<PatMedInhosp> patList = patMedInhospMapper.selectNeedProcessList(); |
| | | log.info("【统一扫描】待处理患者数:{}", patList.size()); |
| | | |
| | | for (PatMedInhosp patMedInhosp1 : patList) { |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedInhosp1.getPatid()); |
| | | if (Objects.isNull(patArchive)) { |
| | | // 三个维度都标记为失败 |
| | | markAllFlagsAsError(patMedInhosp1, "患者基本信息为空"); |
| | | continue; |
| | | } |
| | | |
| | | // ── 维度1:科室 ── |
| | | if ("0".equals(patMedInhosp1.getDeptcheckFlag())) { |
| | | processTasksByDimension(patMedInhosp1, patArchive, config, 1); |
| | | } |
| | | |
| | | // ── 维度2:病区 ──(新华医院跳过) |
| | | if (!active.equals("xh") && "0".equals(patMedInhosp1.getWardcheckFlag())) { |
| | | processTasksByDimension(patMedInhosp1, patArchive, config, 2); |
| | | } |
| | | |
| | | // ── 维度3:疾病 ──(新华医院跳过) |
| | | if (!active.equals("xh") && "0".equals(patMedInhosp1.getDiagcheckFlag())) { |
| | | processTasksByDimension(patMedInhosp1, patArchive, config, 3); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 按维度找到所有匹配长期任务,批量生成 subtask |
| | | * type: 1=科室, 2=病区, 3=疾病 |
| | | */ |
| | | private void processTasksByDimension(PatMedInhosp patMedInhosp1, |
| | | PatArchive patArchive, |
| | | String config, int type) { |
| | | List<Long> matchedTaskIds = findMatchingTaskIds(patMedInhosp1, type); |
| | | |
| | | if (CollectionUtils.isEmpty(matchedTaskIds)) { |
| | | String reason = getDimensionReason(type); |
| | | markFlagAsNoConfig(patMedInhosp1, type, reason); |
| | | return; |
| | | } |
| | | |
| | | // 一条 inhosp 记录 → 多个匹配任务 → 多条 subtask |
| | | for (Long taskId : matchedTaskIds) { |
| | | writeInSubTask(taskId, true, patMedInhosp1, patArchive, type, config); |
| | | } |
| | | } |
| | | |
| | | private String getDimensionReason(int type){ |
| | | switch (type) { |
| | | case 1: { // 科室 |
| | | return "未找到科室匹配的长期任务"; |
| | | } |
| | | case 2: { // 病区 |
| | | return "未找到病区匹配的长期任务"; |
| | | } |
| | | case 3: { // 疾病 |
| | | return "未找到疾病匹配的长期任务"; |
| | | } |
| | | } |
| | | return "多维长期任务-匹配类型为空"; |
| | | } |
| | | |
| | | private void markFlagAsNoConfig(PatMedInhosp patMedInhosp, |
| | | int type, |
| | | String reason){ |
| | | switch (type) { |
| | | case 1: { // 科室 |
| | | patMedInhosp.setDeptcheckFlag("2"); |
| | | patMedInhosp.setRemark(reason); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp); |
| | | break; |
| | | } |
| | | case 2: { // 病区 |
| | | patMedInhosp.setWardcheckFlag("2"); |
| | | patMedInhosp.setRemark(reason); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp); |
| | | break; |
| | | } |
| | | case 3: { // 疾病 |
| | | patMedInhosp.setDiagcheckFlag("2"); |
| | | patMedInhosp.setRemark(reason); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void markAllFlagsAsError(PatMedInhosp patMedInhosp, |
| | | String reason){ |
| | | patMedInhosp.setDeptcheckFlag("2"); |
| | | patMedInhosp.setWardcheckFlag("2"); |
| | | patMedInhosp.setDiagcheckFlag("2"); |
| | | patMedInhosp.setRemark(reason); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp); |
| | | } |
| | | /** |
| | | * 根据维度类型查询匹配的长期任务 ID 列表 |
| | | */ |
| | | private List<Long> findMatchingTaskIds(PatMedInhosp patMedInhosp1, int type) { |
| | | switch (type) { |
| | | case 1: { // 科室 |
| | | ServiceTaskdept query = new ServiceTaskdept(); |
| | | query.setLongtask(1L); |
| | | query.setDeptCode(patMedInhosp1.getLeaveldeptcode()); |
| | | query.setDeptType("1"); |
| | | query.setOrgid(patMedInhosp1.getOrgid()); |
| | | return serviceTaskdeptMapper.selectServiceTaskdeptList(query) |
| | | .stream().map(ServiceTaskdept::getTaskId).collect(Collectors.toList()); |
| | | } |
| | | case 2: { // 病区 |
| | | ServiceTaskdept query = new ServiceTaskdept(); |
| | | query.setLongtask(1L); |
| | | query.setDeptCode(patMedInhosp1.getLeavehospitaldistrictcode()); |
| | | query.setDeptType("2"); |
| | | query.setOrgid(patMedInhosp1.getOrgid()); |
| | | return serviceTaskdeptMapper.selectServiceTaskdeptList(query) |
| | | .stream().map(ServiceTaskdept::getTaskId).collect(Collectors.toList()); |
| | | } |
| | | case 3: { // 疾病 |
| | | if (StringUtils.isEmpty(patMedInhosp1.getLeaveicd10code())) return Collections.emptyList(); |
| | | ServiceTaskdiag query = new ServiceTaskdiag(); |
| | | query.setLongtask(1L); |
| | | query.setIcd10code(patMedInhosp1.getLeaveicd10code()); |
| | | query.setOrgid(patMedInhosp1.getOrgid()); |
| | | return serviceTaskdiagMapper.selectServiceTaskdiagList(query) |
| | | .stream().map(ServiceTaskdiag::getTaskId).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | |
| | | // |
| | | // @Override |
| | | // public int dealOutHospInfo() { |