diff --git a/R/derive_blfl.R b/R/derive_blfl.R index 98414be0..8cd5cf1c 100644 --- a/R/derive_blfl.R +++ b/R/derive_blfl.R @@ -260,6 +260,7 @@ dtc_timepart <- function(dtc, partial_as_na = TRUE, ignore_seconds = TRUE) { #' #' sdtm_in #' +#' # Example 1: #' observed_output <- derive_blfl( #' sdtm_in = sdtm_in, #' dm_domain = dm, @@ -269,6 +270,27 @@ dtc_timepart <- function(dtc, partial_as_na = TRUE, ignore_seconds = TRUE) { #' ) #' observed_output #' +#' # Example 2: +#' observed_output2 <- derive_blfl( +#' sdtm_in = sdtm_in, +#' dm_domain = dm, +#' tgt_var = "VSLOBXFL", +#' ref_var = "RFXSTDTC", +#' baseline_timepoints = c("PRE-DOSE") +#' ) +#' observed_output2 +#' +#' # Example 3: Output is the same as Example 2 +#' observed_output3 <- derive_blfl( +#' sdtm_in = sdtm_in, +#' dm_domain = dm, +#' tgt_var = "VSLOBXFL", +#' ref_var = "RFXSTDTC", +#' baseline_visits = c("SCREENING"), +#' baseline_timepoints = c("PRE-DOSE") +#' ) +#' observed_output3 +#' derive_blfl <- function(sdtm_in, dm_domain, tgt_var, diff --git a/man/derive_blfl.Rd b/man/derive_blfl.Rd index c1fd92b1..129eb126 100644 --- a/man/derive_blfl.Rd +++ b/man/derive_blfl.Rd @@ -222,6 +222,7 @@ sdtm_in <- sdtm_in +# Example 1: observed_output <- derive_blfl( sdtm_in = sdtm_in, dm_domain = dm, @@ -231,4 +232,25 @@ observed_output <- derive_blfl( ) observed_output +# Example 2: +observed_output2 <- derive_blfl( + sdtm_in = sdtm_in, + dm_domain = dm, + tgt_var = "VSLOBXFL", + ref_var = "RFXSTDTC", + baseline_timepoints = c("PRE-DOSE") +) +observed_output2 + +# Example 3: Output is the same as Example 2 +observed_output3 <- derive_blfl( + sdtm_in = sdtm_in, + dm_domain = dm, + tgt_var = "VSLOBXFL", + ref_var = "RFXSTDTC", + baseline_visits = c("SCREENING"), + baseline_timepoints = c("PRE-DOSE") +) +observed_output3 + } diff --git a/tests/testthat/_snaps/derive_blfl.md b/tests/testthat/_snaps/derive_blfl.md index 49bbb4bf..f1b296d2 100644 --- a/tests/testthat/_snaps/derive_blfl.md +++ b/tests/testthat/_snaps/derive_blfl.md @@ -16,7 +16,7 @@ "names": { "type": "character", "attributes": {}, - "value": ["DOMAIN", "oak_id", "raw_source", "patient_number", "USUBJID", "VSDTC", "VSTESTCD", "VSORRES", "VSSTAT", "VISIT", "VSLOBXFL"] + "value": ["DOMAIN", "oak_id", "raw_source", "patient_number", "USUBJID", "VSDTC", "VSTESTCD", "VSORRES", "VSSTAT", "VISIT", "VSTPT", "VSLOBXFL"] } }, "value": [ @@ -73,7 +73,13 @@ { "type": "character", "attributes": {}, - "value": ["Y", null, null, null, "Y", null, "Y", null, "Y", "Y", null] + "value": ["PRE-DOSE", "30 DAY POST-DOSE", "28 DAY POST-DOSE", "30 DAY POST-DOSE", "28 DAY POST-DOSE", "28 DAY POST-DOSE", + "PRE-DOSE", "PRE-DOSE", "PRE-DOSE", "PRE-DOSE", "1 DAY POST-DOSE"] + }, + { + "type": "character", + "attributes": {}, + "value": ["Y", null, null, null, null, "Y", "Y", null, "Y", "Y", null] } ] } diff --git a/tests/testthat/test-derive_blfl.R b/tests/testthat/test-derive_blfl.R index 663f9bb4..44815319 100644 --- a/tests/testthat/test-derive_blfl.R +++ b/tests/testthat/test-derive_blfl.R @@ -9,18 +9,18 @@ dm <- tibble::tribble( sdtm_in <- tibble::tribble( - ~DOMAIN, ~oak_id, ~raw_source, ~patient_number, ~USUBJID, ~VSDTC, ~VSTESTCD, ~VSORRES, ~VSSTAT, ~VISIT, - "VS", 1L, "VTLS1", 375L, "test_study-375", "2020-09-01T13:31", "DIABP", "90", NA, "SCREENING", - "VS", 2L, "VTLS1", 375L, "test_study-375", "2020-10-01T11:20", "DIABP", "90", NA, "SCREENING", - "VS", 1L, "VTLS1", 375L, "test_study-375", "2020-09-28T10:10", "PULSE", "ND", NA, "SCREENING", - "VS", 2L, "VTLS1", 375L, "test_study-375", "2020-10-01T13:31", "PULSE", "85", NA, "SCREENING", - "VS", 1L, "VTLS2", 375L, "test_study-375", "2020-09-28T10:10", "SYSBP", "120", NA, "SCREENING", - "VS", 2L, "VTLS2", 375L, "test_study-375", "2020-09-28T10:05", "SYSBP", "120", NA, "SCREENING", - "VS", 1L, "VTLS1", 376L, "test_study-376", "2020-09-20", "DIABP", "75", NA, "SCREENING", - "VS", 1L, "VTLS1", 376L, "test_study-376", "2020-09-20", "PULSE", NA, "NOT DONE", "SCREENING", # nolint - "VS", 2L, "VTLS1", 376L, "test_study-376", "2020-09-20", "PULSE", "110", NA, "SCREENING", - "VS", 2L, "VTLS1", 378L, "test_study-378", "2020-01-20T10:00", "PULSE", "110", NA, "SCREENING", - "VS", 3L, "VTLS1", 378L, "test_study-378", "2020-01-21T11:00", "PULSE", "105", NA, "SCREENING" + ~DOMAIN, ~oak_id, ~raw_source, ~patient_number, ~USUBJID, ~VSDTC, ~VSTESTCD, ~VSORRES, ~VSSTAT, ~VISIT, ~VSTPT, + "VS", 1L, "VTLS1", 375L, "test_study-375", "2020-09-01T13:31", "DIABP", "90", NA, "SCREENING", "PRE-DOSE", + "VS", 2L, "VTLS1", 375L, "test_study-375", "2020-10-01T11:20", "DIABP", "90", NA, "SCREENING", "30 DAY POST-DOSE", + "VS", 1L, "VTLS1", 375L, "test_study-375", "2020-09-28T10:10", "PULSE", "ND", NA, "SCREENING", "28 DAY POST-DOSE", + "VS", 2L, "VTLS1", 375L, "test_study-375", "2020-10-01T13:31", "PULSE", "85", NA, "SCREENING", "30 DAY POST-DOSE", + "VS", 1L, "VTLS2", 375L, "test_study-375", "2020-09-28T10:10", "SYSBP", "120", NA, "SCREENING", "28 DAY POST-DOSE", + "VS", 2L, "VTLS2", 375L, "test_study-375", "2020-09-28T10:05", "SYSBP", "120", NA, "SCREENING", "28 DAY POST-DOSE", + "VS", 1L, "VTLS1", 376L, "test_study-376", "2020-09-20", "DIABP", "75", NA, "SCREENING", "PRE-DOSE", + "VS", 1L, "VTLS1", 376L, "test_study-376", "2020-09-20", "PULSE", NA, "NOT DONE", "SCREENING", "PRE-DOSE", # nolint + "VS", 2L, "VTLS1", 376L, "test_study-376", "2020-09-20", "PULSE", "110", NA, "SCREENING", "PRE-DOSE", + "VS", 2L, "VTLS1", 378L, "test_study-378", "2020-01-20T10:00", "PULSE", "110", NA, "SCREENING", "PRE-DOSE", + "VS", 3L, "VTLS1", 378L, "test_study-378", "2020-01-21T11:00", "PULSE", "105", NA, "SCREENING", "1 DAY POST-DOSE" ) d <- list(sdtm_in = sdtm_in, dm = dm) @@ -32,7 +32,8 @@ test_that("derive_blfl example works", { dm_domain = d$dm, tgt_var = "VSLOBXFL", ref_var = "RFXSTDTC", - baseline_visits = c("SCREENING") + baseline_visits = c("SCREENING"), + baseline_timepoints = c("PRE-DOSE") ) observed_output