FHIR SDK for Databricks

FHIR SDK for Databricks

PyPi: https://pypi.org/project/helix.fhir.client.sdk/
Source Code: https://github.com/icanbwell/helix.fhir.client.sdk
Documentation: https://icanbwell.github.io/helix.fhir.client.sdk/

This Python package makes it easy to communicate with any FHIR server but can take advantage of the b.well high performance FHIR server. Clients can just provide data to send to the FHIR server or to stream down. The SDK manages all the complexity around data streaming, can automatically refresh OAuth tokens when they expire, uses async/await programming to do parallel calls to FHIR servers and even simulates the $graph operation on FHIR servers that don’t support it.

The FHIR Client SDK has no dependency on Databricks and can be used in any Python program. This SDK is used by other packages in the SDK when there is a need to push and pull data from the FHIR server.

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'])