Skip to content

Commit

Permalink
addressing missing treatment start dates
Browse files Browse the repository at this point in the history
  • Loading branch information
ddsjoberg committed Aug 4, 2023
1 parent 697a4ec commit 93495dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/derive_var_ontrtfl.R
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ derive_var_ontrtfl <- function(dataset,
if (ignore_time_for_ref_end_date) {
end_cond <- expr(
(date(!!start_date) <= date(!!ref_end_date) + days(!!ref_end_window)) |
is.na(!!ref_end_date)
(!is.na(!!ref_start_date) & is.na(!!ref_end_date))
)
} else {
end_cond <- expr(
(!!start_date <= !!ref_end_date + days(!!ref_end_window)) |
is.na(!!ref_end_date)
(!is.na(!!ref_start_date) & is.na(!!ref_end_date))
)
}
dataset <- mutate(
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/_snaps/derive_var_ontrtfl.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
1 P01 2018-03-15 2019-01-01 NA 2022-12-01 Y
2 P02 2020-04-30 2019-01-01 NA 2022-03-15 Y
3 P03 2020-04-30 2019-01-01 NA <NA> Y
4 P04 2020-04-30 <NA> NA <NA> <NA>

---

Expand All @@ -19,4 +20,5 @@
1 P01 2018-03-15 2019-01-01 NA 2022-12-01 <NA>
2 P02 2020-04-30 2019-01-01 NA 2022-03-15 Y
3 P03 2020-04-30 2019-01-01 NA <NA> Y
4 P04 2020-04-30 <NA> NA <NA> <NA>

1 change: 1 addition & 0 deletions tests/testthat/test-derive_var_ontrtfl.R
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ test_that("derive_var_ontrtfl Test 15: if trt end date is missing, the obs may s
"P01", ymd("2018-03-15"), ymd("2019-01-01"), NA, ymd("2022-12-01"),
"P02", ymd("2020-04-30"), ymd("2019-01-01"), NA, ymd("2022-03-15"),
"P03", ymd("2020-04-30"), ymd("2019-01-01"), NA, NA,
"P04", ymd("2020-04-30"), NA, NA, NA
) %>%
as.data.frame()

Expand Down

0 comments on commit 93495dd

Please sign in to comment.