| | |
| | | import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueueSaveReqVO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO; |
| | | 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.feign.RemoteDataService; |
| | | import cn.lihu.jh.module.ecg.feign.RestApiReqBodyVo; |
| | | import cn.lihu.jh.module.ecg.feign.RestApiResult; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.lihu.jh.framework.common.pojo.CommonResult.error; |
| | |
| | | */ |
| | | @Override |
| | | public List<AppointmentDO> queryAndCreateAppointmentByPatId(String patCode) { |
| | | // 先从医院平台查询 |
| | | // 从医院平台查询 |
| | | List<AppointmentDO> appointmentExtermalList = getAppointmentExtermal( patCode ); |
| | | |
| | | for ( int appointmentIndex = 0; appointmentIndex < appointmentExtermalList.size(); appointmentIndex++ ) { |
| | |
| | | if (null == appointmentExtermal ) |
| | | continue; |
| | | |
| | | // 从DB查到预约,是否已经存在 |
| | | // 从DB查询预约,是否已经存在 |
| | | AppointmentDO appointmentDO = appointmentMapper.getByPatAndCheckTypeAndBookDate(appointmentExtermal.getPatId(), appointmentExtermal.getBookCheckType(), appointmentExtermal.getBookDate()); |
| | | if (null == appointmentDO) { |
| | | appointmentMapper.insert(appointmentExtermal); |
| | | } else { |
| | | appointmentExtermal.setId( appointmentDO.getId() ); // 确保 返回值保护 appointment id |
| | | appointmentExtermal.setId( appointmentDO.getId() ); // 确保 返回值包含 appointment id |
| | | } |
| | | } |
| | | |
| | | // 查询[queue表]补充 book_seq_num 到返回值中 |
| | | if (!appointmentExtermalList.isEmpty()) { |
| | | List<Long> appointIdlist = appointmentExtermalList.stream().map(appointmentDO -> appointmentDO.getId()).toList(); |
| | | List<QueueDO> simpleQueueDOList = queueService.selectBookSeqNumByAppointIdList(appointIdlist); |
| | | if (!simpleQueueDOList.isEmpty()) { |
| | | Map<Long, Integer> mapAppointIdVsBookSeqNo = simpleQueueDOList.stream().collect(Collectors.toMap(QueueDO::getAppointId, QueueDO::getBookSeqNum)); |
| | | appointmentExtermalList.forEach(appointmentExterma -> appointmentExterma.setBookSeqNum(mapAppointIdVsBookSeqNo.get(appointmentExterma.getId()))); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | try { |
| | | QueueSaveReqVO queueSaveReqVO = new QueueSaveReqVO(); |
| | | queueSaveReqVO.setAppointId(appointment.getId()); |
| | | queueSaveReqVO.setPatId(appointment.getPatId()); |
| | | queueSaveReqVO.setPatName(appointment.getPatName()); |
| | | queueSaveReqVO.setPatGender(appointment.getPatGender()); |