Skip to main content

🔥 fhiry — FHIR to Pandas DataFrame for Data Analytics, AI, and ML

Release Build status codecov Commit activity License Downloads Documentation

Generated by github-dependents-info

FHIRy is a Python package that simplifies health data analytics and machine learning by converting FHIR bundles or NDJSON files from bulk data export into pandas DataFrames. These DataFrames can be used directly with ML libraries such as TensorFlow and PyTorch. FHIRy also supports FHIR server search and FHIR tables on BigQuery.


✨ Features

  • Flatten FHIR Bundles/NDJSON to DataFrames for analytics and ML
  • Import from FHIR Server via FHIR Search API
  • Query FHIR Data on Google BigQuery
  • LLM-based Natural Language Queries (see examples/llm_example.py)
  • Flexible Filtering and Column Selection

🔧 Quick Start

Installation

Stable release:

pip install fhiry

Latest development version:

pip install git+https://github.com/dermatologist/fhiry.git

LLM support:

pip install fhiry[llm]

Usage

1. Import FHIR Bundles (JSON) from Folder

import fhiry.parallel as fp
df = fp.process('/path/to/fhir/resources')
print(df.info())

Example dataset: Synthea Notebook: notebooks/synthea.ipynb


2. Import NDJSON from Folder

import fhiry.parallel as fp
df = fp.ndjson('/path/to/fhir/ndjson/files')
print(df.info())

Example dataset: SMART Bulk Data Server Notebook: notebooks/ndjson.ipynb


3. Import FHIR Search Results

Fetch resources from a FHIR server using the FHIR Search API:

from fhiry.fhirsearch import Fhirsearch

fs = Fhirsearch(fhir_base_url="http://fhir-server:8080/fhir")
params = {"code": "http://snomed.info/sct|39065001"}
df = fs.search(resource_type="Condition", search_parameters=params)
print(df.info())

See fhir-search.md for details.


4. Import from Google BigQuery FHIR Dataset

from fhiry.bqsearch import BQsearch
bqs = BQsearch()
df = bqs.search("SELECT * FROM `bigquery-public-data.fhir_synthea.patient` LIMIT 20")

🚀 5. LLM-based Natural Language Queries

FHIRy supports natural language queries over FHIR bundles/NDJSON using llama-index:

pip install fhiry[llm]

See usage: examples/llm_example.py


🚀 6. Convert FHIR Bundles/Resources to Text for LLMs

Convert a FHIR Bundle or resource to a textual representation for LLMs:

from fhiry import FlattenFhir
import json

bundle = json.load(open('bundle.json'))
flatten_fhir = FlattenFhir(bundle)
print(flatten_fhir.flattened)

Filters and Column Selection

You can pass a config JSON to any constructor to remove or rename columns:

df = fp.process('/path/to/fhir/resources', config_json='{ "REMOVE": ["resource.text.div"], "RENAME": { "resource.id": "id" } }')
fs = Fhirsearch(fhir_base_url="http://fhir-server:8080/fhir", config_json='{ "REMOVE": ["resource.text.div"], "RENAME": { "resource.id": "id" } }')
bqs = BQsearch('{ "REMOVE": ["resource.text.div"], "RENAME": { "resource.id": "id" } }')

See df.columns for available columns. Example columns:

patientId
fullUrl
resource.resourceType
resource.id
resource.name
resource.telecom
resource.gender
...

Command Line Interface (CLI)

See CLI examples:

fhiry --help

Documentation

Full documentation: https://dermatologist.github.io/fhiry/


Contributing

We welcome contributions! See CONTRIBUTING.md.


Give Us a Star ⭐️

If you find this project useful, please give us a star to help others discover it.


Contributors

Metadata

Release files for fhiry 5.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fhiry 5.2.3
File Size Uploaded Provenance Actions
fhiry-5.2.3.tar.gz 935.5 kB With provenance Details for fhiry-5.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fhiry 5.2.3
File Interpreter ABI Platform Actions
fhiry-5.2.3-py3-none-any.whl Python 3 none any Details for fhiry-5.2.3-py3-none-any.whl

Total release size: 955.1 kB

Release files / fhiry-5.2.3.tar.gz

Download URL fhiry-5.2.3.tar.gz
Size 935.5 kB
Tags Source
SHA-256 checksum
How to use checksums
31879ecfb260574624527b49a3a5a068d61e2fb3fc1fd2a65ee9a2a66b61e703
BLAKE2b-256 checksum
How to use checksums
62072845796594c33b6b4be22d0ac554e124209e5b6aacf6d283b973c8dcc504
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / fhiry-5.2.3-py3-none-any.whl

Download URL fhiry-5.2.3-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
542b898da5250c71a2eaddf2b9dddfa7e89c7b11e4b4be109646868d67f09d21
BLAKE2b-256 checksum
How to use checksums
3eeffce062e845bf5586e8d52c5c064e365b46380b95d2d63f3b89b213d5f60b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for fhiry 5.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fhiry-5.2.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page