This check looks for missing CMDECOD values
check_cm_cmdecod(CM, preproc = identity, ...)
boolean value if check failed or passed with 'msg' attribute if the test failed
CM <- data.frame(
USUBJID = 1:5,
DOMAIN = rep("CM", 5),
CMTRT = rep("DRUG TERM", 5),
CMDECOD = rep("CODED DRUG TERM", 5),
CMSTDTC = 1:5,
CMENDTC = 1:5,
CMCAT = "CONCOMITANT MEDICATIONS",
CMSPID = c("FORMNAME-R:13/L:13XXXX",
"FORMNAME-R:16/L:16XXXX",
"FORMNAME-R:2/L:2XXXX",
"FORMNAME-R:19/L:19XXXX",
"FORMNAME-R:5/L:5XXXX"),
stringsAsFactors=FALSE
)
check_cm_cmdecod(CM)
#> [1] TRUE
CM$CMDECOD[1] = NA
CM$CMDECOD[2] = "NA"
CM$CMDECOD[3:5] = ""
check_cm_cmdecod(CM)
#> [1] FALSE
#> attr(,"msg")
#> [1] "CM has 5 record(s) with missing CMDECOD. "
#> attr(,"data")
#> USUBJID CMSTDTC CMTRT CMDECOD
#> 1 1 1 DRUG TERM <NA>
#> 2 2 2 DRUG TERM NA
#> 3 3 3 DRUG TERM
#> 4 4 4 DRUG TERM
#> 5 5 5 DRUG TERM
check_cm_cmdecod(CM,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "CM has 5 record(s) with missing CMDECOD. "
#> attr(,"data")
#> USUBJID CMSTDTC CMTRT CMDECOD RAVE
#> 1 1 1 DRUG TERM <NA> FORMNAME-R:13
#> 2 2 2 DRUG TERM NA FORMNAME-R:16
#> 3 3 3 DRUG TERM FORMNAME-R:2
#> 4 4 4 DRUG TERM FORMNAME-R:19
#> 5 5 5 DRUG TERM FORMNAME-R:5
CM$CMDECOD <- NULL
check_cm_cmdecod(CM)
#> [1] FALSE
#> attr(,"msg")
#> [1] "CM is missing the variable: CMDECOD"