Skip to content

Add support for pagination in FHIR accessor #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

emiller95
Copy link

Adds support for paginating results from the AHDS FHIR rest API

url = base_url
while url and len(entries) < result_count_limit:
print(f"Fetching from URL: {url}")
response = requests.get(url, headers=await self.get_headers())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using aiohttp here

token = extract_continuation_token(response_json)
if token:
# Append or replace query string with continuation token
parsed_url = urllib.parse.urlparse(base_url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be done outside of the loop. base_url doesn't change.

if token:
# Append or replace query string with continuation token
parsed_url = urllib.parse.urlparse(base_url)
url = f"{parsed_url.scheme}://{parsed_url.netloc}{parsed_url.path}?{token}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider building the base url outside of the loop. URL scheme, domain and path should not change once inside the loop.

@emiller95 emiller95 closed this Jun 4, 2025
@emiller95 emiller95 deleted the evmiller/FhirAccessorUpdate branch June 4, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants