REST API Query Format

Quick question: does anyone know the format for a REST API Query to search for all patients at a specified location?

openmrs/ws/rest/v1/patient?location=uuidoflocation

For ref - https://wiki.openmrs.org/display/docs/REST+Web+Service+Resources+in+OpenMRS+1.9#RESTWebServiceResourcesinOpenMRS1.9-Patient

That returns an empty array, however I know for sure that this location has seen patients.

Can you see patients at that location from openmrs UI?

What do you mean by patients “at a” location. Do you mean who have ever been seen at that location?

Regardless of what you mean, there is no built-in REST query for this.

You would need to add the reporting and reportingrest modules (though I don’t think this is documented anywhere…)

I don’t see any documentation of a “location” parameter for the patient resource at the link you pasted.

Yes, I was. I know, otherwise OpenMRS does not have any location specific patients.

I had mistaken it as loggedlocation in Bahmni.

I’ll also try reporting and reportingrest modules. Thank you

Yes, I was referring to a way to see patients who have been seen at that location.

But I guess that’s not possible as of yet.

@darius @ramashish, what @amalafrozalam was sharing was specific to a telemedicine use case. We’re using a cloud hosted OpenMRS instance as the patient data repository. Health workers use tablet devices to see patients at various telemedicine clinics. We wanted to be able to download a cohort of patients seen at a particular clinic, aka “location”. Since the REST API does not contain any resource to GET all patients at a particular location. we can do one of the following,

Option 1: Use cohorts. Assign patients to cohort and download by cohort. Unfortunately, we are unable to find a resource in the REST API that maps to the cohort_member table (unless it does exist but hasn’t been documented?). This makes the most functional sense.

Option 2: Use programs. There are API resources for programs and we can enroll a patient into a program and download by the program. Strictly this does not fit the definition of a program and doesn’t make as much functional sense.

@dbarretto

@ngoel2 did you try out the snapshot version of the rest webservices module which has the work @darius did here? https://issues.openmrs.org/browse/RESTWS-657

@ngoel2 the Cohort resource is what you use to get cohort members.

If your goal is to find all patients who ever had an encounter at a location, you can build this as a CohortDefinition, and evaluate this via the reporting rest API. This would give you dynamic behavior without needing to manually maintain the cohorts.

-Darius (by phone)

1 Like