Check for missing month when lab specimen collection date (LBDTC) has known year and day

check_lb_missing_month(LB)

Arguments

LB

Laboratory data SDTM dataset with variables USUBJID,LBTEST,LBDTC,VISIT

Value

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

Author

Sara Bodach

Examples


LB <- data.frame(
 USUBJID = 1:4,
 LBTEST = c("TEST1","TEST2","TEST3","TEST3"),
 LBDTC = c("2017-01-01","2017-02-01","2017---01", "2017----01"),
 VISIT = c("VISIT1","VISIT2","VISIT3","VISIT3"),
 stringsAsFactors=FALSE
)

check_lb_missing_month(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 2 patients with a lab date that has year and day present but missing month. "
#> attr(,"data")
#>   USUBJID LBTEST      LBDTC  VISIT
#> 1       3  TEST3  2017---01 VISIT3
#> 2       4  TEST3 2017----01 VISIT3

LB$LBDTC = NULL

check_lb_missing_month(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "LB is missing the variable: LBDTC"