Skip to contents

Add the maximum number of ingredients an individual is exposed simultaneously in a certain window.

Usage

addPolypharmacyCount(
  x,
  indexDate = "cohort_start_date",
  window = c(0, 0),
  nameStyle = "polypharmacy_count",
  name = tableName(x)
)

Arguments

x

A cdm_table object.

indexDate

Name of a 'date' column that indicates the index date.

window

Window of interest.

nameStyle

Name of the new column.

name

Name of the new table.

Value

The table x with a new column column with the number of ingredients used in the window of interest.

Examples

# \donttest{
library(OmopIndices)
library(omock)
library(dplyr)

cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
#>  Loading bundled GiBleed tables from package data.
#>  Adding drug_strength table.
#>  Creating local <cdm_reference> object.
#>  Inserting <cdm_reference> into duckdb.

cdm$condition_occurrence |>
  slice_sample(n = 10) |>
  select("person_id", "condition_start_date") |>
  addPolypharmacyCount(indexDate = "condition_start_date")
#> # Source:   table<results.test_condition_occurrence> [?? x 3]
#> # Database: DuckDB 1.5.2 [unknown@Linux 6.17.0-1010-azure:R 4.5.3//tmp/RtmpQncwPK/file19a25e229021.duckdb]
#>    person_id condition_start_date polypharmacy_count
#>        <int> <date>                            <int>
#>  1       299 2000-10-07                            0
#>  2       569 2009-01-29                            0
#>  3      1852 1975-09-28                            0
#>  4      2525 1978-11-04                            0
#>  5      3141 2010-09-15                            0
#>  6      3090 2002-07-31                            0
#>  7      3593 1977-03-13                            0
#>  8      4359 1985-02-14                            0
#>  9      4279 1987-08-16                            0
#> 10      4460 1961-03-19                            0
# }