This check looks for LB dates that occur after death date

check_lb_lbdtc_after_dd(AE, DS, LB)

Arguments

AE

Adverse Event SDTM dataset with variables USUBJID, AEDTHDTC, AESTDTC, AEDECOD, and AETERM

DS

Disposition SDTM dataset with variables USUBJID, DSSTDTC, DSDECOD, and DSTERM

LB

Laboratory Test Findings SDTM dataset with variables USUBJID, LBDTC, LBTESTCD, and LBORRES

Value

Boolean value for whether the check passed or failed, with 'msg' attribute if the check failed

Author

Nina Ting Qi

Examples


AE <- data.frame(STUDYID = 1:5, USUBJID = LETTERS[1:5],
                 AEDTHDTC = c(rep("", 4), "2016-01-01"),
                 AESTDTC = rep("2016-01-01", 5),
                 AEDECOD = LETTERS[1:5], AETERM = LETTERS[1:5],
                 stringsAsFactors = FALSE)

DS <- data.frame(STUDYID = 1:5, USUBJID = LETTERS[1:5],
                 DSSTDTC = rep("2016-01-02", 5),
                 DSDECOD = c(LETTERS[1:4], "death"),
                 DSTERM = letters[1:5],
                 stringsAsFactors = FALSE)

LB <- data.frame(STUDYID = 1:5, USUBJID = LETTERS[1:5],
                 LBDTC = rep("2015-12-31", 5),
                 LBTESTCD = letters[1:5],
                 LBORRES = 1:5,
                 stringsAsFactors = FALSE)

check_lb_lbdtc_after_dd(AE, DS, LB)
#> [1] TRUE

LB$LBDTC[1] <- "2016-01-03"
LB$USUBJID[1] <- LB$USUBJID[5]

check_lb_lbdtc_after_dd(AE, DS, LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "Patient(s) with LB occurring after death date. "
#> attr(,"data")
#>   USUBJID      LBDTC LBTESTCD   AEDTHDTC    DSSTDTC EARLIEST_DTHDTC
#> 1       E 2016-01-03        a 2016-01-01 2016-01-02      2016-01-01