This check identifies RSDTC values when RSEVAL == 'INVESTIGATOR' and RSTESTCD == 'OVRLRESP' that are duplicated or earlier than last visit's. Unscheduled and 'NOT DONE' visits are excluded.

check_rs_rsdtc_visit_ordinal_error(RS)

Arguments

RS

Response SDTM dataset with variables USUBJID, VISITNUM, VISIT, RSDTC, RSTESTCD, RSEVAL, RSSTAT

Value

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

Author

James Zhang

Examples


# no cases
RS<- data.frame(USUBJID = 101:102,
                RSDTC=rep(c("2017-01-01T08:25", "2017-01-05T09:25",
                       "2017-01-15T10:25","2017-01-20T08:25","2017-01-25T08:25"), 2),
                VISITNUM=rep(1:5,2),
                VISIT=rep(c("Screening", "Cycle 1", "Cycle 2","Cycle 3","Follow-up"),2),
                RSTESTCD="OVRLRESP",
                RSEVAL="INVESTIGATOR",
                RSSTAT="",
                stringsAsFactors=FALSE)
check_rs_rsdtc_visit_ordinal_error(RS)
#> [1] TRUE

# adding cases with earler date
RS$RSDTC[RS$USUBJID == 101 & RS$VISIT == "Cycle 3"] <- "2017-01-02T08:25"
RS$RSDTC[RS$USUBJID == 102 & RS$VISIT == "Cycle 1"] <- "2017-01-01T06:25"
check_rs_rsdtc_visit_ordinal_error(RS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "RS has 2 records with Possible RSDTC data entry error. "
#> attr(,"data")
#>   USUBJID VISITNUM   VISIT            RSDTC RSTESTCD       RSEVAL RSSTAT
#> 1     101        4 Cycle 3 2017-01-02T08:25 OVRLRESP INVESTIGATOR       
#> 2     102        2 Cycle 1 2017-01-01T06:25 OVRLRESP INVESTIGATOR       
#>       last.vis.dtc  last.vis visit.order                       check.flag
#> 1 2017-01-15T10:25   Cycle 2           4 Datetime earlier than last Visit
#> 2 2017-01-01T08:25 Screening           2 Datetime earlier than last Visit