| | |
| | | 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 |
| | |
| | | @Override |
| | | public List<AppointmentDO> queryAndCreateAppointmentByPatId(String patCode) { |
| | | // 从医院平台查询 |
| | | List<AppointmentDO> appointmentExtermalList = getAppointmentExtermal(patCode); |
| | | List<AppointmentDO> appointmentExtermalList = appointmentMapper.getCurrentCode(patCode); |
| | | |
| | | for (int appointmentIndex = 0; appointmentIndex < appointmentExtermalList.size(); appointmentIndex++) { |
| | | AppointmentDO appointmentExtermal = appointmentExtermalList.get(appointmentIndex); |
| | |
| | | |
| | | Optional.ofNullable(encounter.get("location")).map(location -> (Map<String, Object>) location).map(location -> (Map<String, Object>) location.get("serviceDeliveryLocation")).map(serviceDeliveryLocation -> (Map<String, Object>) serviceDeliveryLocation.get("location")).map(location -> (Map<String, Object>) location.get("id")).map(id -> (Map<String, Object>) id.get("item")).map(item -> (String) item.get("extension")).ifPresent(appointment::setPatBedNo); |
| | | |
| | | Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject")).map(subject -> (Map<String, Object>) subject.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("zdy")).map(zdy -> { |
| | | Object ISDN = zdy.get("ISDN"); |
| | | if (ISDN != null) { |
| | | return ISDN.toString(); |
| | | } |
| | | return null; |
| | | }).ifPresent(appointment::setTolerance); |
| | | |
| | | // 设置患者来源类型 |
| | | Optional.ofNullable(encounter.get("code")).map(code -> (Map<String, Object>) code).map(code -> (String) code.get("code")).map(Integer::parseInt).ifPresent(appointment::setPatSrc); |
| | |
| | | Optional.ofNullable(encounter.get("subject")).map(subject -> (Map<String, Object>) subject).map(subject -> (Map<String, Object>) subject.get("patient")).map(patient -> (Map<String, Object>) patient.get("patientPerson")).ifPresent(patientPerson -> { |
| | | // 设置患者ID |
| | | Optional.ofNullable(encounter.get("subject")).map(subject -> (Map<String, Object>) subject).map(subject -> (Map<String, Object>) subject.get("patient")).map(patient -> (Map<String, Object>) patient.get("id")).map(id -> (Map<String, Object>) id).map(id -> (List<?>) id.get("item")).filter(items -> items.size() > 1).map(items -> (Map<String, Object>) items.get(1)).map(item -> (String) item.get("extension")).ifPresent(appointment::setPatId); |
| | | |
| | | // 设置患者门诊号 |
| | | Optional.ofNullable(encounter.get("subject")).map(subject -> (Map<String, Object>) subject).map(subject -> (Map<String, Object>) subject.get("patient")).map(patient -> (Map<String, Object>) patient.get("id")).map(id -> (Map<String, Object>) id).map(id -> (List<?>) id.get("item")).filter(items -> items.size() > 1).map(items -> (Map<String, Object>) items.get(2)).map(item -> (String) item.get("extension")).ifPresent(appointment::setOutpatientNo); |
| | | |
| | | // 设置患者住院号 |
| | | Optional.ofNullable(encounter.get("subject")).map(subject -> (Map<String, Object>) subject).map(subject -> (Map<String, Object>) subject.get("patient")).map(patient -> (Map<String, Object>) patient.get("id")).map(id -> (Map<String, Object>) id).map(id -> (List<?>) id.get("item")).filter(items -> items.size() > 1).map(items -> (Map<String, Object>) items.get(2)).map(item -> (String) item.get("extension")).ifPresent(appointment::setHospitalNo); |
| | | |
| | | // 设置患者姓名 |
| | | Optional.ofNullable(patientPerson.get("name")).map(name -> (Map<String, Object>) name).map(name -> (Map<String, Object>) name.get("item")).map(item -> (Map<String, Object>) item.get("part")).map(part -> (String) part.get("value")).ifPresent(appointment::setPatName); |
| | |
| | | |
| | | // 设置患者身份证号 |
| | | Optional.ofNullable(patientPerson.get("id")).map(id -> (Map<String, Object>) id).map(id -> (List<?>) id.get("item")).filter(items -> !items.isEmpty()).map(items -> (Map<String, Object>) items.get(0)).map(item -> (String) item.get("extension")).ifPresent(appointment::setPatIdentityId); |
| | | |
| | | //患者医保卡 |
| | | Optional.ofNullable(patientPerson.get("id")).map(id -> (Map<String, Object>) id).map(id -> (List<?>) id.get("item")).filter(items -> !items.isEmpty()).map(items -> (Map<String, Object>) items.get(1)).map(item -> (String) item.get("extension")).ifPresent(appointment::setMedicalCard); |
| | | }); |
| | | |
| | | // 设置科室和病区信息 |
| | |
| | | |
| | | |
| | | // 从dataMap中提取申请单号 |
| | | String status = Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject")).map(subject -> (Map<String, Object>) subject.get("placerGroup")).map(placerGroup -> (Map<String, Object>) placerGroup.get("component2")).map(component2 -> (Map<String, Object>) component2.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("component1")).map(component1 -> (Map<String, Object>) component1.get("processStep")).map(processStep -> (Map<String, Object>) processStep.get("code")).map(code -> (Map<String, Object>) code.get("displayName")).map(displayName -> (String) displayName.get("value")).orElseThrow(() -> exception(APPOINTMENT_CREATE_FAIL)); |
| | | // String status = Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject")).map(subject -> (Map<String, Object>) subject.get("placerGroup")).map(placerGroup -> (Map<String, Object>) placerGroup.get("component2")).map(component2 -> (Map<String, Object>) component2.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("component1")).map(component1 -> (Map<String, Object>) component1.get("processStep")).map(processStep -> (Map<String, Object>) processStep.get("code")).map(code -> (Map<String, Object>) code.get("displayName")).map(displayName -> (String) displayName.get("value")).orElseThrow(() -> exception(APPOINTMENT_CREATE_FAIL)); |
| | | String status = Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject")).map(subject -> (Map<String, Object>) subject.get("placerGroup")).map(placerGroup -> (Map<String, Object>) placerGroup.get("component2")).map(component2 -> (Map<String, Object>) component2.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("component1")).map(component1 -> (Map<String, Object>) component1.get("processStep")).map(processStep -> (Map<String, Object>) processStep.get("code")).map(code -> (String) code.get("code")).orElseThrow(() -> exception(APPOINTMENT_CREATE_FAIL)); |
| | | |
| | | existingAppointment.setStatus(status); |
| | | // 将AppointmentDO转换为AppointmentSaveReqVO并更新 |
| | |
| | | // 解析预约时间 |
| | | LocalDateTime bookTime = LocalDateTime.parse(bookTimeStr, DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); |
| | | LocalDate bookDate = bookTime.toLocalDate(); |
| | | Integer bookTimeslot = null; |
| | | |
| | | // 获取时间段 |
| | | 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(":", "")); |
| | | |
| | | 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 |
| | | 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); |