private void setOrderInvAppt(Booking_AppointmentVo voAppt) { if (voAppt == null) return; List ordInvAppts = getDomainFactory().find("from OrderInvAppt invAppt where invAppt.appointment.id = '" + voAppt.getID_Booking_Appointment() + "'"); if (ordInvAppts != null && ordInvAppts.size() == 1) { OrderInvAppt doOrdInvAppt = (OrderInvAppt) ordInvAppts.get(0); voAppt.setOrderInvestigation(OrderInvestigationBookingVoAssembler.create(doOrdInvAppt.getOrderInvestigation())); } }
public OrderInvestigationBookingVoCollection listResultsAwaited(PatientRefVo patientRefVo, Integer numDays) { if(numDays == null) throw new CodingRuntimeException("Invalid numDays"); if(patientRefVo == null) throw new CodingRuntimeException("Invalid patientRefVo"); Date dtFrom = new Date().addDay(-numDays); ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); StringBuffer sb = new StringBuffer(" from OrderInvestigation as oi where "); sb.append(" oi.systemInformation.creationDateTime >= :fromDate"); markers.add("fromDate"); values.add(dtFrom.getDate()); sb.append(" and oi.ordInvCurrentStatus.ordInvStatus in (:id1, :id2)"); markers.add("id1"); values.add(getDomLookup(OrderInvStatus.ORDERED)); markers.add("id2"); values.add(getDomLookup(OrderInvStatus.SENT)); sb.append(" and "); sb.append(" oi.orderDetails.patient.id = :pat "); markers.add("pat"); values.add(patientRefVo.getID_Patient()); sb.append(" order by oi.repDateTime desc, oi.ordInvSeq asc"); List result = getDomainFactory().find(sb.toString(), markers, values); return OrderInvestigationBookingVoAssembler.createOrderInvestigationBookingVoCollectionFromOrderInvestigation(result); }
public OrderInvestigationBookingVoCollection listInvestigationResults(PatientRefVo patientRefVo, Integer numDays) { if (numDays == null) throw new CodingRuntimeException("Invalid numDays"); if (patientRefVo == null) throw new CodingRuntimeException("Invalid patientRefVo"); Date dtFrom = new Date().addDay(-numDays); ArrayList<String> markers = new ArrayList<String>(); ArrayList<Object> values = new ArrayList<Object>(); StringBuffer sb = new StringBuffer("SELECT oi FROM OrderInvestigation AS oi LEFT JOIN oi.resultDetails AS resDetails"); sb.append(" LEFT JOIN resDetails.pathologyResultDetails AS pathResDetails LEFT JOIN resDetails.clinicalResultDetails AS clinicalResult where "); sb.append(" oi.systemInformation.creationDateTime >= :fromDate"); markers.add("fromDate"); values.add(dtFrom.getDate()); sb.append(" and ( pathResDetails != null"); sb.append(" or clinicalResult != null)"); sb.append(" and "); sb.append(" oi.orderDetails.patient.id = :pat "); markers.add("pat"); values.add(patientRefVo.getID_Patient()); sb.append(" order by oi.repDateTime desc, oi.ordInvSeq asc"); return OrderInvestigationBookingVoAssembler.createOrderInvestigationBookingVoCollectionFromOrderInvestigation(getDomainFactory().find(sb.toString(), markers, values)); }
public OrderInvestigationBookingVoCollection listInvestigationResults(PatientRefVo patientRefVo, Integer numDays) { if (numDays == null) throw new CodingRuntimeException("Invalid numDays"); if (patientRefVo == null) throw new CodingRuntimeException("Invalid patientRefVo"); Date dtFrom = new Date().addDay(-numDays); ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); StringBuffer sb = new StringBuffer(" from OrderInvestigation as oi where "); sb.append(" oi.systemInformation.creationDateTime >= :fromDate"); markers.add("fromDate"); values.add(dtFrom.getDate()); sb.append(" and ( oi.pathResultDetails != null"); sb.append(" or oi.radReportingDetails != null)"); sb.append(" and "); sb.append(" oi.orderDetails.patient.id = :pat "); markers.add("pat"); values.add(patientRefVo.getID_Patient()); sb.append(" order by oi.repDateTime desc, oi.ordInvSeq asc"); List result = getDomainFactory().find(sb.toString(), markers, values); return OrderInvestigationBookingVoAssembler.createOrderInvestigationBookingVoCollectionFromOrderInvestigation(result); }
public OrderInvestigationBookingVoCollection listResultsAwaited(PatientRefVo patientRefVo, Integer numDays) { if(numDays == null) throw new CodingRuntimeException("Invalid numDays"); if(patientRefVo == null) throw new CodingRuntimeException("Invalid patientRefVo"); Date dtFrom = new Date().addDay(-numDays); ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); StringBuffer sb = new StringBuffer(" from OrderInvestigation as oi where "); sb.append(" oi.systemInformation.creationDateTime >= :fromDate"); markers.add("fromDate"); values.add(dtFrom.getDate()); //WDEV-18620 sb.append(" and oi.resultDetails is null and oi.ordInvCurrentStatus.ordInvStatus.id not in (:id1, :id2)"); markers.add("id1"); values.add(-808); markers.add("id2"); values.add(-794); sb.append(" and "); sb.append(" oi.orderDetails.patient.id = :pat "); markers.add("pat"); values.add(patientRefVo.getID_Patient()); sb.append(" order by oi.repDateTime desc, oi.ordInvSeq asc"); List result = getDomainFactory().find(sb.toString(), markers, values); return OrderInvestigationBookingVoAssembler.createOrderInvestigationBookingVoCollectionFromOrderInvestigation(result); }
public OrderInvestigationBookingVoCollection listClinicalInvestigationsResults(PatientRefVo patientRefVo, Integer numDays) { if (numDays == null) throw new CodingRuntimeException("Invalid numDays"); if (patientRefVo == null) throw new CodingRuntimeException("Invalid patientRefVo"); Date dtFrom = new Date().addDay(-numDays); ArrayList<String> markers = new ArrayList<String>(); ArrayList<Object> values = new ArrayList<Object>(); StringBuffer sb = new StringBuffer("SELECT oi FROM OrderInvestigation AS oi LEFT JOIN oi.resultDetails AS resDetails where"); sb.append(" oi.systemInformation.creationDateTime >= :fromDate"); markers.add("fromDate"); values.add(dtFrom.getDate()); sb.append(" and oi.resultDetails is not null "); sb.append(" and "); sb.append(" oi.orderDetails.patient.id = :pat "); markers.add("pat"); values.add(patientRefVo.getID_Patient()); sb.append(" order by oi.repDateTime desc, oi.ordInvSeq asc"); return OrderInvestigationBookingVoAssembler.createOrderInvestigationBookingVoCollectionFromOrderInvestigation(getDomainFactory().find(sb.toString(), markers, values)); }
/** * getReferralDetail - Referral Booking Vo contains all the data for the top * panel (Referral Details) - in the Booking Screen for CARE_UK */ public ims.RefMan.vo.ReferralBookingVo getReferralDetail(ims.RefMan.vo.CatsReferralRefVo catsReferral) { if (catsReferral == null || catsReferral.getID_CatsReferral() == null) throw new CodingRuntimeException("catsReferral is null or id not provide for method getReferralDetail"); DomainFactory factory = getDomainFactory(); ReferralBookingVo voReferralBooking = new ReferralBookingVo(); CatsReferral doCatsRef = (CatsReferral) factory.getDomainObject(catsReferral); if (doCatsRef != null) { java.util.Date triageDateTime = doCatsRef.getTriageDateTime(); if (triageDateTime != null) voReferralBooking.setTriageDateTime(new ims.framework.utils.DateTime(triageDateTime)); ReferralLetterDetailsBookingVo voReferralLetterDetail = ReferralLetterDetailsBookingVoAssembler.create(doCatsRef.getReferralDetails()); if (voReferralLetterDetail != null) { if (doCatsRef.getContract()!=null)//WDEV-11713 { voReferralLetterDetail.setDayTo1stApp(doCatsRef.getContract().getDaysTo1stAppt());//WDEV-11713 voReferralLetterDetail.setDaysToRTTBreachDate(doCatsRef.getContract().getDaysToRTTBreachDate());//WDEV-11713 } ExclusionDatesVo voExDate = listExclusionDates(); // WDEV-13456 // KPI dates are calculated based on days till first appointment if (voReferralLetterDetail.getDayTo1stAppIsNotNull()) { Date[] arrDates = ExclusionDatesVo.getKPIDays(voReferralLetterDetail.getDateReferralReceived(), voReferralLetterDetail.getDayTo1stApp(), voExDate != null ? voExDate.getDates() : null, true);//WDEV-11713 & WDEV-12918 voReferralLetterDetail.setKPIDays(arrDates); if (voReferralLetterDetail.getDateReferralReceivedIsNotNull()) voReferralLetterDetail.setEndXdayKPI(ExclusionDatesVo.addBusinessDays(voReferralLetterDetail.getDateReferralReceived(), voReferralLetterDetail.getDayTo1stApp(), voExDate != null ? voExDate.getDates() : null, true));//WDEV-11713 & WDEV-12918 voReferralBooking.setReferralLetterDetail(voReferralLetterDetail); } } //WDEV-18411 if (doCatsRef.getReferralCategory() != null) { voReferralBooking.setReferralCategory(LookupHelper.getCatsReferralCategoryInstance(getLookupService(), doCatsRef.getReferralCategory().getId())); } } // CurrentAppts - appts with status of appt_booked for Referral List currentAppts = factory.find("select appt from CatsReferral as catsRef join catsRef.appointments as appt where (catsRef.id = :idCatsRef and appt.apptStatus = :bookedStatus and appt.theatreBooking is null )", new String[]{"idCatsRef", "bookedStatus"}, new Object[]{catsReferral.getID_CatsReferral(), getDomLookup(Status_Reason.BOOKED)}); voReferralBooking.setCurrentAppointments(BookingAppointmentLiteVoAssembler.createBookingAppointmentLiteVoCollectionFromBooking_Appointment(currentAppts)); // Appts Requiring Rebook for Referral List rebookAppts = factory.find("select appt from CatsReferral as catsRef join catsRef.appointments as appt where (catsRef.id = :idCatsRef and appt.requiresRebook = 1 and appt.theatreBooking is null )", new String[]{"idCatsRef"}, new Object[]{catsReferral.getID_CatsReferral()}); voReferralBooking.setAppointmentsRequiringRebook(BookingAppointmentLiteVoAssembler.createBookingAppointmentLiteVoCollectionFromBooking_Appointment(rebookAppts)); //Theatre Appts - WDEV-7653 List theatreAppts = factory.find("select appt from CatsReferral as catsRef join catsRef.appointments as appt where (catsRef.id = :idCatsRef and appt.theatreBooking <> null )", new String[]{"idCatsRef"}, new Object[]{catsReferral.getID_CatsReferral()}); voReferralBooking.setOtherAppointments(BookingAppointmentLiteVoAssembler.createBookingAppointmentLiteVoCollectionFromBooking_Appointment(theatreAppts)); // Invs Requiring an appt - For the CatsReferral - orderInvestigations // that are in the InvestigationOrders Collection and not in the // collection of OrderInvAppt List ordInvs = listInvsRequiringAppt(catsReferral, factory); voReferralBooking.setOrdersRequiringAppt(OrderInvestigationBookingVoAssembler.createOrderInvestigationBookingVoCollectionFromOrderInvestigation(ordInvs)); voReferralBooking.setReferralEROD(getLastOutpatientEROD(catsReferral)); if(doCatsRef != null && doCatsRef.getJourney() != null && doCatsRef.getJourney().getCurrentClock() != null) { voReferralBooking.setCurrentClock(new PathwayClockRefVo(doCatsRef.getJourney().getCurrentClock().getId(), doCatsRef.getJourney().getCurrentClock().getVersion())); } voReferralBooking.setIsCAB(doCatsRef.isIsCAB()); return voReferralBooking; }
/** * getReferralDetail - Referral Booking Vo contains all the data for the top * panel (Referral Details) - in the Booking Screen for CARE_UK */ public ims.RefMan.vo.ReferralBookingVo getReferralDetail(ims.RefMan.vo.CatsReferralRefVo catsReferral) { if (catsReferral == null || catsReferral.getID_CatsReferral() == null) throw new CodingRuntimeException("catsReferral is null or id not provide for method getReferralDetail"); DomainFactory factory = getDomainFactory(); ReferralBookingVo voReferralBooking = new ReferralBookingVo(); CatsReferral doCatsRef = (CatsReferral) factory.getDomainObject(catsReferral); if (doCatsRef != null) { // WDEV-8144 voReferralBooking.setIsFitForSurgery(doCatsRef.isIsFitForSurgery()); if (doCatsRef.getCareContext() != null) voReferralBooking.setCareContext(new CareContextRefVo(doCatsRef.getCareContext().getId(), doCatsRef.getCareContext().getVersion())); java.util.Date triageDateTime = doCatsRef.getTriageDateTime(); if (triageDateTime != null) voReferralBooking.setTriageDateTime(new ims.framework.utils.DateTime(triageDateTime)); ReferralLetterDetailsBookingVo voReferralLetterDetail = ReferralLetterDetailsBookingVoAssembler.create(doCatsRef.getReferralDetails()); if (voReferralLetterDetail != null) { // WDEV-11713-Start if (doCatsRef.getContract() != null) { voReferralLetterDetail.setDayTo1stApp(doCatsRef.getContract().getDaysTo1stAppt()); voReferralLetterDetail.setDaysToRTTBreachDate(doCatsRef.getContract().getDaysToRTTBreachDate()); } // WDEV-11713-End // WDEV-10473 if (voReferralLetterDetail.getDateOfReferralIsNotNull()) { ExclusionDatesVo voExDate = listExclusionDates(); // WDEV-8017 - kpi days within 13 weeks Date[] arrDates = null; if (voReferralLetterDetail.getDayTo1stAppIsNotNull())// WDEV-11713 arrDates = ExclusionDatesVo.getKPIDays(voReferralLetterDetail.getDateOfReferral(), voReferralLetterDetail.getDaysToRTTBreachDate(), voExDate != null ? voExDate.getDates() : null, true);// WDEV-11713 & WDEV-12918 voReferralLetterDetail.setKPIDays(arrDates); // WDEV-9539 superceding - kpi within 13 weeks voReferralLetterDetail.setEndXdayKPI((ExclusionDatesVo.addBusinessDays(voReferralLetterDetail.getDateOfReferral(), voReferralLetterDetail.getDaysToRTTBreachDate(), voExDate != null ? voExDate.getDates() : null, true)));// WDEV-11713 & WDEV-12918 } voReferralBooking.setReferralLetterDetail(voReferralLetterDetail); } } // Theatre CurrentAppts - theatre appts with status of Booked for // Referral List theatreAppts = factory.find("select appt from CatsReferral as catsRef join catsRef.appointments as appt where (catsRef.id = :idCatsRef and appt.apptStatus = :bookedStatus and appt.theatreBooking <> null )", new String[]{"idCatsRef", "bookedStatus"}, new Object[]{catsReferral.getID_CatsReferral(), getDomLookup(Status_Reason.BOOKED)}); voReferralBooking.setCurrentAppointments(BookingAppointmentLiteVoAssembler.createBookingAppointmentLiteVoCollectionFromBooking_Appointment(theatreAppts)); // TheatreAppts Requiring Rebook for Referral List rebookTheatreAppts = factory.find("select appt from CatsReferral as catsRef join catsRef.appointments as appt where (catsRef.id = :idCatsRef and appt.requiresRebook = 1 and appt.theatreBooking <> null )", new String[]{"idCatsRef"}, new Object[]{catsReferral.getID_CatsReferral()}); voReferralBooking.setAppointmentsRequiringRebook(BookingAppointmentLiteVoAssembler.createBookingAppointmentLiteVoCollectionFromBooking_Appointment(rebookTheatreAppts)); // Clinical Appts - WDEV-7653 List clinAppts = factory.find("select appt from CatsReferral as catsRef join catsRef.appointments as appt where (catsRef.id = :idCatsRef and appt.theatreBooking is null )", new String[]{"idCatsRef"}, new Object[]{catsReferral.getID_CatsReferral()}); voReferralBooking.setOtherAppointments(BookingAppointmentLiteVoAssembler.createBookingAppointmentLiteVoCollectionFromBooking_Appointment(clinAppts)); // Invs Requiring an appt - For the CatsReferral - orderInvestigations // that are in the InvestigationOrders Collection and not in the // collection of OrderInvAppt List ordInvs = listInvsRequiringAppt(catsReferral, factory); voReferralBooking.setOrdersRequiringAppt(OrderInvestigationBookingVoAssembler.createOrderInvestigationBookingVoCollectionFromOrderInvestigation(ordInvs)); voReferralBooking.setReferralEROD(getLastTheatreEROD(catsReferral)); return voReferralBooking; }
public OrderInvestigationBookingVoCollection listPendingResults(PatientRefVo patient, CareContextShortVo careContext) { if(patient == null || patient.getID_Patient() == null) throw new CodingRuntimeException("Can not list investigations that are requested during the inpatient stay on null Patient."); if(careContext == null) throw new CodingRuntimeException("Can not list investigations that are requested during the inpatient stay on null CareContext."); StringBuffer sb = new StringBuffer(" from OrderInvestigation as oi where "); ArrayList<String> markers = new ArrayList<String>(); ArrayList<Object> values = new ArrayList<Object>(); sb.append(" oi.orderDetails.patient.id = :pat "); markers.add("pat"); values.add(patient.getID_Patient()); sb.append(" and "); sb.append(" oi.systemInformation.creationDateTime >= :fromDate"); markers.add("fromDate"); values.add(careContext.getStartDateTime().getJavaDate()); sb.append(" and "); sb.append(" oi.systemInformation.creationDateTime <= :toDate"); markers.add("toDate"); values.add(careContext.getEndDateTime() != null ? careContext.getEndDateTime().getJavaDate() : new DateTime().getJavaDate()); sb.append(" and "); sb.append(" oi.ordInvCurrentStatus.ordInvStatus.id in (:statusAwaiting, :statusOrdered, :statusSent, :statusReceived, :statusAccepted, :statusInProgress, :statusScheduled, :statusCompleted, :statusAwaitingAppointment, :statusHeld) "); markers.add("statusAwaiting"); values.add(OrderInvStatus.AWAITING_AUTHORISATION.getID()); markers.add("statusOrdered"); values.add(OrderInvStatus.ORDERED.getID()); markers.add("statusSent"); values.add(OrderInvStatus.SENT.getID()); markers.add("statusReceived"); values.add(OrderInvStatus.RECEIVED.getID()); markers.add("statusAccepted"); values.add(OrderInvStatus.ACCEPTED.getID()); markers.add("statusInProgress"); values.add(OrderInvStatus.INPROGRESS.getID()); markers.add("statusScheduled"); values.add(OrderInvStatus.INPROGRESS_SCH.getID()); markers.add("statusCompleted"); values.add(OrderInvStatus.COMPLETE.getID()); markers.add("statusAwaitingAppointment"); values.add(OrderInvStatus.ORDERED_AWAITING_APPT.getID()); markers.add("statusHeld"); values.add(OrderInvStatus.HELD.getID()); sb.append(" order by oi.displayDateTime desc"); List<?> result = getDomainFactory().find(sb.toString(), markers, values); return OrderInvestigationBookingVoAssembler.createOrderInvestigationBookingVoCollectionFromOrderInvestigation(result); }