How to get all patient from Database using Rest Api.

I want to retrieve all available patient from Database using rest api.If this is not possible I want to retrieve minimum 100 patient.Does the currently available Patient Rest api provide this support.

1 Like

@naveed1228, that is currently not supported and not encouraged as it may lead to “out of memory issues” , in case there too many patients.

youll want to use some thing like

"http://localhost:8081/openmrs-standalone/ws/rest/v1/patient?limit=100

where the limit parameter give the maximum number of patients

.to take a look at all the suported endpoints , check this

http://localhost:***/openmrs-standalone/module/webservices/rest/apiDocs.htm

thanks for the reply but the provided url is not working.I have test it before

https://demo.openmrs.org/openmrs/module/webservices/rest/test.htm

I’m testing the server using this url: https://demo.openmrs.org/openmrs/ws/rest/v1/patient?limit=100

@naveed1228 just as @mozzy said this is not supported. i have open the url and the http status is said to be forbidden that means it is not yet supported. and from the look it may cause issues just as @mozzy mentioned.

Ok I agree on first point.I think the limit should work but why Its not working?

@naveed1228, another issue is that to fetch many patients at ago,you need to set other params eg limit= , startIndex= , q=

what should I set q to because I want to get all patient list for example 100.Can you please provide an example url for this.

eg

` "http://localhost:8081/openmrs-standalone/ws/rest/v1/patient?limit=100&startIndex=0&q=hor` 


returned

{
  "results": [
    {
      "uuid": "dd553355-1691-11df-97a5-7038c432aabf",
      "display": "101-6 - Mr. Horatio L Hornblower",
      "links": [
        {
          "rel": "self",
          "uri": "http://localhost:8081/openmrs-standalone/ws/rest/v1/patient/dd553355-1691-11df-97a5-7038c432aabf"
        }
      ]
    },
    {
      "uuid": "dd753510-1691-11df-97a5-7038c432aabf",
      "display": "2268EG-0 - Horba Shira Ngere",
      "links": [
        {
          "rel": "self",
          "uri": "http://localhost:8081/openmrs-standalone/ws/rest/v1/patient/dd753510-1691-11df-97a5-7038c432aabf"
        }
      ]
    }
  ]
}

no you cant get all the patients list @naveed1228 :hugs: , its not supported , unless its a custom implementation that you made ou self. but its not advisable

q is a query string that represents the "initial characters of a patient name " something like that

Yes man I understand your point.Consider I want to get 30 to 40 patient which url should I used for it?

wat do u mean 40minute??

Sorry I mean 40 patient

no you cant specify the exact number of results you want to get , you can only specify the maximum number which you dont want the results to exceed >> limit of the reults. the actual number will depend on other parameters like the q