Enable appointment search for a given patient.

Hi Everyone,

We are planning to have a widget on openmrs-coreapps to show upcoming appointment for a patient on different dashboards based on configuration ( link to talk) , and could not find and api in openmrs-module-appointments that gives us the information.

Currently the search endpoint defined within AppointmentsController accepts only start-date and an end-date and both the fields are mandatory.

We are thinking of modifying this end point to

  1. Add an optional field to search by patient uuid as well
  2. Making end-date optional to fetch all future appointments.

Please let us know your thoughts.

@angshuonline @mksd @snehabagri @binduak @swetha184 @mddubey @rrameshbtech

1 Like

Sounds like a good idea.

We are currently working on recurring appointment, if we do not give any end date it will end up giving a lot of appointments. If we do not want end date to be mandate can we add one more parameter to indicate the noOfAppointments we want to fetch. If no value is provided we can fetch everything??


Thanks for the reply.
Shall we go ahead and create a card for this? so that we can finalise the exact requirement and pick this up soon.

Should this be on bahmni board or openmrs?


I have created a placeholder card for this.

Can we please confirm if :

  • If end date is to be made non mandatory.
  • Do we want another field to limit the no of search results (Irrespective of end date being non mandatory)

Yes, we can make end date non mandatory. Also we would need some way to limit the no. of appointments we want so if we can include no of search results it will be good.


For endDate and limit this is what we have in mind

  1. If endDate is Not passed and limit is passed - use the value from limit.
  2. If endDate is NOT passed and limit is NOT passed - Default the limit to a certain value.
  3. If endDate is passed and limit is passed - Use both
  4. If endDate is passed and limit is NOT passed - Should behave as is (no default limit will be applied)

As far as patient uuid is concerned, the filter should only be applied if it is passed.

I will update the details in the card and move it to in DEV.



When ever a limit N is applied we need to order by appointment startDate to get the next N appointments.

We are thinking of ordering the appointment even if there is no limit condition. Please let us know if there are any concerns.

Sounds good.

For point 3, if we have both end date and limit, which will take priority?

If both are passed then we will use both in the query,

Therefore if limit is N and the no of appointments within the date range is greater than N then we will be returning the first N appointments in order of start date.

ok, I think it is fine.

@snehabagri Tested on my local and raised a PR.

Can someone from your team please review it. Thanks