| | |
| | | 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.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; |
| | |
| | | */ |
| | | @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(); |
| | | String userHisId = SecurityFrameworkUtils.getLoginUserHisId(); |
| | | |
| | | // 同样 在预约确认时 就进入 [dev_rent] 表了 |
| | | // 在预约确认时 就进入 [dev_rent] 表了 |
| | | Long rent_id = createReqVO.getId(); |
| | | |
| | | List<Integer> jobTypeList = new ArrayList<Integer>(); |
| | |
| | | procAffinityWhenRoutineFinish( firstOnStageQueueItem.getPatId(), checkTypeDO.getAffinityCheckTypes() ); |
| | | } |
| | | |
| | | // 确费处理 |
| | | feeConfirm(firstOnStageQueueItem, userHisId, userNickname); |
| | | return CommonResult.success(rent_id); |
| | | } |
| | | |
| | |
| | | public CommonResult<Long> readyOperation(DevRentSaveReqVO createReqVO) { |
| | | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| | | String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); |
| | | |
| | | // 在预约确认时 就进入 [dev_rent] 表了 |
| | | Long rent_id = createReqVO.getId(); // dev_rent 表的ID |
| | | |
| | | // 标注设备 已领取 |
| | |
| | | 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); |
| | | } |
| | | |
| | | // 设置设备 使用中 |
| | |
| | | return devRentMapper.getRentByState(searchReqVO); |
| | | } |
| | | |
| | | // 确费处理 |
| | | // 返回值: 0 成功 1 失败 2 不用确费 |
| | | @Override |
| | | public Integer feeConfirm(Long rentId, String hisId, String userNickname, Boolean isFeeConfirmOrCancel) { |
| | | DevRentDO devRentDO = devRentMapper.selectById(rentId); |
| | | |
| | | // 查询检查类型,确定是否需要确费 |
| | | 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"); |
| | | msgHeader.setMsgVersion("3.0"); |
| | | msgHeader.setSender("ECG"); |
| | | hisFeeConfirmReqBody.setMsgHeader(msgHeader); |
| | | Item item = new Item(); |
| | | item.setItemCode( getHisCheckCode(devRentDO.getCheckType()) ); // |
| | | item.setItemStatus( isFeeConfirmOrCancel? "5" : "6" ); // 5 确费 6 取消确费 |
| | | item.setExeOrganization("47162057-2"); |
| | | item.setExeDeptName("心电科"); |
| | | item.setExeDept("心电科"); |
| | | item.setExeDoctor( hisId ); // |
| | | item.setExeDoctorName( userNickname ); // |
| | | item.setExeDateTime( getCurTimeString() ); // |
| | | ExmRequest exmRequest = new ExmRequest(); |
| | | exmRequest.setAuthorOrganization("47162057-2"); |
| | | exmRequest.setRequestId( devRentDO.getApplyNo() ); // |
| | | exmRequest.setPatientType( getPatientType(patDetails.getSource()) ); // |
| | | exmRequest.setItem(item); |
| | | hisFeeConfirmReqBody.setExmRequest(exmRequest); |
| | | 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; // 0 成功 1 失败 2 不用确费 |
| | | } |
| | | |
| | | // 标记 设备已被领取 |
| | | private Integer markDevRecieved(String devId, Long rentId, PatDetails patDetails) { |
| | | // 设备标注 已领取 |
| | |
| | | tmpQueueDO.setBedNo( bedInstallingQueueItem.getBedNo() ); // 从 [领用] 到 [安装], 可鞥在不同工位上操作 |
| | | queueMapper.updateById(tmpQueueDO); |
| | | } |
| | | } |
| | | |
| | | private void feeConfirm(QueueDO queueItem, String hisId, String userNickname, Boolean isFeeConfirmCancel) throws JsonProcessingException { |
| | | PatDetails patDetails = queueItem.getPatDetails(); |
| | | |
| | | HisFeeConfirmReqBody hisFeeConfirmReqBody = new HisFeeConfirmReqBody(); |
| | | MsgHeader msgHeader = new MsgHeader(); |
| | | msgHeader.setMsgType("ODS_2212"); |
| | | msgHeader.setMsgVersion("3.0"); |
| | | msgHeader.setSender("ECG"); |
| | | hisFeeConfirmReqBody.setMsgHeader(msgHeader); |
| | | Item item = new Item(); |
| | | item.setItemCode( getHisCheckCode(queueItem.getBookCheckType()) ); // |
| | | item.setItemStatus( isFeeConfirmCancel? "6" : "5" ); // |
| | | item.setExeOrganization("47162057-2"); |
| | | item.setExeDeptName("心电科"); |
| | | item.setExeDept("心电科"); |
| | | item.setExeDoctor( hisId ); // |
| | | item.setExeDoctorName( userNickname ); // |
| | | item.setExeDateTime( getCurTimeString() ); // |
| | | ExmRequest exmRequest = new ExmRequest(); |
| | | exmRequest.setAuthorOrganization("47162057-2"); |
| | | exmRequest.setRequestId( patDetails.getApplyNo() ); // |
| | | exmRequest.setPatientType( getPatientType(patDetails.getSource()) ); // |
| | | exmRequest.setItem(item); |
| | | hisFeeConfirmReqBody.setExmRequest(exmRequest); |
| | | HisFeeConfirmRespResult result = remoteDataService.httpFeeApi("UpdateExmRequestStatus", "ECG", "ECG", hisFeeConfirmReqBody); |
| | | result.getMsgHeader().getStatus(); |
| | | } |
| | | |
| | | private String getHisCheckCode(Integer checkType) { |