Check if SC.SCCAT = "STUDY EYE SELECTION" and SC.SCTESTCD = "ELIGEYE", then SC.SCORRES should have "OS", "OD", or "OU" values. Flag if subject is in DM and without an associated SC.SCORRES value or the ELIGEYE Eye Meeting Eligibility Criteria value is not "OS", "OD", or "OU".

check_sc_dm_eligcrit(DM, SC)

Arguments

DM

Subject Demographics SDTM dataset with variable USUBJID

SC

Subject Characteristics SDTM dataset for Ophtho Study with variables USUBJID, SCTESTCD, SCTEST, SCCAT, SCORRES, SCDTC

Value

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

Author

Monarch Shah (HackR 2021 Team Eye)

Examples


dm <- data.frame(USUBJID = c(1,2))
sc <- data.frame(USUBJID  = c(1,1,1,2,2,2),
                 SCTEST   = c("Eye Meeting Eligibility Criteria",
                              "Focus of Study-Specific Interest",
                              " ",
                              "Eye Meeting Eligibility Criteria",
                              "Focus of Study-Specific Interest", " "),
                 SCTESTCD = c("ELIGEYE", "FOCID", "", "ELIGEYE", "FOCID", ""),
                 SCCAT    = c("STUDY EYE SELECTION",
                              "STUDY EYE SELECTION",
                              "",
                              "STUDY EYE SELECTION",
                              "STUDY EYE SELECTION",
                              ""),
                 SCORRES  = c("OS", "OS", "", "", "OU", ""),
                 SCDTC    = rep("2021-01-01", 6),
                 stringsAsFactors = FALSE)

check_sc_dm_eligcrit(SC=sc, DM=dm)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 record(s) missing eye(s) that met study criteria in SC. "
#> attr(,"data")
#>   USUBJID SCTESTCD                           SCTEST               SCCAT SCORRES
#> 1       2  ELIGEYE Eye Meeting Eligibility Criteria STUDY EYE SELECTION        
#>        SCDTC
#> 1 2021-01-01

dm <- data.frame(USUBJID = c(1,2,3,4))
sc$SCORRES[4] = "OS"
check_sc_dm_eligcrit(SC=sc, DM=dm)
#> [1] FALSE
#> attr(,"msg")
#> [1] "2 record(s) missing eye(s) that met study criteria in SC. "
#> attr(,"data")
#>   USUBJID SCTESTCD SCTEST SCCAT SCORRES SCDTC
#> 1       3     <NA>   <NA>  <NA>    <NA>  <NA>
#> 2       4     <NA>   <NA>  <NA>    <NA>  <NA>

sc$SCORRES <- NULL
check_sc_dm_eligcrit(SC=sc, DM=dm)
#> [1] FALSE
#> attr(,"msg")
#> [1] "SC is missing the variable: SCORRES"