R/check_pr_prlat.R
check_pr_prlat.Rd
This check assesses observations where PRCAT contains the word OCULAR and flags records with missing/inconsistent laterality
check_pr_prlat(PR, preproc = identity, ...)
boolean value if check failed or passed with 'msg' attribute if the test failed
PR <- data.frame(
USUBJID = 1:5,
PRCAT = "PRIOR OCULAR SURGERIES AND PROCEDURES",
PRSTDTC = 1:5,
PRLAT = c("Left", "","Bilateral", "", ""),
PRTRT = c("A", "B", "A", "B", "A"),
PROCCUR = c("Y", "N", "N", "Y", "Y"),
PRPRESP = "Y",
PRSPID = "FORMNAME-R:2/L:2XXXX",
stringsAsFactors = FALSE)
check_pr_prlat(PR,preproc=roche_derive_rave_row)
#> [1] FALSE
#> attr(,"msg")
#> [1] "2 record(s) with PRLAT Missing from records with PRCAT containing the word OCULAR when expected to be populated. "
#> attr(,"data")
#> USUBJID PRCAT PRSTDTC RAVE PRLAT
#> 1 4 PRIOR OCULAR SURGERIES AND PROCEDURES 4 FORMNAME-R:2
#> 2 5 PRIOR OCULAR SURGERIES AND PROCEDURES 5 FORMNAME-R:2
#> PRTRT
#> 1 B
#> 2 A
PR <- data.frame(
USUBJID = 1:5,
PRCAT = "CONCURRENT OCULAR PROCEDURE",
PRSTDTC = 1:5,
PRLAT = c("Left", "LEFT","Bilateral", "RIGHT", "RIgHT"),
PRTRT = c("A", "B", "A", "B", "A"),
PROCCUR = NA,
PRPRESP = NA,
stringsAsFactors = FALSE)
check_pr_prlat(PR)
#> [1] TRUE
PR <- data.frame(
USUBJID = 1:5,
PRCAT = "CONCURRENT OCULAR PROCEDURE",
PRSTDTC = 1:5,
PRLAT = c("Left", "LEFT","Bilateral", "RIGHT", ""),
PRTRT = c("A", "B", "A", "B", "A"),
PROCCUR = NA,
PRPRESP = NA,
stringsAsFactors = FALSE)
check_pr_prlat(PR)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 record(s) with PRLAT Missing from records with PRCAT containing the word OCULAR when expected to be populated. "
#> attr(,"data")
#> USUBJID PRCAT PRSTDTC PRLAT PRTRT
#> 1 5 CONCURRENT OCULAR PROCEDURE 5 A
PR <- data.frame(
USUBJID = 1:5,
PRCAT = "CONCURRENT OCULAR PROCEDURE",
PRSTDTC = 1:5,
PRLAT = c("Left", "","Bilateral", "RIGHT", ""),
PRTRT = c("A", "B", "A", "B", "A"),
PROCCUR = c("Y", "N", "N", "Y", "Y"),
PRPRESP = "Y",
stringsAsFactors = FALSE)
check_pr_prlat(PR)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 record(s) with PRLAT Missing from records with PRCAT containing the word OCULAR when expected to be populated. "
#> attr(,"data")
#> USUBJID PRCAT PRSTDTC PRLAT PRTRT
#> 1 5 CONCURRENT OCULAR PROCEDURE 5 A
PR <- data.frame(
USUBJID = 1:5,
PRCAT = c(rep("CONCURRENT NON-OCULAR PROCEDURE",3),rep("CONCURRENT OCULAR PROCEDURE",2)),
PRSTDTC = 1:5,
PRLAT = c("", "","", "RIGHT", ""),
PRTRT = c("A", "B", "A", "B", "A"),
PROCCUR = c("Y", "N", "N", "Y", "Y"),
PRPRESP = "Y",
stringsAsFactors = FALSE)
check_pr_prlat(PR)
#> [1] FALSE
#> attr(,"msg")
#> [1] "1 record(s) with PRLAT Missing from records with PRCAT containing the word OCULAR when expected to be populated. "
#> attr(,"data")
#> USUBJID PRCAT PRSTDTC PRLAT PRTRT
#> 1 5 CONCURRENT OCULAR PROCEDURE 5 A