We will typically want to save the codelists we create for re-use. To show how we can do this, let’s first create an empty folder to store our codelists in.
Now let’s create a couple of codelists that we will save.
codelist <- list("codes1" = c(1L, 2L, 3L),
"codes2" = c(4L, 5L, 10L))
codelist <- newCodelist(codelist)
codelist We can use exportCodelist() to save these as two CSVs,
one for each codelist.
To import codelists, we have importCodelist(). Here we
can see that we can easily import our codelists back into R.
As we’ve seen in the previous vignettes, codelists can also be
represented as concept set which is resolved against the OMOP CDM
vocabulary. To import these we can use
importConceptSetExpression().
Take this example concept set expression.
library(jsonlite)
concept_set_path <- system.file("concepts_for_mock/arthritis_with_excluded.json",
package = "CodelistGenerator")
fromJSON(concept_set_path) |> toJSON(pretty = TRUE, auto_unbox = TRUE)We can bring this into R as a concept set expression.
And we can then resolve it to a concept set. Note, for this we will need to specify a cdm reference as the result will be tied to a given OMOP CDM vocabulary version which will specify the relevant descendants.