private MyOrderOutpatAttendVo findTodayAppointment(PatientRefVo patient, PASEventRefVo pasEvent) { if (patient == null) return null; ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); StringBuilder todayQuery = new StringBuilder("FROM OutpatientAttendance AS outp "); todayQuery.append("WHERE outp.pasEvent.patient.id = :PATIENT_ID "); paramNames.add("PATIENT_ID"); paramValues.add(patient.getID_Patient()); if (pasEvent != null) { todayQuery.append("AND outp.pasEvent.id = :PAS_EVENT_ID "); paramNames.add("PAS_EVENT_ID"); paramValues.add(pasEvent.getID_PASEvent()); } todayQuery.append("AND outp.clinic is not null AND outp.appointmentStatus.id != :CANCELLED_STATUS and outp.appointmentDateTime BETWEEN :TODAY AND :TODAY_MIDNIGHT"); paramNames.add("CANCELLED_STATUS"); paramValues.add(Status_Reason.CANCELLED.getID()); paramNames.add("TODAY"); paramValues.add(new DateTime(new Date(), new Time(0, 0, 0)).getJavaDate()); paramNames.add("TODAY_MIDNIGHT"); paramValues.add(new DateTime(new Date(), new Time(23, 59, 59)).getJavaDate()); MyOrderOutpatAttendVoCollection outpatientAttendances = MyOrderOutpatAttendVoAssembler.createMyOrderOutpatAttendVoCollectionFromOutpatientAttendance(getDomainFactory().find(todayQuery.toString(), paramNames, paramValues)); if (outpatientAttendances != null && outpatientAttendances.size() > 0) return outpatientAttendances.get(0); return null; }