SASFHIR
A Python implementation that converts FHIR resources into tabular formats.
Overview
This library provides functionality to transform FHIR resources into tabular data structures based on SQL on FHIR view definitions. It extends the fhirpathpy library with custom functions and handles the conversion of FHIR resources into structured data that can be used for analytics and reporting.
Features
- FHIRPath Expression Evaluation: Evaluates FHIRPath expressions against FHIR resources
- SQL on FHIR View Processing: Processes view definitions to extract structured data
- Union Operations: Supports
unionAlloperations for combining multiple data sources - Conditional Processing: Handles
whereclauses and conditional logic - Column Mapping: Maps FHIR resource elements to named columns
- Iteration Support: Provides
forEachandforEachOrNulloperations
Installation
pip install sqlonfhir
Dependencies
fhirpathpy: Core FHIRPath evaluation engineantlr4-python3-runtime: ANTLR runtime for parsingpython-dateutil: Date/time utilities
Usage
from sqlonfhir import evaluate
# Define your view definition
view_definition = {
"resource": "Patient",
"column": [
{"name": "id", "path": "id"},
{"name": "name", "path": "name.given.first()"}
]
}
# Your FHIR resources
resources = [
{
"resourceType": "Patient",
"id": "patient1",
"name": [{"given": ["John"], "family": "Doe"}]
}
]
# Evaluate the view
result = evaluate(resources, view_definition)
print(result)
API
eval(resources, view_definition)
Main evaluation function that processes FHIR resources against a view definition.
Parameters:
resources: List of FHIR resources to processview_definition: SQL on FHIR view definition
Returns:
- List of dictionaries representing the extracted tabular data
Testing
Run the test suite:
uv run pytest
Generate test report:
./generate_test_report.sh
Project Structure
sasfhir/
├── sasfhir/
│ ├── __init__.py
│ └── sasfhir.py # Main implementation
├── tests/
│ ├── resources/ # Test FHIR resources and view definitions
│ └── test.py # Test suite
├── test_report/ # Test reporting utilities
├── requirements.txt # Dependencies
└── README.md # This file
Contributing
Maintainers are accepting patches and contributions to this project. Please read CONTRIBUTING.md for details about submitting contributions to this project.
License
This project is licensed under the Apache 2.0 License.
Those implementing FHIR projects should ensure they have the appropriate licenses to cover any required third party data standards.
Metadata
Release files for sqlonfhir 0.0.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 | Provenance | Actions |
|---|---|---|---|---|
| sqlonfhir-0.0.2.tar.gz | 4.8 kB | Without provenance | Details for sqlonfhir-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlonfhir-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for sqlonfhir-0.0.2-py3-none-any.whl |
Total release size: 10.3 kB
Release files / sqlonfhir-0.0.2.tar.gz
| Download URL | sqlonfhir-0.0.2.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb105bd2741de28c45928eb1f9b6d680407fd1f1423fb49877ee0d0000fac8e5
|
|
BLAKE2b-256 checksum How to use checksums |
f9e3b46d06f7b6127d1ac453ca1eb50c5aae0d342fbc2f75ae1d093ffdd3fa4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.13
|
Release files / sqlonfhir-0.0.2-py3-none-any.whl
| Download URL | sqlonfhir-0.0.2-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e1f4104d0f49572a7536fbd14277eb927f7869f4eba75d795833013e52e3dbf
|
|
BLAKE2b-256 checksum How to use checksums |
9d37c2b0a2af98c801131a47d97352a3269a80091e3341f2554e08b827b63163
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.13
|
Security for sqlonfhir 0.0.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.