Skip to content

Commit

Permalink
#32: Updated to pipe to derive all height/length parameters in single…
Browse files Browse the repository at this point in the history
… step.
  • Loading branch information
Lina2689 committed Jun 10, 2024
1 parent 24054a0 commit 846353c
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions inst/templates/ad_advs.R
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ message("To derive height/length parameters, below function needs to call separa
as it depends on your CRF guidelines.")

### Use measure=LENGTH for patient current age < 2 years ----
advs_lgth <- advs %>%
advs_ht_lgth <- advs %>%
filter(AAGECUR < 730.5) %>%
derive_params_growth_height(
sex = SEX,
Expand All @@ -342,34 +342,29 @@ advs_lgth <- advs %>%
PARAMCD = "WGTHPCTL",
PARAM = "Weight-for-length/height Percentile"
)
)

### Use measure=HEIGHT for patient current age >= 2 years ----
advs_ht <- advs %>%
filter(AAGECUR >= 730.5) %>%
derive_params_growth_height(
sex = SEX,
height = HGTTMP,
height_unit = HGTTMPU,
meta_criteria = who_wt_for_ht_lgth %>% filter(MEASURE == "HEIGHT"),
parameter = VSTESTCD == "WEIGHT",
analysis_var = AVAL,
set_values_to_sds = exprs(
PARAMCD = "WGTHSDS",
PARAM = "Weight-for-length/height Z-Score"
),
set_values_to_pctl = exprs(
PARAMCD = "WGTHPCTL",
PARAM = "Weight-for-length/height Percentile"
)
)
) %>%
# Use measure=HEIGHT for patient current age >= 2 years
bind_rows(advs %>% filter(AAGECUR >= 730.5) %>%
derive_params_growth_height(
sex = SEX,
height = HGTTMP,
height_unit = HGTTMPU,
meta_criteria = who_wt_for_ht_lgth %>% filter(MEASURE == "HEIGHT"),
parameter = VSTESTCD == "WEIGHT",
analysis_var = AVAL,
set_values_to_sds = exprs(
PARAMCD = "WGTHSDS",
PARAM = "Weight-for-length/height Z-Score"
),
set_values_to_pctl = exprs(
PARAMCD = "WGTHPCTL",
PARAM = "Weight-for-length/height Percentile"
)
))

## Combine the records for Weight by Height/Length ----
advs <- advs_age %>%
bind_rows(
advs_lgth %>% filter(PARAMCD %in% c("WGTHSDS", "WGTHPCTL")),
advs_ht %>% filter(PARAMCD %in% c("WGTHSDS", "WGTHPCTL"))
)
bind_rows(advs_ht_lgth %>% filter(PARAMCD %in% c("WGTHSDS", "WGTHPCTL")))

## Add PARAM/PARAMN ----
advs <- advs %>%
Expand Down

0 comments on commit 846353c

Please sign in to comment.