# 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
```bash
pip install fhir4ds
```
### Database Setup
```python
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
```python
# 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
```python
# 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
```python
# 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](./docs/README.md).
## Testing
Run the comprehensive test suite:
```bash
# 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
- [SQL-on-FHIR Specification](https://github.com/FHIR/sql-on-fhir-v2) - Official specification
- [FHIR R4 Specification](https://hl7.org/fhir/R4/) - FHIR standard
- [DuckDB](https://duckdb.org/) - High-performance analytics database
- [PostgreSQL](https://www.postgresql.org/) - Enterprise-grade relational database
Raw data
{
"_id": null,
"home_page": null,
"name": "fhir4ds",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "analytics, data-science, duckdb, fhir, fhirpath, healthcare, postgresql, sql, viewdefinition",
"author": null,
"author_email": "Joel Montavon <joelmontavon@gmail.com>",
"download_url": null,
"platform": null,
"description": "# FHIR for Data Science (FHIR4DS)\n\nProduction-ready healthcare analytics platform providing 100% SQL-on-FHIR v2.0 compliance with dual database support (DuckDB + PostgreSQL).\n\n**Current Version**: 0.5.0 (Complete FHIRPath Specification Implementation) \n**Test Compliance**: 100% (117/117 tests passing)\n**Database Support**: DuckDB 100% + PostgreSQL 100% \n**User Experience**: One-line setup, multi-format export, batch processing\n\n## Key Features\n\n- **100% SQL-on-FHIR v2.0 compliance** - All 117 official tests passing\n- **Dual database support** - DuckDB and PostgreSQL with identical functionality\n- **Advanced FHIRPath parsing** - Complete parser with 187 choice type mappings\n- **CTE-based SQL generation** - 95% reduction in SQL complexity\n- **Parallel processing** - High-performance data loading and query execution\n- **Multi-format export** - Pandas, JSON, CSV, Excel, Parquet\n- **Database object creation** - Views, tables, schemas from ViewDefinitions\n\n## Quick Start\n\n### Installation\n```bash\npip install fhir4ds\n```\n\n### Database Setup\n```python\nfrom fhir4ds.datastore import QuickConnect\n\n# DuckDB (recommended for analytics)\ndb = QuickConnect.duckdb(\"./healthcare_data.db\")\n\n# PostgreSQL (enterprise-grade)\ndb = QuickConnect.postgresql(\"postgresql://user:pass@host:5432/db\")\n\n# Auto-detect from connection string\ndb = QuickConnect.auto(\"./local.db\") # \u2192 DuckDB\n```\n\n### Load Data\n```python\n# Load FHIR resources with parallel processing\ndb.load_resources(fhir_resources, parallel=True)\n\n# Load from JSON files (optimized for large files)\ndb.load_from_json_file(\"fhir_bundle.json\", use_native_json=True)\n```\n\n### Execute Queries and Export\n```python\n# Execute ViewDefinitions with immediate export\ndf = db.execute_to_dataframe(view_definition)\ndb.execute_to_excel([query1, query2], \"report.xlsx\", parallel=True)\ndb.execute_to_parquet(analytics_query, \"dataset.parquet\")\n\n# Batch processing with progress monitoring\nresults = db.execute_batch(queries, parallel=True, show_progress=True)\n```\n\n### Create Database Objects\n```python\n# Create analytics infrastructure\ndb.create_schema(\"clinical_analytics\")\ndb.create_view(patient_view, \"patient_demographics\")\ndb.create_table(observation_view, \"vital_signs_table\")\n\n# List created objects\ntables = db.list_tables()\nviews = db.list_views()\n```\n\nFor more details, please see the [documentation](./docs/README.md).\n\n## Testing\n\nRun the comprehensive test suite:\n\n```bash\n# Test both DuckDB and PostgreSQL dialects\npython tests/run_tests.py --dialect all\n\n# Test specific dialect\npython tests/run_tests.py --dialect duckdb\npython tests/run_tests.py --dialect postgresql\n```\n\nTest results: 117/117 tests passing on both DuckDB and PostgreSQL.\n\n## License\n\nGNU General Public License v3 (GPLv3)\n\n## Related Projects\n\n- [SQL-on-FHIR Specification](https://github.com/FHIR/sql-on-fhir-v2) - Official specification\n- [FHIR R4 Specification](https://hl7.org/fhir/R4/) - FHIR standard\n- [DuckDB](https://duckdb.org/) - High-performance analytics database\n- [PostgreSQL](https://www.postgresql.org/) - Enterprise-grade relational database",
"bugtrack_url": null,
"license": "GNU General Public License v3 (GPLv3)",
"summary": "Production-ready healthcare analytics platform providing 100% SQL-on-FHIR v2.0 compliance with dual database support (DuckDB + PostgreSQL)",
"version": "0.5.1",
"project_urls": {
"Bug Tracker": "https://github.com/joelmontavon/fhir4ds/issues",
"Documentation": "https://github.com/joelmontavon/fhir4ds/blob/main/docs/README.md",
"Homepage": "https://github.com/joelmontavon/fhir4ds",
"Repository": "https://github.com/joelmontavon/fhir4ds"
},
"split_keywords": [
"analytics",
" data-science",
" duckdb",
" fhir",
" fhirpath",
" healthcare",
" postgresql",
" sql",
" viewdefinition"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "5487ad5ad3c01af4c513369670203fa87e20cd3174522dc4f0077f511fd2d2c1",
"md5": "07a4e90adb1bf567abaaad3a09db8c3c",
"sha256": "9ce451d9f4b24ac07f04f9808425f0fe0a9af6b07aab904948a26a404440651a"
},
"downloads": -1,
"filename": "fhir4ds-0.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "07a4e90adb1bf567abaaad3a09db8c3c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 195888,
"upload_time": "2025-07-11T00:28:47",
"upload_time_iso_8601": "2025-07-11T00:28:47.823739Z",
"url": "https://files.pythonhosted.org/packages/54/87/ad5ad3c01af4c513369670203fa87e20cd3174522dc4f0077f511fd2d2c1/fhir4ds-0.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-11 00:28:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "joelmontavon",
"github_project": "fhir4ds",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "fhir4ds"
}