R/check_ae_aeacnoth_ds_disctx.R
check_ae_aeacnoth_ds_disctx.Rd
This code checks that when a patient has an AE with AEACNOTx = "SUBJECT DISCONTINUED FROM STUDY" (x = "H", "1", "2", ...) then there should also be a record in DS where DS.DSSCAT = "STUDY COMPLETION/EARLY DISCONTINUATION" and DS.DSDECOD != "COMPLETED".
check_ae_aeacnoth_ds_disctx(AE, DS, preproc = identity, ...)
boolean value if check returns 0 obs, otherwise return subset dataframe.
AE <- data.frame(
STUDYID = "1001",
USUBJID = c("1","2","3","4","5","1"),
AESTDTC = rep('2020-05-05', 6),
AEDECOD = c("HEADACHE", "HEART ATTACK","CHILLS", "PNEUMONIA", "ARTHRITIS", "FATIGUE"),
AEACNOTH = c("NONE", "SUBJECT DISCONTINUED FROM STUDY", "MULTIPLE", "NONE",
"SUBJECT DISCONTINUED FROM STUDY", "SUBJECT DISCONTINUED FROM STUDY"),
AEACNOT1 = c("", "", "PROCEDURE/SURGERY", "", "", ""),
AEACNOT2 = c("", "", "SUBJECT DISCONTINUED FROM STUDY", "", "", ""),
AESPID = "FORMNAME-R:13/L:13XXXX",
stringsAsFactors = FALSE
)
DS <- data.frame(
USUBJID = c("1","5"),
DSCAT = c("DISPOSITION EVENT", "DISPOSITION EVENT"),
DSSCAT = c("STUDY COMPLETION/EARLY DISCONTINUATION", "STUDY COMPLETION/EARLY DISCONTINUATION"),
DSDECOD = c("ADVERSE EVENT", "ADVERSE EVENT" ),
stringsAsFactors = FALSE
)
check_ae_aeacnoth_ds_disctx(AE, DS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "2 patient(s) with AEs leading to Study Discontinuation but no corresponding record in DS. "
#> attr(,"data")
#> USUBJID AEDECOD AESTDTC AEACNOTH
#> 1 2 HEART ATTACK 2020-05-05 SUBJECT DISCONTINUED FROM STUDY
#> 2 3 CHILLS 2020-05-05 MULTIPLE
#> AEACNOT1 AEACNOT2 DSCAT DSSCAT DSDECOD
#> 1 <NA> <NA> <NA>
#> 2 PROCEDURE/SURGERY SUBJECT DISCONTINUED FROM STUDY <NA> <NA> <NA>
check_ae_aeacnoth_ds_disctx(AE, DS, preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "2 patient(s) with AEs leading to Study Discontinuation but no corresponding record in DS. "
#> attr(,"data")
#> USUBJID AEDECOD AESTDTC AEACNOTH
#> 1 2 HEART ATTACK 2020-05-05 SUBJECT DISCONTINUED FROM STUDY
#> 2 3 CHILLS 2020-05-05 MULTIPLE
#> AEACNOT1 AEACNOT2 RAVE DSCAT DSSCAT
#> 1 FORMNAME-R:13 <NA> <NA>
#> 2 PROCEDURE/SURGERY SUBJECT DISCONTINUED FROM STUDY FORMNAME-R:13 <NA> <NA>
#> DSDECOD
#> 1 <NA>
#> 2 <NA>