Skip to contents

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

Usage

addInObservationQuery(
  x,
  indexDate = "cohort_start_date",
  window = c(0, 0),
  completeInterval = FALSE,
  nameStyle = "in_observation",
  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.

window

Window or windows of time relative to indexDate to consider.

completeInterval

If TRUE, individuals must be observed for the full requested interval.

nameStyle

Naming pattern for the added column or columns. It should include the required formatting variables. If more than one tableName is provided, it must include {table_name}.

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 an added column assessing observation. Values are 1/TRUE in observation and 0/FALSE otherwise, according to type.

Examples

# \donttest{
library(PatientProfiles)

cdm <- mockPatientProfiles(source = "duckdb")

cdm$cohort1 |>
  addInObservationQuery()
#> # A query:  ?? x 5
#> # Database: DuckDB 1.5.4 [unknown@Linux 6.17.0-1020-azure:R 4.6.1/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    3         10 1989-06-02        2000-06-24     
#>  2                    2          4 1963-08-23        1971-10-22     
#>  3                    2          6 1915-07-08        1929-04-05     
#>  4                    2          5 1934-02-03        1941-07-02     
#>  5                    1          2 1932-02-24        1956-02-03     
#>  6                    2          8 1993-06-06        1996-01-18     
#>  7                    1          9 1965-06-29        1988-10-18     
#>  8                    2          7 1951-03-13        1958-04-04     
#>  9                    1          1 1929-12-15        1931-03-18     
#> 10                    3          3 1984-09-10        1986-06-05     
#> # ℹ 1 more variable: in_observation <dbl>

# }