This check identifies TUDTC values that are duplicated or earlier than last visit's. Unscheduled visits are excluded.

check_tu_tudtc_visit_ordinal_error(TU)

Arguments

TU

Tumor Identification SDTM dataset with variables USUBJID,TUORRES ,TULOC, VISITNUM, VISIT, TUDTC, TUEVAL

Value

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

Author

Jingyuan Chen

Examples


# no case
TU <- data.frame(USUBJID = 101:102,
                TUORRES = rep(c("NEW", "TARGET"), 5),
                TULOC=rep(c("BONE","LIVER"),5),
                TUDTC = 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( "Visit 1", "Visit 2", "Visit 3", "Visit 4","VIsit 5"), 2),
                TUEVAL="INVESTIGATOR",
                stringsAsFactors = FALSE)
check_tu_tudtc_visit_ordinal_error(TU)
#> [1] TRUE

# adding cases with earler date
TU$TUDTC[TU$USUBJID == 101 & TU$VISIT == "Visit 4"] <- "2017-01-10T08:25"
TU$TUDTC[TU$USUBJID == 102 & TU$VISIT == "Visit 2"] <- "2017-01-01T06:25"
check_tu_tudtc_visit_ordinal_error(TU)
#> [1] FALSE
#> attr(,"msg")
#> [1] "TU has 2 records with Possible TUDTC data entry error. "
#> attr(,"data")
#>   USUBJID TUORRES TULOC VISITNUM   VISIT            TUDTC       TUEVAL
#> 1     101     NEW  BONE        4 Visit 4 2017-01-10T08:25 INVESTIGATOR
#> 2     102  TARGET LIVER        2 Visit 2 2017-01-01T06:25 INVESTIGATOR
#>       last.vis.dtc last.vis visit.order                       check.flag
#> 1 2017-01-15T10:25  Visit 3           4 Datetime earlier than last Visit
#> 2 2017-01-01T08:25  Visit 1           2 Datetime earlier than last Visit

# adding cases with duplicated date
TU$TUDTC[TU$USUBJID == 101 & TU$VISIT == "Visit 5"] <- "2017-01-10T08:25"
TU$TUDTC[TU$USUBJID == 102 & TU$VISIT == "Visit 3"] <- "2017-01-01T06:25"
 check_tu_tudtc_visit_ordinal_error(TU)
#> [1] FALSE
#> attr(,"msg")
#> [1] "TU has 3 records with Possible TUDTC data entry error. "
#> attr(,"data")
#>   USUBJID TUORRES TULOC VISITNUM   VISIT            TUDTC       TUEVAL
#> 1     101     NEW  BONE        4 Visit 4 2017-01-10T08:25 INVESTIGATOR
#> 2     102  TARGET LIVER        2 Visit 2 2017-01-01T06:25 INVESTIGATOR
#> 3     102  TARGET LIVER        3 Visit 3 2017-01-01T06:25 INVESTIGATOR
#>       last.vis.dtc last.vis visit.order                       check.flag
#> 1 2017-01-15T10:25  Visit 3           4 Datetime earlier than last Visit
#> 2 2017-01-01T08:25  Visit 1           2 Datetime earlier than last Visit
#> 3 2017-01-01T06:25  Visit 2           3                       Duplicated