Skip to content

Commit

Permalink
Add ordering and set max results (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
SooryaKumaranC-tw authored Dec 12, 2023
1 parent 4cac231 commit 2c2779a
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -206,6 +207,10 @@ public List<Appointment> 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();
}
}

0 comments on commit 2c2779a

Please sign in to comment.