R/check_cm_cmlat.R
check_cm_cmlat.Rd
This check assesses CMCAT = "CONCOMITANT MEDICATIONS" and flags potential ocular records with missing/inconsistent route and laterality: for eye-related CMROUTE ('INTRAVITREAL', 'OPHTHALMIC', etc.), CMLAT is not populated -or- CMROUTE is not eye-related (i.e., not INTRAVITREAL, OPHTHALMIC, TOPICAL, etc.) but CMLAT is LEFT/RIGHT/BILATERAL.
check_cm_cmlat(CM, preproc = identity, ...)
boolean value if check failed or passed with 'msg' attribute if the test failed
CM <- data.frame(
USUBJID = 1:7,
CMCAT = "CONCOMITANT MEDICATIONS",
CMSTDTC = 1:7,
CMLAT = c("Left", "","Bilateral", "", "", "LEFT", ""),
CMTRT = c("A", "B", "A", "B", "A", "A", "B"),
CMDECOD = c("A", "B", "A", "B", "A", "A", "B"),
CMROUTE = c("","OPHTHALMIC","INTRAVITREAL","INTRAVITREAL",
"opHTHALMIC", "INTRaOCULAr", "INTRaOCULAr"),
CMSPID = "FORMNAME-R:13/L:13XXXX",
stringsAsFactors = FALSE)
check_cm_cmlat(CM,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "5 record(s) with CMLAT Missing when CM is Eye related, or CMLAT is LEFT/RIGHT/BILATERAL and CMROUTE is not Eye related."
#> attr(,"data")
#> USUBJID CMSTDTC RAVE CMLAT CMTRT CMDECOD CMROUTE
#> 1 1 1 FORMNAME-R:13 Left A A
#> 2 2 2 FORMNAME-R:13 B B OPHTHALMIC
#> 3 4 4 FORMNAME-R:13 B B INTRAVITREAL
#> 4 5 5 FORMNAME-R:13 A A opHTHALMIC
#> 5 7 7 FORMNAME-R:13 B B INTRaOCULAr
CM <- data.frame(
USUBJID = 1:5,
CMCAT = rep("CONCOMITANT MEDICATIONS",5),
CMSTDTC = 1:5,
CMLAT = c("Left", "LEFT","Bilateral",
"RIGHT", "RIgHT"),
CMTRT = c("A", "B", "A", "B", "A"),
CMDECOD = c("A", "B", "A", "B", "A"),
CMROUTE = c("","OPHTHALMIC","INTRAVITREAL",
"INTRaOCULAr", "opHTHALMIC"),
stringsAsFactors = FALSE)
check_cm_cmlat(CM)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 record(s) with CMLAT Missing when CM is Eye related, or CMLAT is LEFT/RIGHT/BILATERAL and CMROUTE is not Eye related."
#> attr(,"data")
#> USUBJID CMSTDTC CMLAT CMTRT CMDECOD CMROUTE
#> 1 1 1 Left A A
CM <- data.frame(
USUBJID = 1:5,
CMCAT = "CONCOMITANT MEDICATIONS",
CMSTDTC = 1:5,
CMLAT = c("Left", "LEFT","Bilateral", "RIGHT", "RIgHT"),
CMTRT = c("A", "B", "A", "B", "A"),
CMDECOD = c("A", "B", "A", "B", "A"),
#CMROUTE = c("","OPHTHALMIC","INTRAVITREAL","INTRaOCULAr", "opHTHALMIC"),
stringsAsFactors = FALSE)
check_cm_cmlat(CM)
#> [1] FALSE
#> attr(,"msg")
#> [1] "CM is missing the variable: CMROUTE"