I am trying to get the patients from a certain city (in this example Barcelona) via Rest, but when I make the call it returns all the patients even the ones that are not from Barcelona.
This is the generated Curl when i test it from the server.
curl -X GET "http://XXX/openmrs-standalone/ws/rest/v1/patient?v=full&matchSimilar=true&city=Barcelona -H “accept: application/json”
Am I doing something wrong?
The patient resource does not support searching by city. It accepts a “q” parameter which you can use to search on name, identifier, or searchable person attributes.
I’m curious where you got that URL template from. As Daniel says, we don’t support
city. Is there some documentation somewhere suggesting this?
Hi I got this from going to the API documentation in advanced Administration (/module/webservices/rest/apiDocs.htm)
(System Administration -> Advanced Administration -> (Under Rest Web Services) API Documentation)
When I open the GET Patient tab, it lets me try it using diferent parameters (city being one of them), and it generates the url posted above.
We are trying to download the patients into the Android app, and it would be nice to be able to do it by city/Village instead of by name as we intend to use the app mostly in offline mode, and downloading patients by name would take too much time. Is there any other way this can be done? Can it be done with the “q” parameter that @dkayiwa mentioned ?
Thanks for the help.
Interesting I didn’t know about that feature, but it comes from the
registrationcore module (this code).
If you’re an advanced dev I would suggest trying to debug the server-side code for this search handler and see what’s going on.
Otherwise, most of the patient searching functionality is in the
reporting module (with
reportingrest) though I’m not sure if searching by address is supported. And its API is a bit different, because it’s going to return references to patients rather than the whole patients themselves.
(Just thinking about this now, I guess it would be a nice feature to include a Search Handler in the reporting module that lets the
patient resource run reporting cohort queries…)