R/check_ex_exoccur_exdose_exstdtc.R
check_ex_exoccur_exdose_exstdtc.Rd
This check looks for valid exposures (EXOCCUR=Y or doesn't exist) but EXDOSE (dose per administration) is not > 0 (>= 0 in case of placebo) and/or EXSTDTC (start date/treatment date) is missing or incomplete in the EX (exposure) SDTM domain
check_ex_exoccur_exdose_exstdtc(EX)
Boolean value for whether the check passed or failed, with 'msg' attribute if the check failed
EX <- data.frame(USUBJID = LETTERS[1:5],
VISIT = paste0("Visit ", 1:5),
VISITNUM = 1:5,
EXOCCUR = c('Y', rep('', 4)),
EXTRT = LETTERS[1:5],
EXDOSE = 1:5,
EXSTDTC = c('2010-01-01', rep('', 4)),
EXENDTC = c('2010-01-01', rep('', 4)),
stringsAsFactors = FALSE)
EX$EXOCCUR[2] <- 'Y'
EX$EXSTDTC[2] <- '2011'
EX$EXDOSE[1] <- 0
check_ex_exoccur_exdose_exstdtc(EX)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 EX records with invalid dosing amount or missing full treatment administration date. "
#> attr(,"data")
#> USUBJID VISIT VISITNUM EXOCCUR EXTRT EXDOSE EXSTDTC EXENDTC
#> 1 A Visit 1 1 Y A 0 2010-01-01 2010-01-01
#> 2 B Visit 2 2 Y B 2 2011
EX$VISIT <- NULL
check_ex_exoccur_exdose_exstdtc(EX)
#> [1] FALSE
#> attr(,"msg")
#> [1] "EX is missing the variable: VISIT"