Skip to content

Commit

Permalink
Mark startWindow and endWindow as deprecated and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonysena committed Dec 11, 2024
1 parent 67fbe54 commit 46d5903
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
33 changes: 24 additions & 9 deletions R/Subsets.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion man/CohortSubsetOperator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions man/createCohortSubset.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions man/createSubsetCohortWindow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 46d5903

Please sign in to comment.