public PendingEmergencyAdmissionAdmitVo automaticDischarge(PendingEmergencyAdmissionRefVo pendingEmergencyAdmission, DateTime admissionDateTime, HcpLiteVo consultant) throws StaleObjectException { if (pendingEmergencyAdmission == null || pendingEmergencyAdmission.getID_PendingEmergencyAdmission() == null) return null; try { Class<?> emergencyHelper = Class.forName("ims.emergency.helper.EmergencyHelper"); IEmergencyHelper implEmergencyHelper = (IEmergencyHelper) getDomainImpl(emergencyHelper); return implEmergencyHelper.autoDischargeFromEmergencyTracking(pendingEmergencyAdmission, admissionDateTime, consultant); } catch (ClassNotFoundException e) { createSystemLogEntry(SystemLogType.APPLICATION, SystemLogLevel.INFORMATION, "Class 'Emergency Helper' not found when attempting to auto-discharge a PendingEmergencyAdmission form ED. This functionality might not be available in the application"); return PendingEmergencyAdmissionAdmitVoAssembler.create((PendingEmergencyAdmission) getDomainFactory().getDomainObject(PendingEmergencyAdmission.class, pendingEmergencyAdmission.getID_PendingEmergencyAdmission())); } }
public PendingEmergencyAdmissionAdmitVoCollection listEmergencyAdmission(LocationRefVo voLocation) { if(voLocation == null) throw new CodingRuntimeException("voLocation is null in method listEmergencyAdmission"); DomainFactory factory = getDomainFactory(); List pendingEmergencies = factory.find("from PendingEmergencyAdmission pea where pea.allocatedWard.id = :idWard and ( pea.admissionStatus = :discharged or pea.admissionStatus = :dta )", new String[]{"idWard", "discharged", "dta"}, new Object[]{voLocation.getID_Location(), getDomLookup(EmergencyAdmissionStatus.DISCHARGED), getDomLookup(EmergencyAdmissionStatus.DTA)}); return PendingEmergencyAdmissionAdmitVoAssembler.createPendingEmergencyAdmissionAdmitVoCollectionFromPendingEmergencyAdmission(pendingEmergencies); }
public PendingEmergencyAdmissionAdmitVo autoDischargeFromEmergencyTracking(PendingEmergencyAdmissionRefVo pendingEmergencyAdmissionRef, DateTime conclusionDateTime, HcpLiteVo consultant) throws StaleObjectException { if (pendingEmergencyAdmissionRef == null || pendingEmergencyAdmissionRef.getID_PendingEmergencyAdmission() == null) throw new CodingRuntimeException("Invalid parameter: PendingEmergencyAdmission record cannot be null."); DomainFactory factory = getDomainFactory(); // Get Tracking record StringBuilder queryTracking = new StringBuilder("SELECT tracking "); queryTracking.append(" FROM Tracking AS tracking "); queryTracking.append(" LEFT JOIN tracking.associatedPendingEmergencyAdmission AS emergency "); queryTracking.append(" WHERE emergency.id = :ER_ADMISSION_ID "); Tracking doTracking = (Tracking) factory.findFirst(queryTracking.toString(), "ER_ADMISSION_ID", pendingEmergencyAdmissionRef.getID_PendingEmergencyAdmission()); TrackingAttendanceOutcomeVo tracking = TrackingAttendanceOutcomeVoAssembler.create(doTracking); // Set the Conclusion and Outcome details tracking.getAttendance().setConclusionDateTime(conclusionDateTime); tracking.getAttendance().setOutcome(AttendanceOutcome.ADMISSIONS); tracking.getAttendance().setDischargeDateTime(conclusionDateTime); AuthoringInformationVo discharghingAuthoringInformation = new AuthoringInformationVo(); discharghingAuthoringInformation.setAuthoringDateTime(conclusionDateTime); discharghingAuthoringInformation.setAuthoringHcp(consultant); tracking.getAttendance().setDischargingHCP(discharghingAuthoringInformation); // Set tracking status // Create new current status (Decision To Admit) for tracking TrackingAttendanceStatusVo newStatus = new TrackingAttendanceStatusVo(); newStatus.setPatient(new PatientRefVo(doTracking.getPatient().getId(), doTracking.getPatient().getVersion())); newStatus.setEpisode(new EpisodeOfCareRefVo(doTracking.getEpisode().getEpisodeOfCare().getId(), doTracking.getEpisode().getEpisodeOfCare().getVersion())); newStatus.setAttendance(new CareContextRefVo(doTracking.getAttendance().getCareContext().getId(), doTracking.getAttendance().getCareContext().getVersion())); if (doTracking.getCurrentArea() != null) newStatus.setTrackingArea(new TrackingAreaRefVo(doTracking.getCurrentArea().getId(), doTracking.getCurrentArea().getVersion())); newStatus.setStatusDatetime(new DateTime()); newStatus.setCreatedBy((MemberOfStaffRefVo) getMosUser()); newStatus.setStatus(TrackingStatus.DISCHARGED); newStatus.setPrevStatus((tracking != null && tracking.getCurrentStatus() != null) ? tracking.getCurrentStatus().getStatus() : null); newStatus.setPrevTrackingArea((tracking != null && tracking.getCurrentStatus() != null) ? tracking.getCurrentStatus().getTrackingArea() : null); tracking.setCurrentStatus(newStatus); // Set the status of the associated PendingEmergencyAddmision if (tracking.getAssociatedPendingEmergencyAdmission() != null && EmergencyAdmissionStatus.DTA.equals(tracking.getAssociatedPendingEmergencyAdmission().getAdmissionStatus())) { tracking.getAssociatedPendingEmergencyAdmission().setAdmissionStatus(EmergencyAdmissionStatus.DISCHARGED); tracking.getAssociatedPendingEmergencyAdmission().setConclusionDate(conclusionDateTime); } tracking.setRequiringDischargeDocumentationReview(true); // Set Discharging data tracking.setIsDischarged(Boolean.TRUE); tracking.setCurrentArea(null); tracking.getAttendance().getCareContext().setEndDateTime(conclusionDateTime); // Save Tracking record doTracking = TrackingAttendanceOutcomeVoAssembler.extractTracking(getDomainFactory(), tracking); factory.save(doTracking); // Return updated PendingEmergencyAdmission return PendingEmergencyAdmissionAdmitVoAssembler.create((PendingEmergencyAdmission) factory.getDomainObject(PendingEmergencyAdmission.class, pendingEmergencyAdmissionRef.getID_PendingEmergencyAdmission())); }