/** * Function used to retrieve the Tracking record based on CareContext provided (must be equal to Tracking.Attendance.CareContext) */ public TrackingAttendanceOutcomeVo getTrackingAttendanceOutcomeVo(CareContextRefVo careContext) { // Check care context parameter if (careContext == null || careContext.getID_CareContext() == null) return null; StringBuilder query = new StringBuilder(); query.append("SELECT track FROM Tracking AS track "); query.append(" LEFT JOIN FETCH track.attendance AS attend "); query.append(" LEFT JOIN FETCH attend.careContext as context "); query.append(" LEFT JOIN FETCH track.currentStatus "); query.append(" LEFT JOIN FETCH attend.emergencyEpisode "); query.append(" LEFT JOIN FETCH attend.patient "); query.append(" WHERE context.id = :CONTEXT_ID "); return TrackingAttendanceOutcomeVoAssembler.create((Tracking) getDomainFactory().findFirst(query.toString(), "CONTEXT_ID", careContext.getID_CareContext())); }
/** * Function used to populate data to instance controls */ private void populateInstanceControls(TrackingAttendanceOutcomeVo record) { // Clear instance controls clearInstanceControls(); // Populate Date of Death from patient form.dteDateOfDeath().setValue(form.getGlobalContext().Core.getPatientShort() != null ? form.getGlobalContext().Core.getPatientShort().getDod() : null); // Check record parameter if (record == null) return; // Populate instance controls with data from record form.cmbCategory().setValue(record.getAttendance().getEmergencyEpisode().getCategory()); // Populate conclusion date time for attendance form.dtimConclusion().setValue(record.getAttendance().getConclusionDateTime()); // Populate Decision to Admit details if (record.getBedAvailability() != null && record.getBedAvailability().getRequestedBy() != null) form.lblRequestedBy().setValue(record.getBedAvailability().getRequestedBy().toString()); if (record.getAssociatedPendingEmergencyAdmission() != null && !EmergencyAdmissionStatus.CANCELLED.equals(record.getAssociatedPendingEmergencyAdmission().getAdmissionStatus())) { if (record.getAssociatedPendingEmergencyAdmission().getDTADateTime() != null) form.lblDecisionToAdmit().setValue(record.getAssociatedPendingEmergencyAdmission().getDTADateTime().toString()); if (record.getAssociatedPendingEmergencyAdmission().getBedTypeRequested() != null) form.lblBedType().setValue(record.getAssociatedPendingEmergencyAdmission().getBedTypeRequested().getText()); } if (record.getBedAvailability() != null && record.getBedAvailability().getAvailableDateTime() != null) form.lblAvailableBedTime().setValue(record.getBedAvailability().getAvailableDateTime().toString()); if (record.getAttendance().getOutcome() != null) { form.cmbOutcome().setValue(record.getAttendance().getOutcome()); form.txtDestination().setValue(record.getAttendance().getDestination()); form.dteDateOfDeath().setValue(record.getAttendance().getPatient().getDod()); form.dtimDischargeTime().setValue(record.getAttendance().getDischargeDateTime()); } form.ccAuthoring().setValue(record.getAttendance().getDischargingHCP()); }
private TrackingAttendanceOutcomeVo populateDataToUndoDischarge(TrackingAttendanceOutcomeVo record) { TrackingAttendanceOutcomeVo recordToSave = (TrackingAttendanceOutcomeVo) record.clone(); //WDEV-17389 if (AttendanceOutcome.MORTUARY.equals(recordToSave.getAttendance().getOutcome()) || AttendanceOutcome.BID.equals(recordToSave.getAttendance().getOutcome()) || AttendanceOutcome.DOA.equals(recordToSave.getAttendance().getOutcome()) || AttendanceOutcome.DID.equals(recordToSave.getAttendance().getOutcome())) { recordToSave.getAttendance().getPatient().setDod(null); } recordToSave.getAttendance().setOutcome(null); recordToSave.getAttendance().setDestination(null); recordToSave.getAttendance().setDischargeDateTime(null); recordToSave.setReasonForBreach(null); recordToSave.getAttendance().getCareContext().setEndDateTime(null); recordToSave.setCurrentArea(form.getLocalContext().getRecord().getCurrentStatus().getPrevTrackingArea()); recordToSave.setIsDischarged(null); recordToSave.getAttendance().setDischargingHCP(null); //WDEV-17247 if (recordToSave.getCurrentDNW() != null && recordToSave.getCurrentDNW().getCurrentStatus() != null && recordToSave.getCurrentDNW().getCurrentStatus().getCalledAmount() != 0 && recordToSave.getCurrentDNW().getCurrentStatus().getCalledAmount() == ConfigFlag.DOM.AUTOMATICALLY_DISCHARGE_PATIENT_FROM_ED_ON_DNA_CALL_NUMBER.getValue()) { recordToSave.getCurrentDNW().getCurrentStatus().setCalledAmount(recordToSave.getCurrentDNW().getCurrentStatus().getCalledAmount() - 1); } recordToSave.setCurrentStatus(populateTrackingAttendanceStatus(form.getGlobalContext().Emergency.getTrackingAttendanceStatus().getStatus()));//WDEV-17408 //WDEV-17407 // if (recordToSave.getAssociatedPendingEmergencyAdmission() != null && (EmergencyAdmissionStatus.DISCHARGED.equals(recordToSave.getAssociatedPendingEmergencyAdmission().getAdmissionStatus()) || (AttendanceOutcome.DID_NOT_WAIT.equals(form.cmbOutcome().getValue()) && EmergencyAdmissionStatus.CANCELLED.equals(recordToSave.getAssociatedPendingEmergencyAdmission().getAdmissionStatus()) && form.cmbBedType().getValue()!=null)))//WDEV-17283 //WDEV-17471 //WDEV-17532 // { // recordToSave.getAssociatedPendingEmergencyAdmission().setAdmissionStatus(EmergencyAdmissionStatus.DTA); // } return recordToSave; }
@Override protected void onCmbOutcomeValueChanged() throws PresentationLogicException { form.getLocalContext().setCustomEvent(null); if (AttendanceOutcome.MORTUARY.equals(form.cmbOutcome().getValue())) { // Display confirmation dialog form.getLocalContext().setMortuaryOutcomeMessageBoxId(engine.showMessage("Are you sure you wish to select Mortuary?", "Warning", MessageButtons.YESNO)); return; } if (! (AttendanceOutcome.MORTUARY.equals(form.cmbOutcome().getValue()) || AttendanceOutcome.BID.equals(form.cmbOutcome().getValue()) || AttendanceOutcome.DOA.equals(form.cmbOutcome().getValue()) || AttendanceOutcome.DID.equals(form.cmbOutcome().getValue()))) { if (form.getLocalContext().getRecord().getAttendance().getPatient().getDod() == null) { form.dteDateOfDeath().setValue(null); form.getGlobalContext().Core.getPatientShort().setDod(null); } if (form.getLocalContext().getRecord().getAttendance().getPatient().getTimeOfDeath() == null) { form.timTimeOfDeath().setValue(null); form.getGlobalContext().Core.getPatientShort().setTimeOfDeath(null); } form.getGlobalContext().Core.setDeathDetails(null); } else if (AttendanceOutcome.BID.equals(form.cmbOutcome().getValue()) || AttendanceOutcome.DOA.equals(form.cmbOutcome().getValue()) || AttendanceOutcome.DID.equals(form.cmbOutcome().getValue())) { form.getGlobalContext().Core.setParentFormMode(form.getMode()); engine.open(form.getForms().Clinical.DeathDetails); } //WDEV-19242 TrackingAttendanceOutcomeVo record = form.getLocalContext().getRecord(); boolean showBedRequestMessage = record != null && (!record.getAssociatedPendingEmergencyAdmissionIsNotNull() || ( record.getAssociatedPendingEmergencyAdmissionIsNotNull() && EmergencyAdmissionStatus.CANCELLED.equals(record.getAssociatedPendingEmergencyAdmission().getAdmissionStatus())))&& AttendanceOutcome.ADMISSIONS.equals(form.cmbOutcome().getValue()); boolean pendingDischare = ConfigFlag.GEN.ED_DTA_ADMISSION_FUNCTIONALITY.getValue().equals("PENDING"); if (pendingDischare && showBedRequestMessage) engine.showMessage("This patient cannot be departed until the Bed Request is completed for the attendance."); //WDEV-19060 if (AttendanceOutcome.ADCC_CLINIC.equals(form.cmbOutcome().getValue())) { engine.open(form.getForms().Emergency.EDClinicDetails, new Object[] {form.getMode()}); } // Update controls state updateControlsState(); }
/** * Function used to populate data to instance controls */ private void populateInstanceControls(TrackingAttendanceOutcomeVo record) //WDEV-19375 { // Clear instance controls clearInstanceControls(); // Populate Date of Death from patient form.dteDateOfDeath().setValue(form.getGlobalContext().Core.getPatientShort() != null ? form.getGlobalContext().Core.getPatientShort().getDod() : null); form.timTimeOfDeath().setValue(form.getGlobalContext().Core.getPatientShort() != null ? form.getGlobalContext().Core.getPatientShort().getTimeOfDeath() : null); // Check record parameter if (record == null) return; // Populate instance controls with data from record form.cmbCategory().setValue(record.getAttendance().getEmergencyEpisode().getCategory()); // Populate conclusion date time for attendance form.dtimConclusion().setValue(record.getAttendance().getConclusionDateTime()); // Populate Decision to Admit details //WDEV-19059 if (ConfigFlag.GEN.ED_DTA_ADMISSION_FUNCTIONALITY.getValue().equals("PENDING")) { if (record.getBedAvailability() != null && record.getBedAvailability().getRequestedBy() != null) form.lblRequestedBy().setValue(record.getBedAvailability().getRequestedBy().toString()); if (record.getAssociatedPendingEmergencyAdmission() != null && !EmergencyAdmissionStatus.CANCELLED.equals(record.getAssociatedPendingEmergencyAdmission().getAdmissionStatus())) { if (record.getAssociatedPendingEmergencyAdmission().getDTADateTime() != null) form.lblDecisionToAdmit().setValue(record.getAssociatedPendingEmergencyAdmission().getDTADateTime().toString()); if (record.getAssociatedPendingEmergencyAdmission().getBedTypeRequested() != null) form.lblBedType().setValue(record.getAssociatedPendingEmergencyAdmission().getBedTypeRequested().getText()); } if (record.getBedAvailability() != null && record.getBedAvailability().getAvailableDateTime() != null) form.lblAvailableBedTime().setValue(record.getBedAvailability().getAvailableDateTime().toString()); } else if (ConfigFlag.GEN.ED_DTA_ADMISSION_FUNCTIONALITY.getValue().equals("PARTIAL") && record.getCurrentPartialAdmissionIsNotNull()) { EDPartialAdmissionForDischargeDetailOutcomeVo currentpartialAdmission = record.getCurrentPartialAdmission(); form.lblDecisionToAdmit().setValue(currentpartialAdmission.getDecisionToAdmitDateTime().toString()); form.lblRequestedBy().setValue(currentpartialAdmission.getAuthoringInfo()!=null && currentpartialAdmission.getAuthoringInfo().getAuthoringHcpIsNotNull() ? currentpartialAdmission.getAuthoringInfo().getAuthoringHcp().getIHcpName() : ""); form.lblBedType().setValue(currentpartialAdmission.getAccomodationRequestedTypeIsNotNull() ? currentpartialAdmission.getAccomodationRequestedType().getText() : ""); //WDEV-17661 form.lblAvailableBedTime().setValue(currentpartialAdmission.getAllocatedDateTimeIsNotNull()? currentpartialAdmission.getAllocatedDateTime().toString() : ""); } if (record.getAttendance().getOutcome() != null || record.getAttendance().getDischargeDateTime() != null) //WDEV-19031 { form.cmbOutcome().setValue(record.getAttendance().getOutcome()); form.txtDestination().setValue(record.getAttendance().getDestination()); form.dteDateOfDeath().setValue(record.getAttendance().getPatient().getDod()); form.timTimeOfDeath().setValue(record.getAttendance().getPatient().getTimeOfDeath()); form.dtimDischargeTime().setValue(record.getAttendance().getDischargeDateTime()); //WDEV-19059 form.txtOtherOutcome().setValue(record.getAttendance().getAttendanceOutcomeComment()); form.cmbGPLetterStatus().setValue(record.getAttendance().getGPLetterStatus()); } form.ccAuthoring().setValue(record.getAttendance().getDischargingHCP()); form.getGlobalContext().Emergency.setEDClinicDetails(AttendanceOutcome.ADCC_CLINIC.equals(form.cmbOutcome().getValue()) ? record.getAttendance().getEDClinicDetails() : null); //WDEV-19060 }
private TrackingAttendanceOutcomeVo populateDataToUndoDischarge(TrackingAttendanceOutcomeVo record) { TrackingAttendanceOutcomeVo recordToSave = (TrackingAttendanceOutcomeVo) record.clone(); //WDEV-17389 //WDEV-19682 if (AttendanceOutcome.MORTUARY.equals(recordToSave.getAttendance().getOutcome()) || AttendanceOutcome.BID.equals(recordToSave.getAttendance().getOutcome()) || AttendanceOutcome.DOA.equals(recordToSave.getAttendance().getOutcome()) || AttendanceOutcome.DID.equals(recordToSave.getAttendance().getOutcome())) { recordToSave.getAttendance().getPatient().setDod(null); recordToSave.getAttendance().getPatient().setTimeOfDeath(null); } recordToSave.getAttendance().setOutcome(null); recordToSave.getAttendance().setDestination(null); recordToSave.getAttendance().setDischargeDateTime(null); recordToSave.setReasonForBreach(null); recordToSave.getAttendance().getCareContext().setEndDateTime(null); recordToSave.setCurrentArea(form.getLocalContext().getRecord().getCurrentStatus().getPrevTrackingArea()); recordToSave.setIsDischarged(null); recordToSave.getAttendance().setDischargingHCP(null); //WDEV-17247 if (recordToSave.getCurrentDNW() != null && recordToSave.getCurrentDNW().getCurrentStatus() != null && recordToSave.getCurrentDNW().getCurrentStatus().getCalledAmount() != 0 && recordToSave.getCurrentDNW().getCurrentStatus().getCalledAmount() == ConfigFlag.DOM.AUTOMATICALLY_DISCHARGE_PATIENT_FROM_ED_ON_DNA_CALL_NUMBER.getValue()) { recordToSave.getCurrentDNW().getCurrentStatus().setCalledAmount(recordToSave.getCurrentDNW().getCurrentStatus().getCalledAmount() - 1); } recordToSave.setCurrentStatus(populateTrackingAttendanceStatus(form.getGlobalContext().Emergency.getTrackingAttendanceStatus().getStatus()));//WDEV-17408 //WDEV-17407 // if (recordToSave.getAssociatedPendingEmergencyAdmission() != null && (EmergencyAdmissionStatus.DISCHARGED.equals(recordToSave.getAssociatedPendingEmergencyAdmission().getAdmissionStatus()) || (AttendanceOutcome.DID_NOT_WAIT.equals(form.cmbOutcome().getValue()) && EmergencyAdmissionStatus.CANCELLED.equals(recordToSave.getAssociatedPendingEmergencyAdmission().getAdmissionStatus()) && form.cmbBedType().getValue()!=null)))//WDEV-17283 //WDEV-17471 //WDEV-17532 // { // recordToSave.getAssociatedPendingEmergencyAdmission().setAdmissionStatus(EmergencyAdmissionStatus.DTA); // } //WDEV-19031 recordToSave.setDisplayInED(false); return recordToSave; }
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())); }