R/check_qs_qsstat_qsstresc.R
    check_qs_qsstat_qsstresc.RdThis check is for studies with PRO outcomes data (i.e., QS domain), check that within a given instrument (e.g., QS.QSCAT='BFI' or QS.QSCAT ='MDASI"), if QS.QSSTAT=NOT DONE and QSTESTCD=QSALL, then there should be no populated responses(QS.QSSTRESC) for a particular visit (QS.VISIT), return a dataframe if otherwise
check_qs_qsstat_qsstresc(QS)boolean value if check failed or passed with 'msg' attribute if the test failed
QS <- data.frame(
STUDYID = 1,
USUBJID = c(rep(1,6),rep(2,6)),
QSSTRESC = 1:12,
VISIT = c(rep(1,3),rep(2,3),rep(1,3),rep(2,3)),
QSSTAT = rep(c("DONE","NOT DONE"),6),
QSCAT = rep(c("INDIVIDUAL","OVERALL","BFI"),4),
QSDTC = "2016-01-01",
QSTESTCD = "QSALL",
stringsAsFactors = FALSE
)
check_qs_qsstat_qsstresc(QS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are non-missing QSSTRESC records for the following visits when QSSTAT=NOT DONE and QSTESTCD=QSALL.  "
#> attr(,"data")
#>   USUBJID VISIT      QSCAT      QSDTC   QSSTAT QSSTRESC
#> 1       1     1    OVERALL 2016-01-01 NOT DONE        2
#> 2       1     2        BFI 2016-01-01 NOT DONE        6
#> 3       1     2 INDIVIDUAL 2016-01-01 NOT DONE        4
#> 4       2     1    OVERALL 2016-01-01 NOT DONE        8
#> 5       2     2        BFI 2016-01-01 NOT DONE       12
#> 6       2     2 INDIVIDUAL 2016-01-01 NOT DONE       10
QS$QSSTRESC[4]=" "
QS$QSSTRESC[6]=NA
QS$QSSTRESC[8]="."
check_qs_qsstat_qsstresc(QS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are non-missing QSSTRESC records for the following visits when QSSTAT=NOT DONE and QSTESTCD=QSALL.  "
#> attr(,"data")
#>   USUBJID VISIT      QSCAT      QSDTC   QSSTAT QSSTRESC
#> 1       1     1    OVERALL 2016-01-01 NOT DONE        2
#> 2       2     2        BFI 2016-01-01 NOT DONE       12
#> 3       2     2 INDIVIDUAL 2016-01-01 NOT DONE       10
QS$QSSTRESC=NULL
check_qs_qsstat_qsstresc(QS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "QS is missing the variable: QSSTRESC"