| | |
| | | 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.enums.AppointmentTypeEnum; |
| | | import cn.lihu.jh.module.ecg.enums.HisCheckCodeEnum; |
| | | import cn.lihu.jh.module.ecg.feign.RemoteDataService; |
| | | import cn.lihu.jh.module.ecg.service.config.EcgConfigService; |
| | | import cn.lihu.jh.module.ecg.service.devrent.ApplicationTemplate; |
| | | import cn.lihu.jh.module.ecg.service.queue.QueueService; |
| | | import cn.lihu.jh.module.ecg.service.queuesequence.QueueSequenceService; |
| | | import cn.lihu.jh.module.ecg.webservice.WebServiceClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.dao.DuplicateKeyException; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | @Resource |
| | | private AppointmentMapper appointmentMapper; |
| | | |
| | | @Autowired |
| | | private WebServiceClient webServiceClient; |
| | | |
| | | @Override |
| | | public Long createAppointment(AppointmentSaveReqVO createReqVO) { |
| | | // 插入 |
| | |
| | | // 更新 |
| | | AppointmentDO updateObj = BeanUtils.toBean(updateReqVO, AppointmentDO.class); |
| | | appointmentMapper.updateById(updateObj); |
| | | } |
| | | |
| | | @Override |
| | | public void updateAppointmentStatus(AppointmentSaveReqVO updateReqVO) { |
| | | // 校验存在 |
| | | validateAppointmentExists(updateReqVO.getId()); |
| | | |
| | | // 获取完整的预约信息 |
| | | AppointmentDO appointment = appointmentMapper.selectById(updateReqVO.getId()); |
| | | if (appointment == null) { |
| | | throw exception(APPOINTMENT_NOT_EXISTS); |
| | | } |
| | | |
| | | // 更新状态 |
| | | appointment.setStatus(updateReqVO.getStatus()); |
| | | |
| | | // 调用HIS系统更新状态 |
| | | String action = "S0405"; |
| | | ApplicationTemplate app = new ApplicationTemplate(); |
| | | String statusName = AppointmentTypeEnum.getByType(appointment.getStatus()); |
| | | String message = app.getXML( |
| | | appointment.getApplyNo(), |
| | | appointment.getStatus(), |
| | | statusName, |
| | | null, |
| | | appointment.getPatDeptCode(), |
| | | appointment.getPatDeptDesc(), |
| | | appointment.getPatWardCode(), |
| | | appointment.getPatWardDesc(), |
| | | appointment.getPatBedNo(), |
| | | appointment.getEpisodeId(), |
| | | String.valueOf(appointment.getBookSrc()), |
| | | appointment.getPatId(), |
| | | appointment.getPatName() |
| | | ); |
| | | |
| | | try { |
| | | String response = webServiceClient.callJHFWTYRK(action, "", message); |
| | | if (response.contains("更新成功")) { |
| | | // 更新本地数据库 |
| | | appointmentMapper.updateById(appointment); |
| | | |
| | | |
| | | } else { |
| | | throw exception(APPOINTMENT_UPDATE_FAIL); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("[updateAppointmentStatus][更新预约状态失败 appointment({})]", appointment, e); |
| | | throw exception(APPOINTMENT_UPDATE_FAIL); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | // 将AppointmentDO转换为AppointmentSaveReqVO并保存 |
| | | AppointmentSaveReqVO saveReqVO = BeanUtils.toBean(appointment, AppointmentSaveReqVO.class); |
| | | saveReqVO.setStatus("1"); |
| | | return createAppointment(saveReqVO); |
| | | } catch (Exception e) { |
| | | log.error("[handleAppointmentCreate][处理预约创建失败 dataMap({})]", dataMap, e); |
| | |
| | | // 解析预约时间 |
| | | LocalDateTime bookTime = LocalDateTime.parse(bookTimeStr, DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); |
| | | LocalDate bookDate = bookTime.toLocalDate(); |
| | | Integer bookTimeslot = null; |
| | | |
| | | // 获取时间段 |
| | | try { |
| | | // String timeRange = (String) ((Map<String, Object>) actAppointment.get("ZDY")).get("time");这行如果是更新操作的时候,有可能报空指针(但不影响,可以不用管) |
| | | String timeRange = (String) ((Map<String, Object>) actAppointment.get("ZDY")).get("time"); |
| | | String[] time1 = timeRange.split(" "); |
| | | String[] times = time1[1].split("-"); |
| | | String startTime = times[0].trim(); |
| | | String endTime = times[1].trim(); |
| | | |
| | | // 转换时间段格式为hhmmhhmm |
| | | int bookTimeslot = Integer.parseInt(startTime.replace(":", "")) * 10000 + Integer.parseInt(endTime.replace(":", "")); |
| | | |
| | | bookTimeslot = Integer.parseInt(startTime.replace(":", "")) * 10000 + Integer.parseInt(endTime.replace(":", "")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // 更新预约信息 |
| | | appointment.setBookDate(bookDate); |
| | | appointment.setBookTimeslot(bookTimeslot); |
| | | appointment.setBookTime(bookTime); |
| | | appointment.setBookSrc(Integer.parseInt(bookSrc)); |
| | | appointment.setStatus((String) ((Map<String, Object>) actAppointment.get("ZDY")).get("statusCode")); |
| | | |
| | | // 保存更新 |
| | | appointmentMapper.updateById(appointment); |