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:
Target cohort definition: Cohort 1790466 - added new inclusion rules.
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)
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:
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:
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.
Thank you for considering this feature request!
Gowtham