R/check_ds_dsdecod_death.R
check_ds_dsdecod_death.Rd
If a patient has a record where DS.DSDECOD == DEATH they should also have a Study Discon Record
check_ds_dsdecod_death(DS, preproc = identity, ...)
boolean value if check failed or passed with 'msg' attribute if the test failed
DS <- data.frame(
STUDYID = 1,
USUBJID = 1:3,
DSDECOD = c(NA,"DEATH",NA),
DSSTDTC = c(NA,"DSDATE",NA),
DSCAT = c('DISPOSITION EVENT', 'DISPOSITION EVENT', 'OTHER'),
DSSCAT = c('STUDY COMPLETION/EARLY DISCONTINUATION',
'TREATMENT DISCONTINUATION',
'STUDY TREATMENT'),
DSOTH = 1:3,
DSSPID = "XXX-R:0",
stringsAsFactors=FALSE
)
check_ds_dsdecod_death(DS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 record(s) for 1 unique patient(s) with DSDECOD='DEATH' but no record with DSSCAT indicating STUDY DISCONTINUATION. "
#> attr(,"data")
#> USUBJID DSDECOD DSCAT DSSTDTC
#> 1 2 DEATH DISPOSITION EVENT DSDATE
check_ds_dsdecod_death(DS,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 record(s) for 1 unique patient(s) with DSDECOD='DEATH' but no record with DSSCAT indicating STUDY DISCONTINUATION. "
#> attr(,"data")
#> USUBJID DSDECOD DSCAT DSSTDTC RAVE
#> 1 2 DEATH DISPOSITION EVENT DSDATE XXX-R:0
DS$DSSCAT[2] <- "STUDY COMPLETION/EARLY DISCONTINUATION"
check_ds_dsdecod_death(DS)
#> [1] TRUE
DS$DSDECOD = NULL
check_ds_dsdecod_death(DS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "DS is missing the variable: DSDECOD"