| | |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.devmanage.DeviceDO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.jobrecord.JobRecordDO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.patient.PatDetails; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.devmanage.DeviceMapper; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.jobrecord.JobRecordMapper; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import cn.lihu.jh.module.ecg.controller.admin.devrent.vo.*; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.devrent.DevRentDO; |
| | |
| | | // 检查项目.亲和性 处理逻辑 |
| | | CheckTypeDO checkTypeDO = queueServiceTxFunctions.getCheckTypeItem( firstOnStageQueueItem.getBookCheckType() ); |
| | | if (checkTypeDO.getAffinityCheckTypes().length > 0) { |
| | | List<QueueDO> affinityAffinityWaitingItems = queueMapper.getCurPatGivenCheckTypesAndStatus(firstOnStageQueueItem.getPatId(), checkTypeDO.getAffinityCheckTypes(), QueueStatusEnum.AFFINITY_WAITING.getStatus()); |
| | | if (!affinityAffinityWaitingItems.isEmpty()) { |
| | | QueueDO tmpQueueDO = affinityAffinityWaitingItems.get(0); |
| | | tmpQueueDO.setStatus(QueueStatusEnum.ONSTAGE.getStatus()); |
| | | queueMapper.updateById(tmpQueueDO); |
| | | } |
| | | procAffinityWhenRoutineFinish( firstOnStageQueueItem.getPatId(), checkTypeDO.getAffinityCheckTypes() ); |
| | | } |
| | | |
| | | return CommonResult.success(rent_id); |
| | |
| | | Long rent_id = createReqVO.getId(); // dev_rent 表的ID |
| | | |
| | | // 标注设备 已领取 |
| | | Integer ret = markDevRecieved(createReqVO.getDevId(), rent_id); |
| | | Integer ret = markDevRecieved(createReqVO.getDevId(), rent_id, createReqVO.getPatDetails()); |
| | | if (null == ret || 0 == ret) { |
| | | throw exception(DEVICE_NOT_FREE); |
| | | } |
| | |
| | | //queueMapper.updateBedQueueStatus(createReqVO.getRoomId(), createReqVO.getBedNo(), |
| | | // QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.RECEIVED.getStatus()); |
| | | |
| | | QueueDO firstOnStageQueueItem = queueMapper.getFirstItemByBedAndStatus(createReqVO.getRoomId(), createReqVO.getBedNo(), QueueStatusEnum.ONSTAGE.getStatus()); |
| | | CheckTypeDO checkTypeDO = queueServiceTxFunctions.getCheckTypeItem( firstOnStageQueueItem.getBookCheckType() ); |
| | | |
| | | // QueueStatusEnum.ONSTAGE => QueueStatusEnum.RECEIVED |
| | | firstOnStageQueueItem.setStatus(QueueStatusEnum.RECEIVED.getStatus()); // 默认状态 设置 |
| | | // 检查项目.亲和性 处理逻辑 |
| | | if (checkTypeDO.getAffinityCheckTypes().length > 0) { |
| | | List<QueueDO> affinityInstallingItems = queueMapper.getCurPatGivenCheckTypesAndStatus(firstOnStageQueueItem.getPatId(), checkTypeDO.getAffinityCheckTypes(), QueueStatusEnum.INSTALLING.getStatus()); |
| | | if (!affinityInstallingItems.isEmpty()) { |
| | | firstOnStageQueueItem.setStatus(QueueStatusEnum.AFFINITY_RECEIVED.getStatus()); |
| | | } |
| | | } |
| | | queueMapper.updateById( firstOnStageQueueItem ); |
| | | QueueDO bedOnStageQueueItem = queueMapper.getFirstItemByBedAndStatus( |
| | | createReqVO.getRoomId(), createReqVO.getBedNo(), QueueStatusEnum.ONSTAGE.getStatus() ); |
| | | CheckTypeDO checkTypeDO = queueServiceTxFunctions.getCheckTypeItem( bedOnStageQueueItem.getBookCheckType() ); |
| | | bedOnStageQueueItem.setStatus(QueueStatusEnum.RECEIVED.getStatus()); // [已领用] 状态 |
| | | |
| | | // 检查项目.亲和性 处理逻辑 |
| | | // 检查项目.亲和性 处理逻辑 , 更新 bedOnStageQueueItem |
| | | if (checkTypeDO.getAffinityCheckTypes().length > 0) { |
| | | List<QueueDO> affinityAffinityWaitingItems = queueMapper.getCurPatGivenCheckTypesAndStatus(firstOnStageQueueItem.getPatId(), checkTypeDO.getAffinityCheckTypes(), QueueStatusEnum.AFFINITY_WAITING.getStatus()); |
| | | if (!affinityAffinityWaitingItems.isEmpty()) { |
| | | QueueDO tmpQueueDO = affinityAffinityWaitingItems.get(0); |
| | | tmpQueueDO.setStatus(QueueStatusEnum.ONSTAGE.getStatus()); |
| | | queueMapper.updateById(tmpQueueDO); |
| | | } |
| | | procAffinityWhenReadyFinish(/*IN, OUT*/bedOnStageQueueItem, checkTypeDO.getAffinityCheckTypes()); |
| | | } |
| | | |
| | | queueMapper.updateById( bedOnStageQueueItem ); |
| | | return CommonResult.success(rent_id); |
| | | } |
| | | |
| | |
| | | //queueMapper.updateBedQueueStatus(createReqVO.getRoomId(), createReqVO.getBedNo(), |
| | | // QueueStatusEnum.INSTALLING.getStatus(), QueueStatusEnum.FINISH.getStatus()); |
| | | |
| | | QueueDO firstInstallingQueueItem = queueMapper.getFirstItemByBedAndStatus(createReqVO.getRoomId(), |
| | | createReqVO.getBedNo(), QueueStatusEnum.INSTALLING.getStatus()); |
| | | // QueueStatusEnum.INSTALLING => QueueStatusEnum.FINISH |
| | | firstInstallingQueueItem.setStatus(QueueStatusEnum.FINISH.getStatus()); // 默认状态 设置 |
| | | queueMapper.updateById( firstInstallingQueueItem ); |
| | | QueueDO bedInstallingQueueItem = queueMapper.getFirstItemByBedAndStatus( |
| | | createReqVO.getRoomId(), createReqVO.getBedNo(), QueueStatusEnum.INSTALLING.getStatus()); |
| | | bedInstallingQueueItem.setStatus(QueueStatusEnum.FINISH.getStatus()); // 默认状态 设置 |
| | | queueMapper.updateById( bedInstallingQueueItem ); |
| | | |
| | | // 检查项目.亲和性 处理逻辑 |
| | | CheckTypeDO checkTypeDO = queueServiceTxFunctions.getCheckTypeItem( firstInstallingQueueItem.getBookCheckType() ); |
| | | CheckTypeDO checkTypeDO = queueServiceTxFunctions.getCheckTypeItem( bedInstallingQueueItem.getBookCheckType() ); |
| | | if (checkTypeDO.getAffinityCheckTypes().length > 0) { |
| | | List<QueueDO> affinityAffinityReceivedItems = queueMapper.getCurPatGivenCheckTypesAndStatus(firstInstallingQueueItem.getPatId(), checkTypeDO.getAffinityCheckTypes(), QueueStatusEnum.AFFINITY_RECEIVED.getStatus()); |
| | | if (!affinityAffinityReceivedItems.isEmpty()) { |
| | | QueueDO tmpQueueDO = affinityAffinityReceivedItems.get(0); |
| | | tmpQueueDO.setStatus(QueueStatusEnum.INSTALLING.getStatus()); |
| | | queueMapper.updateById(tmpQueueDO); |
| | | } |
| | | procAffinityWhenInstallFinish(bedInstallingQueueItem, checkTypeDO.getAffinityCheckTypes()); |
| | | } |
| | | |
| | | return CommonResult.success(rent_id); |
| | |
| | | } |
| | | |
| | | // 标记 设备已被领取 |
| | | private Integer markDevRecieved(String devId, Long rentId) { |
| | | private Integer markDevRecieved(String devId, Long rentId, PatDetails patDetails) { |
| | | // 设备标注 已领取 |
| | | DeviceDO deviceDO = deviceMapper.getDeviceByDevId(devId); |
| | | if (null != deviceDO && DevStateEnum.FREE.isEqual(deviceDO.getState())) { |
| | | deviceDO.setState( DevStateEnum.RECEIVED.getState() ); |
| | | deviceDO.setRentId( rentId ); |
| | | deviceDO.setStateDate( LocalDate.now() ); |
| | | deviceDO.setPatDetails( patDetails ); |
| | | return deviceMapper.updateById(deviceDO); |
| | | } |
| | | |
| | |
| | | deviceDO.setState( DevStateEnum.FREE.getState() ); |
| | | deviceDO.setStateDate( LocalDate.now() ); |
| | | deviceDO.setRentId(null); |
| | | deviceDO.setPatDetails(null); |
| | | return deviceMapper.updateById(deviceDO); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | private void procAffinityWhenRoutineFinish(String patId, Integer[] affinityCheckTypes) { |
| | | // 如果存在 [亲和-排队] 亲和项,则选择 其中一个亲和项 接替其 处于 [就诊中] |
| | | List<QueueDO> affinityAffinityWaitingItems = queueMapper.getCurPatGivenCheckTypesAndStatus( |
| | | patId, affinityCheckTypes, QueueStatusEnum.AFFINITY_WAITING.getStatus()); |
| | | if (!affinityAffinityWaitingItems.isEmpty()) { |
| | | QueueDO tmpQueueDO = affinityAffinityWaitingItems.get(0); |
| | | tmpQueueDO.setStatus(QueueStatusEnum.ONSTAGE.getStatus()); |
| | | queueMapper.updateById(tmpQueueDO); |
| | | } |
| | | } |
| | | |
| | | private void procAffinityWhenReadyFinish(/*IN,OUT*/QueueDO bedOnStageQueueItem, Integer[] affinityCheckTypes) { |
| | | // 如果存在 [安装中] 亲和项,则跟随其中一个亲和项 |
| | | List<QueueDO> affinityInstallingItems = queueMapper.getCurPatGivenCheckTypesAndStatus( |
| | | bedOnStageQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.INSTALLING.getStatus()); |
| | | if (!affinityInstallingItems.isEmpty()) { |
| | | QueueDO affinityInstallingItem = affinityInstallingItems.get(0); |
| | | bedOnStageQueueItem.setStatus(QueueStatusEnum.AFFINITY_RECEIVED.getStatus()); // 亲和-领用 |
| | | bedOnStageQueueItem.setRoomId( affinityInstallingItem.getRoomId() ); |
| | | bedOnStageQueueItem.setBedNo( affinityInstallingItem.getBedNo() ); // 领用 到 安装 可能会在不同工位 |
| | | } |
| | | |
| | | // 如果存在 [亲和-排队] 亲和项,则选择 其中一个亲和项 接替其 处于 [就诊中] |
| | | List<QueueDO> affinityAffinityWaitingItems = queueMapper.getCurPatGivenCheckTypesAndStatus( |
| | | bedOnStageQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.AFFINITY_WAITING.getStatus()); |
| | | if (!affinityAffinityWaitingItems.isEmpty()) { |
| | | QueueDO tmpQueueDO = affinityAffinityWaitingItems.get(0); |
| | | tmpQueueDO.setStatus(QueueStatusEnum.ONSTAGE.getStatus()); |
| | | queueMapper.updateById( tmpQueueDO ); |
| | | } |
| | | } |
| | | |
| | | private void procAffinityWhenInstallFinish(QueueDO bedInstallingQueueItem, Integer[] affinityCheckTypes) { |
| | | List<QueueDO> affinityAffinityReceivedItems = queueMapper.getCurPatGivenCheckTypesAndStatus( |
| | | bedInstallingQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.AFFINITY_RECEIVED.getStatus()); |
| | | if (!affinityAffinityReceivedItems.isEmpty()) { |
| | | QueueDO tmpQueueDO = affinityAffinityReceivedItems.get(0); |
| | | tmpQueueDO.setStatus(QueueStatusEnum.INSTALLING.getStatus()); |
| | | tmpQueueDO.setRoomId( bedInstallingQueueItem.getRoomId() ); |
| | | tmpQueueDO.setBedNo( bedInstallingQueueItem.getBedNo() ); // 从 [领用] 到 [安装], 可鞥在不同工位上操作 |
| | | queueMapper.updateById(tmpQueueDO); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |