Identifies multiple dates at the same visit in QS
check_qs_dup(QS)
Boolean value for whether the check passed or failed, with 'msg' attribute if the test failed
QS1 <- data.frame(USUBJID = c(rep(101, 5), rep(102, 5)),
QSCAT = "DLQI",
QSDTC = 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", "UNSCheduled!!!","VIsit 5"), 2),
stringsAsFactors = FALSE)
check_qs_dup(QS = QS1)
#> [1] TRUE
# multiple dates for the same visit in QS
QS2 <- QS1
QS2$VISIT[QS2$USUBJID == 101] <- "Visit 1"
check_qs_dup(QS = QS2)
#> [1] FALSE
#> attr(,"msg")
#> [1] "Multiple dates for the same visit in QS. "
#> attr(,"data")
#> # A tibble: 5 × 4
#> # Groups: USUBJID, QSCAT, VISIT [1]
#> USUBJID QSCAT QSDTC VISIT
#> <dbl> <chr> <chr> <chr>
#> 1 101 DLQI 2017-01-01 Visit 1
#> 2 101 DLQI 2017-01-05 Visit 1
#> 3 101 DLQI 2017-01-15 Visit 1
#> 4 101 DLQI 2017-01-20 Visit 1
#> 5 101 DLQI 2017-01-25 Visit 1
# multiple visit labels for the same date
QS3 <- QS1
QS3$QSDTC[QS3$USUBJID == 101] <- "2017-01-01"
QS3
#> USUBJID QSCAT QSDTC VISITNUM VISIT
#> 1 101 DLQI 2017-01-01 1 Visit 1
#> 2 101 DLQI 2017-01-01 2 Visit 2
#> 3 101 DLQI 2017-01-01 3 Visit 3
#> 4 101 DLQI 2017-01-01 4 UNSCheduled!!!
#> 5 101 DLQI 2017-01-01 5 VIsit 5
#> 6 102 DLQI 2017-01-01T08:25 1 Visit 1
#> 7 102 DLQI 2017-01-05T09:25 2 Visit 2
#> 8 102 DLQI 2017-01-15T10:25 3 Visit 3
#> 9 102 DLQI 2017-01-20T08:25 4 UNSCheduled!!!
#> 10 102 DLQI 2017-01-25T08:25 5 VIsit 5
check_qs_dup(QS = QS3)
#> [1] TRUE