Querying for all visits of a patient

Just a quick question about the default REST API. Can someone tell me how I can get all the visits of a specific patient?

Basically, I want to know all the visits that Jane Doe has ever made and return them, using the REST API.

1 Like

You use the visit resource, with a patient parameter, like this:

http://demo.openmrs.org:8080/openmrs/ws/rest/v1/visit?patient=dd895eef-d275-4f56-8085-ec0e73c5a443

Have you seen the REST API documentation? It’s at http://demo.openmrs.org/openmrs/module/webservices/rest/apiDocs.htm (or the equivalent URL on your own server).

For some reason the API docs do not correctly describe the visit resource (e.g. they don’t mention the patient or includeInactive parameters). @pascal, are there instructions anywhere that would tell a dev like me how to fix things when I notice missing documentation for REST behavior?

This is perfect!

Yes, I didn’t see that in the documentation and was trying out different combinations of things. I just didn’t think to add the patient bit at the end of the API call. Thank you!