helix.fhir.client.sdk

Fluent API to call the FHIR server that handles:

  1. Authentication to FHIR server

  2. Renewing access token when they expire

  3. Retry when there are transient errors

  4. Un-bundling the resources received from FHIR server

Main EntryPoint is FhirClient.

Github Repo

Example

from helix_fhir_client_sdk.fhir_client import FhirClient
server_url = "https://fhir.icanbwell.com/4_0_0"
auth_client_id = "{put client_id here}"
auth_client_secret = "{put client_secret here}"
auth_scopes = ["user/*.read", "access/*.*"]
fhir_client: FhirClient = FhirClient()
fhir_client = fhir_client.url(server_url)
fhir_client = fhir_client.resource("Patient")
fhir_client = fhir_client.client_credentials(auth_client_id, auth_client_secret)
fhir_client = fhir_client.auth_scopes(auth_scopes)

result = fhir_client.get()

import json
resource_list = json.loads(result.responses)
for resource in resource_list:
   print(resource['id'])

Indices and tables