R/check_ae_withdr_ds_discon.R
check_ae_withdr_ds_discon.Rd
This checks that if there is an AE with AEACN="DRUG WITHDRAWN" then there should be a treatment discontinuation record indicated by DS.DSSCAT
check_ae_withdr_ds_discon(AE, DS, TS, preproc = identity, ...)
boolean value if check failed or passed with 'msg' attribute if the test failed
AE <- data.frame(
USUBJID = 1:6,
AEACN = c("DRUG WITHDRAWN",NA,NA,NA,NA,NA),
AETOXGR = c(NA,NA,NA,NA,"5",NA),
AEDECOD=c("NAUSEA","HEADACHE"),
AESPID = "FORMNAME-R:5/L:5XXXX"
)
DS <- data.frame(
USUBJID = 1:3,
DSCAT="DISPOSITION EVENT",
DSSCAT="STUDY TREATMENT",
DSDECOD=c("COMPLETED","ADVERSE EVENT","DEATH")
)
TS <- data.frame(
TSPARMCD="TRT",
TSVAL="CHECK"
)
check_ae_withdr_ds_discon(AE,DS,TS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 1 patient(s) where AE data treatment discontinuation but no treatment discontinuation record in DS. "
#> attr(,"data")
#> USUBJID DSSCAT DSCAT AEACN AEDECOD
#> 1 1 <NA> <NA> DRUG WITHDRAWN NAUSEA
check_ae_withdr_ds_discon(AE,DS,TS,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 1 patient(s) where AE data treatment discontinuation but no treatment discontinuation record in DS. "
#> attr(,"data")
#> USUBJID DSSCAT DSCAT AEACN AEDECOD RAVE
#> 1 1 <NA> <NA> DRUG WITHDRAWN NAUSEA FORMNAME-R:5
DS$DSSCAT = NULL
check_ae_withdr_ds_discon(AE,DS,TS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "DS is missing the variable: DSSCAT"