【丽水】 同一 inhospid + taskid 已存在未删除的首次随访(upid 为空)时,不再插入,避免出现两条首次随访
已修改3个文件
26 ■■■■■ 文件已修改
smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
@@ -708,6 +708,29 @@
        //记录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,如果之前的小于现在的,则直接将之前的停掉(原因再入院)
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -1630,6 +1630,8 @@
            ServiceTask serviceTask1 = serviceTaskService.selectServiceTaskByTaskid(serviceTask.getTaskid());
            ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity();
            serviceSubtaskVO.setTaskid(serviceTask1.getTaskid());
            //只删除首次随访未完成的
            serviceSubtaskVO.setVisitCount(1);
            serviceSubtaskVO.setSendstate(2L);
            List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO);
            serviceSubtaskVO.setSendstate(1L);
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -405,6 +405,7 @@
        <if test="managementDoctorCode != null ">and management_doctor_code = #{managementDoctorCode}</if>
        <if test="submit != null ">and submit = #{submit}</if>
        <if test="upid != null ">and upid = #{upid}</if>
        <if test="visitCount != null ">and visit_count = #{visitCount}</if>
        <if test="patfrom != null ">and patfrom = #{patfrom}</if>
        <if test="serviceType != null ">and service_type = #{serviceType}</if>
        <if test="patid != null ">and patid = #{patid}</if>