Patient search webservice pagination doesn't work

Hi All,

I’m trying to retrieve a paginated list of patients by passing startIndex and limit as request params to http://{host}/{context_path}/ws/rest/v1/patient?q=something The results are very inconsistent. Passing startIndex = 1, limit = 5 returns only 2 results. Passing startIndex=1, limit=10 returns 4 results.

Aren’t v1 webservices meant to have pagination features?

Thanks

Andrew

Can you explain your setup a bit. What version of core and Rest Web Services are you using? If you look in the database, how many patients actually match your query? Are you using any proxy or caching server?

Paging seems to work fine on my server: https://openmrs.psbrandt.io/openmrs/ws/rest/v1/patient?q=j&startIndex=6&limit=10 (u: admin, p: Admin123).

Could you try to reproduce the issue on my server?

Did anyone change patients between queries?

1 Like

openmrs-core 1.11, webservices.rest-2.12. I’m running on my localhost - no proxy, caching server.

@pascal It seems to work fine on your server.

Checkout the queries and results I’m getting patient_search2.txt (5.0 KB) patient_search.txt (2.9 KB) Thanks

Nope. I’m testing on my localhost

Are you using v1.11.6 of core? Can you try to do that and also use the latest version of Rest Web Services (v2.14)?

Do you see same behaviour without the custom representations?

Doubling the limit doubles the results, looks like a bug. Can you try limit = 20 to confirm the pattern ?

This is the behaviour I expect, since limit specifies how many results should be returned (see the Limiting the number of results, and paging section here).

True when number of results > limit, but the first call (limit = 5) returns 2 results. Maybe the service works fine and returns 5 results, and the resource applies a second filter ?

Here the limit is greater than the number of results and it behaves as I expect.

Same behavior with/without the custom param.

And with the latest version of core and the Rest Web Services module?

limit = 20 gives back 7 results.

I will give it a try

Weird. Anyway do as Pascal suggests or else debug the REST call (it’s probably a bug already solved).

@pascal @lluismf Sorry for the very late response.

I have been testing using different REST versions (.9, 1.12, 1.13, 1.14) with the same results.

Can you reproduce the issue on a public server (e.g. here or here) so that we can take a look?

testing…

I would debug the REST call in my local machine and see what’s going on.