OHDSICohortExpressions.jl

Reimplementation of OHDSI's Circe JSON->SQL compiler
Author MechanicalRabbit
Popularity
7 Stars
Updated Last
5 Months Ago
Started In
June 2021

OHDSICohortExpressions.jl

OHDSI Cohort Expressions is a re-implementation of OHDSI's Circe

Zulip Chat Open Issues Apache License

This is an alpha-quality implementation of a conversion from the JSON cohort definitions used in the OHDSI ecosystem into an SQL transaction.

Project Status

This project has only implemented a subset of the OHDSI Circe format which we are able to verify via the OHDSI PhentotypeLibrary. Other permutations are left as an assert error. If you encounter one of these, you could open a gap issue. We've not implemented these permutations since it's important to have a regression test, therefore providing an example cohort definition and results is helpful.

Example Usage

First, load or generate a cohort definition in OHDSI Circe format. In this example, we load the cohort definition from demo/ex-10-2.json, which corresponds to excercise 10.2 from the Book of OHDSI.

cohort_definition = read("demo/ex-10-2.json", String)

Next, use OHDSICohortExpressions.translate() to convert this cohort definition to a FunSQL query object.

using OHDSICohortExpressions: translate

q = translate(cohort_definition, cohort_definition_id = 1)

Run DBInterface.connect() to create a connection to an OMOP CDM database. The arguments of DBInterface.connect() depend on the database engine and connection parameters. Consult FunSQL documentation for more information.

using FunSQL, DBInterface

db = DBInterface.connect(FunSQL.SQLConnection{  },  )

Execute the query to return the corresponding cohort.

using DataFrames

cr = DBInterface.execute(db, q)

df = DataFrame(cr)

Used By Packages

No packages found.