R/check_ex_exdose_pos_exoccur_no.R
    check_ex_exdose_pos_exoccur_no.RdThis checks looks for EXDOSE values greater than 0 when EXOCCUR is not "Y". It could be for a specified drug/treatment, or for all drugs/treatments in the dataset.
check_ex_exdose_pos_exoccur_no(EX, drug = NULL)Boolean value for whether the check passed or failed, with 'msg' attribute if the test failed
EX <- data.frame(
 USUBJID = 1:5,
 EXSTDTC = rep("2017-01-01",5),
 EXTRT   = c(rep("TRT A",2),rep("TRT B",3)),
 EXOCCUR = c(".","", "N", "N", "Y"),
 EXDOSE  = 0:4,
 VISIT = "VISIT 1",
 stringsAsFactors = FALSE
)
check_ex_exdose_pos_exoccur_no(EX)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 3 patients with positive dose amount (EXDOSE>0) when occurrence (EXOCCUR) is not 'Y'. "
#> attr(,"data")
#>   USUBJID EXTRT    EXSTDTC EXOCCUR EXDOSE   VISIT
#> 1       2 TRT A 2017-01-01              1 VISIT 1
#> 2       3 TRT B 2017-01-01       N      2 VISIT 1
#> 3       4 TRT B 2017-01-01       N      3 VISIT 1
check_ex_exdose_pos_exoccur_no(EX, drug = "TRT A")
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 1 patients with positive dose amount (EXDOSE>0) when occurrence (EXOCCUR) for TRT A is not 'Y'. "
#> attr(,"data")
#>   USUBJID EXTRT    EXSTDTC EXOCCUR EXDOSE   VISIT
#> 1       2 TRT A 2017-01-01              1 VISIT 1
check_ex_exdose_pos_exoccur_no(EX, drug = "TRT B")
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 patients with positive dose amount (EXDOSE>0) when occurrence (EXOCCUR) for TRT B is not 'Y'. "
#> attr(,"data")
#>   USUBJID EXTRT    EXSTDTC EXOCCUR EXDOSE   VISIT
#> 1       3 TRT B 2017-01-01       N      2 VISIT 1
#> 2       4 TRT B 2017-01-01       N      3 VISIT 1
EX$EXDOSE = NULL
check_ex_exdose_pos_exoccur_no(EX)
#> [1] FALSE
#> attr(,"msg")
#> [1] "EX is missing the variable: EXDOSE"