OHDSI Home | Forums | Wiki | Github

Getting CONCEPT_ID-s used in the cohort definition JSON

I have a set of cohort definition JSONs. Is there a function in any of the OHDSI R packages that uses the JSON as input and gives out all CONCEPT_ID-s used within this definition (preferably with the “descendants” flag)? I’ve been trying to find such without success (Capr allows only creating a new cohort, Capr::readInCirce() seems to be deprecated, etc…)

Of course I can come up with

cohortjson <- jsonlite::fromJSON(mycohortjson)
all_concept_ids <- unique(unlist(lapply(cohortjson$ConceptSets$expression$items, function(item) item$concept$CONCEPT_ID)))

but perhaps there is more elegant solution available.

Latest version of circeR has this function. This will give you the query that you can execute on a CDM vocabulary database and it will give you back the ‘resolved’ concept IDs.

If you just want to know what concepts are in the expression itself, what you have above works fine. You can just filter out the items that have the IS_DESCENDANT flag set, but also probably makes sense to remove the IS_EXCLUDED ones since those are marked to remove concepts from the result, so probably not what you are looking for.

1 Like