You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The [anymed2] notation tells rec_with_table() to look for anymed2 as a starting variable in the source data — but anymed2 doesn't exist in CHMS source data. It's a workflow artifact (numeric copy of anymed). Same for diab_drug2.
Impact
rec_with_table() will fail when trying to derive these variables
MockData can't generate them (12 remaining discrepancies from PR Mock data review #7 are all anymed2/diab_drug2)
Downstream variables that depend on these (highbp14090, highbp14090_adj, control14090, control14090_adj, diabx) can't be derived automatically
Users must follow a manual multi-step workflow documented in the vignette
Current manual workflow
# Step 1: derive anymed in medication datacycle1_meds_recoded<- rec_with_table(cycle1_meds, ..., "anymed", ...)
# Step 2: MANUAL — create numeric copycycle1_meds_recoded$anymed2<- as.numeric(as.character(cycle1_meds_recoded$anymed))
# Step 3: MANUAL — merge into main cycle datacycle1<- merge(cycle1, select(cycle1_meds_recoded, clinicid, anymed2))
# Step 4: now can derive hypertension variablescycle1_final<- rec_with_table(cycle1, ..., "highbp14090", ...)
Options to fix
A. Mark as derived from anymed/diab_drug
Change variableStart to DerivedVar::[anymed] and DerivedVar::[diab_drug]. This documents the dependency correctly but requires recodeflow to support chained derivations (anymed itself is derived).
B. Make derivation functions return numeric
Change cycles1to2_any_antiHTN_meds() to return numeric instead of factor. Then anymed2 is no longer needed. Update determine_hypertension() to accept the output directly.
C. Handle conversion in consuming functions
Make determine_hypertension() and determine_inclusive_diabetes() convert factor to numeric internally, eliminating the need for separate anymed2/diab_drug2 variables entirely.
Option C is the simplest and removes the most complexity. Option B is also clean. Option A preserves the current architecture but adds metadata complexity.
Priority: P0 (CRAN-blocking)
Problem
anymed2anddiab_drug2invariables.csvhave self-referentialvariableStartvalues:The
[anymed2]notation tellsrec_with_table()to look foranymed2as a starting variable in the source data — butanymed2doesn't exist in CHMS source data. It's a workflow artifact (numeric copy ofanymed). Same fordiab_drug2.Impact
rec_with_table()will fail when trying to derive these variableshighbp14090,highbp14090_adj,control14090,control14090_adj,diabx) can't be derived automaticallyCurrent manual workflow
Options to fix
A. Mark as derived from anymed/diab_drug
Change
variableStarttoDerivedVar::[anymed]andDerivedVar::[diab_drug]. This documents the dependency correctly but requires recodeflow to support chained derivations (anymed itself is derived).B. Make derivation functions return numeric
Change
cycles1to2_any_antiHTN_meds()to return numeric instead of factor. Thenanymed2is no longer needed. Updatedetermine_hypertension()to accept the output directly.C. Handle conversion in consuming functions
Make
determine_hypertension()anddetermine_inclusive_diabetes()convert factor to numeric internally, eliminating the need for separateanymed2/diab_drug2variables entirely.Option C is the simplest and removes the most complexity. Option B is also clean. Option A preserves the current architecture but adds metadata complexity.
Files involved
inst/extdata/variables.csv— self-referential variableStartinst/extdata/variable-details.csv— recTo: copy (but nothing to copy from)R/blood-pressure.R—determine_hypertension()expects ANYMED2R/diabetes.R—determine_inclusive_diabetes()expects diab_drug2vignettes/recoding_medications.qmd— documents manual workflow