R/check_ae_aesdth_aedthdtc.R
check_ae_aesdth_aedthdtc.Rd
This check looks for AE entries with AESDTH of "Y" but no AEDTHDTC (death date) value
check_ae_aesdth_aedthdtc(AE, preproc = identity, ...)
Boolean value for whether the check passed or failed, with 'msg' attribute if the check failed
AE <- data.frame(
USUBJID = c(1:7),
AEDECOD = c(letters[1:5], "", NA),
AETERM = letters[1:7],
AESDTH = c(NA, rep("", 4), "Y", "Y"),
AEDTHDTC = c(1:5, "2020", "2020-01-02"),
AESTDTC = c(1:7),
AESPID = "FORMNAME-R:5/L:5XXXX",
stringsAsFactors=FALSE)
# expect pass
check_ae_aesdth_aedthdtc(AE)
#> [1] TRUE
check_ae_aesdth_aedthdtc(AE,preproc=roche_derive_rave_row)
#> [1] TRUE
# expect fail
AE1 <- AE
AE1$AEDTHDTC[3] <- NA
AE1$AESDTH[3] <- "Y"
check_ae_aesdth_aedthdtc(AE1)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 1 record(s) with AESDTH equal to 'Y' where AEDTHDTC does not have a value. "
#> attr(,"data")
#> USUBJID AETERM AEDECOD AESTDTC AESDTH AEDTHDTC
#> 1 3 c c 3 Y <NA>
check_ae_aesdth_aedthdtc(AE1,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 1 record(s) with AESDTH equal to 'Y' where AEDTHDTC does not have a value. "
#> attr(,"data")
#> USUBJID AETERM AEDECOD AESTDTC AESDTH AEDTHDTC RAVE
#> 1 3 c c 3 Y <NA> FORMNAME-R:5
# expect fail
AE2 <- AE1
AE2$AEDTHDTC[4] <- ""
AE2$AESDTH[4] <- "Y"
check_ae_aesdth_aedthdtc(AE2)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 2 record(s) with AESDTH equal to 'Y' where AEDTHDTC does not have a value. "
#> attr(,"data")
#> USUBJID AETERM AEDECOD AESTDTC AESDTH AEDTHDTC
#> 1 3 c c 3 Y <NA>
#> 2 4 d d 4 Y
check_ae_aesdth_aedthdtc(AE2,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 2 record(s) with AESDTH equal to 'Y' where AEDTHDTC does not have a value. "
#> attr(,"data")
#> USUBJID AETERM AEDECOD AESTDTC AESDTH AEDTHDTC RAVE
#> 1 3 c c 3 Y <NA> FORMNAME-R:5
#> 2 4 d d 4 Y FORMNAME-R:5
# non-required variable missing
AE2$AESPID <- NULL
check_ae_aesdth_aedthdtc(AE2)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 2 record(s) with AESDTH equal to 'Y' where AEDTHDTC does not have a value. "
#> attr(,"data")
#> USUBJID AETERM AEDECOD AESTDTC AESDTH AEDTHDTC
#> 1 3 c c 3 Y <NA>
#> 2 4 d d 4 Y
check_ae_aesdth_aedthdtc(AE2,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 2 record(s) with AESDTH equal to 'Y' where AEDTHDTC does not have a value. "
#> attr(,"data")
#> USUBJID AETERM AEDECOD AESTDTC AESDTH AEDTHDTC
#> 1 3 c c 3 Y <NA>
#> 2 4 d d 4 Y
# required variable missing
AE2$AESDTH <- NULL
check_ae_aesdth_aedthdtc(AE2)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE is missing the variable: AESDTH"
check_ae_aesdth_aedthdtc(AE2,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE is missing the variable: AESDTH"