This code flags when QSSTAT Completion Status is marked as NOT DONE but QSREASND Reason Not Performed is not populated. Some but not all questionnaires in a study may collect Reason Not Performed information, so there may be instances of false positives in which no data correction is required. While QSREASND is a permissible variable, this scenario will be flagged in P21.

check_qs_qsstat_qsreasnd(QS)

Arguments

QS

Questionnaire SDTMv dataset with USUBJID, QSCAT, QSDTC, QSSTAT, QSREASND, VISIT (optional) variables

Value

boolean value if check returns 0 obs, otherwise return subset dataframe.

Author

Katie Patel, Bonita Viegas Monteiro, Tom Stone (HackR 2021 Team WeRawesome)

Examples


QS <- data.frame(USUBJID = c(1,1,1,2,2,2),
                 QSDTC   = c("2015-06-30", "2015-09-30", "2015-12-30", 
                             "2015-06-30", "2015-09-30", "2015-12-30"),
                 QSCAT   = "A",
                 VISIT  =  c("Week 1", "Week 12", "Week 24", "Week 1", "Week 12", "Week 24"),
                 QSSTAT  = c("Not Done","NOT DONE","not done", rep("",3)),
                 QSREASND = c("Reasons",rep("",5)),
                 stringsAsFactors = FALSE)

 check_qs_qsstat_qsreasnd(QS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "Completion status for 2 record(s) is 'NOT DONE' but Reason Not Performed not given. "
#> attr(,"data")
#>   USUBJID      QSDTC QSCAT   VISIT   QSSTAT QSREASND
#> 2       1 2015-09-30     A Week 12 NOT DONE         
#> 3       1 2015-12-30     A Week 24 not done         

 QS$QSSTAT=NULL

 check_qs_qsstat_qsreasnd(QS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "QS is missing the variable: QSSTAT"