OHDSI Home | Forums | Wiki | Github

Can I Create an Atlas Cohort using R code? (not with mouse-point-and-click)


(Vojtech Huser) #1

Atlas allows creation of cohorts (via GUI) and generates SQL code for a user to use (in GUI or in R code). I looked at Circe on OHDSI Github and I understand it provides some layer of functionality. (but the repo seems somewhat dormant).

My questions is: Is it possible to create a cohort using R code (some hypothetical CohortMaker package).

…thus eliminating the need to point-and-click and use strictly Atlas web GUI.

Something like CohortMaker::InitialEventAddDrugExposure() and CohortMaker::createConceptSet().

I don’t need all GUI functionality (just 50% of the most important widgets).

If people point me to the right development direction, I am even volunteering to help develop this OhdsiCohortMaker package.


(Lee Evans) #2

@Vojtech_Huser we demonstrated the LTS CAPR R package that creates Atlas compatible cohorts programmatically, in a software demo at the US OHDSI symposium. We’re looking for additional use cases. Direct message me if you would like more details.


(Vojtech Huser) #3

Thank you for pointers. Important keyword is “Atlas compatible cohorts”. I think the key is to know how the current system works.

I think it is like this: GUI creates .JSON definition. Circe (or some other “package”) then takes this definition and generates .SQL

Well, maybe I will resort to just creating ConceptSets that can be nicely pasted into the GUI.

More questions:

  1. Where can I find the JSON schema for the cohort JSON.

  2. Looks like ConceptSets are defined by ancestors (as one option). I imported the below definition into Atlas to see it via GUI. http://atlas-demo.ohdsi.org/#/cohortdefinition/1772851 (in fact that is a side project (import of multiple .JSON files into Atlas). Right know, my tools depend on this being in Atlas (to get .sql). (tools defined here btw; older version as of now)

Example JSON:
https://raw.githubusercontent.com/OHDSI/Legend/master/inst/cohorts/Chronic%20kidney%20disease.json

image


(Pascal Brandt) #4

@pmadril created some schemas here:

Another way to determine the schema, if you are familiar with Java, is to look at the Circe Java objects, which you can find here. The submitted JSON objects are deserialized into these Java objects by the WebAPI.

To figure out how the final SQL is actually generated, you can inspect the builders here.

EDIT: This might be another useful resource (see cohortdefinition link on the right).


(Pablo J. Madril) #5

This was the motivation to write a JSON Schema for Atlas Cohort. I knew somebody else will need to exchange cohorts definitions without been constrained to Atlas tools. The mentioned API doesn’t help too much because there, the cohort definition, is just an string parameter. Circe Java objects helps more and were my consulting source during schema development.

The schema available at:

Atlas 2.7.4 Cohort Definition JSON Schema

fully describe a Atlas 2.7.4 cohort definition. Not just data types, but also validation constraints.
So, you can write a JSON and validate it with this schema or it can be used to generate a data entry form (like Atlas).

In fact, you can:

Hope this helps.


t