public ReferralNoteVo saveReferralNote(ReferralNoteVo voReferralNote) throws DomainInterfaceException, StaleObjectException { if(voReferralNote == null) throw new DomainRuntimeException("Invalid referral note to save"); if(!voReferralNote.isValidated()) throw new DomainRuntimeException("Record not validated before save"); DomainFactory factory = getDomainFactory(); CorrespondenceNote domainObject = ReferralNoteVoAssembler.extractCorrespondenceNote(factory, voReferralNote); factory.save(domainObject); return ReferralNoteVoAssembler.create(domainObject); }
public ReferralNoteVoCollection listReferralNote(CareContextRefVo voCareContextRef) { DomainFactory factory = getDomainFactory(); if (voCareContextRef != null && voCareContextRef.getID_CareContextIsNotNull()) { java.util.List list = factory.find("select note from CorrespondenceNote note left join note.careContext as cc where cc.id = :idCC", new String[]{"idCC"}, new Object[]{voCareContextRef.getID_CareContext()}); return ReferralNoteVoAssembler.createReferralNoteVoCollectionFromCorrespondenceNote(list).sort(); } return null; }
public void undoProviderCancellation(CatsReferralListVo referral, ReferralNoteVo referralNote) throws StaleObjectException, ForeignKeyViolationException { if (!(referral.getCurrentStatusIsNotNull() && ReferralApptStatus.REFERRAL_CANCELLED_BY_PROVIDER.equals(referral.getCurrentStatus().getReferralStatus()))) { throw new DomainRuntimeException("The referral is not cancelled by provided !"); } //referral.get DomainFactory factory = getDomainFactory(); CatsReferralStatusVoCollection statusHistory = referral.getStatusHistory(); if (statusHistory == null) { throw new DomainRuntimeException("Cats referral doesn't have any history"); } //Hold the current status so that remove can be done in db CatsReferralStatusVo removeStatus = referral.getCurrentStatus(); //Remove the current status from the history and set the current status to the latest statusHistory.remove(removeStatus); CatsReferralStatusVo latestStatus = getLatestStatus(statusHistory); // Check for a referral letter associated to referral PatientDocumentLiteVo referralLetter = getReferralLetter(referral); if (ReferralApptStatus.REFERRAL_RECEIVED.equals(latestStatus.getReferralStatus()) && referralLetter != null) { // Create new status for referral CatsReferralStatusVo status = new CatsReferralStatusVo(); status.setReferralStatus(ReferralApptStatus.AWAITING_TRIAGE); status.setAuthoringUser(referralLetter.getRecordingUser()); status.setComment(""); status.setStatusDateTime(new DateTime()); referral.setCurrentStatus(status); statusHistory.add(status); } else { referral.setCurrentStatus(latestStatus); } CatsReferral referralBo = CatsReferralListVoAssembler.extractCatsReferral(factory, referral); ProviderCancellation pCancellation = referralBo.getProviderCancellation(); referralBo.setProviderCancellation(null); factory.save(referralBo); factory.delete(CatsReferralStatusVoAssembler.extractCATSReferralStatus(factory, removeStatus)); if (pCancellation != null) factory.delete(pCancellation); //WDEV-12088 ims.core.domain.objects.CorrespondenceNote domainObject = ReferralNoteVoAssembler.extractCorrespondenceNote(factory, referralNote); factory.save(domainObject); }