Skip to content

Commit

Permalink
Closes #2484 Used restrict_derivation() with AVISITN > 0 to restrict …
Browse files Browse the repository at this point in the history
…CHG and PCHG to post-baseline records (#2488)

* Used restrict_derivation() with AVISITN > 0 to restrict CHG and PCHG derivations to post-baseline observations. Note that NA visit changes are also not derived.

* feat: #2484 updated comments for CHG and PCHG

* feat: #2484 Manually added "Rothstein" to inst/WORDLIST

* feat: #2484 Updated CHG/PCHG comments and restrict_derivation call to notify that as per ADaM IG, the decision on how to populate pre-baseline and baseline values of CHG/PCHG is left to producer choice.

* feat: #2484 Changed 'sponsor' to 'producer'

* feat: #2484 Use restrict_derivation() with filter AVISITN > 0 to derive CHG and PCHG for post-baseline records only

* feat: #2484 Run style_file()

* feat: #2484 Add piping back to derive_var_obs_number() for adgdssf dataframe
  • Loading branch information
steventing12 authored Sep 3, 2024
1 parent eea45a6 commit f126ce8
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 19 deletions.
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ repo
reproducibility
rlang
roche
Rothstein
roxygen
scalable
signif
Expand Down
2 changes: 1 addition & 1 deletion inst/templates/ad_adcm.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ adcm <- adcm %>%
# Derive Follow-Up flag
mutate(FUPFL = if_else(ASTDT > TRTEDT, "Y", NA_character_)) %>%
# Derive ANL01FL
# This variable is sponsor specific and may be used to indicate particular
# This variable is producer specific and may be used to indicate particular
# records to be used in subsequent derivations or analysis.
mutate(ANL01FL = if_else(ONTRTFL == "Y", "Y", NA_character_)) %>%
# Derive 1st Occurrence of Preferred Term Flag
Expand Down
16 changes: 12 additions & 4 deletions inst/templates/ad_adeg.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,18 @@ adeg <- adeg %>%
source_var = ANRIND,
new_var = BNRIND
) %>%
# Calculate CHG
derive_var_chg() %>%
# Calculate PCHG
derive_var_pchg()
# Calculate CHG for post-baseline records
# The decision on how to populate pre-baseline and baseline values of CHG is left to producer choice
restrict_derivation(
derivation = derive_var_chg,
filter = AVISITN > 0
) %>%
# Calculate PCHG for post-baseline records
# The decision on how to populate pre-baseline and baseline values of PCHG is left to producer choice
restrict_derivation(
derivation = derive_var_pchg,
filter = AVISITN > 0
)

## ANL01FL: Flag last result within an AVISIT and ATPT for post-baseline records ----
adeg <- adeg %>%
Expand Down
17 changes: 12 additions & 5 deletions inst/templates/ad_adlb.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,18 @@ adlb <- adlb %>%
source_var = ANRIND,
new_var = BNRIND
) %>%
# Calculate CHG
derive_var_chg() %>%
# Calculate PCHG
derive_var_pchg()

# Calculate CHG for post-baseline records
# The decision on how to populate pre-baseline and baseline values of CHG is left to producer choice
restrict_derivation(
derivation = derive_var_chg,
filter = AVISITN > 0
) %>%
# Calculate PCHG for post-baseline records
# The decision on how to populate pre-baseline and baseline values of PCHG is left to producer choice
restrict_derivation(
derivation = derive_var_pchg,
filter = AVISITN > 0
)

## Calculate lab grading ----

Expand Down
8 changes: 7 additions & 1 deletion inst/templates/ad_adpc.R
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,13 @@ adpc_base <- adpc_dtype %>%
filter = ABLFL == "Y"
)

adpc_chg <- derive_var_chg(adpc_base)
# Calculate CHG for post-baseline records
# The decision on how to populate pre-baseline and baseline values of CHG is left to producer choice
adpc_chg <- restrict_derivation(
adpc_base,
derivation = derive_var_chg,
filter = AVISITN > 0
)

# ---- Add ASEQ ----

Expand Down
17 changes: 12 additions & 5 deletions inst/templates/ad_advs.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,18 @@ advs <- advs %>%
source_var = ANRIND,
new_var = BNRIND
) %>%
# Calculate CHG
derive_var_chg() %>%
# Calculate PCHG
derive_var_pchg()

# Calculate CHG for post-baseline records
# The decision on how to populate pre-baseline and baseline values of CHG is left to producer choice
restrict_derivation(
derivation = derive_var_chg,
filter = AVISITN > 0
) %>%
# Calculate PCHG for post-baseline records
# The decision on how to populate pre-baseline and baseline values of PCHG is left to producer choice
restrict_derivation(
derivation = derive_var_pchg,
filter = AVISITN > 0
)

## ANL01FL: Flag last result within an AVISIT and ATPT for post-baseline records ----
advs <- advs %>%
Expand Down
8 changes: 7 additions & 1 deletion vignettes/pk_adnca.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,13 @@ adpc_base <- adpc_dtype %>%
filter = ABLFL == "Y"
)
adpc_chg <- derive_var_chg(adpc_base)
# Calculate CHG for post-baseline records
# The decision on how to populate pre-baseline and baseline values of CHG is left to producer choice
adpc_chg <- restrict_derivation(
adpc_base,
derivation = derive_var_chg,
filter = AVISITN > 0
)
# ---- Add ASEQ ----
Expand Down
14 changes: 12 additions & 2 deletions vignettes/questionnaires.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,18 @@ adgdssf <- adgdssf %>%
source_var = AVAL,
new_var = BASE
) %>%
derive_var_chg() %>%
derive_var_pchg() %>%
# Calculate CHG for post-baseline records
# The decision on how to populate pre-baseline and baseline values of CHG is left to producer choice
restrict_derivation(
derivation = derive_var_chg,
filter = AVISITN > 0
) %>%
# Calculate PCHG for post-baseline records
# The decision on how to populate pre-baseline and baseline values of PCHG is left to producer choice
restrict_derivation(
derivation = derive_var_pchg,
filter = AVISITN > 0
) %>%
# Derive sequence number
derive_var_obs_number(
by_vars = exprs(STUDYID, USUBJID),
Expand Down

0 comments on commit f126ce8

Please sign in to comment.