/** * Function used to retrieve the OrderInvestigation Booking VO */ public OrderInvestigationBookingWithStatusVo getOrderInvestigationBooking(OrderInvestigationRefVo investigation) { if (investigation == null || !investigation.getID_OrderInvestigationIsNotNull()) return null; return OrderInvestigationBookingWithStatusVoAssembler.create((OrderInvestigation) getDomainFactory().getDomainObject(OrderInvestigation.class, investigation.getID_OrderInvestigation())); }
/** * Function used to cancel the appointment / or associate with the new investigation (or first investigation in order if multiple are selected for order) */ private void changeInvestigationAppointment(OcsOrderVo newOrder, OrderInvestigationLiteVo investigationToAmend) throws StaleObjectException { // Get appointment linked to order investigation if any OrderInvWithStatusApptVo orderInvAppointment = domain.getOrderInvestigationAppointment(investigationToAmend); // Check for OrderInvestigationAppointment record if (orderInvAppointment == null) return; // Get appointment Booking_AppointmentVo appointment = orderInvAppointment.getAppointment(); // Check for appointment record if (appointment == null) return; // Check if the modality was changed for the investigation to be amended if (hasModalityChanged(newOrder, investigationToAmend)) { // Check current status of the appointment - see if it was cancelled already // If the appointment wasn't cancelled - cancel it now if (!Status_Reason.CANCELLED.equals(appointment.getApptStatus())) { cancelAppointment(appointment); // OK to do this as this function should only be called in CARE UK project domain.updateCatsReferralCancelStatus(form.getGlobalContext().RefMan.getCatsReferral()); } } else { // Update investigation - with first investigation, else if (newOrder.getInvestigationsIsNotNull() && newOrder.getInvestigations().size() > 0) { OrderInvestigationBookingWithStatusVo orderInvestigationBooking = domain.getOrderInvestigationBooking(newOrder.getInvestigations().get(0)); orderInvestigationBooking.setAppointmentDate(new DateTime(appointment.getAppointmentDate(), appointment.getApptStartTime())); orderInvestigationBooking.setDisplayDateTime(new DateTime(appointment.getAppointmentDate(), appointment.getApptStartTime())); orderInvAppointment.setOrderInvestigation(orderInvestigationBooking); // Remove AppointmentDate and AppointmentTime from investigationToAmend investigationToAmend.setAppointmentDate(null); // Create status OrderedInvestigationStatusVo status = new OrderedInvestigationStatusVo(); status.setChangeDateTime(new DateTime()); status.setChangeUser(domain.getHcpLiteUser() != null ? ((HcpLiteVo) domain.getHcpLiteUser()).getIMosName() : null); status.setProcessedDateTime(new DateTime()); status.setOrdInvStatus(OrderInvStatus.ORDERED); orderInvestigationBooking.setOrdInvCurrentStatus(status); if (orderInvestigationBooking.getOrdInvStatusHistory() == null) orderInvestigationBooking.setOrdInvStatusHistory(new OrderedInvestigationStatusVoCollection()); orderInvestigationBooking.getOrdInvStatusHistory().add(status); } orderInvAppointment.validate(); domain.updateOrderInvestigationAppointment(orderInvAppointment, investigationToAmend); } }
/** * Function used to cancel the appointment / or associate with the new investigation (or first investigation in order if multiple are selected for order) * @throws DomainInterfaceException */ private void changeInvestigationAppointment(OcsOrderVo newOrder, OrderInvestigationLiteVo investigationToAmend) throws StaleObjectException, DomainInterfaceException { // Get appointment linked to order investigation if any OrderInvWithStatusApptVo orderInvAppointment = domain.getOrderInvestigationAppointment(investigationToAmend); // Check for OrderInvestigationAppointment record if (orderInvAppointment == null) return; // Get appointment Booking_AppointmentVo appointment = orderInvAppointment.getAppointment(); // Check for appointment record if (appointment == null) return; // Check if the modality was changed for the investigation to be amended if (hasModalityChanged(newOrder, investigationToAmend)) { // Check current status of the appointment - see if it was cancelled already // If the appointment wasn't cancelled - cancel it now if (!Status_Reason.CANCELLED.equals(appointment.getApptStatus())) { cancelAppointment(appointment); } } else { // Update investigation - with first investigation, else if (newOrder.getInvestigationsIsNotNull() && newOrder.getInvestigations().size() > 0) { OrderInvestigationBookingWithStatusVo orderInvestigationBooking = domain.getOrderInvestigationBooking(newOrder.getInvestigations().get(0)); orderInvestigationBooking.setAppointmentDate(new DateTime(appointment.getAppointmentDate(), appointment.getApptStartTime())); orderInvestigationBooking.setDisplayDateTime(new DateTime(appointment.getAppointmentDate(), appointment.getApptStartTime())); orderInvAppointment.setOrderInvestigation(orderInvestigationBooking); // Remove AppointmentDate and AppointmentTime from investigationToAmend investigationToAmend.setAppointmentDate(null); // Create status OrderedInvestigationStatusVo status = new OrderedInvestigationStatusVo(); status.setChangeDateTime(new DateTime()); status.setChangeUser(domain.getHcpLiteUser() != null ? ((HcpLiteVo) domain.getHcpLiteUser()).getIMosName() : null); status.setProcessedDateTime(new DateTime()); status.setOrdInvStatus(OrderInvStatus.ORDERED); orderInvestigationBooking.setOrdInvCurrentStatus(status); if (orderInvestigationBooking.getOrdInvStatusHistory() == null) orderInvestigationBooking.setOrdInvStatusHistory(new OrderedInvestigationStatusVoCollection()); orderInvestigationBooking.getOrdInvStatusHistory().add(status); } orderInvAppointment.validate(); domain.updateOrderInvestigationAppointment(orderInvAppointment, investigationToAmend); } }
/** * Function used to cancel the appointment / or associate with the new investigation (or first investigation in order if multiple are selected for order) */ private void changeInvestigationAppointment(OcsOrderVo newOrder, OrderInvestigationLiteVo investigationToAmend) throws StaleObjectException { // Get appointment linked to order investigation if any OrderInvWithStatusApptVo orderInvAppointment = domain.getOrderInvestigationAppointment(investigationToAmend); // Check for OrderInvestigationAppointment record if (orderInvAppointment == null) return; // Get appointment Booking_AppointmentVo appointment = orderInvAppointment.getAppointment(); // Check for appointment record if (appointment == null) return; // Check if the modality was changed for the investigation to be amended if (hasModalityChanged(newOrder, investigationToAmend)) { // Check current status of the appointment - see if it was cancelled already // If the appointment wasn't cancelled - cancel it now if (!Status_Reason.CANCELLED.equals(appointment.getApptStatus())) { cancelAppointment(appointment); // OK to do this as this function should only be called in CARE UK project domain.updateCatsReferralCancelStatus(form.getGlobalContext().CareUk.getCatsReferral()); } } else { // Update investigation - with first investigation, else if (newOrder.getInvestigationsIsNotNull() && newOrder.getInvestigations().size() > 0) { OrderInvestigationBookingWithStatusVo orderInvestigationBooking = domain.getOrderInvestigationBooking(newOrder.getInvestigations().get(0)); orderInvestigationBooking.setAppointmentDate(new DateTime(appointment.getAppointmentDate(), appointment.getApptStartTime())); orderInvestigationBooking.setDisplayDateTime(new DateTime(appointment.getAppointmentDate(), appointment.getApptStartTime())); orderInvAppointment.setOrderInvestigation(orderInvestigationBooking); // Remove AppointmentDate and AppointmentTime from investigationToAmend investigationToAmend.setAppointmentDate(null); // Create status OrderedInvestigationStatusVo status = new OrderedInvestigationStatusVo(); status.setChangeDateTime(new DateTime()); status.setChangeUser(domain.getHcpLiteUser() != null ? ((HcpLiteVo) domain.getHcpLiteUser()).getIMosName() : null); status.setProcessedDateTime(new DateTime()); status.setOrdInvStatus(OrderInvStatus.ORDERED); orderInvestigationBooking.setOrdInvCurrentStatus(status); if (orderInvestigationBooking.getOrdInvStatusHistory() == null) orderInvestigationBooking.setOrdInvStatusHistory(new OrderedInvestigationStatusVoCollection()); orderInvestigationBooking.getOrdInvStatusHistory().add(status); } orderInvAppointment.validate(); domain.updateOrderInvestigationAppointment(orderInvAppointment, investigationToAmend); } }