All Projects → arkhn → FHIR2Dataset

arkhn / FHIR2Dataset

Licence: Apache-2.0 License
Query FHIR apis with SQL, for analytics and ML.

Programming Languages

python
139335 projects - #7 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to FHIR2Dataset

Projeto-EAR-Celso
e-AR - Emergency Ventilator
Stars: ✭ 17 (-34.62%)
Mutual labels:  covid-19
covidseir
Bayesian SEIR model to estimate the effects of social-distancing on COVID-19
Stars: ✭ 23 (-11.54%)
Mutual labels:  covid-19
covid-estados
Este proyecto recopila, sistematiza y facilita el acceso a información oficial relevante, líneas de atención y medidas de restricción o protección implementadas por los gobiernos estatales.
Stars: ✭ 19 (-26.92%)
Mutual labels:  covid-19
coronavirus-stats
Automatically scrape data and statistics on Coronavirus to make them easily accessible in CSV format
Stars: ✭ 47 (+80.77%)
Mutual labels:  covid-19
dockerfiles
Dockerfiles everywhere 🐳
Stars: ✭ 17 (-34.62%)
Mutual labels:  covid-19
covid19-badges
🦠 SVG badges displaying cases and deaths of COVID-19
Stars: ✭ 31 (+19.23%)
Mutual labels:  covid-19
covid-19-datasette
Deploys a Datasette instance of COVID-19 data from Johns Hopkins CSSE and the New York Times
Stars: ✭ 62 (+138.46%)
Mutual labels:  covid-19
covid-19-data-cleanup
Scripts to cleanup data from https://github.com/CSSEGISandData/COVID-19
Stars: ✭ 25 (-3.85%)
Mutual labels:  covid-19
social-data
Code and data for eviction and housing analysis in the US
Stars: ✭ 17 (-34.62%)
Mutual labels:  covid-19
corona-widget-at
COVID-19 incidence widget for iOS within Austria 🇦🇹
Stars: ✭ 16 (-38.46%)
Mutual labels:  covid-19
COVID-19-Datasets
Novel Coronavirus (COVID-19) Cases for India, provided by University of Kalyani.
Stars: ✭ 19 (-26.92%)
Mutual labels:  covid-19
covid-19-community
Community effort to build a Neo4j Knowledge Graph (KG) that links heterogeneous data about COVID-19
Stars: ✭ 95 (+265.38%)
Mutual labels:  covid-19
covid19-api
Covid19 Data API (JSON) - LIVE
Stars: ✭ 20 (-23.08%)
Mutual labels:  covid-19
covid-stats
COVID-19 Stats Chrome Extension - React & TypeScript
Stars: ✭ 30 (+15.38%)
Mutual labels:  covid-19
neleryasak
Yeni normalleşme süreci şehirler özelindeki yasaklar toolu :)
Stars: ✭ 43 (+65.38%)
Mutual labels:  covid-19
quarantine-bot
WhatsApp bot powered by Twilio API to get through the quarantine. Latest COVID19 statistics, world news, inspirational quotes and cat photos.
Stars: ✭ 24 (-7.69%)
Mutual labels:  covid-19
covid hospitals demographics
COVID-19 relevant data on hospital location / capacity, nursing home location / capacity, county demographics
Stars: ✭ 21 (-19.23%)
Mutual labels:  covid-19
cl-covid19
Explore COVID-19 data with Common Lisp, gnuplot, SQL and Grafana
Stars: ✭ 51 (+96.15%)
Mutual labels:  covid-19
ontario-covid19
Simple dashboard that fetches official Covid-19 data from Ontario and plots it
Stars: ✭ 39 (+50%)
Mutual labels:  covid-19
React-Covid19-Tracker
🏪🏪New updated Covid -19 tracker with neat and clean UI. Here we can able to sort and search by different country. Here we used ReactJs and basic HTML5 and CSS.
Stars: ✭ 17 (-34.62%)
Mutual labels:  covid-19

FHIR Query

Query any FHIR api using SQL to get tabular datasets.

Usage

import fhir2dataset as query
sql_query = """
SELECT Patient.name.family, Patient.address.city
FROM Patient
WHERE Patient.birthdate = 2000-01-01 AND Patient.gender = 'female'
"""
query.sql(sql_query)
100%|██████████| 1000/1000 [00:01<00:00, 16it/s]

    Patient.name.family        Patient.address.city
--------------------------------------------
0   Mozart                     Paris
1   Chopin                     London
2   Listz                      Vienna
...

FHIR Query is still under active development, feedback and contributions are welcome!

Installation

pip install fhir2dataset

From source

After cloning this repository, you can install the required dependencies

pip install -r requirements.txt
npm install --prefix ./fhir2dataset/tools/metadata

Check that the version of antlr4 is 4.8: npm view antlr4 version. If not, run cd fhir2dataset/metadata && npm install [email protected].

Getting started

There are two possible ways to enter the query: as a SQL query or as a JSON config file

SQL query

You can define SQL queries of the following form:

SELECT alias_1.a, alias_1.b, alias_2.a
FROM Resource_1 AS alias_1
INNER JOIN Resource_2 AS alias_2 ON alias_1.d = alias_2
WHERE alias_1.c = value_1
AND alias_2.d = value_2

Important note: Attributes in the SELECT clause should be valid fhir paths, while attributes in the WHERE clause should be valid search parameters.

Note that we only support a subset of SQL keywords.

By default, FHIR Query will use the HAPI FHIR Api. But you can use your own api using the following syntax:

import fhir2dataset as query

sql_query = "SELECT ..."

query.sql(
    sql_query=sql_query,
    fhir_api_url="https://api.awesome.fhir.org/baseR4/",
    token="<my token>"
)

To have more infos about the execution, you can enable logging:

import logging
logging.basicConfig(level=logging.INFO)

JSON config file

You can also use JSON configuration files.

from fhir2dataset.query import Query
from fhir2dataset.fhirrules_getter import FHIRRules

fhir_api_url = 'http://hapi.fhir.org/baseR4/'
fhir_rules = FHIRRules(fhir_api_url=fhir_api_url)
query = Query(fhir_api_url, fhir_rules=fhir_rules)

config.json:

{
  "select": {
    "alias_1": ["a", "b"],
    "alias_2": ["a"]
  },
  "from": {
    "alias_1": "Resource_1",
    "alias_2": "Resource_2"
  },
  "join": {
    "inner": {
      "alias_1": {
        "d": "alias_2"
      }
    }
  },
  "where": {
    "alias_1": {
      "c": "value_1"
    },
    "alias_2": {
      "d": "value_2"
    }
  }
}
with open('/path/to/config.json') as json_file:
    config = json.load(json_file)

query = Query(fhir_api_url=fhir_api_url, token=token)
query = query.from_config(config)
query.execute()

For extended usage, you can refer to this tutorial and then this Jupyter Notebook

More Examples

Check out examples of queries and how they are transformed in call to the FHIR api!

Contributing

The following commands on a terminal and in your virtual environment allow you to do some minimal local testing before each commit:

pip install -r requirements-dev.txt
pre-commit install

If you ever want to delete them you just have to do:

pre-commit clean
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].