Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Convert Cohort Expression JSON from ATLAS to Capr Object for Programmatic Modifications #101

Open
gowthamrao opened this issue Aug 22, 2024 · 1 comment

Comments

@gowthamrao
Copy link
Member

I have a use case where I need to programmatically modify a set of existing cohort definitions that are already defined in ATLAS (e.g., OHDSI Phenotype Library). Specifically, I would like to modify around 100+ cohort definitions by doing things like:

  • Editing an existing inclusion rule
  • Adding new inclusion rules with new concept sets
  • Changing the exit criteria
  • Other similar modifications

Capr seems like a fantastic tool for achieving this, but to proceed, I first need to convert an existing cohort expression from ATLAS into a Capr object. Currently, it appears there is no straightforward way to achieve this conversion.

Reproducible Code Example:

Here’s an example of what I’m trying to do. I want to convert the cohort definition to a Capr object, programmatically modify it, and post it back into Atlas:

Steps:

baseUrl <- "https://atlas-demo.ohdsi.org/WebAPI"

# Retrieve the cohort definition from ATLAS, which includes metadata like the cohort name
cohortDefinition <- ROhdsiWebApi::getCohortDefinition(cohortId = 1790465, baseUrl = baseUrl)

# Extract only the cohort expression component as a list from cohortDefinition
cohortExpressionList <- cohortDefinition$expression

# Convert the expression to JSON
cohortExpressionJson <- cohortExpressionList |> RJSONIO::toJSON(digits = 23)

# stuck - should cohortExpressionJson be converted to Capr object?

Feature Request: asCapr

Could a function be added to Capr that allows for the conversion of a cohort expression JSON (retrieved from ATLAS via WebAPI) into a Capr object, such as 'asCapr'? This would enable users to leverage Capr’s powerful programmatic interface to modify existing cohort definitions easily.

# This is the step where I would like to convert the JSON to a Capr object, but there is no function like 'asCapr'
cohortExpressionCapr <- Capr::asCapr(cohortExpressionJson)

Thank you for considering this feature request!

Gowtham

@mdlavallee92
Copy link
Collaborator

Yes this feature needs to be added. It was in an older version of Capr. Will need some time to implement it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants