Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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:**
Expand All @@ -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
```

Expand Down
2 changes: 1 addition & 1 deletion sqlonfhir/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
21 changes: 21 additions & 0 deletions sqlonfhir/sqlonfhir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down