Skip to contents

`r lifecycle::badge("experimental")` 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"
)

Arguments

x

Table with individuals in the cdm.

indexDate

Variable in x that contains the date to compute the observation flag.

window

window to consider events of.

completeInterval

If the individuals are in observation for the full window.

nameStyle

Name of the new columns to create, it must contain "window_name" if multiple windows are provided.

Value

cohort table with the added binary column assessing inObservation.

Examples

# \donttest{
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
  addInObservationQuery()
#> # Source:   SQL [10 x 5]
#> # Database: DuckDB v1.1.2 [unknown@Linux 6.5.0-1025-azure:R 4.4.2/:memory:]
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date
#>                   <int>      <int> <date>            <date>         
#>  1                    2          1 1946-05-20        1965-01-25     
#>  2                    2          2 1998-12-23        1999-08-08     
#>  3                    2          3 1926-08-03        1927-01-13     
#>  4                    3          4 1995-11-26        2001-02-07     
#>  5                    1          5 1953-07-20        1968-01-20     
#>  6                    3          6 1979-02-04        1981-11-02     
#>  7                    2          7 1957-01-27        1960-07-25     
#>  8                    2          8 1915-06-28        1937-04-22     
#>  9                    2          9 1967-10-06        1987-10-15     
#> 10                    1         10 1978-06-22        1979-08-27     
#> # ℹ 1 more variable: in_observation <int>
mockDisconnect(cdm = cdm)
# }