public TrackingForADTWardAndSpecialtyDialogVo getTracking(PendingEmergencyAdmissionRefVo pendingemergencyadmissionRef) { if (pendingemergencyadmissionRef == null || pendingemergencyadmissionRef.getID_PendingEmergencyAdmission() == null) throw new CodingRuntimeException("pendingemergencyadmissionRef is null or id not provided "); String hql = "select t1_1 from Tracking as t1_1 left join t1_1.associatedPendingEmergencyAdmission as p1_1 where p1_1.id = " + pendingemergencyadmissionRef.getID_PendingEmergencyAdmission() + "order by t1_1.systemInformation.creationDateTime desc "; List lstTracking = getDomainFactory().find(hql); if( lstTracking != null && lstTracking.size() > 0) { TrackingForADTWardAndSpecialtyDialogVoCollection tempColl = TrackingForADTWardAndSpecialtyDialogVoAssembler.createTrackingForADTWardAndSpecialtyDialogVoCollectionFromTracking(lstTracking); if( tempColl != null && tempColl.size() > 0) return tempColl.get(0); } return null; }
/** * savePendingEmergency */ public void savePendingEmergency(ims.core.vo.PendingEmergencyAdmissionLiteVo emergency, Boolean hasWardChanged,TrackingForADTWardAndSpecialtyDialogVo tracking) throws ims.domain.exceptions.StaleObjectException { if (hasWardChanged == null) throw new CodingRuntimeException("hasWardChanged cannot be null in method savePendingEmergency"); if (emergency == null) throw new CodingRuntimeException("emergency is null in method savePendingEmergency"); if (!emergency.isValidated()) throw new CodingRuntimeException("emergency has not been validated in method savePendingEmergency"); //WDEV-10421 DomainFactory factory = getDomainFactory(); PendingEmergencyAdmission doPendingEmergency = PendingEmergencyAdmissionLiteVoAssembler.extractPendingEmergencyAdmission(factory, emergency); if(hasWardChanged) { AllocatedWardHistory doAllocWardHist = new AllocatedWardHistory(); doAllocWardHist.setAllocatedWard(doPendingEmergency.getAllocatedWard()); doAllocWardHist.setAllocatedWardDateTime(new Date()); if(getLoggedInUser() != null) doAllocWardHist.setAllocatingUser((AppUser) getDomainFactory().getDomainObject((AppUserRefVo) getLoggedInUser())); doPendingEmergency.getAllocatedWardHistory().add(doAllocWardHist); } factory.save(doPendingEmergency); //wdev-16866 if( tracking != null ) { Tracking doTracking = TrackingForADTWardAndSpecialtyDialogVoAssembler.extractTracking(factory, tracking); factory.save(doTracking); } //------------ }
@Override protected void onBtnSaveClick() throws ims.framework.exceptions.PresentationLogicException { PendingEmergencyAdmissionLiteVo voEmergencyAdmission = populateDataFormScreen(); ArrayList<String> screenErrors = new ArrayList<String>(); if (form.cmbWard().getValue() == null) screenErrors.add("Ward is a mandatory item."); if (form.cmbSpecialty().getValue() == null) screenErrors.add("Specialty is a mandatory item."); String[] arrErrors = voEmergencyAdmission.validate(); String[] arrScreenAndVoErrors = addScreenErrorsToVOErrors(screenErrors, arrErrors); if (arrScreenAndVoErrors.length != 0) { engine.showErrors(arrScreenAndVoErrors); return; } Boolean hasWardChanged = form.getLocalContext().getSelectedWard() == null; if(form.getLocalContext().getSelectedWardIsNotNull() && form.getGlobalContext().Core.getADTPendingEmergencyAdmissionIsNotNull() && form.getGlobalContext().Core.getADTPendingEmergencyAdmission().getAllocatedWardIsNotNull()) hasWardChanged = !form.getLocalContext().getSelectedWard().equals(form.getGlobalContext().Core.getADTPendingEmergencyAdmission().getAllocatedWard()); //wdev-16866 TrackingForADTWardAndSpecialtyDialogVo trackVo = null; if( voEmergencyAdmission != null && voEmergencyAdmission.getID_PendingEmergencyAdmissionIsNotNull()) { trackVo = domain.getTracking(voEmergencyAdmission); if( trackVo != null) { if( trackVo.getBedAvailabilityIsNotNull() ) { trackVo.getBedAvailability().setWard(voEmergencyAdmission.getAllocatedWard()); trackVo.getBedAvailability().setAvailableDateTime(new DateTime()); } } } //------------ try { domain.savePendingEmergency(voEmergencyAdmission, hasWardChanged,trackVo); //wdev-16866 } catch (StaleObjectException e) { engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); open(); } engine.close(DialogResult.OK); }