Skip to content

Commit

Permalink
#409 Updated comments and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vbshuliar committed Sep 17, 2024
1 parent 8bd8627 commit ee12370
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions R/check_ec_sc_lat.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand All @@ -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)
#'
Expand Down Expand Up @@ -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)
#'
Expand Down Expand Up @@ -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)
#'
Expand All @@ -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")))

}

Expand Down Expand Up @@ -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"
Expand All @@ -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()
Expand Down
22 changes: 11 additions & 11 deletions R/check_oe_sc_lat_count_fingers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
#'
Expand Down Expand Up @@ -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)
#'
Expand Down Expand Up @@ -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)
#'
Expand All @@ -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")))

}

Expand All @@ -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) {
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions R/check_sc_dm_seyeselc.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit ee12370

Please sign in to comment.