fhir-query
A simple Python client library for querying FHIR servers. Sync and async support.
Features
- Synchronous and asynchronous FHIR server querying
- Multiple authentication methods (Basic Auth, Token Auth, Login Auth)
- Support for GET and POST search requests
- Pagination handling
- Bundle response handling with DataFrame conversion
- Type hints and resource type validation
Installation
pip install fhir-query
Quick Start
Synchronous Client
from fhir_query import FhirQueryClient
# Initialize the client
client = FhirQueryClient(
base_url="https://hapi.fhir.org/baseR4/",
)
# Query patients
response = client.get(resource_type="Patient", params={"family": "Smith"})
# Access the raw bundle
bundle = response.data
print(bundle)
# Access the resources
resources = response.resources
print(resources)
Asynchronous Client
from fhir_query import AsyncFhirQueryClient
import asyncio
async def main():
# Initialize the async client
client = AsyncFhirQueryClient(
base_url="https://hapi.fhir.org/baseR4/",
)
# Query patients
response = await client.get(
resource_type="Patient",
params={"gender": "female"}
)
# Convert to DataFrame
df = response.to_df()
print(df)
asyncio.run(main())
Authentication Methods
The client supports three authentication methods:
basic: Basic HTTP authentication with username and passwordtoken: Bearer token authenticationlogin: Login-based authentication that obtains a token from a login endpoint
Bundle Handling
The FhirQueryBundle class provides convenient methods to work with FHIR Bundle responses:
# Get total count
total_count = bundle.total
# Access resources
resources = bundle.resources
# Convert to DataFrame
df = bundle.to_df()
# Pagination
next_link = bundle.next_link
previous_link = bundle.previous_link
Metadata
Release files for fhir-query 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fhir_query-0.1.2.tar.gz | 15.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fhir_query-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.9 kB
Release files / fhir_query-0.1.2.tar.gz
| Download URL | fhir_query-0.1.2.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69ebeeb75c353ffe86c88be8880d9a0c7ae684a2e57332ac0d53f2b9f5e8294d
|
|
BLAKE2b-256 checksum How to use checksums |
0c01fd38ca9983feeafbf4942b6042eec6007d40cc2a4528d73b159e73005a97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.22
|
Release files / fhir_query-0.1.2-py3-none-any.whl
| Download URL | fhir_query-0.1.2-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2260f367be08a37b75266ea576fac9d76eaf721bd8657f09cf4cd398c4064ed5
|
|
BLAKE2b-256 checksum How to use checksums |
7191b0b4db34ca93aac7044d7a5034db059873435d918cd245b0f31eb1176ebb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.22
|