From f2aa08ec64453c7def631239dda1ce12470e1b33 Mon Sep 17 00:00:00 2001 From: steventing12 Date: Mon, 5 Aug 2024 09:15:24 +0000 Subject: [PATCH 1/8] 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. --- inst/templates/ad_advs.R | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/inst/templates/ad_advs.R b/inst/templates/ad_advs.R index 6fbd2b8d76..0bffc4446d 100644 --- a/inst/templates/ad_advs.R +++ b/inst/templates/ad_advs.R @@ -227,10 +227,16 @@ advs <- advs %>% source_var = ANRIND, new_var = BNRIND ) %>% - # Calculate CHG - derive_var_chg() %>% - # Calculate PCHG - derive_var_pchg() + # Calculate CHG for post-baseline + restrict_derivation( + derivation = derive_var_chg, + filter = AVISITN > 0 + ) %>% + # Calculate PCHG for post-baseline + restrict_derivation( + derivation = derive_var_pchg, + filter = AVISITN > 0 + ) ## ANL01FL: Flag last result within an AVISIT and ATPT for post-baseline records ---- From 93be737dceaa329c55a4515310cf472e87dec9f6 Mon Sep 17 00:00:00 2001 From: steventing12 Date: Tue, 13 Aug 2024 02:30:42 +0000 Subject: [PATCH 2/8] feat: #2484 updated comments for CHG and PCHG --- inst/templates/ad_advs.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/templates/ad_advs.R b/inst/templates/ad_advs.R index 0bffc4446d..bccc8d9d90 100644 --- a/inst/templates/ad_advs.R +++ b/inst/templates/ad_advs.R @@ -227,12 +227,12 @@ advs <- advs %>% source_var = ANRIND, new_var = BNRIND ) %>% - # Calculate CHG for post-baseline + # Calculate CHG for post-baseline records restrict_derivation( derivation = derive_var_chg, filter = AVISITN > 0 ) %>% - # Calculate PCHG for post-baseline + # Calculate PCHG for post-baseline records restrict_derivation( derivation = derive_var_pchg, filter = AVISITN > 0 From c7e8893e6a32e9c88aa8eeea5b42cfbdbd0494ec Mon Sep 17 00:00:00 2001 From: steventing12 Date: Wed, 14 Aug 2024 04:10:54 +0000 Subject: [PATCH 3/8] feat: #2484 Manually added "Rothstein" to inst/WORDLIST --- inst/WORDLIST | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/WORDLIST b/inst/WORDLIST index ad1b8d709e..cda8d6b29d 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -314,6 +314,7 @@ repo reproducibility rlang roche +Rothstein roxygen scalable signif From d372084897fdfdac34b25bdb7c7ab2212a420da7 Mon Sep 17 00:00:00 2001 From: steventing12 Date: Fri, 23 Aug 2024 08:37:32 +0000 Subject: [PATCH 4/8] 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. --- inst/templates/ad_adeg.R | 16 ++++++++++++---- inst/templates/ad_adlb.R | 17 ++++++++++++----- inst/templates/ad_adpc.R | 8 +++++++- inst/templates/ad_advs.R | 3 ++- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/inst/templates/ad_adeg.R b/inst/templates/ad_adeg.R index f4da10e1d4..7c1bbff4e9 100644 --- a/inst/templates/ad_adeg.R +++ b/inst/templates/ad_adeg.R @@ -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 %>% diff --git a/inst/templates/ad_adlb.R b/inst/templates/ad_adlb.R index 1aeee14a25..f5a55b706a 100644 --- a/inst/templates/ad_adlb.R +++ b/inst/templates/ad_adlb.R @@ -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 ---- diff --git a/inst/templates/ad_adpc.R b/inst/templates/ad_adpc.R index d7c844a264..1b932fb934 100644 --- a/inst/templates/ad_adpc.R +++ b/inst/templates/ad_adpc.R @@ -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 ---- diff --git a/inst/templates/ad_advs.R b/inst/templates/ad_advs.R index bccc8d9d90..fd199c2382 100644 --- a/inst/templates/ad_advs.R +++ b/inst/templates/ad_advs.R @@ -228,17 +228,18 @@ advs <- advs %>% new_var = BNRIND ) %>% # 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 %>% restrict_derivation( From 3fe0297fe3ece62b6101e505319c8cdae70ff44e Mon Sep 17 00:00:00 2001 From: steventing12 Date: Fri, 30 Aug 2024 02:37:40 +0000 Subject: [PATCH 5/8] feat: #2484 Changed 'sponsor' to 'producer' --- inst/templates/ad_adcm.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/templates/ad_adcm.R b/inst/templates/ad_adcm.R index e80ed2032a..0cf4dc1c21 100644 --- a/inst/templates/ad_adcm.R +++ b/inst/templates/ad_adcm.R @@ -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 From 0bbbe4175ef2704c3250b81f3113eca31d116045 Mon Sep 17 00:00:00 2001 From: steventing12 Date: Fri, 30 Aug 2024 02:48:42 +0000 Subject: [PATCH 6/8] feat: #2484 Use restrict_derivation() with filter AVISITN > 0 to derive CHG and PCHG for post-baseline records only --- vignettes/pk_adnca.Rmd | 8 +++++++- vignettes/questionnaires.Rmd | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/vignettes/pk_adnca.Rmd b/vignettes/pk_adnca.Rmd index a947df46fb..c354b3f644 100644 --- a/vignettes/pk_adnca.Rmd +++ b/vignettes/pk_adnca.Rmd @@ -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 ---- diff --git a/vignettes/questionnaires.Rmd b/vignettes/questionnaires.Rmd index b408ec756d..abdbb340c3 100644 --- a/vignettes/questionnaires.Rmd +++ b/vignettes/questionnaires.Rmd @@ -218,8 +218,19 @@ 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), From c5c09f1351530c21ef1d3a9aed8a49cf201098c4 Mon Sep 17 00:00:00 2001 From: steventing12 Date: Tue, 3 Sep 2024 06:12:50 +0000 Subject: [PATCH 7/8] feat: #2484 Run style_file() --- vignettes/questionnaires.Rmd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vignettes/questionnaires.Rmd b/vignettes/questionnaires.Rmd index abdbb340c3..4f636089bd 100644 --- a/vignettes/questionnaires.Rmd +++ b/vignettes/questionnaires.Rmd @@ -231,12 +231,12 @@ adgdssf <- adgdssf %>% filter = AVISITN > 0 ) - # Derive sequence number - derive_var_obs_number( - by_vars = exprs(STUDYID, USUBJID), - order = exprs(PARAMCD, ADT), - check_type = "error" - ) +# Derive sequence number +derive_var_obs_number( + by_vars = exprs(STUDYID, USUBJID), + order = exprs(PARAMCD, ADT), + check_type = "error" +) ``` ```{r echo=FALSE} From 56acd480db46a5925b58d80a4f5313f86fcc1fef Mon Sep 17 00:00:00 2001 From: steventing12 Date: Tue, 3 Sep 2024 06:25:51 +0000 Subject: [PATCH 8/8] feat: #2484 Add piping back to derive_var_obs_number() for adgdssf dataframe --- vignettes/questionnaires.Rmd | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/vignettes/questionnaires.Rmd b/vignettes/questionnaires.Rmd index 4f636089bd..1982bc1285 100644 --- a/vignettes/questionnaires.Rmd +++ b/vignettes/questionnaires.Rmd @@ -229,14 +229,13 @@ adgdssf <- adgdssf %>% restrict_derivation( derivation = derive_var_pchg, filter = AVISITN > 0 + ) %>% + # Derive sequence number + derive_var_obs_number( + by_vars = exprs(STUDYID, USUBJID), + order = exprs(PARAMCD, ADT), + check_type = "error" ) - -# Derive sequence number -derive_var_obs_number( - by_vars = exprs(STUDYID, USUBJID), - order = exprs(PARAMCD, ADT), - check_type = "error" -) ``` ```{r echo=FALSE}