private CatsReferral createNewReferral(Sch_Booking doBooking) { CatsReferral catsRef = new CatsReferral(); ICABReferral domReferral = new ICABReferral(); domReferral.setAuthoringDateTime(new java.util.Date()); domReferral.setReferralType(getDomLookup(ReferralType.EXTERNAL)); domReferral.setPatient(doBooking.getPatient()); domReferral.setUBRN(doBooking.getUBRN()); domReferral.setStatus(getDomLookup(ICABReferralStatus.CHOOSEANDBOOK)); catsRef.setICABReferral(domReferral); catsRef.setPatient(doBooking.getPatient()); CATSReferralStatus refStat = new CATSReferralStatus(); refStat.setStatusDateTime(new java.util.Date()); refStat.setReferralStatus(getDomLookup(ReferralApptStatus.REFERRAL_RECEIVED)); catsRef.setCurrentStatus(refStat); catsRef.setStatusHistory(new HashSet()); catsRef.getStatusHistory().add(refStat); return catsRef; }
private CatsReferral createNewReferral(DomainFactory factory, Sch_Booking doBooking) throws StaleObjectException { CatsReferral catsRef = new CatsReferral(); ICABReferral domReferral = new ICABReferral(); domReferral.setAuthoringDateTime(new java.util.Date()); domReferral.setReferralType(getDomLookup(ReferralType.EXTERNAL)); domReferral.setPatient(doBooking.getPatient()); domReferral.setUBRN(doBooking.getUBRN()); domReferral.setStatus(getDomLookup(ICABReferralStatus.CHOOSEANDBOOK)); catsRef.setICABReferral(domReferral); catsRef.setPatient(doBooking.getPatient()); catsRef.setIsCAB(Boolean.TRUE); catsRef.setAdditionalInvApptsStatus(getDomLookup(AdditionalInvestigationAppointmentsStatus.NONE)); catsRef.setConsultationAppt(doBooking.getFirstAppointment()); catsRef.setHasAppointments(Boolean.TRUE); //WDEV-5507 catsRef.setDOS(doBooking.getFirstAppointment().getSessionSlot().getDOSfromUBRN(doBooking.getUBRN())); // wdev-10023 Set the ContractId from the DOS if (catsRef.getDOS() != null) //WDEV-11713 catsRef.setContract(catsRef.getDOS().getContract()); CATSReferralStatus refStat = new CATSReferralStatus(); refStat.setStatusDateTime(new java.util.Date()); refStat.setReferralStatus(getDomLookup(ReferralApptStatus.REFERRAL_RECEIVED)); catsRef.setCurrentStatus(refStat); catsRef.setStatusHistory(new HashSet()); catsRef.getStatusHistory().add(refStat); // Need to create CareSpell, EpisodeOfCare and CareContext as // CareContext required for CatsReferral CareSpell domCS = new CareSpell(); domCS.setStartDate(new java.util.Date()); domCS.setPatient(doBooking.getPatient()); EpisodeOfCare domEpis = new EpisodeOfCare(); domEpis.setCareSpell(domCS); domEpis.setStartDate(new java.util.Date()); domEpis.setSpecialty(doBooking.getFirstAppointment().getSession().getService().getSpecialty()); Set episSt = new HashSet(); episSt.add(domEpis); domCS.setEpisodes(episSt); CareContext domCC = new CareContext(); domCC.setStartDateTime(new java.util.Date()); domCC.setEpisodeOfCare(domEpis); domCC.setContext(getDomLookup(ContextType.OUTPATIENT)); Set ccSt = new HashSet(); ccSt.add(domCC); domEpis.setCareContexts(ccSt); factory.save(domCS); catsRef.setCareContext(domCC); return catsRef; }