Skip to content

Commit

Permalink
Add test case for baseline_timepoints in derive_blfl function (#95)
Browse files Browse the repository at this point in the history
* Modified test case

* style file

* Add examples to function

* Empty commit, trigger CI jobs

---------

Co-authored-by: Adam Forys <[email protected]>
  • Loading branch information
ShiyuC and galachad authored Sep 12, 2024
1 parent 048aad5 commit 31aadcd
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 15 deletions.
22 changes: 22 additions & 0 deletions R/derive_blfl.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
22 changes: 22 additions & 0 deletions man/derive_blfl.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions tests/testthat/_snaps/derive_blfl.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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]
}
]
}
Expand Down
27 changes: 14 additions & 13 deletions tests/testthat/test-derive_blfl.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 31aadcd

Please sign in to comment.