Skip to main content

No project description provided

Project description

fhir-query

Leveraging FHIR GraphDefinition for Data Traversals and Local Analysis


Overview

This project leverages FHIR GraphDefinition objects to define and execute graph-based traversals across multiple interconnected FHIR resource graphs. The data retrieved is written to a local SQLite database for persistence and later transformed into analyst-friendly dataframes for analysis using tools like Python’s pandas library.


Motivation

FHIR Search provides a robust querying framework but comes with significant limitations:

  1. Deep Chaining Limits:
    Chaining searches (e.g., Patient -> Observation -> Encounter -> Procedure) often hits server depth limitations.

  2. Inefficient Query Execution:
    Searching deeply related resources requires multiple chained requests, leading to performance issues and unnecessary round trips.

  3. Lack of Explicit Traversals:
    Relationships in FHIR are implicit in references (e.g., Observation.subject pointing to Patient). This implicit structure requires manual composition of queries, which is prone to errors.

By using FHIR GraphDefinition, we declaratively define resource relationships and efficiently retrieve data. Once retrieved, the data is stored locally and can be transformed into dataframes for advanced analysis.


Key Features

  • GraphDefinition-Driven Traversals: Use GraphDefinition objects to define explicit relationships between resources and automate traversal logic.
  • Local SQLite Storage: Persist the retrieved FHIR data in a local SQLite database for querying and offline analysis.
  • Analyst-Friendly Dataframes: Convert stored FHIR resources into pandas dataframes for ease of use in analytical workflows.
  • Reusable Graph Definitions: Maintain a library of GraphDefinition YAML files that can be reused across different workflows and projects.

Architecture

Components

  1. GraphDefinition Library

  2. Traversal Engine

    • Reads a GraphDefinition and iteratively queries the FHIR server using RESTful _include and _revinclude operations for efficiency.
    • Stores the retrieved resources in a SQLite database in JSON format for flexibility.
  3. SQLite Data Storage

    • Table Schema: see fhir_query.ResourceDB
  4. Analyst-Friendly DataFrames TODO

    • Transforms FHIR data from SQLite into pandas dataframes for easier analysis.
    • Data can be filtered, aggregated, or visualized to meet analytical use cases.

Workflow

  1. Load a GraphDefinition

    • Define a GraphDefinition object (e.g., study-to-documents) to specify the traversal path.
  2. Execute Traversal

    • Use the Traversal Engine to query the FHIR server based on the GraphDefinition.
    • Follow each link and include related resources efficiently using _include or _revinclude.
  3. Store Data Locally

    • Write the retrieved resources to the SQLite database with their resource types and full JSON representation.
  4. Transform to DataFrames TODO

    • Retrieve specific resource types or relationships from the SQLite database.
    • Convert the JSON data into structured pandas dataframes for analysis.

Usage

To use the fq command, you need to provide the necessary options. Below is an example of how to use the command:

fq --help
Usage: fq [OPTIONS] COMMAND [ARGS]...

  FHIR-Aggregator utilities.

Commands:
  ls          List all the installed GraphDefinitions.
  run         Run GraphDefinition queries.
  results     Work with the results of a GraphDefinition query.
  vocabulary  FHIR-Aggregator's key Resources and CodeSystems.

Examples:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fhir_aggregator_client-0.2.tar.gz (29.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fhir_aggregator_client-0.2.0-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

fhir_aggregator_client-0.2-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file fhir_aggregator_client-0.2.tar.gz.

File metadata

  • Download URL: fhir_aggregator_client-0.2.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for fhir_aggregator_client-0.2.tar.gz
Algorithm Hash digest
SHA256 a22f84fcbdee20c8d07a9463b47aa26e9c52a4dac497a326cc4392a4ed57630a
MD5 16ad14a6083218690af81985b8b2bebe
BLAKE2b-256 4bac0fd3d1893de1c4d3599e6356ba70bd53da336a8bab0f02c8966115f0a41a

See more details on using hashes here.

File details

Details for the file fhir_aggregator_client-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fhir_aggregator_client-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6af42f4fe8c50f69eeef38905ac20df020a5f7f01df6b7029b4e3a0ec67568c
MD5 a42bc5ecb95256f674764e22f4950998
BLAKE2b-256 0cd9a0a474099fc3c468c96a3a2b14e0c7a601f1b7a99ffee31c9ffec2093185

See more details on using hashes here.

File details

Details for the file fhir_aggregator_client-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for fhir_aggregator_client-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d9effbdb12944b2097b6e2dfcd91c96c6df6fec5f75b2a9501f288e89a0a2c93
MD5 2cf42db82310e8eb785897fcf6b27232
BLAKE2b-256 fc8d8ef5fd9f9e9dfecea0faaf02a05581b32b5f59511d6b6d7d227e17a179d6

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