eight
2024-11-13 cac7f142c909d712d6d49c45b0d4efbdef673e48
过号 - 检查项目.亲和性
已修改6个文件
129 ■■■■ 文件已修改
jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java
@@ -27,6 +27,7 @@
    ErrorCode QUEUE_BED_EXIST = new ErrorCode(1_010_003_002, "工位队列已存在");
    ErrorCode QUEUE_HAVE_PATIENT = new ErrorCode(1_010_003_003, "队列中有患者");
    ErrorCode QUEUE_NOT_READY_PATIENT = new ErrorCode(1_010_003_004, "没有准备中的患者");
    ErrorCode QUEUE_RECALL_INSTALL_NOT_CUR_ROOM = new ErrorCode(1_010_003_005, "不能召回其他诊室的安装患者");
    ErrorCode PATIENT_NOT_EXISTS = new ErrorCode(1_010_004_000, "患者不存在");
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java
@@ -28,8 +28,7 @@
import static cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants.SUCCESS;
import static cn.lihu.jh.framework.common.pojo.CommonResult.error;
import static cn.lihu.jh.framework.common.pojo.CommonResult.success;
import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.ECG_INNER_ERROR;
import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.PATIENT_NOT_EXISTS;
import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*;
@Tag(name = "管理后台 - 医生叫号")
@RestController
@@ -385,9 +384,12 @@
    public CommonResult<String> recallPatient(
            @RequestParam("roomId") Long roomId,
            @RequestParam("bedNo") String bedNo,
            @RequestParam("patId") String patId )
            @RequestParam("patId") String patId,
            @RequestParam("checkType") Integer checkType,
            @RequestParam("roomId_operator") Long roomId_operator,
            @RequestParam("bedNo_operator") String bedNo_operator )
    {
        Integer result = queueService.recallPatient(roomId, bedNo, patId);
        Integer result = queueService.recallPatient(roomId, bedNo, patId, checkType);
        if (null == result || 0 == result)
            return error(PATIENT_NOT_EXISTS);
@@ -399,13 +401,20 @@
    @Parameter(name = "roomId", description = "诊室编号", required = true, example = "116")
    @Parameter(name = "bedNo", description = "工位编号", required = true, example = "B2")
    @Parameter(name = "patId", description = "患者编号", required = true, example = "B2")
    @Parameter(name = "checkType", description = "检查类型", required = true, example = "100")
    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
    public CommonResult<String> recallInstallPatient(
            @RequestParam("roomId") Long roomId,
            @RequestParam("bedNo") String bedNo,
            @RequestParam("patId") String patId )
            @RequestParam("patId") String patId,
            @RequestParam("checkType") Integer checkType,
            @RequestParam("roomId_operator") Long roomId_operator,
            @RequestParam("bedNo_operator") String bedNo_operator )
    {
        Integer result = queueService.recallInstallPatient(roomId, bedNo, patId);
        if (roomId != roomId_operator)
            return error(QUEUE_RECALL_INSTALL_NOT_CUR_ROOM);
        Integer result = queueService.recallInstallPatient(roomId, bedNo, patId, checkType, bedNo_operator);
        if (null == result || 0 == result)
            return error(PATIENT_NOT_EXISTS);
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java
@@ -174,6 +174,15 @@
            "</script>" )
    QueueDO getFirstItemByRoomAndStatus(@Param("roomId")Long roomId, @Param("curStatusList")List<Integer> curStatusList);
/*
    @Select("select * from lihu.queue where room_id = #{roomId} and bed_no = #{bedNo} " +
            " and status = #{curStatus} and pat_id = #{patId} and book_check_type=#{checkType}")
    QueueDO XXX(@Param("roomId")Long roomId, @Param("bedNo")String bedNo,
                                       @Param("patId")String patId, @Param("checkType")Integer checkType,
                                       @Param("curStatus")Integer curStatus);
*/
    @Update("update lihu.queue set status = #{newStatus} where status = #{curStatus} and seq_num = \n" +
            "(select a.min_seq_num from \n" +
            " (select min(seq_num) as min_seq_num from lihu.queue where room_id = #{roomId} and bed_no = #{bedNo} and status = #{curStatus}) a )")
@@ -220,14 +229,16 @@
    // 常规检查 或 领用 的患者召回, 原工位处理
    @Update("update lihu.queue set status = #{newStatus}, passed = 1 " +
            " where room_id = #{roomId} and bed_no = #{bedNo} and status = #{curStatus} and pat_id = #{patId} ")
    Integer recallPassedPatient(@Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("patId")String patId,
            " where room_id = #{roomId} and bed_no = #{bedNo} and status = #{curStatus} and pat_id = #{patId} and book_check_type=#{checkType}")
    Integer recallPassedPatient(@Param("roomId")Long roomId, @Param("bedNo")String bedNo,
                                @Param("patId")String patId, @Param("checkType")Integer checkType,
                                @Param("curStatus")Integer curStatus, @Param("newStatus")Integer newStatus);
    // 装机医生 允许抢占 本科室 [安装过号] 的患者
    @Update("update lihu.queue set status = #{newStatus}, bed_no = #{bedNo}, passed = 1 " +
            " where room_id = #{roomId} and status = #{curStatus} and pat_id = #{patId} ")
    Integer recallPassedInstallPatient(@Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("patId")String patId,
            " where room_id = #{roomId} and status = #{curStatus} and pat_id = #{patId} and book_check_type=#{checkType}")
    Integer recallPassedInstallPatient(@Param("roomId")Long roomId, @Param("bedNo")String bedNo,
                                       @Param("patId")String patId, @Param("checkType")Integer checkType,
                                @Param("curStatus")Integer curStatus, @Param("newStatus")Integer newStatus);
    @Update("update lihu.queue set jump_flag = #{jumped} " +
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java
@@ -124,9 +124,9 @@
    PatientStatisticVO getBedDevInstallStatistic(Long roomId, String bedNo);
    Integer recallPatient(Long roomId, String bedNo, String patId);
    Integer recallPatient(Long roomId, String bedNo, String patId, Integer checkType);
    Integer recallInstallPatient(Long roomId, String bedNo, String patId);
    Integer recallInstallPatient(Long roomId, String bedNo, String patId, Integer checkType, String bedNo_operator);
    Integer patientJump(String patId, Byte jumped );
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
@@ -523,18 +523,26 @@
    }
    @Override
    public Integer recallPatient(Long roomId, String bedNo, String patId) {
        Integer updateNum = queueMapper.recallPassedPatient(roomId, bedNo, patId,
    public Integer recallPatient(Long roomId, String bedNo, String patId, Integer checkType) {
        Integer updateNum = queueMapper.recallPassedPatient(roomId, bedNo, patId, checkType,
                QueueStatusEnum.PASSED.getStatus(), QueueStatusEnum.RECALLED.getStatus());
        // 检查项目.亲和性 不需要在这里处理
        // 会在 HurryUpOnBed 里面处理 检查项目.亲和性
        startHurryUpOneBed(roomId, bedNo);
        return updateNum;
    }
    @Override
    public Integer recallInstallPatient(Long roomId, String bedNo, String patId) {
        Integer updateNum = queueMapper.recallPassedInstallPatient(roomId, bedNo, patId,
    public Integer recallInstallPatient(Long roomId, String bedNo, String patId, Integer checkType, String bedNo_operator) {
        Integer updateNum = queueMapper.recallPassedInstallPatient(roomId, bedNo_operator, patId, checkType,
                QueueStatusEnum.PASSED_INSTALL.getStatus(), QueueStatusEnum.RECALLED_INSTALL.getStatus());
        // 安装工位 不设计 优先队列
        // 检查项目.亲和性 处理
        updateAffinityItemsWhenInstallRecall(patId, checkType, bedNo_operator);
        // 安装工位 不涉及 优先队列
        //startHurryUpOneBed(roomId, bedNo);
        return updateNum;
    }
@@ -634,4 +642,17 @@
        return roomDO;
    }
    private void updateAffinityItemsWhenInstallRecall(String patId, Integer checkType, String bedNo_operator) {
        CheckTypeDO checkTypeDO = queueServiceTxFunctions.getCheckTypeItem( checkType );
        if ( checkTypeDO.getAffinityCheckTypes().length > 0) {
            List<QueueDO> affinityItems = queueMapper.getCurPatGivenCheckTypesAndStatus(patId,
                    checkTypeDO.getAffinityCheckTypes(), QueueStatusEnum.AFFINITY_RECEIVED.getStatus());
            for (int i = 0; i < affinityItems.size(); i++) {
                QueueDO queueItem = affinityItems.get(i);
                queueItem.setBedNo( bedNo_operator );
                //queueItem.setSeqNum( preemptQueueItem.getSeqNum() );  // 装机时 内部序号不变
                queueMapper.updateById(queueItem);
            }
        }
    }
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java
@@ -401,11 +401,15 @@
                    bedQueueBO.getRoomId(),
                    bedQueueBO.getRoomName(),
                    bedQueueBO.getBedNo(),
                    curSeqNum.get() + 1,
                    curSeqNum.get() + 1,  // 过号回来,排到当前的下一位
                    QueueStatusEnum.RECALLED.getStatus(), // 不需要处理 [安装召回], 原因: 安装工位 没有优先队列
                    QueueStatusEnum.READY.getStatus());
            if (null == updateNum || 0 == updateNum)
                break;
            // 召回 [过号] 患者后,处理 检查项目.亲和性 逻辑
            QueueDO recalledQueueItem = queueMapper.getQueueItemBySeqNum(curSeqNum.get() + 1);
            updateAffinityItemsWhenRecalled( recalledQueueItem );
            curSeqNum.getAndIncrement();
@@ -455,21 +459,8 @@
            }
            // 抢到排队患者后,处理 检查项目.亲和性 逻辑
            QueueDO queueDO = queueMapper.getQueueItemBySeqNum(curSeqNum.get() + 1);
            CheckTypeDO checkTypeDO = getCheckTypeItem( queueDO.getBookCheckType() );
            if ( checkTypeDO.getAffinityCheckTypes().length > 0) {
                List<QueueDO> affinityItems = queueMapper.getCurPatGivenCheckTypesAndStatus(queueDO.getPatId(),
                        checkTypeDO.getAffinityCheckTypes(), QueueStatusEnum.WAITING.getStatus());
                for (int i = 0; i < affinityItems.size(); i++) {
                    QueueDO queueItem = affinityItems.get(i);
                    queueItem.setStatus(QueueStatusEnum.AFFINITY_WAITING.getStatus()); //改变 排队状态
                    queueItem.setRoomId(queueDO.getRoomId());
                    queueItem.setRoomName(queueDO.getRoomName());
                    queueItem.setBedNo(queueDO.getBedNo());
                    queueItem.setSeqNum(curSeqNum.get() + 1);  // 使用同一个 内部序号
                    queueMapper.updateById(queueItem);
                }
            }
            QueueDO preemptQueueItem = queueMapper.getQueueItemBySeqNum(curSeqNum.get() + 1);
            updateAffinityItemsWhenPreempt( preemptQueueItem );
            curSeqNum.getAndIncrement();
@@ -516,6 +507,36 @@
        log.info(" opening " + openingFlag.get() + " " + monitorInfoVO.getQueueNum() + " " + monitorInfoVO.getActiveQueueNum() + " " + monitorInfoVO.getCheckTypeBedInfo().toString() );
    }
    private void updateAffinityItemsWhenPreempt(QueueDO preemptQueueItem) {
        CheckTypeDO checkTypeDO = getCheckTypeItem( preemptQueueItem.getBookCheckType() );
        if ( checkTypeDO.getAffinityCheckTypes().length > 0) {
            List<QueueDO> affinityItems = queueMapper.getCurPatGivenCheckTypesAndStatus(preemptQueueItem.getPatId(),
                    checkTypeDO.getAffinityCheckTypes(), QueueStatusEnum.WAITING.getStatus());
            for (int i = 0; i < affinityItems.size(); i++) {
                QueueDO queueItem = affinityItems.get(i);
                queueItem.setStatus(QueueStatusEnum.AFFINITY_WAITING.getStatus()); //改变 排队状态
                queueItem.setRoomId(preemptQueueItem.getRoomId());
                queueItem.setRoomName(preemptQueueItem.getRoomName());
                queueItem.setBedNo(preemptQueueItem.getBedNo());
                queueItem.setSeqNum( preemptQueueItem.getSeqNum());  // 使用同一个 内部序号
                queueMapper.updateById(queueItem);
            }
        }
    }
    private void updateAffinityItemsWhenRecalled(QueueDO recalledQueueItem) {
        CheckTypeDO checkTypeDO = getCheckTypeItem( recalledQueueItem.getBookCheckType() );
        if ( checkTypeDO.getAffinityCheckTypes().length > 0) {
            List<QueueDO> affinityItems = queueMapper.getCurPatGivenCheckTypesAndStatus(recalledQueueItem.getPatId(),
                    checkTypeDO.getAffinityCheckTypes(), QueueStatusEnum.AFFINITY_WAITING.getStatus());
            for (int i = 0; i < affinityItems.size(); i++) {
                QueueDO queueItem = affinityItems.get(i);
                queueItem.setSeqNum( recalledQueueItem.getSeqNum() );  // 召回后,原内部序号更新
                queueMapper.updateById(queueItem);
            }
        }
    }
    private Integer getBedReadyMax(Long roomId, String bedNo) {
        RoomDO roomDO = roomMapper.getRoom(roomId, bedNo);
        Integer[] checkTypes = roomDO.getCheckTypes();