R/check_lb_lbstresn_missing.R
check_lb_lbstresn_missing.Rd
This check looks for missing standardized finding (LBSTRESN/LBSTRESC) when original finding (LBORRES) is not missing
check_lb_lbstresn_missing(LB, preproc = identity, ...)
boolean value if check failed or passed with 'msg' attribute if the test failed
LB <- data.frame(
USUBJID = c("Patient 1","Patient 2","Patient 3"),
LBTEST = "Test A",
LBTESTCD = "TA",
LBDTC = "2017-01-01",
LBORRES = c("5","6","7"),
LBSTRESC = c("5","6","7"),
LBORRESU = rep("mg",3),
LBSTRESN = c(5,6,NA),
stringsAsFactors=FALSE
)
check_lb_lbstresn_missing(LB)
#> [1] TRUE
LB$LBSTRESC[3] = ""
check_lb_lbstresn_missing(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 unique patient(s) with 1 lab record(s) with result reported without standard value. "
#> attr(,"data")
#> USUBJID LBTESTCD LBDTC LBORRES LBORRESU LBSTRESN LBSTRESC
#> 3 Patient 3 TA 2017-01-01 7 mg NA
LB$LBSTRESC[1] = ""
check_lb_lbstresn_missing(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 unique patient(s) with 1 lab record(s) with result reported without standard value. "
#> attr(,"data")
#> USUBJID LBTESTCD LBDTC LBORRES LBORRESU LBSTRESN LBSTRESC
#> 3 Patient 3 TA 2017-01-01 7 mg NA
LB$VISIT = "SCREENING"
check_lb_lbstresn_missing(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 unique patient(s) with 1 lab record(s) with result reported without standard value. "
#> attr(,"data")
#> USUBJID LBTESTCD LBDTC LBORRES LBORRESU LBSTRESN LBSTRESC VISIT
#> 3 Patient 3 TA 2017-01-01 7 mg NA SCREENING
LB$LBSPID= "FORMNAME-R:2/L:2XXXX"
check_lb_lbstresn_missing(LB,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 unique patient(s) with 1 lab record(s) with result reported without standard value. "
#> attr(,"data")
#> USUBJID LBTESTCD LBDTC LBORRES LBORRESU LBSTRESN LBSTRESC RAVE
#> 3 Patient 3 TA 2017-01-01 7 mg NA FORMNAME-R:2
#> VISIT
#> 3 SCREENING
LB$LBSTRESN = NULL
check_lb_lbstresn_missing(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "LB is missing the variable: LBSTRESN"
LB$LBSTRESC = NULL
check_lb_lbstresn_missing(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "LB is missing the variables: LBSTRESN, LBSTRESC"