Skip to contents

Subset a codelist to only those codes from a particular domain.

Usage

subsetOnDomain(x, cdm, domain, negate = FALSE)

Arguments

x

A codelist.

cdm

A cdm reference via CDMConnector.

domain

Character vector with one or more of the OMOP CDM domains. The results will be restricted to the given domains. Check the available ones by running getDomains(). If NULL, all supported domains are included: Condition, Drug, Procedure, Device, Observation, and Measurement.

negate

If FALSE, only concepts with the domain specified will be returned. If TRUE, concepts with the domain specified will be excluded.

Value

The codelist with only those concepts associated with the domain (if negate = FALSE) or the codelist without those concepts associated with the domain (if negate = TRUE).

Examples

# \donttest{
library(CodelistGenerator)
cdm <- mockVocabRef()
#> Warning: There are observation period end dates after the current date: 2025-04-11
#>  The latest max observation period end date found is 2025-12-31
codes <- subsetOnDomain(
              x = list("codes" = c(10,13,15)),
              cdm = cdm,
              domain = "Drug")
#> Warning: ! `codelist` casted to integers.
codes
#> 
#> ── 1 codelist ──────────────────────────────────────────────────────────────────
#> 
#> - codes (2 codes)
# }