# Server side pagination in patient search

**URL:** <https://talk.openmrs.org/t/server-side-pagination-in-patient-search/32620>\
**Category:** Development\
**Tags:** module, openmrs\
**Created:** [March 12, 2021, 11:14am UTC](https://talk.openmrs.org/t/server-side-pagination-in-patient-search/32620 "2021-03-12T11:14:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![atiq](https://talk.openmrs.org/user_avatar/talk.openmrs.org/atiq/32/14179_2.png) [@atiq](https://talk.openmrs.org/u/atiq)\
**Post date:** [March 12, 2021, 11:14am UTC](https://talk.openmrs.org/t/server-side-pagination-in-patient-search/32620/1 "2021-03-12T11:14:40Z")

</div>

Hello There, I am willing to know about the patient search screen, do we have server side pagination in patient search screen. because I saw limit parameter in /patient(search patient) api to search a patient. Thanks

---

<div class="post-metadata">

**Author:** ![mozzy](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mozzy/32/11815_2.png) [@mozzy](https://talk.openmrs.org/u/mozzy)\
**Post date:** [March 12, 2021, 11:30am UTC](https://talk.openmrs.org/t/server-side-pagination-in-patient-search/32620/2 "2021-03-12T11:30:07Z")

</div>

The Rest module does some king of [pagination](https://github.com/openmrs/openmrs-module-webservices.rest/blob/master/omod-1.11/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_11/LivingPatientSearchHandler1_11.java#L65) on most Resource search basically using the `startIndex` and `limit` params .

On doing serch for many resources , the` limit` and [startIndex](https://github.com/openmrs/openmrs-module-webservices.rest/blob/b6e6fe09307bad6720357dd7bb0af093bd7e327f/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/NeedsPaging.java#L39) params are a [must](https://github.com/openmrs/openmrs-module-webservices.rest/blob/b6e6fe09307bad6720357dd7bb0af093bd7e327f/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/NeedsPaging.java#L39)

The Limit is used to limit the number of results returned on a single page and the startIndex to move to the next page

Read more here ,see [Sapmle Rest Calls](https://wiki.openmrs.org/display/docs/REST+Web+Services+API+For+Clients#RESTWebServicesAPIForClients-SampleRESTcalls)

---

<div class="post-metadata">

**Author:** ![atiq](https://talk.openmrs.org/user_avatar/talk.openmrs.org/atiq/32/14179_2.png) [@atiq](https://talk.openmrs.org/u/atiq)\
**Post date:** [March 12, 2021, 11:36am UTC](https://talk.openmrs.org/t/server-side-pagination-in-patient-search/32620/3 "2021-03-12T11:36:47Z")

</div>

You mean we need to take care about limit and start index at client side. Is patient search will support this approach because what I see in rest docs is [OpenMRS Docs](https://rest.openmrs.org/#available-operations-for-patients).

So I think it support pagination.

---

<div class="post-metadata">

**Author:** ![gcliff](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gcliff/32/8783_2.png) [@gcliff](https://talk.openmrs.org/u/gcliff)\
**Post date:** [March 12, 2021, 11:41am UTC](https://talk.openmrs.org/t/server-side-pagination-in-patient-search/32620/4 "2021-03-12T11:41:08Z")

</div>

> [@atiq](#):
>
> You mean we need to take care about limit and start index at client side

yes , some thing like `curl -i ` `'https://localhost:8443/openmrs/ws/rest/v1/concept?limit=2&startIndex=2'`

---

<div class="post-metadata">

**Author:** ![gcliff](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gcliff/32/8783_2.png) [@gcliff](https://talk.openmrs.org/u/gcliff)\
**Post date:** [March 12, 2021, 11:42am UTC](https://talk.openmrs.org/t/server-side-pagination-in-patient-search/32620/5 "2021-03-12T11:42:04Z")

</div>

Clients may request more or fewer results with the _limit_ parameter. For example:

`curl -u admin:test -i ` `'http://localhost:8080/openmrs/ws/rest/v1/concept?limit=2'`

The above will return only 2 concepts. To retrieve the next page of two concepts, use the _startIndex_ tag. For example:

`curl -i ` `'https://localhost:8443/openmrs/ws/rest/v1/concept?limit=2&startIndex=2'`

As a system administrator you can configure both the default limit (applied whenever the client does not specify a limit) and the absolute limit (which the client is not allowed to exceed), from the “Settings” page of the ws module.

---

<div class="post-metadata">

**Author:** ![atiq](https://talk.openmrs.org/user_avatar/talk.openmrs.org/atiq/32/14179_2.png) [@atiq](https://talk.openmrs.org/u/atiq)\
**Post date:** [March 12, 2021, 11:43am UTC](https://talk.openmrs.org/t/server-side-pagination-in-patient-search/32620/6 "2021-03-12T11:43:36Z")

</div>

Thats cool !! ,Thanks @mozzy for quick help. 😊

---

<div class="post-metadata">

**Author:** ![atiq](https://talk.openmrs.org/user_avatar/talk.openmrs.org/atiq/32/14179_2.png) [@atiq](https://talk.openmrs.org/u/atiq)\
**Post date:** [March 12, 2021, 11:54am UTC](https://talk.openmrs.org/t/server-side-pagination-in-patient-search/32620/7 "2021-03-12T11:54:26Z")

</div>

Thanks @gcliff for your help. 👍
