From 46d590332ef610435f34268e283795d3f1eae0a1 Mon Sep 17 00:00:00 2001 From: Anthony Sena Date: Wed, 11 Dec 2024 12:53:49 -0500 Subject: [PATCH] Mark startWindow and endWindow as deprecated and update docs --- R/Subsets.R | 33 ++++++++++++++++++++++++--------- man/CohortSubsetOperator.Rd | 3 ++- man/createCohortSubset.Rd | 9 ++++++--- man/createSubsetCohortWindow.Rd | 17 +++++++++++------ 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/R/Subsets.R b/R/Subsets.R index ec2b160..cfab717 100644 --- a/R/Subsets.R +++ b/R/Subsets.R @@ -127,12 +127,19 @@ SubsetCohortWindow <- R6::R6Class( ) # createSubsetCohortWindow ------------------------------ -#' A definition of subset functions to be applied to a set of cohorts +#' @title Create a relative time window for cohort subset operations +#' @description +#' This function is used to create a relative time window for +#' cohort subset operations. The cohort window allows you to define an interval +#' of time relative to the target cohort's start/end date and the +#' subset cohort's start/end date. #' @export -#' @param startDay The start day for the window -#' @param endDay The end day for the window -#' @param targetAnchor To anchor using the target cohort's start date or end date -#' @param subsetAnchor To anchor using the subset cohort's start date or end date +#' @param startDay The start day for the time window +#' @param endDay The end day for the time window +#' @param targetAnchor To anchor using the target cohort's start date or end date. +#' The parameter is specified as 'cohortStart' or 'cohortEnd'. +#' @param subsetAnchor To anchor using the subset cohort's start date or end date. +#' The parameter is specified as 'cohortStart' or 'cohortEnd'. #' @returns a SubsetCohortWindow instance createSubsetCohortWindow <- function(startDay, endDay, targetAnchor, subsetAnchor = NULL) { if (is.null(subsetAnchor)) @@ -397,7 +404,8 @@ CohortSubsetOperator <- R6::R6Class( private$.negate <- negate self }, - #' @field windows list of time windows to use evaluating the subset cohort relative to the target cohort + #' @field windows list of time windows to use when evaluating the subset + #' cohort relative to the target cohort windows = function(windows) { if (missing(windows)) { return(private$.windows) @@ -425,9 +433,12 @@ CohortSubsetOperator <- R6::R6Class( #' @param cohortCombinationOperator "any" or "all" if using more than one cohort id allow a subject to be in any cohort #' or require that they are in all cohorts in specified windows #' -#' @param startWindow A SubsetCohortWindow that patients must fall inside (see createSubsetCohortWindow) -#' @param endWindow A SubsetCohortWindow that patients must fall inside (see createSubsetCohortWindow) -#' @param windows A list of additional windows to be applied (logic is to always apply these with AND conditions) +#' @param startWindow DEPRECATED: Use `windows` instead. +#' @param endWindow DEPRECATED: Use `windows` instead. +#' @param windows A list of time windows to use to evaluate subset cohorts in relation to the +#' target cohorts. The logic is to always apply these windows with logical AND conditions. +#' See [@seealso [createSubsetCohortWindow()]] for more details on how to create +#' these windows. #' @param negate The opposite of this definition - include patients who do NOT meet the specified criteria #' @returns a CohortSubsetOperator instance createCohortSubset <- function(name = NULL, cohortIds, cohortCombinationOperator, negate, windows = list(), startWindow = NULL, endWindow = NULL) { @@ -438,6 +449,10 @@ createCohortSubset <- function(name = NULL, cohortIds, cohortCombinationOperator subset$negate <- negate # Start and end windows must always have subset anchor values set to support backwards compatibility + if (!is.null(startWindow) || !is.null(endWindow)) { + warning("Arguments 'startWindow' and 'endWindow' is deprecated. Use 'windows' instead.") + } + if (!is.null(startWindow)){ startWindow$subsetAnchor <- "cohortStart" windows[[length(windows) + 1]] <- startWindow diff --git a/man/CohortSubsetOperator.Rd b/man/CohortSubsetOperator.Rd index 1fa6592..4895168 100644 --- a/man/CohortSubsetOperator.Rd +++ b/man/CohortSubsetOperator.Rd @@ -18,7 +18,8 @@ A subset of type cohort - subset a population to only those contained within def \item{\code{negate}}{Inverse the subset rule? TRUE will take the patients NOT in the subset} -\item{\code{windows}}{list of time windows to use evaluating the subset cohort relative to the target cohort} +\item{\code{windows}}{list of time windows to use when evaluating the subset +cohort relative to the target cohort} } \if{html}{\out{}} } diff --git a/man/createCohortSubset.Rd b/man/createCohortSubset.Rd index e400e1b..e774709 100644 --- a/man/createCohortSubset.Rd +++ b/man/createCohortSubset.Rd @@ -24,11 +24,14 @@ or require that they are in all cohorts in specified windows} \item{negate}{The opposite of this definition - include patients who do NOT meet the specified criteria} -\item{windows}{A list of additional windows to be applied (logic is to always apply these with AND conditions)} +\item{windows}{A list of time windows to use to evaluate subset cohorts in relation to the +target cohorts. The logic is to always apply these windows with logical AND conditions. +See [@seealso [createSubsetCohortWindow()]] for more details on how to create +these windows.} -\item{startWindow}{A SubsetCohortWindow that patients must fall inside (see createSubsetCohortWindow)} +\item{startWindow}{DEPRECATED: Use `windows` instead.} -\item{endWindow}{A SubsetCohortWindow that patients must fall inside (see createSubsetCohortWindow)} +\item{endWindow}{DEPRECATED: Use `windows` instead.} } \value{ a CohortSubsetOperator instance diff --git a/man/createSubsetCohortWindow.Rd b/man/createSubsetCohortWindow.Rd index 0043009..5a11552 100644 --- a/man/createSubsetCohortWindow.Rd +++ b/man/createSubsetCohortWindow.Rd @@ -2,22 +2,27 @@ % Please edit documentation in R/Subsets.R \name{createSubsetCohortWindow} \alias{createSubsetCohortWindow} -\title{A definition of subset functions to be applied to a set of cohorts} +\title{Create a relative time window for cohort subset operations} \usage{ createSubsetCohortWindow(startDay, endDay, targetAnchor, subsetAnchor = NULL) } \arguments{ -\item{startDay}{The start day for the window} +\item{startDay}{The start day for the time window} -\item{endDay}{The end day for the window} +\item{endDay}{The end day for the time window} -\item{targetAnchor}{To anchor using the target cohort's start date or end date} +\item{targetAnchor}{To anchor using the target cohort's start date or end date. +The parameter is specified as 'cohortStart' or 'cohortEnd'.} -\item{subsetAnchor}{To anchor using the subset cohort's start date or end date} +\item{subsetAnchor}{To anchor using the subset cohort's start date or end date. +The parameter is specified as 'cohortStart' or 'cohortEnd'.} } \value{ a SubsetCohortWindow instance } \description{ -A definition of subset functions to be applied to a set of cohorts +This function is used to create a relative time window for +cohort subset operations. The cohort window allows you to define an interval +of time relative to the target cohort's start/end date and the +subset cohort's start/end date. }