This check identifies records where original lab values (LBORRES) exist but standard lab units (LBSTRESU) are not populated, excluding qualitative results (LBMETHOD) and excluding records when LBTESTCD in ("PH" "SPGRAV")
check_lb_lbstresu(LB, preproc = identity, ...)
Lab SDTM dataset with variables USUBJID, LBSTRESC, LBSTRESN, LBORRES, LBSTRESU, LBTESTCD, LBDTC, LBMETHOD (optional), LBSPID (optional), and VISIT (optional)
An optional company specific preprocessing script
Other arguments passed to methods
boolean value if check failed or passed with 'msg' attribute if the test failed
LB <- data.frame(
USUBJID = 1:10,
LBSTRESC = "5",
LBSTRESN = 1:10,
LBORRES = "5",
LBSTRESU = "g/L",
LBTESTCD = "ALB",
LBDTC = 1:10,
stringsAsFactors=FALSE
)
check_lb_lbstresu(LB)
#> [1] TRUE
LB$LBSTRESU[1]=""
check_lb_lbstresu(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 unique patient(s) with 1 record(s) with missing lab units and non-missing test results. "
#> attr(,"data")
#> USUBJID LBTESTCD LBORRES LBSTRESU LBSTRESC LBDTC
#> 1 1 ALB 5 5 1
LB$LBSTRESU[2]="NA"
check_lb_lbstresu(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "2 unique patient(s) with 2 record(s) with missing lab units and non-missing test results. "
#> attr(,"data")
#> USUBJID LBTESTCD LBORRES LBSTRESU LBSTRESC LBDTC
#> 1 1 ALB 5 5 1
#> 2 2 ALB 5 NA 5 2
LB$LBSTRESU[3]=NA
check_lb_lbstresu(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "3 unique patient(s) with 3 record(s) with missing lab units and non-missing test results. "
#> attr(,"data")
#> USUBJID LBTESTCD LBORRES LBSTRESU LBSTRESC LBDTC
#> 1 1 ALB 5 5 1
#> 2 2 ALB 5 NA 5 2
#> 3 3 ALB 5 <NA> 5 3
LB$LBSPID= "FORMNAME-R:2/L:2XXXX"
check_lb_lbstresu(LB,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "3 unique patient(s) with 3 record(s) with missing lab units and non-missing test results. "
#> attr(,"data")
#> USUBJID LBTESTCD LBORRES LBSTRESU LBSTRESC LBDTC RAVE
#> 1 1 ALB 5 5 1 FORMNAME-R:2
#> 2 2 ALB 5 NA 5 2 FORMNAME-R:2
#> 3 3 ALB 5 <NA> 5 3 FORMNAME-R:2
LB$VISIT= "SCREENING"
check_lb_lbstresu(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "3 unique patient(s) with 3 record(s) with missing lab units and non-missing test results. "
#> attr(,"data")
#> USUBJID LBTESTCD LBORRES LBSTRESU LBSTRESC LBDTC VISIT
#> 1 1 ALB 5 5 1 SCREENING
#> 2 2 ALB 5 NA 5 2 SCREENING
#> 3 3 ALB 5 <NA> 5 3 SCREENING
LB$LBSTRESU=NULL
check_lb_lbstresu(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "LB is missing the variable: LBSTRESU"