Skip to content

Commit d557a4b

Browse files
committed
fix fhir pagination
1 parent c3dd535 commit d557a4b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

jupyterhealth_client/_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class JupyterHealthClient:
7070
Client for JupyterHealth data Exchange
7171
"""
7272

73+
_default_page_size = 1000
74+
7375
def __init__(
7476
self,
7577
url: str = _EXCHANGE_URL,
@@ -152,6 +154,7 @@ def _fhir_list_api_request(
152154
self, path: str, *, limit=None, **kwargs
153155
) -> Generator[dict[str, Any]]:
154156
"""Get a list from a fhir endpoint"""
157+
kwargs.setdefault("params", {}).setdefault("_count", self._default_page_size)
155158
r: dict = self._api_request(path, fhir=True, **kwargs)
156159

157160
records = 0
@@ -176,11 +179,8 @@ def _fhir_list_api_request(
176179
return
177180

178181
# paginated request
179-
next_url = None
180-
for link in r.get("link") or []:
181-
if link["relation"] == "next":
182-
next_url = link["url"]
183-
# only proceed to the next page if this page is empty
182+
next_url = r.get("next")
183+
# only proceed to the next page if this page is not empty
184184
if next_url and new_records:
185185
kwargs.pop("params", None)
186186
r = self._api_request(next_url, **kwargs)

0 commit comments

Comments
 (0)