| | |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.service.IConfigService; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IPatMedInhospService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Autowired |
| | | private ServiceTaskdiagMapper serviceTaskdiagMapper; |
| | | @Autowired |
| | | private ServiceTaskoperMapper serviceTaskoperMapper; |
| | | @Autowired |
| | | private PatArchiveMapper patArchiveMapper; |
| | | @Autowired |
| | | private PatArchiveImportMapper patArchiveImportMapper; |
| | |
| | | private ServiceSubtaskMapper serviceSubtaskMapper; |
| | | @Autowired |
| | | private ServiceSubtaskPreachformMapper serviceSubtaskPreachformMapper; |
| | | @Autowired |
| | | private PatMedOperationMapper patMedOperationMapper; |
| | | @Autowired |
| | | private PatMedOperationItemMapper patMedOperationItemMapper; |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String active; |
| | | @Autowired |
| | | private IConfigService iSysConfigService; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public List<PatMedInhosp> selectPatMedInhospList(PatMedInhosp patMedInhosp) { |
| | | if (patMedInhosp.getCry() == 0) { |
| | | patMedInhosp.setDeptcodeList(patMedInhosp.getLeaveldeptcodes()); |
| | | patMedInhosp.setHospitaldistrictcodeList(patMedInhosp.getLeavehospitaldistrictcodes()); |
| | | patMedInhosp.setLeaveldeptcodes(null); |
| | | patMedInhosp.setLeavehospitaldistrictcodes(null); |
| | | patMedInhosp.setInhospstate("0"); |
| | | } else if (patMedInhosp.getCry() == 1) { |
| | | patMedInhosp.setInhospstate("1"); |
| | | } |
| | | |
| | | List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp); |
| | | for (PatMedInhosp patMedInhosp1 : patMedInhospList) { |
| | | String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid()); |
| | |
| | | public PatMedRes selectPatMedInhospListCount(PatMedReq patMedReq) { |
| | | PatMedRes patMedRes = null; |
| | | // 获取当前登陆人的部门权限 |
| | | if (org.springframework.util.CollectionUtils.isEmpty(patMedReq.getDeptcodeList())) { |
| | | // Long userId = SecurityUtils.getUserId(); |
| | | // List<SysDept> sysDepts = sysUserDeptMapper.selectDeptListByUserId(userId); |
| | | // List<String> deptCode = new ArrayList<>(); |
| | | // for (SysDept sysDept : sysDepts) { |
| | | // deptCode.add(sysDept.getDeptId().toString()); |
| | | // } |
| | | // patMedReq.setDeptcodeList(deptCode); |
| | | // patMedRes = patMedInhospMapper.selectPatMedInhospCount(patMedReq); |
| | | } |
| | | patMedRes = patMedInhospMapper.selectPatMedInhospCount(patMedReq); |
| | | return patMedRes; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public int dealOutHospInfo(String config) { |
| | | //1.入院宣教 |
| | | String helibrarySwitch = iSysConfigService.selectConfigByKey("in.helibrary.switch"); |
| | | if (StringUtils.isNotEmpty(helibrarySwitch) && "2".equals(helibrarySwitch)) { |
| | | PatMedInhosp inhosp = new PatMedInhosp(); |
| | | inhosp.setInDeptcheckFlag("0"); |
| | | inhosp.setInhospstate("0"); |
| | | inhosp.setFuflag("1"); |
| | | List<PatMedInhosp> inPatMedInhosps = patMedInhospMapper.selectPatMedInhospList(inhosp); |
| | | |
| | | //1.1 科室 |
| | | for (PatMedInhosp patMedInhosp1 : inPatMedInhosps) { |
| | | //获取患者信息 |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedInhosp1.getPatid()); |
| | | if (Objects.isNull(patArchive)) { |
| | | patMedInhosp1.setInDeptcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("患者基本信息为空"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | continue; |
| | | } |
| | | try { |
| | | //根据患者所在科室,获取该科室的入院长期宣教任务 |
| | | ServiceTaskdept serviceTaskdept = new ServiceTaskdept(); |
| | | serviceTaskdept.setLongtask(1L); |
| | | serviceTaskdept.setDeptCode(patMedInhosp1.getDeptcode()); |
| | | serviceTaskdept.setDeptType("1"); |
| | | serviceTaskdept.setServiceType("17"); |
| | | serviceTaskdept.setOrgid(patMedInhosp1.getOrgid()); |
| | | List<ServiceTaskdept> serviceTaskdepts = serviceTaskdeptMapper.selectServiceTaskdeptList(serviceTaskdept); |
| | | //如果部门模板为空(将deptIsNull设置为true) |
| | | if (CollectionUtils.isEmpty(serviceTaskdepts) || serviceTaskdepts.size() == 0) { |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid()); |
| | | patMedInhosp1.setInDeptcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason(StringUtils.isNotEmpty(patMedInhosp.getLongTaskReason()) ? patMedInhosp.getLongTaskReason() + "该患者所在科室未配置入院长期宣教任务;" : "该患者所在科室未配置入院长期宣教任务;"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } else { |
| | | for (ServiceTaskdept serviceTaskdept1 : serviceTaskdepts) { |
| | | writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedInhosp1, patArchive, 4, config); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("人员入院科室处理出异常了:{}", e.getMessage()); |
| | | patMedInhosp1.setInDeptcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("人员入院科室处理出异常了:" + e.getMessage()); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } |
| | | } |
| | | |
| | | |
| | | //1.2 病区 |
| | | inhosp.setInDeptcheckFlag(null); |
| | | inhosp.setInWardcheckFlag("0"); |
| | | List<PatMedInhosp> inPatMedInhospsWard = patMedInhospMapper.selectPatMedInhospList(inhosp); |
| | | for (PatMedInhosp patMedInhosp1 : inPatMedInhospsWard) { |
| | | //获取患者信息 |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedInhosp1.getPatid()); |
| | | if (Objects.isNull(patArchive)) { |
| | | patMedInhosp1.setInDeptcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason("患者基本信息为空"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | continue; |
| | | } |
| | | //根据患者所在病区,获取该病区的入院长期宣教任务(会出现一个问题,科室和病区发的同一个模板) |
| | | ServiceTaskdept serviceTaskWard = new ServiceTaskdept(); |
| | | serviceTaskWard.setLongtask(1L); |
| | | serviceTaskWard.setDeptCode(patMedInhosp1.getHospitaldistrictcode()); |
| | | serviceTaskWard.setDeptType("2"); |
| | | serviceTaskWard.setServiceType("17"); |
| | | serviceTaskWard.setOrgid(patMedInhosp1.getOrgid()); |
| | | List<ServiceTaskdept> serviceTaskWardList = serviceTaskdeptMapper.selectServiceTaskdeptList(serviceTaskWard); |
| | | //如果部门模板为空(将deptIsNull设置为true) |
| | | if (CollectionUtils.isEmpty(serviceTaskWardList) || serviceTaskWardList.size() == 0) { |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid()); |
| | | patMedInhosp1.setInDeptcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason(patMedInhosp.getLongTaskReason() + "该患者所在病区未配置入院长期宣教任务;"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } else { |
| | | for (ServiceTaskdept serviceTaskdept1 : serviceTaskWardList) { |
| | | writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedInhosp1, patArchive, 5, config); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //2.出院随访 |
| | | PatMedInhosp pmks = new PatMedInhosp(); |
| | | //获取需要出院部门随访,未处理的数据 |
| | | pmks.setDeptcheckFlag("0"); |
| | |
| | | serviceTaskdept.setLongtask(1L); |
| | | serviceTaskdept.setDeptCode(patMedInhosp1.getLeaveldeptcode()); |
| | | serviceTaskdept.setDeptType("1"); |
| | | serviceTaskdept.setServiceType("2"); |
| | | serviceTaskdept.setOrgid(patMedInhosp1.getOrgid()); |
| | | List<ServiceTaskdept> serviceTaskdepts = serviceTaskdeptMapper.selectServiceTaskdeptList(serviceTaskdept); |
| | | //如果部门模板为空(将deptIsNull设置为true) |
| | | if (CollectionUtils.isEmpty(serviceTaskdepts) || serviceTaskdepts.size() == 0) { |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(patMedInhosp1.getInhospid()); |
| | | patMedInhosp1.setDeptcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason(patMedInhosp.getLongTaskReason() + "该患者所在科室未配置长期任务;"); |
| | | patMedInhosp1.setLongTaskReason(patMedInhosp.getLongTaskReason() + "该患者所在科室未配置离院长期任务;"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } else { |
| | | for (ServiceTaskdept serviceTaskdept1 : serviceTaskdepts) { |
| | | writeInSubTask(serviceTaskdept1.getTaskId(), true, patMedInhosp1, patArchive, 1, config); |
| | | } |
| | | patMedInhosp1.setDeptcheckFlag("1"); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | // patMedInhosp1.setDeptcheckFlag("1"); |
| | | // patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | |
| | | continue; |
| | | } |
| | | try { |
| | | ServiceTaskdept serviceTaskdept = new ServiceTaskdept(); |
| | | serviceTaskdept.setLongtask(1L); |
| | | serviceTaskdept.setDeptCode(pmiBQ1.getLeavehospitaldistrictcode()); |
| | | serviceTaskdept.setDeptType("2"); |
| | | serviceTaskdept.setOrgid(pmiBQ1.getOrgid()); |
| | | List<ServiceTaskdept> serviceTaskdeptList = serviceTaskdeptMapper.selectServiceTaskdeptList(serviceTaskdept); |
| | | String errorreason = null; |
| | | List<ServiceTaskdept> serviceTaskdeptList = null; |
| | | if (!StringUtils.isEmpty(pmiBQ1.getLeavehospitaldistrictcode())) { |
| | | ServiceTaskdept serviceTaskdept = new ServiceTaskdept(); |
| | | serviceTaskdept.setLongtask(1L); |
| | | serviceTaskdept.setDeptCode(pmiBQ1.getLeavehospitaldistrictcode()); |
| | | serviceTaskdept.setDeptType("2"); |
| | | serviceTaskdept.setServiceType("2"); |
| | | serviceTaskdept.setOrgid(pmiBQ1.getOrgid()); |
| | | serviceTaskdeptList = serviceTaskdeptMapper.selectServiceTaskdeptList(serviceTaskdept); |
| | | if (CollectionUtils.isEmpty(serviceTaskdeptList)) { |
| | | errorreason = "该患者所在病区未配置长期任务;"; |
| | | } |
| | | } else { |
| | | errorreason = "离院病区为空;"; |
| | | } |
| | | //如果部门模板为空(将deptIsNull设置为true) |
| | | if (CollectionUtils.isEmpty(serviceTaskdeptList) || serviceTaskdeptList.size() == 0) { |
| | | if (StringUtils.isNotEmpty(errorreason)) { |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(pmiBQ1.getInhospid()); |
| | | pmiBQ1.setWardcheckFlag("2"); |
| | | pmiBQ1.setLongTaskReason(patMedInhosp.getLongTaskReason() + "该患者所在病区未配置长期任务;"); |
| | | pmiBQ1.setLongTaskReason(StringUtils.isNotEmpty(patMedInhosp.getLongTaskReason()) ? patMedInhosp.getLongTaskReason() + errorreason : errorreason); |
| | | patMedInhospMapper.updatePatMedInhosp(pmiBQ1); |
| | | } else { |
| | | for (ServiceTaskdept serviceTaskdept1 : serviceTaskdeptList) { |
| | | writeInSubTask(serviceTaskdept1.getTaskId(), true, pmiBQ1, patArchive, 2, config); |
| | | } |
| | | pmiBQ1.setWardcheckFlag("1"); |
| | | patMedInhospMapper.updatePatMedInhosp(pmiBQ1); |
| | | // pmiBQ1.setWardcheckFlag("1"); |
| | | // patMedInhospMapper.updatePatMedInhosp(pmiBQ1); |
| | | } |
| | | |
| | | |
| | |
| | | continue; |
| | | } |
| | | try { |
| | | String errorIcd = null; |
| | | if (StringUtils.isEmpty(pmiJB.getLeaveicd10code())) { |
| | | continue; |
| | | } |
| | | // 根据患者的疾病,获取该疾病的长期任务 |
| | | ServiceTaskdiag serviceTaskdiag = new ServiceTaskdiag(); |
| | | serviceTaskdiag.setLongtask(1L); |
| | | serviceTaskdiag.setIcd10code(pmiJB.getLeaveicd10code()); |
| | | serviceTaskdiag.setServiceType("2"); |
| | | if (active.equals("nhfy")) { |
| | | //南华附一的icd10code有重复,所以用主诊断名称去查询 |
| | | serviceTaskdiag.setIcd10name(pmiJB.getLeavediagname()); |
| | | if (StringUtils.isEmpty(pmiJB.getLeavediagname())) { |
| | | errorIcd = "该患者主诊断名称为空;"; |
| | | } |
| | | } else { |
| | | serviceTaskdiag.setIcd10code(pmiJB.getLeaveicd10code()); |
| | | if (StringUtils.isEmpty(pmiJB.getLeaveicd10code())) { |
| | | errorIcd = "该患者主诊断ICD10码为空;"; |
| | | } |
| | | } |
| | | serviceTaskdiag.setOrgid(pmiJB.getOrgid()); |
| | | |
| | | List<ServiceTaskdiag> serviceTaskdiags = serviceTaskdiagMapper.selectServiceTaskdiagList(serviceTaskdiag); |
| | | |
| | | //如果部门模板为空(将deptIsNull设置为true) |
| | | if (CollectionUtils.isEmpty(serviceTaskdiags) || serviceTaskdiags.size() == 0) { |
| | | if (StringUtils.isNotEmpty(errorIcd)) { |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(pmiJB.getInhospid()); |
| | | pmiJB.setDiagcheckFlag("2"); |
| | | pmiJB.setLongTaskReason(patMedInhosp.getLongTaskReason() + "所患的疾病未配置长期任务;"); |
| | | pmiJB.setLongTaskReason(StringUtils.isNotEmpty(patMedInhosp.getLongTaskReason()) ? patMedInhosp.getLongTaskReason() + errorIcd : errorIcd); |
| | | patMedInhospMapper.updatePatMedInhosp(pmiJB); |
| | | } else if (CollectionUtils.isEmpty(serviceTaskdiags)) { |
| | | errorIcd = "该患者所在病区未配置长期任务;"; |
| | | PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(pmiJB.getInhospid()); |
| | | pmiJB.setDiagcheckFlag("2"); |
| | | pmiJB.setLongTaskReason(StringUtils.isNotEmpty(patMedInhosp.getLongTaskReason()) ? patMedInhosp.getLongTaskReason() + errorIcd : errorIcd); |
| | | patMedInhospMapper.updatePatMedInhosp(pmiJB); |
| | | } else { |
| | | for (ServiceTaskdiag serviceTaskdept1 : serviceTaskdiags) { |
| | | writeInSubTask(serviceTaskdept1.getTaskId(), true, pmiJB, patArchive, 3, config); |
| | | } |
| | | pmiJB.setDiagcheckFlag("1"); |
| | | patMedInhospMapper.updatePatMedInhosp(pmiJB); |
| | | // pmiJB.setDiagcheckFlag("1"); |
| | | // patMedInhospMapper.updatePatMedInhosp(pmiJB); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | |
| | | pmiJB.setDiagcheckFlag("2"); |
| | | pmiJB.setLongTaskReason("人员疾病处理异常:" + e.getMessage()); |
| | | patMedInhospMapper.updatePatMedInhosp(pmiJB); |
| | | } |
| | | } |
| | | // 手术随访 |
| | | // PatMedInhosp pmss = new PatMedInhosp(); |
| | | // //获取需要出院疾病随访,未处理的数据 |
| | | // pmss.setOpercheckFlag("0"); |
| | | // pmss.setInhospstate("1"); |
| | | // pmss.setFuflag("1"); |
| | | // List<PatMedInhosp> patMedInhospSSs = patMedInhospMapper.selectPatMedInhospList(pmss); |
| | | // log.info("dealOutHospInfo需要处理的出院疾病患者信息:{}", CollectionUtils.isNotEmpty(patMedInhospSSs) ? patMedInhospSSs.size() : null); |
| | | // for (PatMedInhosp patMedInhosp1 : patMedInhospSSs) { |
| | | // String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid()); |
| | | // patMedInhosp1.setTagname(tagname); |
| | | // } |
| | | // |
| | | // for (PatMedInhosp pmiSS : patMedInhospSSs) { |
| | | // //获取患者信息 |
| | | // PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(pmiSS.getPatid()); |
| | | // if (Objects.isNull(patArchive)) { |
| | | // pmiSS.setDiagcheckFlag("2"); |
| | | // pmiSS.setLongTaskReason("患者基本信息为空"); |
| | | // patMedInhospMapper.updatePatMedInhosp(pmiSS); |
| | | // continue; |
| | | // } |
| | | // try { |
| | | //// if (StringUtils.isEmpty(pmiSS.getLeaveicd10code())) { |
| | | //// continue; |
| | | //// } |
| | | // // 根据患者的疾病,获取该疾病的长期任务 |
| | | // ServiceTaskoper serviceTaskoper = new ServiceTaskoper(); |
| | | // serviceTaskoper.setLongtask(1L); |
| | | // serviceTaskoper.setOrgid(pmiSS.getOrgid()); |
| | | // //todo |
| | | // serviceTaskoper.setOplevelcode(""); |
| | | // |
| | | // List<ServiceTaskoper> serviceTaskopers = serviceTaskoperMapper.selectServiceTaskoperList(serviceTaskoper); |
| | | // //如果部门模板为空(将deptIsNull设置为true) |
| | | // if (CollectionUtils.isEmpty(serviceTaskopers) || serviceTaskopers.size() == 0) { |
| | | // PatMedInhosp patMedInhosp = patMedInhospMapper.selectPatMedInhospByInhospid(pmiSS.getInhospid()); |
| | | // pmiSS.setOpercheckFlag("2"); |
| | | // pmiSS.setLongTaskReason(patMedInhosp.getLongTaskReason() + "所患的手术未配置长期任务;"); |
| | | // patMedInhospMapper.updatePatMedInhosp(pmiSS); |
| | | // } else { |
| | | // for (ServiceTaskoper serviceTaskoper1 : serviceTaskopers) { |
| | | // writeInSubTask(serviceTaskoper1.getTaskId(), true, pmiSS, patArchive, 3, config); |
| | | // } |
| | | // } |
| | | // |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // log.error("人员手术处理出异常了:{}", e.getMessage()); |
| | | // pmiSS.setOpercheckFlag("2"); |
| | | // pmiSS.setLongTaskReason("人员手术处理异常:" + e.getMessage()); |
| | | // patMedInhospMapper.updatePatMedInhosp(pmiSS); |
| | | // } |
| | | // } |
| | | // 手术随访 |
| | | PatMedOperationItem pmoi = new PatMedOperationItem(); |
| | | //获取需要出院疾病随访,未处理的数据 |
| | | pmoi.setOpercheckFlag("0"); |
| | | pmoi.setMainFlag("1"); |
| | | |
| | | List<PatMedOperationItem> patMedOperationItems = patMedOperationItemMapper.selectPatMedOperationItemList(pmoi); |
| | | log.info("dealOutHospInfo需要处理的出院手术患者信息:{}", CollectionUtils.isNotEmpty(patMedOperationItems) ? patMedOperationItems.size() : null); |
| | | |
| | | for (PatMedOperationItem opItem : patMedOperationItems) { |
| | | |
| | | try { |
| | | if (StringUtils.isEmpty(opItem.getOplevelcode())) { |
| | | continue; |
| | | } |
| | | // 根据患者的疾病,获取该疾病的长期任务 |
| | | ServiceTaskoper serviceTaskoper = new ServiceTaskoper(); |
| | | serviceTaskoper.setLongtask(1L); |
| | | serviceTaskoper.setOrgid(opItem.getOrgid()); |
| | | serviceTaskoper.setOplevelcode(opItem.getOplevelcode()); |
| | | |
| | | List<ServiceTaskoper> serviceTaskopers = serviceTaskoperMapper.selectServiceTaskoperList(serviceTaskoper); |
| | | //如果部门模板为空(将deptIsNull设置为true) |
| | | if (CollectionUtils.isEmpty(serviceTaskopers) || serviceTaskopers.size() == 0) { |
| | | PatMedOperationItem patMedOperationItem = patMedOperationItemMapper.selectPatMedOperationItemById(opItem.getId()); |
| | | patMedOperationItem.setOpercheckFlag("2"); |
| | | patMedOperationItem.setLongTaskReason(patMedOperationItem.getLongTaskReason() + "所患的手术未配置长期任务;"); |
| | | patMedOperationItemMapper.updatePatMedOperationItem(patMedOperationItem); |
| | | } else { |
| | | for (ServiceTaskoper serviceTaskoper1 : serviceTaskopers) { |
| | | writeInSubTaskForOp(serviceTaskoper1.getTaskId(), true, opItem, config); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("人员手术处理出异常了:{}", e.getMessage()); |
| | | opItem.setOpercheckFlag("2"); |
| | | opItem.setLongTaskReason("人员手术处理异常:" + e.getMessage()); |
| | | patMedOperationItemMapper.updatePatMedOperationItem(opItem); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | 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 |
| | |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * @param taskid 任务id |
| | | * @param check 是否需要校验 |
| | | * @param patMedInhosp1 病人出入院信息 |
| | | * @param patArchive 病人信息 |
| | | * @param type 随访类型(1-科室,2-病区,3-疾病) |
| | | * @param config 配置信息 visit.early.day |
| | | */ |
| | | //将患者放到subtask中 |
| | | private void writeInSubTask(Long taskid, Boolean check, PatMedInhosp patMedInhosp1, PatArchive patArchive, Integer type, String config) { |
| | | String longTaskReason = patMedInhosp1.getLongTaskReason(); |
| | |
| | | //先判断一下,是否需要校验 |
| | | if (check && (Objects.isNull(serviceSubtask.getTaskSituation()) || serviceSubtask.getTaskSituation() != 6)) { |
| | | //在新增之前,先通过患者ID,sendstate=2查询一下,在所有长期任务中,是不是还有该患者待执行的任务,有的话,比较之前的endtime是否小于当前的endtaime,如果之前的小于现在的,则直接将之前的停掉(原因再入院) |
| | | ServiceSubtaskVO subtask = new ServiceSubtaskVO(); |
| | | ServiceSubtaskEntity subtask = new ServiceSubtaskEntity(); |
| | | subtask.setPatid(patArchive.getId()); |
| | | subtask.setSendstate(2L); |
| | | subtask.setTaskid(taskid); |
| | | List<ServiceSubtask> selectServiceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(subtask); |
| | | log.info("该患者待执行的任务:{}", CollectionUtils.isNotEmpty(selectServiceSubtaskList) ? selectServiceSubtaskList.size() : null); |
| | | // log.info("该患者待执行的任务:{}", CollectionUtils.isNotEmpty(selectServiceSubtaskList) ? selectServiceSubtaskList.size() : null); |
| | | if (CollectionUtils.isNotEmpty(selectServiceSubtaskList) && selectServiceSubtaskList.size() > 0) { |
| | | for (ServiceSubtask serviceSubtask1 : selectServiceSubtaskList) { |
| | | if (Objects.isNull(serviceSubtask1.getLongSendTime())) { |
| | |
| | | if (!Objects.isNull(patMedInhosp1.getEndtime())) { |
| | | newDate = addDays(patMedInhosp1.getEndtime(), serviceTask.getSendDay().intValue()); |
| | | } else { |
| | | patMedInhosp1.setDeptcheckFlag("2"); |
| | | patMedInhosp1.setRemark(patMedInhosp1.getRemark() + "& 该患者疾病出院时间为空,出院记录ID为:" + patMedInhosp1.getInhospid()); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | //如果出院时间为空,则返回一个新对象 |
| | | return new ServiceSubtask(); |
| | | } |
| | | serviceSubtask.setLongSendTime(newDate); |
| | | serviceSubtask.setVisitTime(newDate); |
| | | |
| | | if (patMedInhosp1.getFudate() != null) serviceSubtask.setVisitTime(patMedInhosp1.getFudate()); |
| | | // if (patMedInhosp1.getFudate() != null && !patMedInhosp1.getOrgid().equals("47255004333112711A1001")) serviceSubtask.setVisitTime(patMedInhosp1.getFudate()); |
| | | //如果是通知的话,需要提前几天将通过短信发出去(具体几天,这个可以配置在sys_conf表中) |
| | | if ("3".equals(serviceTask.getType())) { |
| | | serviceSubtask.setVisitTime(minusDay(newDate, StringUtils.isNotEmpty(config) ? Integer.parseInt(config) : 0)); |
| | |
| | | for (PatMedInhosp patMedInhosp1 : patMedInhospList) { |
| | | try { |
| | | //获取当前入院患者的待执行的出院子任务随访信息 |
| | | ServiceSubtaskVO subtask = new ServiceSubtaskVO(); |
| | | ServiceSubtaskEntity subtask = new ServiceSubtaskEntity(); |
| | | subtask.setPatid(patMedInhosp1.getPatid()); |
| | | subtask.setSendstate(2L); |
| | | List<ServiceSubtask> selectServiceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(subtask); |
| | |
| | | //不是长期任务,不处理 |
| | | continue; |
| | | } |
| | | if (serviceSubtask1.getEndtime().before(patMedInhosp1.getStarttime())) { |
| | | //如果当前循环的子任务的出院时间在“准备新增的子任务”的出院时间之前,则将循环的子任务停掉 |
| | | // log.error("患者再入院的serviceSubtask1为:{}", serviceSubtask1); |
| | | serviceSubtask1.setSendstate(4L); |
| | | serviceSubtask1.setRemark("患者再入院"); |
| | | serviceSubtask1.setResult("error"); |
| | | // serviceSubtask1.setFinishtime(new Date()); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask1); |
| | | //景宁 出院首次(7天)随访一定要做 |
| | | boolean firstVisit = false; |
| | | if (serviceSubtask1.getOrgid().equals("47255004333112711A1001") && serviceSubtask1.getVisitCount() != null && serviceSubtask1.getVisitCount() == 1) { |
| | | firstVisit = true; |
| | | } |
| | | if (!firstVisit) { |
| | | if (serviceSubtask1.getEndtime().before(patMedInhosp1.getStarttime())) { |
| | | //如果当前循环的子任务的出院时间在“准备新增的子任务”的出院时间之前,则将循环的子任务停掉 |
| | | // log.error("患者再入院的serviceSubtask1为:{}", serviceSubtask1); |
| | | serviceSubtask1.setSendstate(4L); |
| | | serviceSubtask1.setIsVisitAgain(2); |
| | | serviceSubtask1.setRemark("患者再入院"); |
| | | serviceSubtask1.setResult("error"); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask1); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | //将患入的入院数据设置为已处理 |
| | | //更新状态值 patMedInhosp1.setDeptcheckFlag("0"); |
| | | //patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | } catch (Exception e) { |
| | | log.error("入院数据信息出异常了:{},{}", patMedInhosp1, e.getMessage()); |
| | | } |