This check looks for AE entries with an AEDTHDTC (death date) value and AESDTH not equal to "Y"

check_ae_aedthdtc_aesdth(AE, preproc = identity, ...)

Arguments

AE

Adverse Event SDTM dataset with variables USUBJID, AEDTHDTC, AESDTH, AEDECOD, AETERM, and AESTDTC

preproc

An optional company specific preprocessing script

...

Other arguments passed to methods

Value

Boolean value for whether the check passed or failed, with 'msg' attribute if the check failed

Author

Shumei Chi

Examples



AE <- data.frame(
USUBJID = c(1:7), 
AEDECOD = c(letters[1:5], "", NA), 
AETERM = letters[1:7],
AESDTH = "Y",
AEDTHDTC = "2020-01-02",
AESTDTC = c(1:7),
AESPID = "FORMNAME-R:5/L:5XXXX",
stringsAsFactors=FALSE)

# expect pass
check_ae_aedthdtc_aesdth(AE)
#> [1] TRUE
check_ae_aedthdtc_aesdth(AE,preproc=roche_derive_rave_row)
#> [1] TRUE

# expect fail 
AE1 <- AE
AE1$AESDTH[3] <- "N"
check_ae_aedthdtc_aesdth(AE1)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 1 record(s) with AESDTH not equal to 'Y' where AEDTHDTC has a value. "
#> attr(,"data")
#>   USUBJID AETERM AEDECOD AESTDTC   AEDTHDTC AESDTH
#> 1       3      c       c       3 2020-01-02      N
check_ae_aedthdtc_aesdth(AE1,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 1 record(s) with AESDTH not equal to 'Y' where AEDTHDTC has a value. "
#> attr(,"data")
#>   USUBJID AETERM AEDECOD AESTDTC   AEDTHDTC AESDTH         RAVE
#> 1       3      c       c       3 2020-01-02      N FORMNAME-R:5

# expect fail with AESDTH = NA
AE2 <- AE
AE2$AESDTH[4] <- NA
check_ae_aedthdtc_aesdth(AE2)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 1 record(s) with AESDTH not equal to 'Y' where AEDTHDTC has a value. "
#> attr(,"data")
#>   USUBJID AETERM AEDECOD AESTDTC   AEDTHDTC AESDTH
#> 1       4      d       d       4 2020-01-02   <NA>
check_ae_aedthdtc_aesdth(AE2,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 1 record(s) with AESDTH not equal to 'Y' where AEDTHDTC has a value. "
#> attr(,"data")
#>   USUBJID AETERM AEDECOD AESTDTC   AEDTHDTC AESDTH         RAVE
#> 1       4      d       d       4 2020-01-02   <NA> FORMNAME-R:5

# non-required variable missing
AE2$AESPID <- NULL
check_ae_aedthdtc_aesdth(AE2)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 1 record(s) with AESDTH not equal to 'Y' where AEDTHDTC has a value. "
#> attr(,"data")
#>   USUBJID AETERM AEDECOD AESTDTC   AEDTHDTC AESDTH
#> 1       4      d       d       4 2020-01-02   <NA>
check_ae_aedthdtc_aesdth(AE2,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE has 1 record(s) with AESDTH not equal to 'Y' where AEDTHDTC has a value. "
#> attr(,"data")
#>   USUBJID AETERM AEDECOD AESTDTC   AEDTHDTC AESDTH
#> 1       4      d       d       4 2020-01-02   <NA>

# required variable missing 
AE2$AESDTH <- NULL
check_ae_aedthdtc_aesdth(AE2)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE is missing the variable: AESDTH"
check_ae_aedthdtc_aesdth(AE2,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE is missing the variable: AESDTH"