Skip to main content

Production-ready healthcare analytics platform providing 100% SQL-on-FHIR v2.0 compliance with dual database support (DuckDB + PostgreSQL)

Project description

FHIR for Data Science (FHIR4DS)

Production-ready healthcare analytics platform providing 100% SQL-on-FHIR v2.0 compliance with dual database support (DuckDB + PostgreSQL).

Current Version: 0.5.0 (Complete FHIRPath Specification Implementation)
Test Compliance: 100% (117/117 tests passing) Database Support: DuckDB 100% + PostgreSQL 100%
User Experience: One-line setup, multi-format export, batch processing

Key Features

  • 100% SQL-on-FHIR v2.0 compliance - All 117 official tests passing
  • Dual database support - DuckDB and PostgreSQL with identical functionality
  • Advanced FHIRPath parsing - Complete parser with 187 choice type mappings
  • CTE-based SQL generation - 95% reduction in SQL complexity
  • Parallel processing - High-performance data loading and query execution
  • Multi-format export - Pandas, JSON, CSV, Excel, Parquet
  • Database object creation - Views, tables, schemas from ViewDefinitions

Quick Start

Installation

pip install fhir4ds

Database Setup

from fhir4ds.datastore import QuickConnect

# DuckDB (recommended for analytics)
db = QuickConnect.duckdb("./healthcare_data.db")

# PostgreSQL (enterprise-grade)
db = QuickConnect.postgresql("postgresql://user:pass@host:5432/db")

# Auto-detect from connection string
db = QuickConnect.auto("./local.db")  # → DuckDB

Load Data

# Load FHIR resources with parallel processing
db.load_resources(fhir_resources, parallel=True)

# Load from JSON files (optimized for large files)
db.load_from_json_file("fhir_bundle.json", use_native_json=True)

Execute Queries and Export

# Execute ViewDefinitions with immediate export
df = db.execute_to_dataframe(view_definition)
db.execute_to_excel([query1, query2], "report.xlsx", parallel=True)
db.execute_to_parquet(analytics_query, "dataset.parquet")

# Batch processing with progress monitoring
results = db.execute_batch(queries, parallel=True, show_progress=True)

Create Database Objects

# Create analytics infrastructure
db.create_schema("clinical_analytics")
db.create_view(patient_view, "patient_demographics")
db.create_table(observation_view, "vital_signs_table")

# List created objects
tables = db.list_tables()
views = db.list_views()

For more details, please see the documentation.

Testing

Run the comprehensive test suite:

# Test both DuckDB and PostgreSQL dialects
python tests/run_tests.py --dialect all

# Test specific dialect
python tests/run_tests.py --dialect duckdb
python tests/run_tests.py --dialect postgresql

Test results: 117/117 tests passing on both DuckDB and PostgreSQL.

License

GNU General Public License v3 (GPLv3)

Related Projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fhir4ds-0.5.0-py3-none-any.whl (176.6 kB view details)

Uploaded Python 3

File details

Details for the file fhir4ds-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: fhir4ds-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 176.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for fhir4ds-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3fcd3e34ecfb4b47ea716f4eaec9ed2551aa38e238e7b4ef69515f0827b579b
MD5 44dcd470f367129fbbd9be6c417427b5
BLAKE2b-256 75863a789cdf7adabe9f8760036245f52ab065579aeb0244cc37868fa3cf9acb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page