@ShiyuC: This is my narrowing down of the problem you shared with me. Your example included a call to oak_cal_ref_dates() but it is actually (at least) cal_min_max_date() that is having problems. I'm assigning this issue to you as you are the bearer of the original bug but feel free to delegate on me if Ramm and Mohsin feel like having me taking over this function's code.
@rammprasad, @muzzama-1990: The function cal_min_max_date() was written by you, so could you take a look? I'm happy to take over but after looking at the code I would overhaul it entirely...
Reproducible example
library(sdtm.oak)
tibble::tibble(
patient_number = "001",
EX_ST_DT = "25-04-2022",
EX_ST_TM = "15:10") |>
cal_min_max_date(
date_variable = "EX_ST_DT",
time_variable = "EX_ST_TM",
date_format = "d-m-y",
time_format = "H:M"
)
#> # A tibble: 1 × 2
#> patient_number datetime
#> <chr> <chr>
#> 1 001 2022-04-25T15:10
create_iso8601(EX_ST_DT = "25-04-2022", EX_ST_TM = "15:10", .format = c("d-m-y", "H:M"))
#> [1] "2022-04-25T15:10"
# `cal_min_max_date()` fails to derive "2022-04-25" but it ought not.
tibble::tibble(
patient_number = "001",
EX_ST_DT = "25-04-2022",
EX_ST_TM = NA_character_) |>
cal_min_max_date(
date_variable = "EX_ST_DT",
time_variable = "EX_ST_TM",
date_format = "d-m-y",
time_format = "H:M"
)
#> # A tibble: 0 × 2
#> # ℹ 2 variables: patient_number <chr>, datetime <chr>
# `create_iso8601()` works as expected illustrating that the problem comes
# from `cal_min_max_date()`, not from `create_iso8601()`.
create_iso8601(EX_ST_DT = "25-04-2022", EX_ST_TM = NA_character_, .format = c("d-m-y", "H:M"))
#> [1] "2022-04-25"
@ShiyuC: This is my narrowing down of the problem you shared with me. Your example included a call to
oak_cal_ref_dates()but it is actually (at least)cal_min_max_date()that is having problems. I'm assigning this issue to you as you are the bearer of the original bug but feel free to delegate on me if Ramm and Mohsin feel like having me taking over this function's code.@rammprasad, @muzzama-1990: The function
cal_min_max_date()was written by you, so could you take a look? I'm happy to take over but after looking at the code I would overhaul it entirely...Reproducible example