Skip to content

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

@gowthamrao

Description

@gowthamrao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions