Pagination
Every list in the iClinic Integration API returns one page at a time. Each endpoint uses one of two paging styles:
| Style | Endpoints and when to stop |
|---|---|
| Cursorlimit, cursor | /patients /appointments /receipts /therapy-plansStop when nextCursor is null. |
| Page numberpageSize, page | /encountersStop when you have received all total encounters (visits), or when a page is empty. |
Cursor: patients, appointments, receipts, therapy plans
- Make the first call with only
limit(1–500, default 200). - The response has
nextCursor. If it is notnull, there is a next page: call again withcursor=set to that value. - Repeat until
nextCursorisnull.
- Keep
limitandupdatedSince(if you use it) the same on every page. - Use
nextCursorexactly as you received it. Do not construct or parse it yourself. A wrongcursorreturns400 INVALID_CURSOR. - Results are sorted by
(updatedAt, id)in ascending order. Records added or changed between two calls do not shift the later pages: a record that has not changed is never skipped or repeated, and a record that has just changed appears once more, at its new position.
Page number: /encounters
Use page (starting at 0) and pageSize (1–500, default 200). Increase page until you have received all total encounters, or until a page is empty.
Results are sorted newest first. If new encounters are created while you are paging, the pages can shift, so deduplicate by encounterUuid when you merge the results.
from set to one of the last few days, is enough to reconcile appointments.
-
First call, no
cursoryetSend
GET /patients?limit=2Receive2 records,
nextCursordjF8cGF0… -
Paste the
nextCursoryou just received intocursorSend
GET /patients?limit=2&cursor=djF8cGF0…Receive2 records,
nextCursordjF8Z2h5… -
Repeat until
nextCursorisnullSend
GET /patients?limit=2&cursor=djF8Z2h5…Receive1 record,
nextCursornullno more pages, stop
# the first call has no cursor yet: leave this parameter out
cursor = null
loop:
page = GET /patients?limit=500&cursor=CURSOR
process each record in page.patients
cursor = page.nextCursor
if cursor is null: stop
-
First page:
page=0Send
GET /encounters?…&pageSize=200&page=0Receive
total340, 200 encounters -
Increase
pageto 1Send
GET /encounters?…&pageSize=200&page=1Receive
total340, 140 encounters. 200 + 140 = 340 all received, stop
… stands for from and to, which stay the same on every page.