diff --git a/README.md b/README.md index c804881..173fb3c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# SASFHIR +# SQL on FHIR 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. +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. This repository currently used the FHIR R4 specification. ## Features @@ -57,7 +57,7 @@ print(result) ## API -### `eval(resources, view_definition)` +### `evaluate(resources, view_definition)` Main evaluation function that processes FHIR resources against a view definition. **Parameters:** @@ -82,15 +82,15 @@ Generate test report: ## Project Structure ``` -sasfhir/ -├── sasfhir/ +sqlonfhir/ +├── sqlonfhir/ │ ├── __init__.py -│ └── sasfhir.py # Main implementation +│ └── sqlonfhir.py # Main implementation ├── tests/ │ ├── resources/ # Test FHIR resources and view definitions -│ └── test.py # Test suite +│ └── tests.py # Test suite ├── test_report/ # Test reporting utilities -├── requirements.txt # Dependencies +├── pyproject.toml # Project configuration └── README.md # This file ``` diff --git a/sqlonfhir/__init__.py b/sqlonfhir/__init__.py index abbbb1a..30499e8 100644 --- a/sqlonfhir/__init__.py +++ b/sqlonfhir/__init__.py @@ -1,7 +1,7 @@ # Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 -__version__ = "0.1.1-alpha" +__version__ = "0.0.2" from .sqlonfhir import eval as evaluate diff --git a/sqlonfhir/sqlonfhir.py b/sqlonfhir/sqlonfhir.py index 882a139..ce689b8 100644 --- a/sqlonfhir/sqlonfhir.py +++ b/sqlonfhir/sqlonfhir.py @@ -6,6 +6,27 @@ def eval(resources, view_definition): + """Evaluate FHIR resources against a SQL on FHIR view definition. + + Processes a list of FHIR resources and transforms into tabular data based + on the provided view definition. + + Args: + resources: List of FHIR resource dictionaries to process. + view_definition: SQL on FHIR view definition specifying how to + extract data from the resources. + + Returns: + List of dictionaries representing extracted tabular data where + each dictionary represents a row with column name/value pairs. + + Example: + >>> resources = [{"resourceType": "Patient", "id": "123"}] + >>> view = {"resource": "Patient", "column": [{"name": "id", "path": "id"}]} + >>> eval(resources, view) + [{"id": "123"}] + """ + norm = normalize(view_definition) result = [] evaluator = ViewDefinitionEvaluator()