Skip to contents

Use achilles counts to filter a codelist to keep only the codes used in the database

Usage

subsetToCodesInUse(
  x,
  cdm,
  minimumCount = 0L,
  table = c("condition_occurrence", "device_exposure", "drug_exposure", "measurement",
    "observation", "procedure_occurrence", "visit_occurrence")
)

Arguments

x

A codelist

cdm

cdm_reference via CDMConnector

minimumCount

Any codes with a frequency under this will be removed.

table

cdm table

Value

Use achilles counts to filter codelist to only the codes used in the database

Examples

# \donttest{
cdm <- mockVocabRef("database")
#> Warning: There are observation period end dates after the current date: 2025-02-19
#>  The latest max observation period end date found is 2025-12-31
#> Warning: There are observation period end dates after the current date: 2025-02-19
#>  The latest max observation period end date found is 2025-12-31
codes <- getCandidateCodes(cdm = cdm,
                           keywords = "arthritis",
                           domains = "Condition",
                           includeDescendants = FALSE)
#> Limiting to domains of interest
#> Getting concepts to include
#> Search completed. Finishing up.
#>  3 candidate concepts identified
#> Time taken: 0 minutes and 0 seconds
x <- subsetToCodesInUse(list("cs1" = codes$concept_id,
                               "cs2" = 999),
                                cdm = cdm)
#> No codes from codelist cs2 found in the database

x
#> $cs1
#> [1] 4 5
#> 
CDMConnector::cdmDisconnect(cdm)
# }