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.4.1 (Advanced Architecture & Performance Optimizations)
Test Compliance: 100% (117/117 tests passing) ✅ Complete Dual Dialect Compliance
Database Support: DuckDB 100% + PostgreSQL 100% ✅ Production Ready
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.4.1-py3-none-any.whl (169.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fhir4ds-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 169.4 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.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c479fde4a786b2586eecda6cd20fa8fca7f2c6a2ee0c36d2f369fc3a5a926e4
MD5 2543bba20f987582ccda61ffe3c84e50
BLAKE2b-256 55920798498c55a6c31f9dbad3b8f6fa23269384319822f3ce8ed848e9fba07c

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