| | |
| | | //记录insertServiceSubtask语句返回状态 |
| | | Integer i = 0; |
| | | try { |
| | | // 兜底:任务模板修改会重置 pat_med_inhosp 的处理标记,但已完成的首访不会删除。 |
| | | // 同一 inhospid + taskid 已存在未删除的首次随访(upid 为空)时,不再插入,避免出现两条首次随访。 |
| | | if (check |
| | | && ("2".equals(serviceTask.getServiceType()) || "13".equals(serviceTask.getServiceType())) |
| | | && (type == 1 || type == 2 || type == 3)) { |
| | | ServiceSubtaskEntity firstQuery = new ServiceSubtaskEntity(); |
| | | firstQuery.setInhospid(patMedInhosp1.getInhospid()); |
| | | firstQuery.setTaskid(taskid); |
| | | List<ServiceSubtask> firstList = serviceSubtaskMapper.selectServiceSubtaskList(firstQuery); |
| | | boolean firstExists = CollectionUtils.isNotEmpty(firstList) |
| | | && firstList.stream().anyMatch(item -> item.getUpid() == null); |
| | | if (firstExists) { |
| | | log.info("患者{}已存在首次随访任务,跳过重复生成, taskid={}, type={}", |
| | | patMedInhosp1.getInhospid(), taskid, type); |
| | | PatMedInhosp flagUpdate = new PatMedInhosp(); |
| | | flagUpdate.setInhospid(patMedInhosp1.getInhospid()); |
| | | if (type == 1) flagUpdate.setDeptcheckFlag("1"); |
| | | if (type == 2) flagUpdate.setWardcheckFlag("1"); |
| | | if (type == 3) flagUpdate.setDiagcheckFlag("1"); |
| | | patMedInhospMapper.updatePatMedInhosp(flagUpdate); |
| | | return; |
| | | } |
| | | } |
| | | //先判断一下,是否需要校验 |
| | | if (check && (Objects.isNull(serviceSubtask.getTaskSituation()) || serviceSubtask.getTaskSituation() != 6)) { |
| | | //在新增之前,先通过患者ID,sendstate=2查询一下,在所有长期任务中,是不是还有该患者待执行的任务,有的话,比较之前的endtime是否小于当前的endtaime,如果之前的小于现在的,则直接将之前的停掉(原因再入院) |