From 2c2779a2dfeb1c4e89366bbcaaeefe7f4da51c57 Mon Sep 17 00:00:00 2001 From: Soorya Kumaran C <90232857+SooryaKumaranC-tw@users.noreply.github.com> Date: Tue, 12 Dec 2023 10:33:57 +0530 Subject: [PATCH] Add ordering and set max results (#143) --- .../module/appointments/dao/impl/AppointmentDaoImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/src/main/java/org/openmrs/module/appointments/dao/impl/AppointmentDaoImpl.java b/api/src/main/java/org/openmrs/module/appointments/dao/impl/AppointmentDaoImpl.java index aae9d0658..921387688 100644 --- a/api/src/main/java/org/openmrs/module/appointments/dao/impl/AppointmentDaoImpl.java +++ b/api/src/main/java/org/openmrs/module/appointments/dao/impl/AppointmentDaoImpl.java @@ -8,6 +8,7 @@ import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.hibernate.sql.JoinType; +import org.openmrs.api.context.Context; import org.openmrs.module.appointments.dao.AppointmentDao; import org.openmrs.module.appointments.model.Appointment; import org.openmrs.module.appointments.model.AppointmentSearchRequest; @@ -206,6 +207,10 @@ public List getDatelessAppointments() { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Appointment.class); criteria.add(Restrictions.isNull("startDateTime")); criteria.add(Restrictions.isNull("endDateTime")); + criteria.addOrder(Order.asc("dateCreated")); + String limit = Context.getAdministrationService().getGlobalProperty("webservices.rest.maxResultsDefault"); + if(StringUtils.isNotEmpty(limit)) + criteria.setMaxResults(Integer.parseInt(limit)); return criteria.list(); } }