Query All Patients Using REST API

Tags: #<Tag:0x00007f23e0c08a40>

(Matthew Sichterman) #1

Hello. I am wondering if there is a way to fetch all patients in a database using the rest connection in my module. Any help is appreciated!

(Dimitri R) #2

I think the short answer is no, REST WS provides search endpoints to crawl through patients, but no endpoint to return all patients.

But if you’re developing a module, there is nothing that prevents you to implement a REST endpoint that does that.

(Wyclif Luyima) #3

It was intentional to not support this because you could easily end up loading a huge chunk of the DB into memory and that could be a disaster. Only time you need to do this is possibly for data migration purposes and there are alternative tools to achieve this.

What is your driver to needing to load all patients? May be there could be alternative ways.

(Matthew Sichterman) #4

I am using AngularJS to create an OWA module used to notify receptionists of patients with Diabetes who need to schedule follow up visits. I’m using the webservices module and essentially just trying to query for all patients (using only a small collection of patients) in order to determine if they have diabetes and then create notifications for the UI based on that.

(Daniel Kayiwa) #5

Did you take a look at this? https://wiki.openmrs.org/display/docs/Patient+Flags+Module

(Matthew Sichterman) #6

I’m having a hard time implementing those rest calls into my module. I’m getting 404 errors saying the resource doesn’t exist.

(Owais Hussain) #7

@mattsichterman can you pastebin a sample REST call you’re making?

Also keep in mind that the REST module caps the number of objects to return. Look for webservices.rest.maxResultsAbsolute and webservices.rest.maxResultsDefault in global properties.