@Override protected void onBtnSaveClick() throws ims.framework.exceptions.PresentationLogicException { PatientElectiveListBedAdmissionVo patientElectiveList = null; if (Boolean.TRUE.equals(ConfigFlag.GEN.USE_ELECTIVE_LIST_FUNCTIONALITY.getValue())) { // Get current Patient Elective List patientElectiveList = domain.getPatientElectiveListForAppointment( form.getGlobalContext().Scheduling.getBookingAppointmentRef()); if (patientElectiveList != null) { if (Specialty.EMERGENCY.equals(form.cmbSpecialty().getValue())) { // If there are no other elective list to be cancelled TCIOutcomeForPatientElectiveListVo outcome = new TCIOutcomeForPatientElectiveListVo(); if (ElectiveListReason.DIAGNOSTIC.equals(patientElectiveList.getElectiveListReason())) outcome.setOutcome(AdmissionOfferOutcome.PATIENT_ADMITTED); else outcome.setOutcome(AdmissionOfferOutcome.PATIENT_ADMITTED_COMMENCED_8); outcome.setChangeBy((MemberOfStaffRefVo) domain.getMosUser()); outcome.setStatusDateTime(new DateTime()); outcome.setOutcomeReason(null); patientElectiveList.getTCIDetails().setCurrentOutcome(outcome); patientElectiveList.getTCIDetails().getOutcomeHistory().add(outcome); patientElectiveList.getTCIDetails().setIsActive(Boolean.FALSE); if (ElectiveListReason.DIAGNOSTIC.equals(patientElectiveList.getElectiveListReason())) { if (patientElectiveList.getPathwayClock() != null) patientElectiveList .getPathwayClock() .setStopDate( form.dtimAdmDateTime().getValue() != null ? form.dtimAdmDateTime().getValue().getDate() : null); } // Check for existing Patient Elective list if (Boolean.TRUE.equals( domain.hasPatientElectiveListsToBeCancelled( form.getGlobalContext().Core.getPatientShort(), patientElectiveList, patientElectiveList.getElectiveList().getService()))) { form.getLocalContext().setPatientElectiveList(patientElectiveList); engine.showMessage( "Patient has other Patient Elective records for the same service. Cancel these records?", "Warning", MessageButtons.YESNOCANCEL); return; } } } } if (saveAdmission(patientElectiveList, null)) engine.close(DialogResult.OK); }
@Override protected void onMessageBoxClosed(int messageBoxId, DialogResult result) throws PresentationLogicException { if (DialogResult.YES.equals(result)) { PatientElectiveListBedAdmissionVo patientElectiveList = form.getLocalContext().getPatientElectiveList(); PatientElectiveListBedAdmissionVoCollection differentPatientElectiveListForService = null; if (patientElectiveList != null) { differentPatientElectiveListForService = domain.getDifferentPatientElectiveListForService( form.getGlobalContext().Core.getPatientShort(), patientElectiveList, patientElectiveList.getElectiveList().getService()); for (PatientElectiveListBedAdmissionVo patientElective : differentPatientElectiveListForService) { TCIOutcomeForPatientElectiveListVo outcome = new TCIOutcomeForPatientElectiveListVo(); if (patientElective .getTCIDetails() .getTCIDate() .isLessThan(new ims.framework.utils.Date())) outcome.setOutcome(AdmissionOfferOutcome.ADMISSION_CANCELLED_BY_HOSPITAL_BEFORE_6); else outcome.setOutcome(AdmissionOfferOutcome.ADMISSION_CANCELLED_BY_HOSPITAL_ON_DAY_7); outcome.setChangeBy((MemberOfStaffRefVo) domain.getMosUser()); outcome.setStatusDateTime(new DateTime()); outcome.setOutcomeReason(TCIStatusChangeReason.CANCELLEDBYREMOVALOFELECTIVELISTRECORD); patientElective.getTCIDetails().setCurrentOutcome(outcome); patientElective.getTCIDetails().getOutcomeHistory().add(outcome); patientElective.getTCIDetails().setIsActive(false); } } if (saveAdmission(patientElectiveList, differentPatientElectiveListForService)) engine.close(DialogResult.OK); } else if (DialogResult.NO.equals(result)) { if (saveAdmission(form.getLocalContext().getPatientElectiveList(), null)) engine.close(DialogResult.OK); } }