This check looks for patients with text string "PROPHYL" in CMINDC when CMPROPH is not checked as "Y" in studies with given for prophylaxis variable (CMPROPH)

check_cm_cmindc(CM, preproc = identity, ...)

Arguments

CM

Concomitant Medication SDTM dataset with variables USUBJID, CMTRT, CMSTDTC, CMINDC, CMPROPH, CMSPID (optional)

preproc

An optional company specific preprocessing script

...

Other arguments passed to methods

Value

boolean value if check failed or passed with 'msg' attribute if the test failed

Author

Sara Bodach, Stella Banjo (HackR 2021)

Examples


CM <- data.frame(
 USUBJID = c(rep(1,3),rep(2,3),rep(3,3)),
 CMTRT = letters[1:9],
 CMSTDTC = rep("2017-01-01",9),
 CMINDC = c(rep("INDICATION 1",2), rep("indication 2",2),
            rep("Prophylaxis",2),rep("PROPHYLACTIC",2),"PROPHYLAXIS FOR XYZ"),
 CMPROPH = c(rep("Y",3),rep(NA,2),rep("",2),"NA","."),
 CMSPID = "/F:XXX-D:12345-R:123",
 stringsAsFactors=FALSE
)

check_cm_cmindc(CM)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 patients with CM indication containing 'PROPHYL' when given for prophylaxis variable is not checked as 'Y'. "
#> attr(,"data")
#>   USUBJID CMTRT    CMSTDTC              CMINDC CMPROPH
#> 1       2     e 2017-01-01         Prophylaxis    <NA>
#> 2       2     f 2017-01-01         Prophylaxis        
#> 3       3     g 2017-01-01        PROPHYLACTIC        
#> 4       3     h 2017-01-01        PROPHYLACTIC      NA
#> 5       3     i 2017-01-01 PROPHYLAXIS FOR XYZ       .
check_cm_cmindc(CM,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 patients with CM indication containing 'PROPHYL' when given for prophylaxis variable is not checked as 'Y'. "
#> attr(,"data")
#>   USUBJID    RAVE CMTRT    CMSTDTC              CMINDC CMPROPH
#> 1       2 XXX#123     e 2017-01-01         Prophylaxis    <NA>
#> 2       2 XXX#123     f 2017-01-01         Prophylaxis        
#> 3       3 XXX#123     g 2017-01-01        PROPHYLACTIC        
#> 4       3 XXX#123     h 2017-01-01        PROPHYLACTIC      NA
#> 5       3 XXX#123     i 2017-01-01 PROPHYLAXIS FOR XYZ       .

CM$CMPROPH[7] = "Y"
check_cm_cmindc(CM)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 patients with CM indication containing 'PROPHYL' when given for prophylaxis variable is not checked as 'Y'. "
#> attr(,"data")
#>   USUBJID CMTRT    CMSTDTC              CMINDC CMPROPH
#> 1       2     e 2017-01-01         Prophylaxis    <NA>
#> 2       2     f 2017-01-01         Prophylaxis        
#> 3       3     h 2017-01-01        PROPHYLACTIC      NA
#> 4       3     i 2017-01-01 PROPHYLAXIS FOR XYZ       .

CM$CMSPID = NULL
check_cm_cmindc(CM,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 patients with CM indication containing 'PROPHYL' when given for prophylaxis variable is not checked as 'Y'. "
#> attr(,"data")
#>   USUBJID CMTRT    CMSTDTC              CMINDC CMPROPH
#> 1       2     e 2017-01-01         Prophylaxis    <NA>
#> 2       2     f 2017-01-01         Prophylaxis        
#> 3       3     h 2017-01-01        PROPHYLACTIC      NA
#> 4       3     i 2017-01-01 PROPHYLAXIS FOR XYZ       .

CM$CMPROPH = NULL
check_cm_cmindc(CM)
#> [1] FALSE
#> attr(,"msg")
#> [1] "CM is missing the variable: CMPROPH"