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!
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.
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.
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.
Did you take a look at this? https://wiki.openmrs.org/display/docs/Patient+Flags+Module
I’m having a hard time implementing those rest calls into my module. I’m getting 404 errors saying the resource doesn’t exist.
@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.maxResultsDefault in global properties.
I too had a similar need where I need to get all the patient details from my local database. I need this to implement a search function in my OWA that can search for a patient from the database and then use this to fill in a form with that particular patient’s date of birth and gender. I have been using the demo database that comes with the OpenMRS installation and have created some new patient entries on my local instance of OpenMRS.Thus, the number of patients is very limited. How do I query all the patients data ?
You could use the REST API patient resource? Here are some tests to look at: openmrs-module-webservices.rest/PatientController1_9Test.java at 2.36.0 · openmrs/openmrs-module-webservices.rest · GitHub