R/check_ae_aestdtc_after_dd.R
check_ae_aestdtc_after_dd.Rd
This check looks for AE dates that occur after death date
check_ae_aestdtc_after_dd(AE, DS, preproc = identity, ...)
Boolean value for whether the check passed or failed, with 'msg' attribute if the check failed
AE <- data.frame(STUDYID = 1:5, USUBJID = LETTERS[1:5],
AEDTHDTC = c(rep("", 4), "2016-01-01"),
AESTDTC = rep("2016-01-01", 5),
AEDECOD = c("","", rep("Myocarditis",3)),
AETERM = c("INJURY", rep("MYOCARDITIS", 4)),
AESPID = "FORMNAME-R:19/L:19XXXX",
stringsAsFactors = FALSE)
DS <- data.frame(STUDYID = 1:5, USUBJID = LETTERS[1:5],
DSSTDTC = rep("2016-01-02", 5),
DSDECOD = c(LETTERS[1:4], "death"),
DSSPID = "XXX-R:0",
DSTERM = letters[1:5],
stringsAsFactors = FALSE)
check_ae_aestdtc_after_dd(AE,DS)
#> [1] TRUE
AE$AESTDTC[1] <- "2016-01-03"
AE$USUBJID[1] <- AE$USUBJID[5]
check_ae_aestdtc_after_dd(AE, DS,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 patient(s) with AE occurring after death date. "
#> attr(,"data")
#> USUBJID AETERM AESTDTC AEDTHDTC RAVE.AE RAVE.DS DSSTDTC
#> 1 E INJURY 2016-01-03 2016-01-01 FORMNAME-R:19 XXX-R:0 2016-01-02
#> EARLIEST_DTHDTC
#> 1 2016-01-01
AE$AESPID <- NULL
check_ae_aestdtc_after_dd(AE, DS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 patient(s) with AE occurring after death date. "
#> attr(,"data")
#> USUBJID AETERM AESTDTC AEDTHDTC DSSTDTC EARLIEST_DTHDTC
#> 1 E INJURY 2016-01-03 2016-01-01 2016-01-02 2016-01-01
DS$DSSPID <- NULL
check_ae_aestdtc_after_dd(AE, DS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 patient(s) with AE occurring after death date. "
#> attr(,"data")
#> USUBJID AETERM AESTDTC AEDTHDTC DSSTDTC EARLIEST_DTHDTC
#> 1 E INJURY 2016-01-03 2016-01-01 2016-01-02 2016-01-01
AE$AESTDTC <- NULL
check_ae_aestdtc_after_dd(AE, DS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "AE is missing the variable: AESTDTC"