public AdmissionDetailForEventHistoryVo getAdmissionDetail(PatientRefVo patientRef, DateTime dischargeDate) { if (patientRef == null || patientRef.getID_Patient() == null) throw new CodingRuntimeException("Cannot get AdmissionDetails value on null patientRef."); DateTime dischargeDateClone=(DateTime)dischargeDate.clone(); DateTime dischargeDatePlus24 = dischargeDateClone.addHours(ims.configuration.gen.ConfigFlag.UI.ED_SHOW_DISCHARGED_TRACKING_RECORDS_PERIOD.getValue()); StringBuffer hql = new StringBuffer("select admDetail from AdmissionDetail as admDetail left join admDetail.pasEvent as pasEvent where pasEvent.patient.id = :patID and admDetail.admissionDateTime >= :DischDate and admDetail.admissionDateTime < :DischDate24 order by admDetail.systemInformation.creationDateTime desc "); DomainFactory factory = getDomainFactory(); List<?> list = factory.find(hql.toString(), new String[] { "patID","DischDate", "DischDate24" }, new Object[] {patientRef.getID_Patient(),dischargeDate.getJavaDate(),dischargeDatePlus24.getJavaDate() }); if (list != null && list.size() > 0) return AdmissionDetailForEventHistoryVoAssembler.create((AdmissionDetail) list.get(0)); return null; }