Stores the code sets and narrative algorithm description for a single
version of a medical condition definition. Each version is a distinct
object (e.g., spec_acei_v1, spec_acei_v2).
The spec stores:
defs: named list with elementsconditionandoutcome, each holding a narrative algorithm description string (orNULLif not defined).codes: named list of key-level lists keyed by{code_type}_{encounter}(e.g.,dx_icd9). Each key-level list has:codes: character vector of exact short-format codes (no periods).condition: logical vector parallel tocodes;TRUEif the code belongs to the condition/history definition.outcome: logical vector parallel tocodes;TRUEif the code belongs to the outcome definition.definitions: optional character vector of code definitions, parallel tocodes.exclusions: optional character string describing codes to exclude.
Active bindings
conditionShort condition identifier (read-only).
versionVersion label, e.g.
"v1"(read-only).labelHuman-readable condition label (read-only).
Methods
CodeSpec$new()
Create a new CodeSpec.
Usage
CodeSpec$new(
condition,
label,
defs = NULL,
codes = NULL,
version = NULL,
versions = NULL
)Arguments
conditionShort identifier string, e.g.
"htn".labelHuman-readable label, e.g.
"Hypertension".defsNamed list with elements
conditionandoutcome(character strings orNULL).codesNamed list of key-level lists. See class description.
versionOptional version label string, e.g.
"v1".versionsDeprecated. Use
defs/codes/versiondirectly.
CodeSpec$get_codes()
Retrieve codes from the spec as a tidy data frame.
Usage
CodeSpec$get_codes(
code_type = NULL,
variable_type = c("condition", "outcome"),
periods = FALSE,
priority = 1L
)Arguments
code_typeOptional character vector of code types to return. Valid values:
"dx_icd9","dx_icd10","proc_icd9","proc_icd10","hcpcs","cpt","rev".NULLreturns all.variable_type"condition"(default) or"outcome". If the spec has no codes flagged for"outcome", falls back to"condition".periodsLogical. If
TRUE, return codes with decimal periods (e.g.,"401.0"). DefaultFALSEreturns short format ("4010").priorityInteger vector subsetting confidence tiers to include (
1= core,2= probable,3= cautious). Default1.
CodeSpec$get_defs()
Retrieve the narrative algorithm description.
Usage
CodeSpec$get_defs(variable_type = c("condition", "outcome"))