Registry / http-networking / fhirclient

fhirclient

JSON →
library4.4.0pypypi✓ verified 84d ago

fhirclient is a flexible Python client for interacting with FHIR (Fast Healthcare Interoperability Resources) servers, supporting the SMART on FHIR protocol. It provides data model classes for FHIR resources and utilities for API interactions like reading, searching, and authorization. Currently at version 4.4.0, the library is actively maintained with regular releases addressing Python compatibility, FHIR specification updates, and feature enhancements.

pip install fhirclient
INSTALL
IMPORT
SIG · FHIRCLIENT
F
fhirclient
http-networkingpythonv4.4.0
Install
2.4s avg
Import
612ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.644s · 25.1MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.4s · import 0.581s · 26MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FHIRClient
from fhirclient.client import FHIRClient
from fhirclient import client

This quickstart demonstrates how to initialize the `FHIRClient`, fetch a specific patient resource by ID, and perform a basic search query. It uses environment variables for configuration to ensure security and flexibility, falling back to a public SMART Health IT sandbox for demonstration. The example also shows the use of `perform_resources_iter` for handling search results, which is recommended for robust pagination.

import os from fhirclient import client from fhirclient.models.patient import Patient # Configure settings for an open FHIR server settings = { 'app_id': os.environ.get('FHIR_APP_ID', 'my_app'), 'api_base': os.environ.get('FHIR_API_BASE', 'https://r4.smarthealthit.org') } # Initialize the FHIRClient smart = client.FHIRClient(settings=settings) # Try to read a specific patient by ID try: patient_id = os.environ.get('FHIR_PATIENT_ID', '2cda5aad-e409-4070-9a15-e1c35c46ed5a') # Example ID for smarthealthit.org sandbox patient = Patient.read(patient_id, smart.server) print(f"Successfully fetched Patient: {patient.id}") if patient.name: print(f"Patient Name: {smart.human_name(patient.name[0])}") if patient.birthDate: print(f"Birth Date: {patient.birthDate.isostring}") except Exception as e: print(f"Error fetching patient: {e}") # Example of a simple search for Patients try: search = Patient.where({'gender': 'female'}).limit(2) # Using perform_resources_iter for robust pagination handling (introduced in v4.3.0) female_patients = list(search.perform_resources_iter(smart.server)) print(f"\nFound {len(female_patients)} female patients (first 2):") for p in female_patients: print(f" - {smart.human_name(p.name[0]) if p.name else 'Unnamed'} (ID: {p.id})") except Exception as e: print(f"Error during patient search: {e}")
Debug
Known issues
breakingPython 3.8 support was dropped in `fhirclient` v4.3.0. As of v4.4.0, the minimum required Python version is 3.10. Older versions of Python will no longer work with these client versions.
fix
Upgrade your Python environment to 3.10 or newer, or pin `fhirclient` to an older compatible version (e.g., `<4.3.0` for Python 3.8).
affects: >=4.3.0
breakingIn v4.2.0, the date/time model was refined. `FHIRDate` is now a base class, with new specific classes `FHIRDateTime`, `FHIRInstant`, and `FHIRTime` inheriting from it. Code that used `field_type is FHIRDate` for exact type checking will break.
fix
Update type checks from `field_type is FHIRDate` to `issubclass(field_type, FHIRDate)` to correctly identify all FHIR date/time types.
affects: >=4.2.0
gotchaBeginning with v4.3.0, `FHIRSearch.perform_resources` now automatically handles pagination behind the scenes, potentially returning more results than previously. New methods `perform_iter` and `perform_resources_iter` were added for explicit iteration over paged results.
fix
Review existing uses of `FHIRSearch.perform_resources` to ensure the new pagination behavior is intended. For explicit control over pagination or to avoid loading all results into memory at once, switch to `perform_iter` or `perform_resources_iter`.
affects: >=4.3.0
gotchaVersion 4.4.0 added support for PKCE (Proof Key for Code Exchange) parameters in the authorization code exchange. While not a breaking change for existing flows, integration with FHIR servers that mandate PKCE for enhanced security might require client updates for full compliance or prevent authentication with older clients.
fix
Ensure your authorization flow incorporates PKCE if interacting with servers that require it. Refer to the `fhirclient` documentation or the SMART on FHIR specification for details on implementing PKCE with the library.
affects: All
gotchaThe `fhirclient` library's versioning is not directly tied to the FHIR specification versioning (e.g., R4, STU3). Always consult the `fhirclient` documentation or GitHub README to understand which FHIR specification versions a particular client version supports.
fix
Before using `fhirclient`, verify its compatibility with your target FHIR server's specification version by checking the official client-py documentation.
affects: All
deprecatedImplicit deprecation warnings for `FHIRSearch.perform` and `FHIRSearch.perform_resources` were being triggered by their `_iter` counterparts prior to v4.3.1. These warnings were unintended for the `_iter` versions.
fix
Upgrade to `fhirclient` v4.3.1 or newer to avoid spurious deprecation warnings when using `perform_iter` or `perform_resources_iter`.
affects: <4.3.1
Upgrade
Version history
4.4.0latest on PyPI · released Feb 10, 2026
Audit
Dependencies
pythonrequiredMinimum Python version required for fhirclient 4.4.0 is 3.10.
Agent activity
26 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources