From ee123706cba861faf47c5438e7e9cb83099b4d08 Mon Sep 17 00:00:00 2001 From: "Shuliar, Vladyslav {TDBP~WELWYN}" Date: Tue, 17 Sep 2024 16:14:05 +0200 Subject: [PATCH] #409 Updated comments and documentation --- R/check_ec_sc_lat.R | 24 ++++++++++++------------ R/check_oe_sc_lat_count_fingers.R | 22 +++++++++++----------- R/check_sc_dm_seyeselc.R | 4 ++-- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/R/check_ec_sc_lat.R b/R/check_ec_sc_lat.R index de31f76a..5d19127b 100644 --- a/R/check_ec_sc_lat.R +++ b/R/check_ec_sc_lat.R @@ -7,10 +7,10 @@ #' assuming drug administration is collected for study eye only. #' 2.> Subset Subject Characteristics dataset (SC) for only Study Eye Selection #' 3.> Compare Exposure dataset laterality (EC.ECLAT) with Subject Characteristics dataset laterality -#' (SC.SCORRES - OS = LEFT, OD = RIGHT) and report if there is any mismatch. +#' (SC.SCSTRESC - OS = LEFT, OD = RIGHT) and report if there is any mismatch. #' #' @param SC Subject Characteristics Dataset for Ophtha Study with variables -#' USUBJID, SCTEST, SCTESTCD, SCCAT, SCORRES, SCDTC +#' USUBJID, SCTEST, SCTESTCD, SCCAT, SCSTRESC, SCDTC #' @param EC Subject Exposure Dataset with variables #' USUBJID, ECCAT (if available), ECLOC, ECMOOD, ECLAT, ECSTDY, VISIT, ECSTDTC, ECOCCUR, ECROUTE #' @@ -34,7 +34,7 @@ #' SCTESTCD = c("ELIGEYE", "FOCID", "", "ELIGEYE", "FOCID", ""), #' SCCAT = c("STUDY EYE SELECTION", "STUDY EYE SELECTION", "", #' "STUDY EYE SELECTION", "STUDY EYE SELECTION", ""), -#' SCORRES = c("LEFT", "OS", "", "RIGHT", "OD", ""), +#' SCSTRESC = c("LEFT", "OS", "", "RIGHT", "OD", ""), #' SCDTC = "2021-01-01", #' stringsAsFactors = FALSE) #' @@ -67,7 +67,7 @@ #' SCTESTCD = c("ELIGEYE", "FOCID", "", "ELIGEYE", "FOCID", ""), #' SCCAT = c("STUDY EYE SELECTION", "STUDY EYE SELECTION", "", #' "STUDY EYE SELECTION", "STUDY EYE SELECTION", ""), -#' SCORRES = c("LEFT", "OS", "", "RIGHT", "OD", ""), +#' SCSTRESC = c("LEFT", "OS", "", "RIGHT", "OD", ""), #' SCDTC = "2021-01-01", #' stringsAsFactors = FALSE) #' @@ -102,7 +102,7 @@ #' SCCAT = c("STUDY EYE SELECTION", "STUDY EYE SELECTION", "", #' "STUDY EYE SELECTION", #' "STUDY EYE SELECTION", "", "STUDY EYE SELECTION"), -#' SCORRES = c("LEFT", "OS", "", "RIGHT", "OD", "", "RIGHT"), +#' SCSTRESC = c("LEFT", "OS", "", "RIGHT", "OD", "", "RIGHT"), #' SCDTC = "2021-01-01", #' stringsAsFactors = FALSE) #' @@ -127,9 +127,9 @@ check_ec_sc_lat <- function(EC,SC) { - if (SC %lacks_any% c("USUBJID", "SCTEST", "SCTESTCD", "SCCAT", "SCORRES", "SCDTC")) { + if (SC %lacks_any% c("USUBJID", "SCTEST", "SCTESTCD", "SCCAT", "SCSTRESC", "SCDTC")) { - fail(lacks_msg(SC, c("USUBJID","SCTEST","SCTESTCD","SCCAT","SCORRES", "SCDTC"))) + fail(lacks_msg(SC, c("USUBJID","SCTEST","SCTESTCD","SCCAT","SCSTRESC", "SCDTC"))) } @@ -164,13 +164,13 @@ check_ec_sc_lat <- function(EC,SC) { } # Subset SC data on SC.SCCAT = "STUDY EYE SELECTION", and - # SCTESTCD = "FOCID". SC.SCORRES OS (oculus sinister) means the left + # SCTESTCD = "FOCID". SC.SCSTRESC OS (oculus sinister) means the left # eye and OD (oculus dextrus) means the right eye. SC <- SC %>% - select(USUBJID, SCTESTCD, SCTEST, SCCAT, SCORRES, SCDTC) %>% + select(USUBJID, SCTESTCD, SCTEST, SCCAT, SCSTRESC, SCDTC) %>% filter(toupper(SCTESTCD) == "FOCID") %>% - mutate(SC_STUDYEYE = ifelse(toupper(SCORRES) == "OS", "LEFT", - ifelse(toupper(SCORRES) == "OD", "RIGHT","SCORRES Value not OS or OD"))) + mutate(SC_STUDYEYE = ifelse(toupper(SCSTRESC) == "OS", "LEFT", + ifelse(toupper(SCSTRESC) == "OD", "RIGHT","SCSTRESC Value not OS or OD"))) # Subset EC data on EC.ECCAT (if available) remove Fellow Eye Records, # EC.ECMOOD = "PERFORMED" EC.ECOCCUR = "Y" @@ -197,7 +197,7 @@ check_ec_sc_lat <- function(EC,SC) { mydf = mydf1 %>% filter(MISFLAG == 1)%>% filter(ECROUTE != "NON-OCULAR ROUTE" | is.na(ECROUTE)) %>% - select(-MISFLAG, -SCTESTCD, -SCTEST, -SCCAT, -ECLOC, -ECMOOD, -ECOCCUR, -SCORRES) + select(-MISFLAG, -SCTESTCD, -SCTEST, -SCCAT, -ECLOC, -ECMOOD, -ECOCCUR, -SCSTRESC) if ((nrow(mydf) > 0 ) == FALSE) { pass() diff --git a/R/check_oe_sc_lat_count_fingers.R b/R/check_oe_sc_lat_count_fingers.R index cbc4d747..9a732874 100644 --- a/R/check_oe_sc_lat_count_fingers.R +++ b/R/check_oe_sc_lat_count_fingers.R @@ -3,7 +3,7 @@ #' @description Check If Post Treatment Count Fingers in Study Eye is done on the actual Study eye by comparing laterality from OE domain with SC domain. #' Check is ignored if Post Treatment Count Fingers is not collected in study as it is quite common for EP studies #' -#' @param SC Subject Characteristics Dataset for Ophtho Study with variables USUBJID, SCTEST, SCTESTCD, SCCAT, SCORRES, SCDTC +#' @param SC Subject Characteristics Dataset for Ophtho Study with variables USUBJID, SCTEST, SCTESTCD, SCCAT, SCSTRESC, SCDTC #' @param OE Ophthalmic Examination Dataset for Ophtho Study with variables USUBJID, OECAT, OELAT, VISIT, OEDTC, OETEST, OELOC, OESTAT (if present) #' #' @importFrom dplyr %>% filter mutate select @@ -30,7 +30,7 @@ #' SCTESTCD = c("ELIGEYE", "FOCID", "", "ELIGEYE", "FOCID", ""), #' SCCAT = c("STUDY EYE SELECTION", "STUDY EYE SELECTION", "", #' "STUDY EYE SELECTION", "STUDY EYE SELECTION", ""), -#' SCORRES = c("LEFT", "OS", "", "RIGHT", "OD", ""), +#' SCSTRESC = c("LEFT", "OS", "", "RIGHT", "OD", ""), #' SCDTC = rep("2021-01-01", 6), #' stringsAsFactors = FALSE) #' @@ -60,7 +60,7 @@ #' SCTESTCD = c("ELIGEYE", "FOCID", "", "ELIGEYE", "FOCID", ""), #' SCCAT = c("STUDY EYE SELECTION", "STUDY EYE SELECTION", "", #' "STUDY EYE SELECTION", "STUDY EYE SELECTION", ""), -#' SCORRES = c("LEFT", "OS", "", "RIGHT", "OD", ""), +#' SCSTRESC = c("LEFT", "OS", "", "RIGHT", "OD", ""), #' SCDTC = rep("2021-01-01", 6), #' stringsAsFactors = FALSE) #' @@ -93,7 +93,7 @@ #' SCCAT = c("STUDY EYE SELECTION", "STUDY EYE SELECTION", "", #' "STUDY EYE SELECTION", "STUDY EYE SELECTION", #' "", "STUDY EYE SELECTION"), -#' SCORRES = c("LEFT", "OS", "", "RIGHT", "OD", "", "OS"), +#' SCSTRESC = c("LEFT", "OS", "", "RIGHT", "OD", "", "OS"), #' SCDTC = "2021-01-01", #' stringsAsFactors = FALSE) #' @@ -119,9 +119,9 @@ check_oe_sc_lat_count_fingers <- function(OE, SC) { - if (SC %lacks_any% c("USUBJID", "SCTEST", "SCTESTCD", "SCCAT", "SCORRES", "SCDTC")) { + if (SC %lacks_any% c("USUBJID", "SCTEST", "SCTESTCD", "SCCAT", "SCSTRESC", "SCDTC")) { - fail(lacks_msg(SC, c("USUBJID","SCTEST","SCTESTCD","SCCAT","SCORRES", "SCDTC"))) + fail(lacks_msg(SC, c("USUBJID","SCTEST","SCTESTCD","SCCAT","SCSTRESC", "SCDTC"))) } @@ -138,12 +138,12 @@ check_oe_sc_lat_count_fingers <- function(OE, SC) { else { - # Subset SC data on SC.SCCAT = "STUDY EYE SELECTION", and and SCTESTCD = "FOCID". SC.SCORRES OS (oculus sinister) means the left + # Subset SC data on SC.SCCAT = "STUDY EYE SELECTION", and and SCTESTCD = "FOCID". SC.SCSTRESC OS (oculus sinister) means the left # eye and OD (oculus dextrus) means the right eye. - SC <- SC %>% select(USUBJID, SCTESTCD, SCTEST, SCCAT, SCORRES, SCDTC) %>% + SC <- SC %>% select(USUBJID, SCTESTCD, SCTEST, SCCAT, SCSTRESC, SCDTC) %>% filter(SCTESTCD %in% c("FOCID")) %>% - mutate(SC_STUDYEYE = ifelse(SCORRES == "OS", "LEFT", - ifelse(SCORRES == "OD", "RIGHT", "SCORRES Value not OS or OD"))) + mutate(SC_STUDYEYE = ifelse(SCSTRESC == "OS", "LEFT", + ifelse(SCSTRESC == "OD", "RIGHT", "SCSTRESC Value not OS or OD"))) # Remove OESTAT NOT DONE if ((any(names(OE) == "OESTAT")) == TRUE) { @@ -166,7 +166,7 @@ check_oe_sc_lat_count_fingers <- function(OE, SC) { mydf1 <- left_join(SC, OE, by="USUBJID") %>% mutate(MISFLAG = ifelse((toupper(SC_STUDYEYE) != toupper(OELAT)) | is.na(toupper(OELAT)), 1, 0)) - mydf = mydf1 %>% filter(MISFLAG == 1) %>% select(-MISFLAG, -SCTESTCD, -SCTEST, -SCCAT, -SCORRES, -OELOC, -OECAT) + mydf = mydf1 %>% filter(MISFLAG == 1) %>% select(-MISFLAG, -SCTESTCD, -SCTEST, -SCCAT, -SCSTRESC, -OELOC, -OECAT) if ((nrow(mydf) > 0 ) == FALSE) { pass() diff --git a/R/check_sc_dm_seyeselc.R b/R/check_sc_dm_seyeselc.R index 9c7b60df..2e736868 100644 --- a/R/check_sc_dm_seyeselc.R +++ b/R/check_sc_dm_seyeselc.R @@ -1,9 +1,9 @@ #' @title Check SC Study Eye Selection assignments among DM patients #' #' @description Check if SC.SCCAT = "STUDY EYE SELECTION" and SC.SCTESTCD = "FOCID", -#' then SC.SCSTRESC should have "OS", "OD", or "OU" values. Flag if subject is in +#' then SC.SCSTRESC should have "OS" or "OD" values. Flag if subject is in #' DM and without an associated SC.SCSTRESC value or the STUDY EYE SELECTION value -#' is not "OS", "OD", or "OU". +#' is not "OS" or "OD". #' #' @param DM Subject Demographics SDTM dataset with variable USUBJID #' @param SC Subject Characteristics SDTM dataset for Ophtho Study with variables