| | |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.smartor.domain.DTO.ManualVisitDTO; |
| | | import com.smartor.domain.DTO.PatMedInhospDTO; |
| | | import com.smartor.domain.PatMedInhosp; |
| | | import com.smartor.domain.PatMedInhospVO; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 患者住院记录Controller |
| | |
| | | } |
| | | |
| | | /** |
| | | * 患者人工随访:删除未完成随访任务并按指定任务重新生成 |
| | | */ |
| | | @ApiOperation("addManualVisit") |
| | | @PostMapping("/addManualVisit") |
| | | public AjaxResult addManualVisit(@RequestBody ManualVisitDTO manualVisitDTO) { |
| | | Map<String, Object> result = patMedInhospService.addManualVisit(manualVisitDTO); |
| | | if (Boolean.TRUE.equals(result.get("hasDuplicate"))) { |
| | | return AjaxResult.warn((String) result.get("tipMessage"), result); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | /** |
| | | * 处理患者信息,进入子任务表 |
| | | */ |
| | | @ApiOperation("dealOutHospInfoBySchedule") |
| | |
| | | * manualInfo - visitCount = 1 && currentPreachForm = "1" |
| | | * voiceInfo - visitCount = 1 && currentPreachForm = "3" |
| | | * smsInfo - visitCount = 1 && currentPreachForm = "4" |
| | | * manualSuccessInfo - visitCount = 1 && currentPreachForm = "1" && sendstate = 6 |
| | | * voiceSuccessInfo - visitCount = 1 && currentPreachForm = "3" && sendstate = 6 |
| | | * smsSuccessInfo - visitCount = 1 && currentPreachForm = "4" && sendstate = 6 |
| | | * wechatSuccessInfo - visitCount = 1 && currentPreachForm = "5" && sendstate = 6 |
| | | * wechatInfo - visitCount = 1 && currentPreachForm = "5" |
| | | * abnormalInfo - visitCount = 1 && excep = "1" |
| | | * needFollowUpAgainInfo - visitCount > 1 && sendstate != 4 |
| | |
| | | * taskSituation5Info - taskSituation = 5 |
| | | * taskSituation6Info - taskSituation = 7 |
| | | * manuallyCalledInfo - isManuallyCalled = 1L |
| | | * manualCallTimeoutInfo - visitCount = 1 && sendstate = 7 && isManuallyCalled = 0 |
| | | * manualCallTimeoutAgainInfo - visitCount > 1 && sendstate = 7 && isManuallyCalled = 0 |
| | | * pendingFollowUpAllInfo - visitCount = 1 && sendstate in (1,2,3,7) |
| | | * pendingFollowUpAllAgainInfo - visitCount > 1 && sendstate in (1,2,3,7) |
| | | * pendingFollowUpWaitSendInfo - visitCount = 1 && sendstate in (1,2) |
| | | * pendingFollowUpWaitSendAgainInfo - visitCount > 1 && sendstate in (1,2) |
| | | * pendingFollowUpSentInfo - visitCount = 1 && sendstate in (3,7) |
| | | * pendingFollowUpSentAgainInfo - visitCount > 1 && sendstate in (3,7) |
| | | * sentInfo - visitCount = 1 && sendstate = 3 |
| | | * sentAgainInfo - visitCount > 1 && sendstate = 3 |
| | | * firstDischargeCountInfo - visitCount = 1 |
| | | * againFollowUpPushCountInfo - visitCount = 2 && visitDeptCode = sys.smartor.center.dept |
| | | * filterCountList - taskSituation = 6 && sendstate = 4 |
| | |
| | | @Excel(name = " 二次待随访 ") |
| | | private Long pendingFollowUpAgain = 0L; |
| | | |
| | | @ApiModelProperty(value = "首次随访人工电话超时(sendstate=7 且 isManuallyCalled=0)") |
| | | @Excel(name = " 首次随访人工电话超时 ") |
| | | private Long manualCallTimeout = 0L; |
| | | |
| | | @ApiModelProperty(value = "再次随访人工电话超时(sendstate=7 且 isManuallyCalled=0)") |
| | | @Excel(name = " 再次随访人工电话超时 ") |
| | | private Long manualCallTimeoutAgain = 0L; |
| | | |
| | | @ApiModelProperty(value = "首次待随访全部(sendstate in 1,2,3,7)") |
| | | @Excel(name = " 首次待随访全部 ") |
| | | private Long pendingFollowUpAll = 0L; |
| | | |
| | | @ApiModelProperty(value = "再次待随访全部(sendstate in 1,2,3,7)") |
| | | @Excel(name = " 再次待随访全部 ") |
| | | private Long pendingFollowUpAllAgain = 0L; |
| | | |
| | | @ApiModelProperty(value = "首次待随访待发送(sendstate in 1,2)") |
| | | @Excel(name = " 首次待随访待发送 ") |
| | | private Long pendingFollowUpWaitSend = 0L; |
| | | |
| | | @ApiModelProperty(value = "再次待随访待发送(sendstate in 1,2)") |
| | | @Excel(name = " 再次待随访待发送 ") |
| | | private Long pendingFollowUpWaitSendAgain = 0L; |
| | | |
| | | @ApiModelProperty(value = "首次待随访已发送(sendstate in 3,7)") |
| | | @Excel(name = " 首次待随访已发送 ") |
| | | private Long pendingFollowUpSent = 0L; |
| | | |
| | | @ApiModelProperty(value = "再次待随访已发送(sendstate in 3,7)") |
| | | @Excel(name = " 再次待随访已发送 ") |
| | | private Long pendingFollowUpSentAgain = 0L; |
| | | |
| | | @ApiModelProperty(value = "首次已发送(sendstate=3)") |
| | | @Excel(name = " 首次已发送 ") |
| | | private Long sent = 0L; |
| | | |
| | | @ApiModelProperty(value = "再次已发送(sendstate=3)") |
| | | @Excel(name = " 再次已发送 ") |
| | | private Long sentAgain = 0L; |
| | | |
| | | @ApiModelProperty(value = "二次随访成功") |
| | | @Excel(name = " 二次随访成功 ") |
| | | private Long followUpSuccessAgain = 0L; |
| | |
| | | @ApiModelProperty(value = "当前发送方式") |
| | | private String currentPreachform; |
| | | |
| | | /** |
| | | * 当前执行方式多选筛选,多个值用逗号分隔 |
| | | */ |
| | | @ApiModelProperty(value = "当前执行方式多选筛选,多个值用逗号分隔") |
| | | private String currentPreachforms; |
| | | |
| | | |
| | | /** |
| | | * 床号 |
| | |
| | | @ApiModelProperty(value = "当前发送方式") |
| | | private String currentPreachform; |
| | | |
| | | /** |
| | | * 当前执行方式多选筛选,多个值用逗号分隔 |
| | | */ |
| | | @ApiModelProperty(value = "当前执行方式多选筛选,多个值用逗号分隔") |
| | | private String currentPreachforms; |
| | | |
| | | |
| | | /** |
| | | * 床号 |
| | |
| | | */ |
| | | public PatArchive selectPatArchiveByPatid(Long patid); |
| | | |
| | | /** |
| | | * 锁定患者档案行,串行化同一患者的人工随访创建 |
| | | * |
| | | * @param patid 患者档案主键 |
| | | * @return 患者档案主键,档案不存在或已删除时返回 null |
| | | */ |
| | | Long lockPatArchiveByPatid(@Param("patid") Long patid); |
| | | |
| | | List<PatArchive> selectPatArchiveByPatnos(@Param("patnos") List<String> patnos); |
| | | |
| | | List<PatArchive> selectPatArchiveByPatidHiss(@Param("patidHiss") List<String> patidHiss); |
| | |
| | | public int deleteServiceSubtaskByCondition(@Param("taskid") Long id, @Param("patid") Long patid); |
| | | |
| | | /** |
| | | * 删除患者出院记录对应的未完成随访任务 |
| | | * |
| | | * @param patid 患者ID |
| | | * @param inhospids 出院记录ID集合 |
| | | * @param sendstates 未完成状态集合 |
| | | * @return 删除条数 |
| | | */ |
| | | public int deleteUnfinishedServiceSubtaskByInhospids(@Param("patid") Long patid, |
| | | @Param("inhospids") List<Long> inhospids, |
| | | @Param("sendstates") List<Long> sendstates); |
| | | |
| | | /** |
| | | * 统计患者指定任务下未完成的随访任务数量(用于人工随访重复校验) |
| | | * |
| | | * @param patid 患者ID |
| | | * @param taskid 任务ID |
| | | * @param sendstates 未完成状态集合 |
| | | * @return 未完成任务数量 |
| | | */ |
| | | int countUnfinishedServiceSubtaskByPatidAndTaskid(@Param("patid") Long patid, |
| | | @Param("taskid") Long taskid, |
| | | @Param("sendstates") List<Long> sendstates); |
| | | |
| | | /** |
| | | * 删除单一任务(随访) |
| | | * |
| | | * @return 结果 |
| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.DTO.ManualVisitDTO; |
| | | import com.smartor.domain.DTO.PatMedInhospDTO; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | |
| | | */ |
| | | public void dealIcd10Subtask(PatMedInhosp patMedInhospVo, String config); |
| | | |
| | | /** |
| | | * 人工随访:删除患者出院记录对应的未完成随访任务,并按指定任务重新生成 |
| | | * |
| | | * @param manualVisitDTO 患者patid集合及人工随访任务taskid |
| | | * @return 处理结果 |
| | | */ |
| | | public Map<String, Object> addManualVisit(ManualVisitDTO manualVisitDTO); |
| | | |
| | | public ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, PatMedInhosp patMedInhosp1, PatArchive patArchive, String config, Integer type); |
| | | |
| | | /** |
| | |
| | | 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.exception.base.BaseException; |
| | | 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.common.ScheduleSubtaskBuilder; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.DTO.ManualVisitDTO; |
| | | import com.smartor.domain.DTO.PatMedInhospDTO; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | | import com.smartor.mapper.*; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Isolation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.io.IOException; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 人工随访:删除患者出院记录对应的未完成随访任务,并按指定任务重新生成。 |
| | | * 删除旧任务口径:sendstate in (1,2,3,7); |
| | | * 重复任务校验口径:sendstate in (1,2,3,5,7),已有相同 taskid 未完成任务的患者跳过。 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED) |
| | | public Map<String, Object> addManualVisit(ManualVisitDTO manualVisitDTO) { |
| | | if (manualVisitDTO == null) { |
| | | throw new BaseException("入参不能为空"); |
| | | } |
| | | if (CollectionUtils.isEmpty(manualVisitDTO.getPatids())) { |
| | | throw new BaseException("患者patid集合不能为空"); |
| | | } |
| | | if (manualVisitDTO.getTaskid() == null) { |
| | | throw new BaseException("人工随访任务taskid不能为空"); |
| | | } |
| | | |
| | | ServiceTask serviceTask = serviceTaskMapper.selectServiceTaskByTaskid(manualVisitDTO.getTaskid()); |
| | | if (Objects.isNull(serviceTask)) { |
| | | throw new BaseException("人工随访任务不存在,taskid:" + manualVisitDTO.getTaskid()); |
| | | } |
| | | |
| | | // 升序处理,配合患者档案行锁,避免批量请求交叉加锁产生死锁 |
| | | List<Long> patids = manualVisitDTO.getPatids().stream() |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .sorted() |
| | | .collect(Collectors.toList()); |
| | | if (patids.isEmpty()) { |
| | | throw new BaseException("患者patid集合不能为空"); |
| | | } |
| | | |
| | | String config = iSysConfigService.selectConfigByKey("visit.early.day"); |
| | | List<Long> unfinishedSendstates = Arrays.asList(1L, 2L, 3L, 7L); |
| | | // 与前端待随访口径保持一致,发送失败(5)也视为已有未完成任务 |
| | | List<Long> activeSendstates = Arrays.asList(1L, 2L, 3L, 5L, 7L); |
| | | int deletedCount = 0; |
| | | int generatedCount = 0; |
| | | List<Long> noDischargeRecordPatids = new ArrayList<>(); |
| | | List<Long> noArchivePatids = new ArrayList<>(); |
| | | List<Long> generateFailedPatids = new ArrayList<>(); |
| | | List<Long> duplicatePatids = new ArrayList<>(); |
| | | List<String> duplicatePatientNames = new ArrayList<>(); |
| | | |
| | | for (Long patid : patids) { |
| | | // 查询患者全部出院记录,SQL 按出院时间倒序,第一条作为本次生成任务的出院记录 |
| | | PatMedInhosp query = new PatMedInhosp(); |
| | | query.setPatid(patid); |
| | | query.setCry(1); |
| | | if (StringUtils.isNotEmpty(serviceTask.getOrgid())) { |
| | | query.setOrgid(serviceTask.getOrgid()); |
| | | } |
| | | List<PatMedInhosp> inhospList = patMedInhospMapper.selectPatMedInhospList(query); |
| | | if (CollectionUtils.isEmpty(inhospList)) { |
| | | noDischargeRecordPatids.add(patid); |
| | | continue; |
| | | } |
| | | |
| | | PatMedInhosp latestInhosp = inhospList.get(0); |
| | | if (Objects.isNull(latestInhosp.getEndtime())) { |
| | | noDischargeRecordPatids.add(patid); |
| | | continue; |
| | | } |
| | | |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patid); |
| | | if (Objects.isNull(patArchive)) { |
| | | noArchivePatids.add(patid); |
| | | continue; |
| | | } |
| | | |
| | | // 锁定患者档案行,串行化同一患者的并发创建请求 |
| | | Long lockedPatid = patArchiveMapper.lockPatArchiveByPatid(patid); |
| | | if (Objects.isNull(lockedPatid)) { |
| | | noArchivePatids.add(patid); |
| | | continue; |
| | | } |
| | | |
| | | // 同一患者在同一 taskid 下已有未完成随访任务时,跳过该患者,避免重复创建 |
| | | int existingSubtaskCount = serviceSubtaskMapper.countUnfinishedServiceSubtaskByPatidAndTaskid( |
| | | patid, serviceTask.getTaskid(), activeSendstates); |
| | | if (existingSubtaskCount > 0) { |
| | | duplicatePatids.add(patid); |
| | | String patientName = StringUtils.isNotEmpty(patArchive.getName()) |
| | | ? patArchive.getName() : String.valueOf(patid); |
| | | duplicatePatientNames.add(patientName + "(" + patid + ")"); |
| | | log.info("addManualVisit 患者已有相同服务,跳过生成,patid:{},taskid:{},已有任务数:{}", |
| | | patid, serviceTask.getTaskid(), existingSubtaskCount); |
| | | continue; |
| | | } |
| | | |
| | | // 先构建新任务,构建失败时不删除原任务,避免患者丢失待随访任务 |
| | | ServiceSubtask serviceSubtask = boxedServiceSubtask(serviceTask, latestInhosp, patArchive, config, 1); |
| | | if (Objects.isNull(serviceSubtask) || Objects.isNull(serviceSubtask.getTaskid())) { |
| | | generateFailedPatids.add(patid); |
| | | continue; |
| | | } |
| | | |
| | | List<Long> inhospids = inhospList.stream() |
| | | .map(PatMedInhosp::getInhospid) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(inhospids)) { |
| | | deletedCount += serviceSubtaskMapper.deleteUnfinishedServiceSubtaskByInhospids( |
| | | patid, inhospids, unfinishedSendstates); |
| | | } |
| | | |
| | | serviceSubtask.setId(null); |
| | | serviceSubtask.setUpid(null); |
| | | serviceSubtask.setVisitDeptCode(StringUtils.isNotEmpty(latestInhosp.getLeaveldeptcode()) |
| | | ? latestInhosp.getLeaveldeptcode() : latestInhosp.getLeavehospitaldistrictcode()); |
| | | serviceSubtask.setVisitDeptName(StringUtils.isNotEmpty(latestInhosp.getLeaveldeptname()) |
| | | ? latestInhosp.getLeaveldeptname() : latestInhosp.getLeavehospitaldistrictname()); |
| | | // 与常规生成逻辑保持一致:手机号为空时生成任务但不执行 |
| | | if (StringUtils.isEmpty(serviceSubtask.getPhone())) { |
| | | serviceSubtask.setRemark(StringUtils.isNotEmpty(serviceSubtask.getRemark()) |
| | | ? serviceSubtask.getRemark() + ",手机号为空" : "手机号为空"); |
| | | serviceSubtask.setSendstate(4L); |
| | | serviceSubtask.setResult("error"); |
| | | } |
| | | |
| | | int inserted = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask); |
| | | if (inserted != 1) { |
| | | throw new BaseException("生成随访任务失败,patid:" + patid + ",taskid:" + serviceTask.getTaskid()); |
| | | } |
| | | addServiceSubtaskPreachform(serviceSubtask, null); |
| | | generatedCount++; |
| | | log.info("addManualVisit 生成随访任务成功,patid:{},taskid:{},subtaskId:{}", |
| | | patid, serviceTask.getTaskid(), serviceSubtask.getId()); |
| | | } |
| | | |
| | | String tipMessage = null; |
| | | if (CollectionUtils.isNotEmpty(duplicatePatids)) { |
| | | String taskName = StringUtils.isNotEmpty(serviceTask.getTaskName()) |
| | | ? serviceTask.getTaskName() : String.valueOf(serviceTask.getTaskid()); |
| | | tipMessage = "患者" + String.join("、", duplicatePatientNames) |
| | | + "已有相同服务【" + taskName + "】,已跳过"; |
| | | if (generatedCount > 0) { |
| | | tipMessage += ";其余患者已处理"; |
| | | } |
| | | } |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("deletedCount", deletedCount); |
| | | result.put("generatedCount", generatedCount); |
| | | result.put("noDischargeRecordPatids", noDischargeRecordPatids); |
| | | result.put("noArchivePatids", noArchivePatids); |
| | | result.put("generateFailedPatids", generateFailedPatids); |
| | | result.put("duplicatePatids", duplicatePatids); |
| | | result.put("duplicatePatientNames", duplicatePatientNames); |
| | | result.put("hasDuplicate", CollectionUtils.isNotEmpty(duplicatePatids)); |
| | | result.put("tipMessage", tipMessage); |
| | | log.info("addManualVisit 处理完成,patid数:{},taskid:{},删除未完成任务数:{},生成任务数:{},重复跳过数:{}", |
| | | patids.size(), serviceTask.getTaskid(), deletedCount, generatedCount, duplicatePatids.size()); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | |
| | | if (StringUtils.isEmpty(serviceSubtask.getCurrentPreachform())) { |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getPreachform())) { |
| | | //默认取第一个 |
| | | serviceSubtaskRes.setCurrentPreachform(serviceSubtask.getPreachform().split(",")[0]); |
| | | serviceSubtaskRes.setCurrentPreachform(serviceSubtask.getPreachform().split(",")[0].trim()); |
| | | } |
| | | } |
| | | PatMedInhosp inhosp = patMedInhospMapper.selectPatMedInhospByInhospid(serviceSubtask.getInhospid()); |
| | |
| | | |
| | | //首次出院随访 |
| | | if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) { |
| | | applyFirstFollowUpExtraStatistics(serviceSubtaskStatistic, serviceSubtask); |
| | | //首次应随访 |
| | | if (serviceSubtask.getSendstate() != null && !serviceSubtask.getSendstate().equals(4L)) { |
| | | serviceSubtaskStatistic.setNeedFollowUp(serviceSubtaskStatistic.getNeedFollowUp() + 1L); |
| | |
| | | } |
| | | }//二次出院随访 |
| | | else if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() > 1) { |
| | | applyAgainFollowUpExtraStatistics(serviceSubtaskStatistic, serviceSubtask); |
| | | //再次应随访 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) { |
| | | serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 市一统计口径:首次待随访、已发送及人工电话超时。 |
| | | */ |
| | | private void applyFirstFollowUpExtraStatistics(ServiceSubtaskStatistic statistic, ServiceSubtask serviceSubtask) { |
| | | if (serviceSubtask.getVisitCount() == null || serviceSubtask.getVisitCount() != 1 || serviceSubtask.getSendstate() == null) { |
| | | return; |
| | | } |
| | | Long sendstate = serviceSubtask.getSendstate(); |
| | | if (sendstate.equals(3L)) { |
| | | statistic.setSent(statistic.getSent() + 1L); |
| | | } |
| | | if (sendstate.equals(7L) && isManuallyNotCalled(serviceSubtask)) { |
| | | statistic.setManualCallTimeout(statistic.getManualCallTimeout() + 1L); |
| | | } |
| | | if (sendstate.equals(1L) || sendstate.equals(2L) || sendstate.equals(3L) || sendstate.equals(7L)) { |
| | | statistic.setPendingFollowUpAll(statistic.getPendingFollowUpAll() + 1L); |
| | | } |
| | | if (sendstate.equals(1L) || sendstate.equals(2L)) { |
| | | statistic.setPendingFollowUpWaitSend(statistic.getPendingFollowUpWaitSend() + 1L); |
| | | } |
| | | if (sendstate.equals(3L) || sendstate.equals(7L)) { |
| | | statistic.setPendingFollowUpSent(statistic.getPendingFollowUpSent() + 1L); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 市一统计口径:再次待随访、已发送及人工电话超时。 |
| | | */ |
| | | private void applyAgainFollowUpExtraStatistics(ServiceSubtaskStatistic statistic, ServiceSubtask serviceSubtask) { |
| | | if (serviceSubtask.getVisitCount() == null || serviceSubtask.getVisitCount() <= 1 || serviceSubtask.getSendstate() == null) { |
| | | return; |
| | | } |
| | | Long sendstate = serviceSubtask.getSendstate(); |
| | | if (sendstate.equals(3L)) { |
| | | statistic.setSentAgain(statistic.getSentAgain() + 1L); |
| | | } |
| | | if (sendstate.equals(7L) && isManuallyNotCalled(serviceSubtask)) { |
| | | statistic.setManualCallTimeoutAgain(statistic.getManualCallTimeoutAgain() + 1L); |
| | | } |
| | | if (sendstate.equals(1L) || sendstate.equals(2L) || sendstate.equals(3L) || sendstate.equals(7L)) { |
| | | statistic.setPendingFollowUpAllAgain(statistic.getPendingFollowUpAllAgain() + 1L); |
| | | } |
| | | if (sendstate.equals(1L) || sendstate.equals(2L)) { |
| | | statistic.setPendingFollowUpWaitSendAgain(statistic.getPendingFollowUpWaitSendAgain() + 1L); |
| | | } |
| | | if (sendstate.equals(3L) || sendstate.equals(7L)) { |
| | | statistic.setPendingFollowUpSentAgain(statistic.getPendingFollowUpSentAgain() + 1L); |
| | | } |
| | | } |
| | | |
| | | private boolean isManuallyNotCalled(ServiceSubtask serviceSubtask) { |
| | | return serviceSubtask.getIsManuallyCalled() != null && serviceSubtask.getIsManuallyCalled().equals(0L); |
| | | } |
| | | |
| | | /** |
| | | * 首次随访统计 |
| | | * |
| | | * @param serviceSubtaskList |
| | |
| | | serviceSubtaskStatistic.setDischargeCount(serviceSubtaskList.size()); |
| | | |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | applyFirstFollowUpExtraStatistics(serviceSubtaskStatistic, serviceSubtask); |
| | | //无需随访人次 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) { |
| | | serviceSubtaskStatistic.setNonFollowUp(serviceSubtaskStatistic.getNonFollowUp() + 1L); |
| | |
| | | //出院人次 |
| | | serviceSubtaskStatistic.setDischargeCount(serviceSubtaskList.size()); |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | applyAgainFollowUpExtraStatistics(serviceSubtaskStatistic, serviceSubtask); |
| | | //无需随访人次 |
| | | if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) { |
| | | serviceSubtaskStatistic.setNonFollowUp(serviceSubtaskStatistic.getNonFollowUp() + 1L); |
| | |
| | | * taskSituation5Info - taskSituation = 5 |
| | | * taskSituation6Info - taskSituation = 7 |
| | | * manuallyCalledInfo - isManuallyCalled = 1L |
| | | * manualCallTimeoutInfo - visitCount = 1 && sendstate = 7 && isManuallyCalled = 0 |
| | | * manualCallTimeoutAgainInfo - visitCount > 1 && sendstate = 7 && isManuallyCalled = 0 |
| | | * pendingFollowUpAllInfo - visitCount = 1 && sendstate in (1,2,3,7) |
| | | * pendingFollowUpAllAgainInfo - visitCount > 1 && sendstate in (1,2,3,7) |
| | | * pendingFollowUpWaitSendInfo - visitCount = 1 && sendstate in (1,2) |
| | | * pendingFollowUpWaitSendAgainInfo - visitCount > 1 && sendstate in (1,2) |
| | | * pendingFollowUpSentInfo - visitCount = 1 && sendstate in (3,7) |
| | | * pendingFollowUpSentAgainInfo - visitCount > 1 && sendstate in (3,7) |
| | | * sentInfo - visitCount = 1 && sendstate = 3 |
| | | * sentAgainInfo - visitCount > 1 && sendstate = 3 |
| | | * filterCountList - taskSituation = 6 && sendstate = 4 |
| | | * |
| | | */ |
| | |
| | | break; |
| | | case "manuallyCalledInfo": |
| | | serviceSubtaskCountReq.setIsManuallyCalled(1L); |
| | | break; |
| | | case "manualCallTimeoutInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(7L))); |
| | | serviceSubtaskCountReq.setIsManuallyCalled(0L); |
| | | break; |
| | | case "manualCallTimeoutAgainInfo": |
| | | serviceSubtaskCountReq.setVisitCount(2); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(7L))); |
| | | serviceSubtaskCountReq.setIsManuallyCalled(0L); |
| | | break; |
| | | case "pendingFollowUpAllInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 7L))); |
| | | break; |
| | | case "pendingFollowUpAllAgainInfo": |
| | | serviceSubtaskCountReq.setVisitCount(2); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 7L))); |
| | | break; |
| | | case "pendingFollowUpWaitSendInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L))); |
| | | break; |
| | | case "pendingFollowUpWaitSendAgainInfo": |
| | | serviceSubtaskCountReq.setVisitCount(2); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L))); |
| | | break; |
| | | case "pendingFollowUpSentInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(3L, 7L))); |
| | | break; |
| | | case "pendingFollowUpSentAgainInfo": |
| | | serviceSubtaskCountReq.setVisitCount(2); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(3L, 7L))); |
| | | break; |
| | | case "sentInfo": |
| | | serviceSubtaskCountReq.setVisitCount(1); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(3L))); |
| | | break; |
| | | case "sentAgainInfo": |
| | | serviceSubtaskCountReq.setVisitCount(2); |
| | | serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(3L))); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | total.setAbnormal(0L); |
| | | total.setNeedFollowUpAgain(0L); |
| | | total.setPendingFollowUpAgain(0L); |
| | | total.setManualCallTimeout(0L); |
| | | total.setManualCallTimeoutAgain(0L); |
| | | total.setPendingFollowUpAll(0L); |
| | | total.setPendingFollowUpAllAgain(0L); |
| | | total.setPendingFollowUpWaitSend(0L); |
| | | total.setPendingFollowUpWaitSendAgain(0L); |
| | | total.setPendingFollowUpSent(0L); |
| | | total.setPendingFollowUpSentAgain(0L); |
| | | total.setSent(0L); |
| | | total.setSentAgain(0L); |
| | | total.setFollowUpSuccessAgain(0L); |
| | | total.setFollowUpFailAgain(0L); |
| | | total.setManualAgain(0L); |
| | |
| | | total.setAbnormal(total.getAbnormal() + (stat.getAbnormal() != null ? stat.getAbnormal() : 0L)); |
| | | total.setNeedFollowUpAgain(total.getNeedFollowUpAgain() + (stat.getNeedFollowUpAgain() != null ? stat.getNeedFollowUpAgain() : 0L)); |
| | | total.setPendingFollowUpAgain(total.getPendingFollowUpAgain() + (stat.getPendingFollowUpAgain() != null ? stat.getPendingFollowUpAgain() : 0L)); |
| | | total.setManualCallTimeout(total.getManualCallTimeout() + (stat.getManualCallTimeout() != null ? stat.getManualCallTimeout() : 0L)); |
| | | total.setManualCallTimeoutAgain(total.getManualCallTimeoutAgain() + (stat.getManualCallTimeoutAgain() != null ? stat.getManualCallTimeoutAgain() : 0L)); |
| | | total.setPendingFollowUpAll(total.getPendingFollowUpAll() + (stat.getPendingFollowUpAll() != null ? stat.getPendingFollowUpAll() : 0L)); |
| | | total.setPendingFollowUpAllAgain(total.getPendingFollowUpAllAgain() + (stat.getPendingFollowUpAllAgain() != null ? stat.getPendingFollowUpAllAgain() : 0L)); |
| | | total.setPendingFollowUpWaitSend(total.getPendingFollowUpWaitSend() + (stat.getPendingFollowUpWaitSend() != null ? stat.getPendingFollowUpWaitSend() : 0L)); |
| | | total.setPendingFollowUpWaitSendAgain(total.getPendingFollowUpWaitSendAgain() + (stat.getPendingFollowUpWaitSendAgain() != null ? stat.getPendingFollowUpWaitSendAgain() : 0L)); |
| | | total.setPendingFollowUpSent(total.getPendingFollowUpSent() + (stat.getPendingFollowUpSent() != null ? stat.getPendingFollowUpSent() : 0L)); |
| | | total.setPendingFollowUpSentAgain(total.getPendingFollowUpSentAgain() + (stat.getPendingFollowUpSentAgain() != null ? stat.getPendingFollowUpSentAgain() : 0L)); |
| | | total.setSent(total.getSent() + (stat.getSent() != null ? stat.getSent() : 0L)); |
| | | total.setSentAgain(total.getSentAgain() + (stat.getSentAgain() != null ? stat.getSentAgain() : 0L)); |
| | | total.setFollowUpSuccessAgain(total.getFollowUpSuccessAgain() + (stat.getFollowUpSuccessAgain() != null ? stat.getFollowUpSuccessAgain() : 0L)); |
| | | total.setFollowUpFailAgain(total.getFollowUpFailAgain() + (stat.getFollowUpFailAgain() != null ? stat.getFollowUpFailAgain() : 0L)); |
| | | total.setManualAgain(total.getManualAgain() + (stat.getManualAgain() != null ? stat.getManualAgain() : 0L)); |
| | |
| | | where id = #{id} and del_flag=0 |
| | | </select> |
| | | |
| | | <!-- 串行化同一患者的人工随访创建,避免并发重复校验失效 --> |
| | | <select id="lockPatArchiveByPatid" resultType="java.lang.Long"> |
| | | select id |
| | | from pat_archive |
| | | where id = #{patid} and del_flag = 0 |
| | | for update |
| | | </select> |
| | | |
| | | <select id="selectPatArchiveByPatnos" resultMap="PatArchiveResult"> |
| | | SELECT id, patientno |
| | | FROM pat_archive |
| | |
| | | END |
| | | </sql> |
| | | |
| | | <!-- 当前执行方式:首次随访 current_preachform 为空时,取 preachform 的第一个执行方式兜底 --> |
| | | <sql id="effectiveCurrentPreachformExpr"> |
| | | COALESCE(NULLIF(TRIM(current_preachform), ''), TRIM(SUBSTRING_INDEX(preachform, ',', 1))) |
| | | </sql> |
| | | |
| | | <select id="selectServiceSubtaskBySendstate" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity" |
| | | resultMap="ServiceSubtaskResult"> |
| | | <include refid="selectServiceSubtaskVo"/> |
| | |
| | | <if test="campusid != null and campusid != ''">and campusid = #{campusid}</if> |
| | | <if test="pid != null ">and pid = #{pid}</if> |
| | | <if test="preachform != null ">and preachform = #{preachform}</if> |
| | | <if test="currentPreachform != null ">and current_preachform = #{currentPreachform}</if> |
| | | <if test="currentPreachform != null and currentPreachform != '' ">and current_preachform = #{currentPreachform}</if> |
| | | <if test="currentPreachforms != null and currentPreachforms != ''"> |
| | | and FIND_IN_SET(<include refid="effectiveCurrentPreachformExpr"/>, #{currentPreachforms}) |
| | | </if> |
| | | <if test="guid != null and guid != ''">and guid = #{guid}</if> |
| | | <if test="textParam != null and textParam != ''">and text_param = #{textParam}</if> |
| | | <if test="bedNo != null">and bed_no = #{bedNo}</if> |
| | |
| | | <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if> |
| | | <if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if> |
| | | <if test="managementDoctor != null">and management_doctor = #{managementDoctor}</if> |
| | | <if test="currentPreachform != null">and current_preachform = #{currentPreachform}</if> |
| | | <if test="currentPreachform != null and currentPreachform != '' ">and current_preachform = #{currentPreachform}</if> |
| | | <if test="isabnormal != null">and isabnormal = #{isabnormal}</if> |
| | | <if test="continueFlag != null ">and continue_flag = #{continueFlag}</if> |
| | | <if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if> |
| | |
| | | <if test="visitTime != null ">and visit_time = #{visitTime}</if> |
| | | <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if> |
| | | <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if> |
| | | <if test="currentPreachform != null">and current_preachform = #{currentPreachform}</if> |
| | | <if test="currentPreachform != null and currentPreachform != '' ">and current_preachform = #{currentPreachform}</if> |
| | | <if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if> |
| | | <if test="isabnormal != null">and isabnormal = #{isabnormal}</if> |
| | | <if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if> |
| | |
| | | <if test="visitDeptName != null">visit_dept_name,</if> |
| | | <if test="managementDoctorCode != null">management_doctor_code,</if> |
| | | <if test="managementDoctor != null">management_doctor,</if> |
| | | <if test="currentPreachform != null">current_preachform,</if> |
| | | <if test="currentPreachform != null and currentPreachform != '' ">current_preachform,</if> |
| | | <if test="taskSituation != null">task_situation,</if> |
| | | <if test="isabnormal != null">isabnormal,</if> |
| | | <if test="continueFlag != null ">continue_flag,</if> |
| | |
| | | <if test="visitDeptName != null">#{visitDeptName},</if> |
| | | <if test="managementDoctorCode != null">#{managementDoctorCode},</if> |
| | | <if test="managementDoctor != null">#{managementDoctor},</if> |
| | | <if test="currentPreachform != null">#{currentPreachform},</if> |
| | | <if test="currentPreachform != null and currentPreachform != '' ">#{currentPreachform},</if> |
| | | <if test="taskSituation != null">#{taskSituation},</if> |
| | | <if test="isabnormal != null">#{isabnormal},</if> |
| | | <if test="continueFlag != null ">#{continueFlag},</if> |
| | |
| | | <if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if> |
| | | <if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if> |
| | | <if test="managementDoctor != null">management_doctor=#{managementDoctor},</if> |
| | | <if test="currentPreachform != null">current_preachform=#{currentPreachform},</if> |
| | | <if test="currentPreachform != null and currentPreachform != '' ">current_preachform=#{currentPreachform},</if> |
| | | <if test="taskSituation != null">task_situation=#{taskSituation},</if> |
| | | <if test="isabnormal != null">isabnormal=#{isabnormal},</if> |
| | | <if test="continueFlag != null ">continue_flag = #{continueFlag},</if> |
| | |
| | | <if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if> |
| | | <if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if> |
| | | <if test="managementDoctor != null">management_doctor=#{managementDoctor},</if> |
| | | <if test="currentPreachform != null">current_preachform=#{currentPreachform},</if> |
| | | <if test="currentPreachform != null and currentPreachform != '' ">current_preachform=#{currentPreachform},</if> |
| | | <if test="taskSituation != null">task_situation=#{taskSituation},</if> |
| | | <if test="isabnormal != null">isabnormal=#{isabnormal},</if> |
| | | <if test="continueFlag != null ">continue_flag = #{continueFlag},</if> |
| | |
| | | <if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if> |
| | | <if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if> |
| | | <if test="managementDoctor != null">management_doctor=#{managementDoctor},</if> |
| | | <if test="currentPreachform != null">current_preachform=#{currentPreachform},</if> |
| | | <if test="currentPreachform != null and currentPreachform != '' ">current_preachform=#{currentPreachform},</if> |
| | | <if test="taskSituation != null">task_situation=#{taskSituation},</if> |
| | | <if test="isabnormal != null">isabnormal=#{isabnormal},</if> |
| | | <if test="continueFlag != null ">continue_flag = #{continueFlag},</if> |
| | |
| | | <if test="visitDeptName != null">visit_dept_name = #{visitDeptName},</if> |
| | | <if test="managementDoctorCode != null">management_doctor_code = #{managementDoctorCode},</if> |
| | | <if test="managementDoctor != null">management_doctor=#{managementDoctor},</if> |
| | | <if test="currentPreachform != null">current_preachform=#{currentPreachform},</if> |
| | | <if test="currentPreachform != null and currentPreachform != '' ">current_preachform=#{currentPreachform},</if> |
| | | <if test="taskSituation != null">task_situation=#{taskSituation},</if> |
| | | <if test="isabnormal != null">isabnormal=#{isabnormal},</if> |
| | | <if test="continueFlag != null ">continue_flag = #{continueFlag},</if> |
| | |
| | | where patid = #{patid} and taskid = #{taskid} |
| | | </update> |
| | | |
| | | <!-- 人工随访:软删除患者出院记录对应的未完成随访任务 --> |
| | | <update id="deleteUnfinishedServiceSubtaskByInhospids"> |
| | | update service_subtask |
| | | set del_flag = 1 |
| | | where del_flag = 0 |
| | | and patid = #{patid} |
| | | and sendstate in |
| | | <foreach collection="sendstates" item="sendstate" open="(" separator="," close=")"> |
| | | #{sendstate} |
| | | </foreach> |
| | | and inhospid in |
| | | <foreach collection="inhospids" item="inhospid" open="(" separator="," close=")"> |
| | | #{inhospid} |
| | | </foreach> |
| | | </update> |
| | | |
| | | <!-- 人工随访重复校验:同一患者同一任务下是否已有未完成随访任务 --> |
| | | <select id="countUnfinishedServiceSubtaskByPatidAndTaskid" resultType="int"> |
| | | select count(1) |
| | | from service_subtask |
| | | where del_flag = 0 |
| | | and patid = #{patid} |
| | | and taskid = #{taskid} |
| | | and sendstate in |
| | | <foreach collection="sendstates" item="sendstate" open="(" separator="," close=")"> |
| | | #{sendstate} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="getSfStatistics" parameterType="com.smartor.domain.ServiceSubtaskCountReq" |
| | | resultMap="ServiceSubtaskResult"> |
| | | select id, |
| | |
| | | deptname, |
| | | sendstate, |
| | | preachform, |
| | | current_preachform, |
| | | <include refid="effectiveCurrentPreachformExpr"/> AS current_preachform, |
| | | excep, |
| | | nurse_id, |
| | | nurse_name, |
| | |
| | | deptname, |
| | | sendstate, |
| | | preachform, |
| | | current_preachform, |
| | | <include refid="effectiveCurrentPreachformExpr"/> AS current_preachform, |
| | | excep, |
| | | nurse_id, |
| | | nurse_name, |
| | |
| | | #{state} |
| | | </foreach> |
| | | </if> |
| | | <if test="currentPreachform != null"> |
| | | AND current_preachform = #{currentPreachform} |
| | | <if test="currentPreachform != null and currentPreachform != '' "> |
| | | AND <include refid="effectiveCurrentPreachformExpr"/> = #{currentPreachform} |
| | | <if test="followUpCountStyle != null and followUpCountStyle = '1'"> |
| | | AND sendstate != 4 |
| | | </if> |
| | |
| | | #{state} |
| | | </foreach> |
| | | </if> |
| | | <if test="currentPreachforms != null and currentPreachforms != ''"> |
| | | AND FIND_IN_SET(<include refid="effectiveCurrentPreachformExpr"/>, #{currentPreachforms}) |
| | | </if> |
| | | <if test="orgid != null and orgid != ''"> |
| | | AND orgid = #{orgid} |
| | | </if> |