| | |
| | | import cn.lihu.jh.framework.common.pojo.CommonResult; |
| | | import cn.lihu.jh.framework.security.core.util.SecurityFrameworkUtils; |
| | | import cn.lihu.jh.module.ecg.controller.admin.jobrecord.vo.JobRecordSaveReqVO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.appointment.AppointmentDO; |
| | | 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.appointment.AppointmentMapper; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.checktype.CheckTypeMapper; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.devmanage.DeviceMapper; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.jobrecord.JobRecordMapper; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.queue.QueueMapper; |
| | |
| | | import cn.lihu.jh.module.ecg.enums.DevStateEnum; |
| | | import cn.lihu.jh.module.ecg.enums.QueueStatusEnum; |
| | | import cn.lihu.jh.module.ecg.feign.*; |
| | | import cn.lihu.jh.module.ecg.feign.dto.AppointmentExternal; |
| | | import cn.lihu.jh.module.ecg.service.queue.QueueServiceTxFunctions; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.dataformat.xml.XmlMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.Console; |
| | | import java.time.LocalDate; |
| | | 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; |
| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.lihu.jh.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| | | import static cn.lihu.jh.framework.common.util.date.DateUtils.getCurTimeString; |
| | | import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*; |
| | | |
| | |
| | | */ |
| | | @Service |
| | | @Validated |
| | | @Slf4j |
| | | public class DevRentServiceImpl implements DevRentService { |
| | | |
| | | @Resource |
| | | QueueServiceTxFunctions queueServiceTxFunctions; |
| | | |
| | | @Resource |
| | | private RemoteDataService remoteDataService; |
| | | private FeeConfirmFeignService feeConfirmFeignService; |
| | | |
| | | @Resource |
| | | private DevRentMapper devRentMapper; |
| | |
| | | |
| | | @Resource |
| | | QueueMapper queueMapper; |
| | | |
| | | @Resource |
| | | CheckTypeMapper checkTypeMapper; |
| | | |
| | | @Override |
| | | public CommonResult<Long> registerOperation(DevRentSaveReqVO createReqVO) { |
| | |
| | | String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); |
| | | Long rent_id = createReqVO.getId(); |
| | | |
| | | // 对于已有领用,但是装机时使用的不是已领用设备,需释放 源领用 设备 |
| | | DevRentDO devRentDO = getDevRent(rent_id); |
| | | |
| | | // 对于已有领用,但是装机时使用的不是已领用设备,报错 |
| | | if ( null != devRentDO.getDevId() && !createReqVO.getDevId().equals(devRentDO.getDevId()) ) { |
| | | markDevFree( devRentDO.getDevId(), rent_id); |
| | | throw exception(DEVICE_NOT_PAT_RECEIVED); |
| | | } |
| | | |
| | | // 设置设备 使用中 |
| | |
| | | } |
| | | |
| | | // 确费处理 |
| | | // 返回值: 0 成功 1 失败 2 不用确费 |
| | | @Override |
| | | public Integer feeConfirm(Long rentId, String hisId, String userNickname, Boolean isFeeConfirmOrCancel) { |
| | | DevRentDO devRentDO = devRentMapper.selectById(rentId); |
| | | PatDetails patDetails = devRentDO.getPatDetails(); |
| | | |
| | | // 查询检查类型,确定是否需要确费 |
| | | CheckTypeDO checkTypeDO = checkTypeMapper.getCheckTypeByValue(devRentDO.getCheckType()); |
| | | if (0 == checkTypeDO.getExpenseRecognition()) { |
| | | return 2; |
| | | } |
| | | |
| | | PatDetails patDetails = devRentDO.getPatDetails(); |
| | | HisFeeConfirmReqBody hisFeeConfirmReqBody = new HisFeeConfirmReqBody(); |
| | | MsgHeader msgHeader = new MsgHeader(); |
| | | msgHeader.setMsgType("ODS_2212"); |
| | |
| | | item.setExeDateTime( getCurTimeString() ); // |
| | | ExmRequest exmRequest = new ExmRequest(); |
| | | exmRequest.setAuthorOrganization("47162057-2"); |
| | | exmRequest.setRequestId( patDetails.getApplyNo() ); // |
| | | exmRequest.setRequestId( devRentDO.getApplyNo() ); // |
| | | exmRequest.setPatientType( getPatientType(patDetails.getSource()) ); // |
| | | exmRequest.setItem(item); |
| | | hisFeeConfirmReqBody.setExmRequest(exmRequest); |
| | | HisFeeConfirmRespResult result = remoteDataService.httpFeeApi("UpdateExmRequestStatus", "ECG", "ECG", hisFeeConfirmReqBody); |
| | | HisFeeConfirmRespResult result = feeConfirmFeignService.httpFeeApi("UpdateExmRequestStatus", "ECG", "ECG", hisFeeConfirmReqBody); |
| | | log.info( result.getMsgHeader().getStatus() ); |
| | | Integer returnValue = result.getMsgHeader().getStatus().equals("true") ? 0 : 1; |
| | | if (0 == returnValue) { |
| | | devRentMapper.setPaid(rentId, isFeeConfirmOrCancel ? 1 : 0); |
| | | } |
| | | return returnValue; |
| | | return returnValue; // 0 成功 1 失败 2 不用确费 |
| | | } |
| | | |
| | | // 标记 设备已被领取 |
| | |
| | | private void procAffinityWhenRoutineFinish(String patId, Integer[] affinityCheckTypes) { |
| | | // 如果存在 [亲和-排队] 亲和项,则选择 其中一个亲和项 接替其 处于 [就诊中] |
| | | List<QueueDO> affinityAffinityWaitingItems = queueMapper.getCurPatGivenCheckTypesAndStatus( |
| | | patId, affinityCheckTypes, QueueStatusEnum.AFFINITY_WAITING.getStatus()); |
| | | patId, affinityCheckTypes, QueueStatusEnum.AFFINITY.getStatus()); |
| | | if (!affinityAffinityWaitingItems.isEmpty()) { |
| | | QueueDO tmpQueueDO = affinityAffinityWaitingItems.get(0); |
| | | tmpQueueDO.setStatus(QueueStatusEnum.ONSTAGE.getStatus()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 领用完成,主动寻求依附 |
| | | */ |
| | | private void procAffinityWhenReadyFinish(/*IN,OUT*/QueueDO bedOnStageQueueItem, Integer[] affinityCheckTypes) { |
| | | // 如果存在 [安装中] 亲和项,则跟随其中一个亲和项 |
| | | List<QueueDO> affinityInstallingItems = queueMapper.getCurPatGivenCheckTypesAndStatus( |
| | | bedOnStageQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.INSTALLING.getStatus()); |
| | | // 如果存在 [安装中] [安装过号] [安装召回] 能被依附的检查项,则依附到其中一个检查项 |
| | | List<QueueDO> affinityInstallingItems = queueMapper.getCurPatGivenCheckTypesAndStatusList( |
| | | bedOnStageQueueItem.getPatId(), affinityCheckTypes, |
| | | List.of(QueueStatusEnum.INSTALLING.getStatus(), QueueStatusEnum.PASSED_INSTALL.getStatus(), |
| | | QueueStatusEnum.RECALLED_INSTALL.getStatus())); |
| | | if (!affinityInstallingItems.isEmpty()) { |
| | | QueueDO affinityInstallingItem = affinityInstallingItems.get(0); |
| | | bedOnStageQueueItem.setStatus(QueueStatusEnum.AFFINITY_RECEIVED.getStatus()); // 亲和-领用 |
| | | bedOnStageQueueItem.setStatus(QueueStatusEnum.AFFINITY_INSTALL.getStatus()); // 亲和-领用 |
| | | bedOnStageQueueItem.setRoomId( affinityInstallingItem.getRoomId() ); |
| | | bedOnStageQueueItem.setBedNo( affinityInstallingItem.getBedNo() ); // 领用 到 安装 可能会在不同工位 |
| | | } |
| | | |
| | | // 如果存在 [亲和-排队] 亲和项,则选择 其中一个亲和项 接替其 处于 [就诊中] |
| | | List<QueueDO> affinityAffinityWaitingItems = queueMapper.getCurPatGivenCheckTypesAndStatus( |
| | | bedOnStageQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.AFFINITY_WAITING.getStatus()); |
| | | bedOnStageQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.AFFINITY.getStatus()); |
| | | if (!affinityAffinityWaitingItems.isEmpty()) { |
| | | QueueDO tmpQueueDO = affinityAffinityWaitingItems.get(0); |
| | | tmpQueueDO.setStatus(QueueStatusEnum.ONSTAGE.getStatus()); |
| | |
| | | } |
| | | } |
| | | |
| | | // 如果存在 [亲和-领用] 亲和项,则选择 其中一个亲和项 接替其 处于 [安装中] |
| | | private void procAffinityWhenInstallFinish(QueueDO bedInstallingQueueItem, Integer[] affinityCheckTypes) { |
| | | List<QueueDO> affinityAffinityReceivedItems = queueMapper.getCurPatGivenCheckTypesAndStatus( |
| | | bedInstallingQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.AFFINITY_RECEIVED.getStatus()); |
| | | bedInstallingQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.AFFINITY_INSTALL.getStatus()); |
| | | if (!affinityAffinityReceivedItems.isEmpty()) { |
| | | QueueDO tmpQueueDO = affinityAffinityReceivedItems.get(0); |
| | | tmpQueueDO.setStatus(QueueStatusEnum.INSTALLING.getStatus()); |