A CompositeDrugSpec is a composition of all versioned drug class components
that collectively define a composite drug group (e.g., antihypertensives).
It holds references to specific versioned DrugSpec leaf objects,
accessible by name via the component argument.
The components list is a flat named list mapping "name_vX" keys to
DrugSpec objects:
components = list(
acei_v1 = spec_acei_v1,
acei_v2 = spec_acei_v2,
arb_v1 = spec_arb_v1,
...
)The component argument is optional when calling get_generics();
omitting it (or passing "all") returns every component.
Active bindings
drug_classShort drug class identifier (read-only).
versionVersion label (read-only; typically
NULLfor composites).labelHuman-readable label (read-only).
conditionThe single condition/indication this composite represents (read-only), e.g.
"hypertension". Used as the defaultconditionfilter inget_generics().
Methods
CompositeDrugSpec$new()
Create a new CompositeDrugSpec.
Usage
CompositeDrugSpec$new(
drug_class,
label,
defs = NULL,
components = list(),
version = NULL,
condition = NULL
)Arguments
drug_classShort identifier string, e.g.
"antihypertensive".labelHuman-readable label.
defsCharacter string describing the composite.
componentsNamed list of DrugSpec objects, keyed by
"name_vX"strings.versionOptional version label (typically
NULL).conditionRequired character string naming the single condition/indication this composite represents, e.g.
"hypertension". ACompositeDrugSpecalways represents exactly one condition (unlike a leaf DrugSpec built withgeneric_defs, which may span several); this is used as the defaultconditionfilter inget_generics(), so a shared leaf component tagged with multiple conditions (e.g. a GLP-1 spec used by both the obesity and diabetes composites) only contributes its rows for this composite's condition unless the caller overrides the filter explicitly.
CompositeDrugSpec$components()
Return the flat named component list.
Returns
Named list of DrugSpec objects.
CompositeDrugSpec$get_generics()
Retrieve generic (and brand) drug names from one or more components as a tidy data frame.
Arguments
componentOptional component name(s), e.g.
"acei_v1".NULL(default) or"all"returns every component.priorityInteger vector subsetting confidence tiers to include. Default
1.conditionOptional character vector subsetting to specific condition(s), forwarded to each component's
get_generics(). Defaults to this composite's owncondition(e.g."hypertension"), so a shared leaf component tagged with multiple conditions only contributes its rows for this composite's condition. PassNULLexplicitly to disable condition filtering entirely (returns every row from every component regardless of condition).
CompositeDrugSpec$get_meds_labels()
Retrieve the human-readable label for one or more
components as a tidy tibble.
This deliberately surfaces each leaf's label (e.g. "ACE Inhibitors") rather than its free-text defs field. A leaf
DrugSpec's defs is typically just an internal sourcing note
(e.g. "From the Perisphere antihypertensive medication list."),
not a clinical definition – and now that composite drug specs are
named after the condition they treat (e.g. spec_hypertension), a
get_defs()-style function here would be easy to confuse with the
condition side's get_*_v1_defs(), which does return a real
diagnostic-algorithm narrative. Returning labels instead avoids
that confusion by making clear this is a component listing, not a
clinical definition. Version isn't included in the output since
name (the component key, e.g. "acei_v2") already encodes it.