R/check_tr_trdtc_across_visit.R
check_tr_trdtc_across_visit.Rd
This check identifies records where the same date TRDTC occurs across multiple visits for Longest Diameter measurements (TRTESTCD is "LDIAM"). Only applies to assessments by investigator, selected based on uppercased TREVAL = "INVESTIGATOR" or missing or TREVAL variable does not exist.
check_tr_trdtc_across_visit(TR, preproc = identity, ...)
boolean value if check failed or passed with 'msg' attribute if the test failed
TR <- data.frame(
USUBJID = 1,
TRDTC = c(rep("2016-01-01",3), rep("2016-06-01",5), rep("2016-06-24",2)),
VISIT = c(rep("C1D1",3), rep("C1D2",3), rep("C2D1",4)),
TRTESTCD = c(rep("LDIAM",7),rep("SAXIS",3)),
TRSPID = "FORMNAME-R:13/L:13XXXX",
stringsAsFactors=FALSE)
check_tr_trdtc_across_visit(TR)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 TR Longest Diameter records where the same date occurs accross multiple visits. "
#> attr(,"data")
#> USUBJID TRDTC VISIT TRTESTCD
#> 1 1 2016-06-01 C1D2 LDIAM
#> 2 1 2016-06-01 C2D1 LDIAM
check_tr_trdtc_across_visit(TR, preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 TR Longest Diameter records where the same date occurs accross multiple visits. "
#> attr(,"data")
#> USUBJID TRDTC VISIT TRTESTCD RAVE
#> 1 1 2016-06-01 C1D2 LDIAM FORMNAME-R:13
#> 2 1 2016-06-01 C2D1 LDIAM FORMNAME-R:13
TR2 <- TR
TR2$TRSPID[4:5] <- c("FORMNAME2-R:5/L:13XXXX", "FORMNAME3-R:0/L:13XXXX")
check_tr_trdtc_across_visit(TR2)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 TR Longest Diameter records where the same date occurs accross multiple visits. "
#> attr(,"data")
#> USUBJID TRDTC VISIT TRTESTCD
#> 1 1 2016-06-01 C1D2 LDIAM
#> 2 1 2016-06-01 C2D1 LDIAM
check_tr_trdtc_across_visit(TR2, preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 4 TR Longest Diameter records where the same date occurs accross multiple visits. "
#> attr(,"data")
#> USUBJID TRDTC VISIT TRTESTCD RAVE
#> 1 1 2016-06-01 C1D2 LDIAM FORMNAME2-R:5
#> 2 1 2016-06-01 C1D2 LDIAM FORMNAME3-R:0
#> 3 1 2016-06-01 C1D2 LDIAM FORMNAME-R:13
#> 4 1 2016-06-01 C2D1 LDIAM FORMNAME-R:13
# missing optional variable
TR3 <- TR
TR3$TRSPID <- NULL
check_tr_trdtc_across_visit(TR3)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 TR Longest Diameter records where the same date occurs accross multiple visits. "
#> attr(,"data")
#> USUBJID TRDTC VISIT TRTESTCD
#> 1 1 2016-06-01 C1D2 LDIAM
#> 2 1 2016-06-01 C2D1 LDIAM
check_tr_trdtc_across_visit(TR3, preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 TR Longest Diameter records where the same date occurs accross multiple visits. "
#> attr(,"data")
#> USUBJID TRDTC VISIT TRTESTCD
#> 1 1 2016-06-01 C1D2 LDIAM
#> 2 1 2016-06-01 C2D1 LDIAM
# missing required variable
TR4 <- TR
TR4$TRTESTCD <- NULL
check_tr_trdtc_across_visit(TR4)
#> [1] FALSE
#> attr(,"msg")
#> [1] "TR is missing the variable: TRTESTCD"
check_tr_trdtc_across_visit(TR4, preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "TR is missing the variable: TRTESTCD"