R/tst_win_check.r

Defines functions tst_win_check

Documented in tst_win_check

#' Generate a report of TSTs read outside of the 44-76 hour window.
#' 
#' This function generates a data.frame of participants whose TSTs were
#' read less than 44 or more than 76 hours after placement (the window
#' permitted under the study protocol).
#' 
#' @return
#' This function returns a data.frame of participants whose tests fall outside
#' the window, including study ID, date/time placed, date/time read,
#' placer and reader initials, and the hours from placement to reading.
#' 
#' @param cleanlist The list of cleaned TO1 data generated by 
#'   \code{\link{clean_to1}}
#' 
#' @export

tst_win_check <- function(cleanlist) {

    tsts <- cleanlist$skintest[cleanlist$skintest$Status %in% "Submitted", ]


    ########################################################################### 
    # Were TSTs read within 48-72 hours?
    ########################################################################### 

    tsts$hrs_to_read <- round(as.numeric(
       difftime(tsts$dt_read, tsts$dt_placed, units = "hours")), 1)
        


    # Report any outside of the 48-72 hour bounds (which are actually 44-76)
    tsts[tsts$hrs_to_read > 76 | tsts$hrs_to_read < 44, 
        c("StudyID", "dt_placed", "TstPlacedBy",
          "dt_read", "TstReadBy", "hrs_to_read")]



}
mmparker/to1check documentation built on May 23, 2019, 5:05 a.m.