Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2109 ADPP template program has x and y variables #2110

Merged
merged 5 commits into from
Sep 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions inst/templates/ad_adpp.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ format_avalcat1n <- function(param, aval) {
# Get list of ADSL vars required for derivations
adsl_vars <- exprs(TRTSDT, TRTEDT, DTHDT, EOSDT, TRT01P, TRT01A)

adpp <- pp %>%
adpp_pp <- pp %>%
# Join ADSL with PP (need TRTSDT for ADY derivation)
left_join(
select(admiral_adsl, STUDYID, USUBJID, !!!adsl_vars),
by = c("STUDYID", "USUBJID")
derive_vars_merged(
dataset_add = admiral_adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
) %>%
## Calculate ADT, ADY ----
derive_vars_dt(
Expand All @@ -93,7 +94,7 @@ adpp <- pp %>%
) %>%
derive_vars_dy(reference_date = TRTSDT, source_vars = exprs(ADT))

adpp <- adpp %>%
adpp_aval <- adpp_pp %>%
## Add PARAMCD only - add PARAM etc later ----
left_join(
select(param_lookup, PPTESTCD, PARAMCD),
Expand All @@ -117,7 +118,7 @@ adpp <- adpp %>%
## Get visit info ----
# See also the "Visit and Period Variables" vignette
# (https://pharmaverse.github.io/admiral/cran-release/articles/visits_periods.html#visit_bds)
adpp <- adpp %>%
adpp_avisit <- adpp_aval %>%
# Derive Timing
mutate(
VISIT = "", # /!\ To remove
Expand All @@ -141,9 +142,10 @@ adpp <- adpp %>%
derive_vars_merged(dataset_add = avalcat_lookup, by_vars = exprs(PARAMCD, AVALCA1N))

# Add all ADSL variables
adpp <- adpp %>%
left_join(admiral_adsl,
by = c("STUDYID", "USUBJID")
adpp <- adpp_avisit %>%
derive_vars_merged(
dataset_add = select(admiral_adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
)

# Final Steps, Select final variables and Add labels
Expand Down