addPriorObservationQuery: Query to add the number of days of prior observation in the...

View source: R/addDemographicsQuery.R

addPriorObservationQueryR Documentation

Query to add the number of days of prior observation in the current observation period at a certain date

Description

Same as addPriorObservation(), except query is not computed to a table.

Usage

addPriorObservationQuery(
  x,
  indexDate = "cohort_start_date",
  priorObservationName = "prior_observation",
  priorObservationType = "days",
  type = "numeric"
)

Arguments

x

A table containing individuals in a CDM reference.

indexDate

Name of a date column in x, or a single date to use for all rows, used as the reference date.

priorObservationName

Name of the prior-observation column to add.

priorObservationType

Whether to return a "date" or a number of "days".

type

Type of the created column(s). Counts, days, age, and observation durations can be "numeric" or "integer". Flag columns can also be "logical". Field columns can use "auto" to preserve the source type, or can be converted to "numeric", "integer", "logical", or "character".

Value

cohort table with added column containing prior observation of the individuals.

Examples


library(PatientProfiles)

cdm <- mockPatientProfiles(source = "duckdb")

cdm$cohort1 |>
  addPriorObservationQuery()



PatientProfiles documentation built on Aug. 22, 2026, 1:07 a.m.