diff --git a/articles/a02_cohort_table_requirements.html b/articles/a02_cohort_table_requirements.html index 80dfeec..a15967f 100644 --- a/articles/a02_cohort_table_requirements.html +++ b/articles/a02_cohort_table_requirements.html @@ -129,7 +129,7 @@

Keep only the first record per pe earliest cohort entry by using requireIsFirstEntry() from CohortConstructor.

-cdm$acetaminophen <- cdm$acetaminophen %>% 
+cdm$acetaminophen <- cdm$acetaminophen |> 
   requireIsFirstEntry()
 
 summary_attrition <- summariseCohortAttrition(cdm$acetaminophen)
@@ -153,7 +153,7 @@ 

Keep only records within a date r conceptSet = acetaminophen_codes, name = "acetaminophen")

-cdm$acetaminophen <- cdm$acetaminophen %>% 
+cdm$acetaminophen <- cdm$acetaminophen |> 
   requireInDateRange(dateRange = as.Date(c("2010-01-01", "2015-01-01")))
 
 summary_attrition <- summariseCohortAttrition(cdm$acetaminophen)
@@ -170,14 +170,14 @@ 

Applying multiple cohort requirem
 cdm$acetaminophen_1 <- conceptCohort(cdm = cdm, 
                                  conceptSet = acetaminophen_codes, 
-                                 name = "acetaminophen_1") %>% 
-  requireIsFirstEntry() %>%
+                                 name = "acetaminophen_1") |> 
+  requireIsFirstEntry() |>
   requireInDateRange(dateRange = as.Date(c("2010-01-01", "2016-01-01")))
 
 cdm$acetaminophen_2 <- conceptCohort(cdm = cdm, 
                                  conceptSet = acetaminophen_codes, 
-                                 name = "acetaminophen_2") %>%
-  requireInDateRange(dateRange = as.Date(c("2010-01-01", "2016-01-01"))) %>% 
+                                 name = "acetaminophen_2") |>
+  requireInDateRange(dateRange = as.Date(c("2010-01-01", "2016-01-01"))) |> 
   requireIsFirstEntry()
 summary_attrition_1 <- summariseCohortAttrition(cdm$acetaminophen_1)
@@ -239,7 +239,7 @@ 

Kee

If we apply a minimum cohort count of 500, we end up with far fewer cohorts that all have a sufficient number of study participants.

-cdm$medications <- cdm$medications %>% 
+cdm$medications <- cdm$medications |> 
   requireMinCohortCount(minCohortCount = 500)
 
 cohortCount(cdm$medications) |> 
diff --git a/articles/a03_require_demographics.html b/articles/a03_require_demographics.html
index 58fd277..5b2fc9f 100644
--- a/articles/a03_require_demographics.html
+++ b/articles/a03_require_demographics.html
@@ -121,7 +121,7 @@ 

Restrict cohort by ageWe can choose a specific age range for individuals in our cohort using requireAge() from CohortConstructor.

-cdm$fracture <- cdm$fracture %>% 
+cdm$fracture <- cdm$fracture |> 
   requireAge(indexDate = "cohort_start_date",
              ageRange = list(c(18, 100)))
 
@@ -137,7 +137,7 @@ 

Restrict cohort by sexWe can also specify a sex criteria for individuals in our cohort using requireSex() from CohortConstructor.

-cdm$fracture <- cdm$fracture %>% 
+cdm$fracture <- cdm$fracture |> 
   requireSex(sex = "Female")
 
 summary_attrition <- summariseCohortAttrition(cdm$fracture)
@@ -152,7 +152,7 @@ 

Restrict cohort by numb for each individual using requirePriorObservation() from CohortConstructor.

-cdm$fracture <- cdm$fracture %>% 
+cdm$fracture <- cdm$fracture |> 
   requirePriorObservation(indexDate = "cohort_start_date",
                           minPriorObservation = 365)
 
@@ -172,7 +172,7 @@ 

Applying multipl
 cdm$fracture <- conceptCohort(cdm = cdm, 
                                  conceptSet = fracture_codes, 
-                                 name = "fracture") %>% 
+                                 name = "fracture") |> 
   requireDemographics(indexDate = "cohort_start_date",
                       ageRange = c(18,100),
                       sex = "Female",
diff --git a/articles/a04_require_intersections.html b/articles/a04_require_intersections.html
index 6163ef9..6e25fde 100644
--- a/articles/a04_require_intersections.html
+++ b/articles/a04_require_intersections.html
@@ -128,7 +128,7 @@ 

Restrictions on cohort presence
-cdm$warfarin_gi_bleed <- cdm$warfarin  %>%
+cdm$warfarin_gi_bleed <- cdm$warfarin  |>
   requireCohortIntersect(intersections = c(1,Inf),
                          targetCohortTable = "gi_bleed", 
                          targetCohortId = 1,
@@ -149,7 +149,7 @@ 

Restrictions on cohort presence
-cdm$warfarin_no_gi_bleed <- cdm$warfarin %>%
+cdm$warfarin_no_gi_bleed <- cdm$warfarin |>
   requireCohortIntersect(intersections = 0,
                          targetCohortTable = "gi_bleed", 
                          targetCohortId = 1,
@@ -171,7 +171,7 @@ 

Restrictions on concept presence
-cdm$warfarin_gi_bleed <- cdm$warfarin  %>%
+cdm$warfarin_gi_bleed <- cdm$warfarin  |>
   requireConceptIntersect(conceptSet = list("gi_bleed" = 192671), 
                          indexDate = "cohort_start_date", 
                          window = c(-Inf, 0), 
@@ -190,7 +190,7 @@ 

Restrictions on concept presence
-cdm$warfarin_no_gi_bleed <- cdm$warfarin  %>%
+cdm$warfarin_no_gi_bleed <- cdm$warfarin  |>
   requireConceptIntersect(intersections = 0,
                          conceptSet = list("gi_bleed" = 192671), 
                          indexDate = "cohort_start_date", 
@@ -211,7 +211,7 @@ 

Restrictions on presence in reuire that individuals in our warfarin cohort have at least one prior record in the visit occurrence table.

-cdm$warfarin_visit <- cdm$warfarin  %>%
+cdm$warfarin_visit <- cdm$warfarin  |>
   requireTableIntersect(tableName = "visit_occurrence",
                          indexDate = "cohort_start_date", 
                          window = c(-Inf, -1), 
diff --git a/articles/a06_concatanate_cohorts.html b/articles/a06_concatanate_cohorts.html
index 86ac202..51b63ff 100644
--- a/articles/a06_concatanate_cohorts.html
+++ b/articles/a06_concatanate_cohorts.html
@@ -127,20 +127,20 @@
 

Let’s compare how this function would change the records of a single individual.

-cdm$medications %>%
+cdm$medications |>
   filter(subject_id == 1)
 #> # Source:   SQL [4 x 4]
-#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1//tmp/RtmpVp64cB/file1d971854d71c.duckdb]
+#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1//tmp/RtmpVKKQD6/file1d59732448c2.duckdb]
 #>   cohort_definition_id subject_id cohort_start_date cohort_end_date
 #>                  <int>      <int> <date>            <date>         
-#> 1                    1          1 1971-01-04        1971-01-18     
-#> 2                    1          1 1982-09-11        1982-10-02     
-#> 3                    1          1 1980-03-15        1980-03-29     
+#> 1                    1          1 1980-03-15        1980-03-29     
+#> 2                    1          1 1971-01-04        1971-01-18     
+#> 3                    1          1 1982-09-11        1982-10-02     
 #> 4                    1          1 1976-10-20        1976-11-03
-cdm$medications_collapsed %>%
+cdm$medications_collapsed |>
   filter(subject_id == 1)
 #> # Source:   SQL [3 x 4]
-#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1//tmp/RtmpVp64cB/file1d971854d71c.duckdb]
+#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1//tmp/RtmpVKKQD6/file1d59732448c2.duckdb]
 #>   cohort_definition_id subject_id cohort_start_date cohort_end_date
 #>                  <int>      <int> <date>            <date>         
 #> 1                    1          1 1976-10-20        1976-11-03     
diff --git a/articles/a07_filter_cohorts.html b/articles/a07_filter_cohorts.html
index 43fad14..1a0d282 100644
--- a/articles/a07_filter_cohorts.html
+++ b/articles/a07_filter_cohorts.html
@@ -117,26 +117,26 @@
 
 cdm$medications |> sampleCohorts(cohortId = NULL, n = 100)
 #> # Source:   table<main.my_study_medications> [?? x 4]
-#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1//tmp/RtmpoFpOB8/file1ddc766f94a2.duckdb]
+#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1//tmp/RtmpsY7USp/file1da06e130a56.duckdb]
 #>    cohort_definition_id subject_id cohort_start_date cohort_end_date
 #>                   <int>      <int> <date>            <date>         
-#>  1                    1        855 1968-12-22        1968-12-29     
-#>  2                    1       3929 2004-10-09        2004-10-23     
-#>  3                    1       4491 2001-05-29        2001-06-05     
-#>  4                    1       1340 1986-09-09        1986-09-23     
-#>  5                    1       2069 1963-06-22        1963-07-06     
-#>  6                    1       3308 1977-12-18        1978-01-22     
-#>  7                    1       4312 2019-05-16        2019-05-17     
-#>  8                    1       2134 2000-08-14        2000-09-11     
-#>  9                    1       1864 1971-04-08        1971-04-22     
-#> 10                    1       3199 1989-05-08        1989-05-15     
+#>  1                    1       2859 1948-06-02        1948-06-09     
+#>  2                    1       2859 1969-08-22        1969-11-20     
+#>  3                    1       3409 2011-04-26        2011-07-25     
+#>  4                    1       3486 1969-08-05        1969-08-12     
+#>  5                    2        563 2003-01-18        2003-01-18     
+#>  6                    1       1719 1993-02-23        1993-03-30     
+#>  7                    1       2861 1982-03-30        1982-04-20     
+#>  8                    1       2034 1995-07-14        1995-07-21     
+#>  9                    1       3397 1954-01-06        1954-01-20     
+#> 10                    1       3397 1981-09-06        1981-10-11     
 #> # ℹ more rows
 
 cohortCount(cdm$medications)
 #> # A tibble: 2 × 3
 #>   cohort_definition_id number_records number_subjects
 #>                  <int>          <int>           <int>
-#> 1                    1            361             100
+#> 1                    1            389             100
 #> 2                    2            100             100

When cohortId = NULL all cohorts in the table are used. Note that this function does not reduced the number of records in each cohort, diff --git a/articles/a10_match_cohorts.html b/articles/a10_match_cohorts.html index ad94525..b2de354 100644 --- a/articles/a10_match_cohorts.html +++ b/articles/a10_match_cohorts.html @@ -145,10 +145,10 @@

Use ge using cohort_attrition() from CDMConnector package:

 # Original cohort
-CDMConnector::cohort_attrition(cdm$matched_cohort1) %>% filter(cohort_definition_id == 1)
+CDMConnector::cohort_attrition(cdm$matched_cohort1) |> filter(cohort_definition_id == 1)
 
 # Matched cohort
-CDMConnector::cohort_attrition(cdm$matched_cohort1) %>% filter(cohort_definition_id == 4)
+CDMConnector::cohort_attrition(cdm$matched_cohort1) |> filter(cohort_definition_id == 4)

Briefly, from the original cohort, we exclude first those individuals that do not have a match, and then individuals that their matching pair is not in observation during the assigned cohort_start_date. @@ -211,9 +211,9 @@

Generat name = "matched_cohort3", ratio = 2) -CDMConnector::cohort_set(cdm$matched_cohort3) %>% arrange(cohort_definition_id) +CDMConnector::cohort_set(cdm$matched_cohort3) |> arrange(cohort_definition_id) -CDMConnector::cohort_count(cdm$matched_cohort3) %>% arrange(cohort_definition_id)

+CDMConnector::cohort_count(cdm$matched_cohort3) |> arrange(cohort_definition_id)

Notice that each cohort has their own (and independent of other cohorts) matched cohort.

diff --git a/index.html b/index.html index a103f6d..01a2baf 100644 --- a/index.html +++ b/index.html @@ -112,6 +112,9 @@

Creating and manipulating cohortscon <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdm_from_con(con, cdm_schema = "main", write_schema = c(prefix = "my_study_", schema = "main")) +#> Note: method with signature 'DBIConnection#Id' chosen for function 'dbExistsTable', +#> target signature 'duckdb_connection#Id'. +#> "duckdb_connection#ANY" would also be valid cdm #> #> ── # OMOP CDM reference (duckdb) of Synthea synthetic health database ────────── @@ -131,7 +134,6 @@

Generating concept-based frac

We will first need to identify codes that could be used to represent fractures of interest. To find these we’ll use the CodelistGenerator package (note, we will just find a few codes because we are using synthetic data with a subset of the full vocabularies).

 library(CodelistGenerator)
-#> Warning: package 'CodelistGenerator' was built under R version 4.4.1
 
 hip_fx_codes <- getCandidateCodes(cdm, "hip fracture")
 #> Limiting to domains of interest
@@ -158,7 +160,7 @@ 

Generating concept-based frac #> #> - forearm_fracture (1 codes) #> - hip_fracture (1 codes)

-

Now we can quickly create a our cohorts. For this we only need to provide the codes we have defined and we will get a cohort back, where we start by setting cohort exit as the same day as event start (the date of the fracture).

+

Now we can quickly create our cohorts. For this we only need to provide the codes we have defined and we will get a cohort back, where we start by setting cohort exit as the same day as event start (the date of the fracture).

 cdm$fractures <- cdm |> 
   conceptCohort(conceptSet = fx_codes, 
@@ -170,20 +172,20 @@ 

Generating concept-based frac padCohortEnd(days = 180)

We can see that our starting cohorts, before we add any additional restrictions, have the following associated settings, counts, and attrition.

-settings(cdm$fractures) %>% glimpse()
+settings(cdm$fractures) |> glimpse()
 #> Rows: 2
 #> Columns: 4
 #> $ cohort_definition_id <int> 1, 2
 #> $ cohort_name          <chr> "forearm_fracture", "hip_fracture"
 #> $ cdm_version          <chr> "5.3", "5.3"
 #> $ vocabulary_version   <chr> "v5.0 18-JAN-19", "v5.0 18-JAN-19"
-cohort_count(cdm$fractures) %>% glimpse()
+cohort_count(cdm$fractures) |> glimpse()
 #> Rows: 2
 #> Columns: 3
 #> $ cohort_definition_id <int> 1, 2
 #> $ number_records       <int> 569, 138
 #> $ number_subjects      <int> 510, 132
-attrition(cdm$fractures) %>% glimpse()
+attrition(cdm$fractures) |> glimpse()
 #> Rows: 4
 #> Columns: 7
 #> $ cohort_definition_id <int> 1, 1, 2, 2
@@ -224,18 +226,18 @@ 

Require in date range

Once we have created our base fracture cohort, we can then start applying additional cohort requirements. For example, first we can require that individuals’ cohort start date fall within a certain date range.

-cdm$fractures <- cdm$fractures %>% 
+cdm$fractures <- cdm$fractures |> 
   requireInDateRange(dateRange = as.Date(c("2000-01-01", "2020-01-01")))

Now that we’ve applied this date restriction, we can see that our cohort attributes have been updated

-cohort_count(cdm$fractures) %>% glimpse()
+cohort_count(cdm$fractures) |> glimpse()
 #> Rows: 3
 #> Columns: 3
 #> $ cohort_definition_id <int> 1, 2, 3
 #> $ number_records       <int> 152, 62, 214
 #> $ number_subjects      <int> 143, 60, 196
-attrition(cdm$fractures) %>% 
-  filter(reason == "cohort_start_date between 2000-01-01 & 2020-01-01") %>% 
+attrition(cdm$fractures) |> 
+  filter(reason == "cohort_start_date between 2000-01-01 & 2020-01-01") |> 
   glimpse()
 #> Rows: 0
 #> Columns: 7
@@ -252,13 +254,13 @@ 

Applying demographic requirements

We can also add restrictions on patient characteristics such as age (on cohort start date by default) and sex.

-cdm$fractures <- cdm$fractures %>% 
+cdm$fractures <- cdm$fractures |> 
   requireDemographics(ageRange = list(c(40, 65)),
                       sex = "Female")

Again we can see how many individuals we’ve lost after applying these criteria.

-attrition(cdm$fractures) %>% 
-  filter(reason == "Age requirement: 40 to 65") %>% 
+attrition(cdm$fractures) |> 
+  filter(reason == "Age requirement: 40 to 65") |> 
   glimpse()
 #> Rows: 3
 #> Columns: 7
@@ -270,8 +272,8 @@ 

Applying demographic requirements#> $ excluded_records <int> 88, 40, 128 #> $ excluded_subjects <int> 81, 38, 113 -attrition(cdm$fractures) %>% - filter(reason == "Sex requirement: Female") %>% +attrition(cdm$fractures) |> + filter(reason == "Sex requirement: Female") |> glimpse() #> Rows: 3 #> Columns: 7 @@ -292,13 +294,13 @@

Require presence in another cohort conceptCohort(conceptSet = list("gibleed" = 192671L), name = "gibleed") -cdm$fractures <- cdm$fractures %>% +cdm$fractures <- cdm$fractures |> requireCohortIntersect(targetCohortTable = "gibleed", intersections = 0, window = c(-Inf, 0))

-attrition(cdm$fractures) %>% 
-  filter(reason == "Not in cohort gibleed between -Inf & 0 days relative to cohort_start_date") %>% 
+attrition(cdm$fractures) |> 
+  filter(reason == "Not in cohort gibleed between -Inf & 0 days relative to cohort_start_date") |> 
   glimpse()
 #> Rows: 3
 #> Columns: 7
diff --git a/pkgdown.yml b/pkgdown.yml
index e0fcc92..d03861b 100644
--- a/pkgdown.yml
+++ b/pkgdown.yml
@@ -14,7 +14,7 @@ articles:
   a09_combine_cohorts: a09_combine_cohorts.html
   a10_match_cohorts: a10_match_cohorts.html
   a11_benchmark: a11_benchmark.html
-last_built: 2024-10-23T13:19Z
+last_built: 2024-10-25T16:20Z
 urls:
   reference: https://ohdsi.github.io/CohortConstructor/reference
   article: https://ohdsi.github.io/CohortConstructor/articles
diff --git a/reference/entryAtFirstDate.html b/reference/entryAtFirstDate.html
index ad09e9b..c6354e3 100644
--- a/reference/entryAtFirstDate.html
+++ b/reference/entryAtFirstDate.html
@@ -164,9 +164,9 @@ 

Examples#> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> #> 1 1 3 2015-02-14 2015-02-15 -#> 2 1 4 2002-12-09 2002-12-09 +#> 2 1 2 2001-01-01 2001-01-12 #> 3 1 1 2001-08-01 2001-09-01 -#> 4 1 2 2001-01-01 2001-01-12 +#> 4 1 4 2002-12-09 2002-12-09 #> # ℹ 7 more variables: cohort_definition_name <chr>, #> # cohort_definition_description <chr>, definition_type_concept_id <int>, #> # cohort_definition_syntax <chr>, subject_concept_id <int>, diff --git a/reference/entryAtLastDate.html b/reference/entryAtLastDate.html index a965238..202c417 100644 --- a/reference/entryAtLastDate.html +++ b/reference/entryAtLastDate.html @@ -164,9 +164,9 @@

Examples#> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> #> 1 1 3 2015-02-14 2015-02-15 -#> 2 1 4 2002-12-09 2002-12-09 -#> 3 1 2 2001-01-01 2001-01-12 -#> 4 1 1 2001-08-01 2001-09-01 +#> 2 1 2 2001-01-01 2001-01-12 +#> 3 1 1 2001-08-01 2001-09-01 +#> 4 1 4 2002-12-09 2002-12-09 #> # ℹ 7 more variables: cohort_definition_name <chr>, #> # cohort_definition_description <chr>, definition_type_concept_id <int>, #> # cohort_definition_syntax <chr>, subject_concept_id <int>, diff --git a/reference/exitAtDeath.html b/reference/exitAtDeath.html index 3e27e86..f39ea9b 100644 --- a/reference/exitAtDeath.html +++ b/reference/exitAtDeath.html @@ -112,16 +112,16 @@

Examples#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 3 2 1918-06-14 1921-11-28 -#> 2 1 9 1940-05-01 1945-06-29 -#> 3 3 8 1921-10-07 1931-05-01 -#> 4 3 7 1962-05-14 1964-03-08 -#> 5 2 3 1939-07-24 1944-01-14 -#> 6 2 5 1966-05-05 1970-11-15 -#> 7 1 1 1943-11-26 1949-06-21 -#> 8 2 4 1949-03-07 1951-05-08 -#> 9 3 6 1966-09-27 1975-03-05 -#> 10 1 10 1948-08-08 1952-03-27 +#> 1 2 3 1939-07-24 1944-01-14 +#> 2 2 5 1966-05-05 1970-11-15 +#> 3 1 1 1943-11-26 1949-06-21 +#> 4 2 4 1949-03-07 1951-05-08 +#> 5 3 6 1966-09-27 1975-03-05 +#> 6 1 10 1948-08-08 1952-03-27 +#> 7 1 9 1940-05-01 1945-06-29 +#> 8 3 8 1921-10-07 1931-05-01 +#> 9 3 2 1918-06-14 1921-11-28 +#> 10 3 7 1962-05-14 1964-03-08 # }

diff --git a/reference/exitAtFirstDate.html b/reference/exitAtFirstDate.html index e5298fd..693e6e5 100644 --- a/reference/exitAtFirstDate.html +++ b/reference/exitAtFirstDate.html @@ -163,10 +163,10 @@

Examples#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 1 2 2000-01-01 2001-01-01 -#> 2 1 4 2000-12-09 2002-12-09 -#> 3 1 1 2000-06-03 2001-08-01 -#> 4 1 3 2015-01-15 2015-01-15 +#> 1 1 3 2015-01-15 2015-01-15 +#> 2 1 2 2000-01-01 2001-01-01 +#> 3 1 4 2000-12-09 2002-12-09 +#> 4 1 1 2000-06-03 2001-08-01 #> # ℹ 7 more variables: cohort_definition_name <chr>, #> # cohort_definition_description <chr>, definition_type_concept_id <int>, #> # cohort_definition_syntax <chr>, subject_concept_id <int>, diff --git a/reference/exitAtLastDate.html b/reference/exitAtLastDate.html index 955e06d..a9c0f9f 100644 --- a/reference/exitAtLastDate.html +++ b/reference/exitAtLastDate.html @@ -163,10 +163,10 @@

Examples#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 1 3 2015-01-15 2015-04-15 -#> 2 1 4 2000-12-09 2002-12-09 -#> 3 1 1 2000-06-03 2001-08-01 -#> 4 1 2 2000-01-01 2001-01-01 +#> 1 1 2 2000-01-01 2001-01-01 +#> 2 1 3 2015-01-15 2015-04-15 +#> 3 1 4 2000-12-09 2002-12-09 +#> 4 1 1 2000-06-03 2001-08-01 #> # ℹ 7 more variables: cohort_definition_name <chr>, #> # cohort_definition_description <chr>, definition_type_concept_id <int>, #> # cohort_definition_syntax <chr>, subject_concept_id <int>, diff --git a/reference/exitAtObservationEnd.html b/reference/exitAtObservationEnd.html index d819e6c..c0aaab4 100644 --- a/reference/exitAtObservationEnd.html +++ b/reference/exitAtObservationEnd.html @@ -119,12 +119,12 @@

Examples#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 1 9 2012-01-18 2012-06-30 -#> 2 1 2 1964-09-18 1968-04-03 -#> 3 1 4 1998-06-22 2013-05-12 -#> 4 1 5 2007-10-19 2014-09-25 -#> 5 1 3 1976-11-28 2000-04-25 -#> 6 1 6 2003-10-31 2005-11-04 +#> 1 1 5 2007-10-19 2014-09-25 +#> 2 1 3 1976-11-28 2000-04-25 +#> 3 1 6 2003-10-31 2005-11-04 +#> 4 1 9 2012-01-18 2012-06-30 +#> 5 1 2 1964-09-18 1968-04-03 +#> 6 1 4 1998-06-22 2013-05-12 # }

diff --git a/reference/matchCohorts.html b/reference/matchCohorts.html index a549a91..8474198 100644 --- a/reference/matchCohorts.html +++ b/reference/matchCohorts.html @@ -154,16 +154,16 @@

Examples#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date cluster_id #> <int> <int> <date> <date> <dbl> -#> 1 1 89 2002-04-17 2005-07-29 54 -#> 2 1 150 2008-01-10 2008-11-21 113 -#> 3 1 148 2006-09-04 2011-12-31 37 -#> 4 1 67 2009-01-30 2010-03-12 78 -#> 5 1 46 2014-12-28 2015-06-28 79 -#> 6 1 47 1993-01-02 1994-03-22 89 -#> 7 1 103 1979-10-16 1982-05-26 21 -#> 8 1 9 2012-01-30 2012-04-08 101 -#> 9 1 16 2007-05-18 2007-10-08 102 -#> 10 1 110 2005-10-01 2006-06-12 99 +#> 1 1 166 2017-05-16 2017-09-25 59 +#> 2 1 103 1979-10-16 1982-05-26 21 +#> 3 1 110 2005-10-01 2006-06-12 99 +#> 4 1 19 2015-04-24 2015-09-01 108 +#> 5 1 33 1993-05-10 1997-04-01 14 +#> 6 1 39 2004-08-08 2006-11-19 44 +#> 7 1 16 2007-05-18 2007-10-08 102 +#> 8 1 80 2000-12-22 2002-04-17 18 +#> 9 1 91 1995-05-16 2002-02-02 42 +#> 10 1 67 2009-01-30 2010-03-12 78 #> # ℹ more rows # }

diff --git a/reference/padCohortEnd.html b/reference/padCohortEnd.html index dc497e6..00a1971 100644 --- a/reference/padCohortEnd.html +++ b/reference/padCohortEnd.html @@ -128,12 +128,12 @@

Examples#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 1 6 2003-10-31 2004-04-20 -#> 2 1 9 2012-01-18 2012-03-18 -#> 3 1 4 1998-06-22 2001-02-22 -#> 4 1 2 1964-09-18 1965-09-09 -#> 5 1 5 2007-10-19 2011-09-22 -#> 6 1 3 1976-11-28 1987-03-08 +#> 1 1 9 2012-01-18 2012-03-18 +#> 2 1 4 1998-06-22 2001-02-22 +#> 3 1 2 1964-09-18 1965-09-09 +#> 4 1 5 2007-10-19 2011-09-22 +#> 5 1 3 1976-11-28 1987-03-08 +#> 6 1 6 2003-10-31 2004-04-20 # }

diff --git a/reference/requireCohortIntersect.html b/reference/requireCohortIntersect.html index eb6914c..8799839 100644 --- a/reference/requireCohortIntersect.html +++ b/reference/requireCohortIntersect.html @@ -158,16 +158,16 @@

Examples#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 1 5 2007-10-19 2008-11-10 -#> 2 1 3 1977-03-12 1978-04-03 -#> 3 1 3 1978-04-04 1987-02-26 -#> 4 1 4 1998-06-22 2001-02-12 -#> 5 1 2 1964-09-18 1965-08-30 -#> 6 1 6 2003-11-15 2004-04-10 -#> 7 1 3 1976-11-28 1977-03-11 -#> 8 1 5 2008-11-11 2011-09-12 -#> 9 1 9 2012-01-18 2012-03-08 -#> 10 1 6 2003-10-31 2003-11-14 +#> 1 1 2 1964-09-18 1965-08-30 +#> 2 1 3 1978-04-04 1987-02-26 +#> 3 1 5 2007-10-19 2008-11-10 +#> 4 1 3 1977-03-12 1978-04-03 +#> 5 1 4 1998-06-22 2001-02-12 +#> 6 1 5 2008-11-11 2011-09-12 +#> 7 1 9 2012-01-18 2012-03-08 +#> 8 1 6 2003-10-31 2003-11-14 +#> 9 1 6 2003-11-15 2004-04-10 +#> 10 1 3 1976-11-28 1977-03-11 #> # ℹ 1 more variable: intersect_cohort <dbl> # }

diff --git a/reference/sampleCohorts.html b/reference/sampleCohorts.html index d6d1e00..aa099b4 100644 --- a/reference/sampleCohorts.html +++ b/reference/sampleCohorts.html @@ -104,16 +104,16 @@

Examples#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 1 15 2018-03-20 2018-04-01 -#> 2 1 21 1981-04-20 1986-09-10 +#> 1 1 12 2000-11-15 2013-03-04 +#> 2 1 15 2018-03-20 2018-04-01 #> 3 1 23 2000-10-08 2001-06-04 #> 4 1 23 2001-06-05 2003-08-26 -#> 5 1 38 1978-07-24 1979-07-04 -#> 6 1 38 1979-07-05 1982-01-31 -#> 7 1 51 1979-04-13 1982-12-04 -#> 8 1 51 1982-12-05 2003-05-24 -#> 9 1 52 1991-10-19 1992-12-11 -#> 10 1 62 2007-12-22 2008-12-08 +#> 5 1 26 1984-05-16 1993-10-28 +#> 6 1 31 2012-09-03 2013-02-18 +#> 7 1 31 2013-02-19 2013-03-28 +#> 8 1 31 2013-03-29 2014-04-29 +#> 9 1 32 1982-10-28 1984-05-05 +#> 10 1 32 1984-05-06 1989-01-03 #> # ℹ more rows # }

diff --git a/reference/stratifyCohorts.html b/reference/stratifyCohorts.html index 7582271..62a2a56 100644 --- a/reference/stratifyCohorts.html +++ b/reference/stratifyCohorts.html @@ -122,15 +122,15 @@

Examples#> cohort_definition_id subject_id cohort_start_date cohort_end_date age #> <int> <int> <date> <date> <int> #> 1 1 2 1964-09-18 1965-08-30 9 -#> 2 1 3 1978-04-04 1987-02-26 19 +#> 2 1 3 1976-11-28 1977-03-11 17 #> 3 1 4 1998-06-22 2001-02-12 16 -#> 4 1 5 2007-10-19 2008-11-10 44 +#> 4 1 5 2008-11-11 2011-09-12 45 #> 5 2 6 2003-11-15 2004-04-10 35 #> 6 1 9 2012-01-18 2012-03-08 27 -#> 7 1 3 1977-03-12 1978-04-03 17 -#> 8 1 5 2008-11-11 2011-09-12 45 +#> 7 1 3 1978-04-04 1987-02-26 19 +#> 8 1 5 2007-10-19 2008-11-10 44 #> 9 2 6 2003-10-31 2003-11-14 35 -#> 10 1 3 1976-11-28 1977-03-11 17 +#> 10 1 3 1977-03-12 1978-04-03 17 #> # ℹ more rows settings(cdm$my_cohort) diff --git a/reference/trimDemographics.html b/reference/trimDemographics.html index faf1d64..787857a 100644 --- a/reference/trimDemographics.html +++ b/reference/trimDemographics.html @@ -132,16 +132,16 @@

Examples#> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 1 38 1979-07-05 1981-02-09 -#> 2 1 43 1990-02-26 1995-03-03 -#> 3 1 51 1982-12-05 1997-10-16 -#> 4 1 53 1998-02-23 1998-12-09 -#> 5 1 74 2007-11-14 2008-11-21 -#> 6 1 78 2001-08-27 2005-04-11 -#> 7 1 38 1978-07-24 1979-07-04 -#> 8 1 51 1979-04-13 1982-12-04 -#> 9 1 53 1997-03-26 1998-02-22 -#> 10 1 74 2007-06-26 2007-11-13 +#> 1 1 4 1998-12-14 2002-02-14 +#> 2 1 9 2011-12-30 2012-04-02 +#> 3 1 21 1985-08-16 1986-09-10 +#> 4 1 26 1984-05-16 1989-03-22 +#> 5 1 35 2007-05-13 2010-07-22 +#> 6 1 39 2000-03-07 2009-03-17 +#> 7 1 41 2000-11-22 2000-12-09 +#> 8 1 69 2003-01-14 2003-05-28 +#> 9 1 71 2009-02-01 2009-09-05 +#> 10 1 83 2007-05-29 2008-05-01 #> # ℹ more rows # }

diff --git a/search.json b/search.json index 9788948..15592a2 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"Apache License","title":"Apache License","text":"Version 2.0, January 2004 ","code":""},{"path":[]},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_1-definitions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"1. Definitions","title":"Apache License","text":"“License” shall mean terms conditions use, reproduction, distribution defined Sections 1 9 document. “Licensor” shall mean copyright owner entity authorized copyright owner granting License. “Legal Entity” shall mean union acting entity entities control, controlled , common control entity. purposes definition, “control” means () power, direct indirect, cause direction management entity, whether contract otherwise, (ii) ownership fifty percent (50%) outstanding shares, (iii) beneficial ownership entity. “” (“”) shall mean individual Legal Entity exercising permissions granted License. “Source” form shall mean preferred form making modifications, including limited software source code, documentation source, configuration files. “Object” form shall mean form resulting mechanical transformation translation Source form, including limited compiled object code, generated documentation, conversions media types. “Work” shall mean work authorship, whether Source Object form, made available License, indicated copyright notice included attached work (example provided Appendix ). “Derivative Works” shall mean work, whether Source Object form, based (derived ) Work editorial revisions, annotations, elaborations, modifications represent, whole, original work authorship. purposes License, Derivative Works shall include works remain separable , merely link (bind name) interfaces , Work Derivative Works thereof. “Contribution” shall mean work authorship, including original version Work modifications additions Work Derivative Works thereof, intentionally submitted Licensor inclusion Work copyright owner individual Legal Entity authorized submit behalf copyright owner. purposes definition, “submitted” means form electronic, verbal, written communication sent Licensor representatives, including limited communication electronic mailing lists, source code control systems, issue tracking systems managed , behalf , Licensor purpose discussing improving Work, excluding communication conspicuously marked otherwise designated writing copyright owner “Contribution.” “Contributor” shall mean Licensor individual Legal Entity behalf Contribution received Licensor subsequently incorporated within Work.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_2-grant-of-copyright-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"2. Grant of Copyright License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable copyright license reproduce, prepare Derivative Works , publicly display, publicly perform, sublicense, distribute Work Derivative Works Source Object form.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_3-grant-of-patent-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"3. Grant of Patent License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable (except stated section) patent license make, made, use, offer sell, sell, import, otherwise transfer Work, license applies patent claims licensable Contributor necessarily infringed Contribution(s) alone combination Contribution(s) Work Contribution(s) submitted. institute patent litigation entity (including cross-claim counterclaim lawsuit) alleging Work Contribution incorporated within Work constitutes direct contributory patent infringement, patent licenses granted License Work shall terminate date litigation filed.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_4-redistribution","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"4. Redistribution","title":"Apache License","text":"may reproduce distribute copies Work Derivative Works thereof medium, without modifications, Source Object form, provided meet following conditions: () must give recipients Work Derivative Works copy License; (b) must cause modified files carry prominent notices stating changed files; (c) must retain, Source form Derivative Works distribute, copyright, patent, trademark, attribution notices Source form Work, excluding notices pertain part Derivative Works; (d) Work includes “NOTICE” text file part distribution, Derivative Works distribute must include readable copy attribution notices contained within NOTICE file, excluding notices pertain part Derivative Works, least one following places: within NOTICE text file distributed part Derivative Works; within Source form documentation, provided along Derivative Works; , within display generated Derivative Works, wherever third-party notices normally appear. contents NOTICE file informational purposes modify License. may add attribution notices within Derivative Works distribute, alongside addendum NOTICE text Work, provided additional attribution notices construed modifying License. may add copyright statement modifications may provide additional different license terms conditions use, reproduction, distribution modifications, Derivative Works whole, provided use, reproduction, distribution Work otherwise complies conditions stated License.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_5-submission-of-contributions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"5. Submission of Contributions","title":"Apache License","text":"Unless explicitly state otherwise, Contribution intentionally submitted inclusion Work Licensor shall terms conditions License, without additional terms conditions. Notwithstanding , nothing herein shall supersede modify terms separate license agreement may executed Licensor regarding Contributions.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_6-trademarks","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"6. Trademarks","title":"Apache License","text":"License grant permission use trade names, trademarks, service marks, product names Licensor, except required reasonable customary use describing origin Work reproducing content NOTICE file.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_7-disclaimer-of-warranty","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"7. Disclaimer of Warranty","title":"Apache License","text":"Unless required applicable law agreed writing, Licensor provides Work (Contributor provides Contributions) “” BASIS, WITHOUT WARRANTIES CONDITIONS KIND, either express implied, including, without limitation, warranties conditions TITLE, NON-INFRINGEMENT, MERCHANTABILITY, FITNESS PARTICULAR PURPOSE. solely responsible determining appropriateness using redistributing Work assume risks associated exercise permissions License.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_8-limitation-of-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"8. Limitation of Liability","title":"Apache License","text":"event legal theory, whether tort (including negligence), contract, otherwise, unless required applicable law (deliberate grossly negligent acts) agreed writing, shall Contributor liable damages, including direct, indirect, special, incidental, consequential damages character arising result License use inability use Work (including limited damages loss goodwill, work stoppage, computer failure malfunction, commercial damages losses), even Contributor advised possibility damages.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_9-accepting-warranty-or-additional-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"9. Accepting Warranty or Additional Liability","title":"Apache License","text":"redistributing Work Derivative Works thereof, may choose offer, charge fee , acceptance support, warranty, indemnity, liability obligations /rights consistent License. However, accepting obligations, may act behalf sole responsibility, behalf Contributor, agree indemnify, defend, hold Contributor harmless liability incurred , claims asserted , Contributor reason accepting warranty additional liability. END TERMS CONDITIONS","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"appendix-how-to-apply-the-apache-license-to-your-work","dir":"","previous_headings":"","what":"APPENDIX: How to apply the Apache License to your work","title":"Apache License","text":"apply Apache License work, attach following boilerplate notice, fields enclosed brackets [] replaced identifying information. (Don’t include brackets!) text enclosed appropriate comment syntax file format. also recommend file class name description purpose included “printed page” copyright notice easier identification within third-party archives.","code":"Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a00_introduction.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Introduction","text":"CohortConstructor package designed support cohort building pipelines. using package general workflow first build set base cohorts subsequently apply inclusion criteria derive final study cohorts interest. Base cohorts built domain (rather cohort definition) one base cohort many study cohorts can derived.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a00_introduction.html","id":"building-a-cohort-set-by-domain","dir":"Articles","previous_headings":"","what":"Building a cohort set by domain","title":"Introduction","text":"Let´s say want build 5 cohorts 3 (asthma, copd, diabetes) defined based concepts seen condition occurrence table 2 (acetaminophen warfarin) based concepts recorded drug exposure table. can build cohorts independently, one . However, approach mean repeating 3 joins condition occurrence tables 2 joins drug exposure table (concepts concept sets). make less computationally expensive, instead create cohorts domain. case instead make one join condition occurrence table one drug exposure (using concept sets together).","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a00_introduction.html","id":"deriving-study-cohorts-from-base-cohorts","dir":"Articles","previous_headings":"","what":"Deriving study cohorts from base cohorts","title":"Introduction","text":"making study cohorts often concept sets define clinical event along various study-specific inclusion criteria, example criteria around amount prior observation age. Often may sensitivity analysis concept set remains inclusion criteria change. situations can make cohorts one--one. However, can lead duplication can see example identify asthma records multiple times. alternative approach build base cohort, case based asthma records, derive multiple cohorts different inclusion criteria applied.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a00_introduction.html","id":"considerations-when-building-cohorts","dir":"Articles","previous_headings":"","what":"Considerations when building cohorts","title":"Introduction","text":"CohortConstructor provides means building cohorts via pipeline, cohorts created application sequence functions. important note order sequence often important implications. example just one individual three recorded diagnoses asthma. One diagnosis 2008 two 2009, last coming individual´s 18th birthday. three cohort pipelines shown restrictions around calendar dates, age, record first. cohort pipeline , however, individual included final cohort, third diagnosis used cohort start. pipeline B C individual excluded.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a01_building_base_cohorts.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Building base cohorts","text":"Let’s first create cdm reference Eunomia synthetic data.","code":"library(CDMConnector) library(CodelistGenerator) library(PatientProfiles) library(CohortConstructor) library(dplyr) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdm_from_con(con, cdm_schema = \"main\", write_schema = c(prefix = \"my_study_\", schema = \"main\"))"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a01_building_base_cohorts.html","id":"concept-based-cohort-creation","dir":"Articles","previous_headings":"","what":"Concept based cohort creation","title":"Building base cohorts","text":"way defining base cohorts identify clinical records codes pre-specified list. example ’ll first find codes diclofenac acetaminophen. Now codes interest, ’ll make cohorts cohort exit defined event start date (drug exposure end date).","code":"drug_codes <- getDrugIngredientCodes(cdm, name = c(\"acetaminophen\", \"amoxicillin\", \"diclofenac\", \"simvastatin\", \"warfarin\")) drug_codes #> #> - 11289_warfarin (2 codes) #> - 161_acetaminophen (7 codes) #> - 3355_diclofenac (1 codes) #> - 36567_simvastatin (2 codes) #> - 723_amoxicillin (4 codes) cdm$drugs <- conceptCohort(cdm, conceptSet = drug_codes, exit = \"event_end_date\", name = \"drugs\") settings(cdm$drugs) #> # A tibble: 5 × 4 #> cohort_definition_id cohort_name cdm_version vocabulary_version #> #> 1 1 11289_warfarin 5.3 v5.0 18-JAN-19 #> 2 2 161_acetaminophen 5.3 v5.0 18-JAN-19 #> 3 3 3355_diclofenac 5.3 v5.0 18-JAN-19 #> 4 4 36567_simvastatin 5.3 v5.0 18-JAN-19 #> 5 5 723_amoxicillin 5.3 v5.0 18-JAN-19 cohortCount(cdm$drugs) #> # A tibble: 5 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 137 137 #> 2 2 13908 2679 #> 3 3 830 830 #> 4 4 182 182 #> 5 5 4307 2130 attrition(cdm$drugs) #> # A tibble: 20 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 137 137 1 Initial qualif… #> 2 1 137 137 2 Record start <… #> 3 1 137 137 3 Record in obse… #> 4 1 137 137 4 Collapse overl… #> 5 2 14205 2679 1 Initial qualif… #> 6 2 14205 2679 2 Record start <… #> 7 2 14205 2679 3 Record in obse… #> 8 2 13908 2679 4 Collapse overl… #> 9 3 850 850 1 Initial qualif… #> 10 3 850 850 2 Record start <… #> 11 3 830 830 3 Record in obse… #> 12 3 830 830 4 Collapse overl… #> 13 4 182 182 1 Initial qualif… #> 14 4 182 182 2 Record start <… #> 15 4 182 182 3 Record in obse… #> 16 4 182 182 4 Collapse overl… #> 17 5 4309 2130 1 Initial qualif… #> 18 5 4309 2130 2 Record start <… #> 19 5 4309 2130 3 Record in obse… #> 20 5 4307 2130 4 Collapse overl… #> # ℹ 2 more variables: excluded_records , excluded_subjects "},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a01_building_base_cohorts.html","id":"demographic-based-cohort-creation","dir":"Articles","previous_headings":"","what":"Demographic based cohort creation","title":"Building base cohorts","text":"One base cohort can create based around patient demographics. example create cohort people enter 18th birthday leave day 66th birthday.","code":"cdm$working_age_cohort <- demographicsCohort(cdm = cdm, ageRange = c(18, 65), name = \"working_age_cohort\")"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_cohort_table_requirements.html","id":"keep-only-the-first-record-per-person","dir":"Articles","previous_headings":"","what":"Keep only the first record per person","title":"Applying cohort table requirements","text":"can see starting cohort individuals multiple entries use acetaminophen. However, keep earliest cohort entry using requireIsFirstEntry() CohortConstructor. number individuals remains unchanged, records individual’s first excluded. wanted keep latest record per person instead earliest use requireIsLastEntry() instead. want keep range records per person can use requireIsEntry() function.","code":"cdm$acetaminophen <- cdm$acetaminophen %>% requireIsFirstEntry() summary_attrition <- summariseCohortAttrition(cdm$acetaminophen) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_cohort_table_requirements.html","id":"keep-only-records-within-a-date-range","dir":"Articles","previous_headings":"","what":"Keep only records within a date range","title":"Applying cohort table requirements","text":"Individuals may contribute multiple records extended periods. can filter records fall outside specified date range using requireInDateRange function.","code":"cdm$acetaminophen <- conceptCohort(cdm = cdm, conceptSet = acetaminophen_codes, name = \"acetaminophen\") cdm$acetaminophen <- cdm$acetaminophen %>% requireInDateRange(dateRange = as.Date(c(\"2010-01-01\", \"2015-01-01\"))) summary_attrition <- summariseCohortAttrition(cdm$acetaminophen) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_cohort_table_requirements.html","id":"applying-multiple-cohort-requirements","dir":"Articles","previous_headings":"","what":"Applying multiple cohort requirements","title":"Applying cohort table requirements","text":"Multiple restrictions can applied cohort, however important note order requirements applied often matter. see attrition apply entry requirement date requirement. case cohort people first ever record acetaminophen occurs study period. see attrition apply date requirement entry requirement. case cohort people first record acetaminophen study period, although necessarily first record ever.","code":"cdm$acetaminophen_1 <- conceptCohort(cdm = cdm, conceptSet = acetaminophen_codes, name = \"acetaminophen_1\") %>% requireIsFirstEntry() %>% requireInDateRange(dateRange = as.Date(c(\"2010-01-01\", \"2016-01-01\"))) cdm$acetaminophen_2 <- conceptCohort(cdm = cdm, conceptSet = acetaminophen_codes, name = \"acetaminophen_2\") %>% requireInDateRange(dateRange = as.Date(c(\"2010-01-01\", \"2016-01-01\"))) %>% requireIsFirstEntry() summary_attrition_1 <- summariseCohortAttrition(cdm$acetaminophen_1) summary_attrition_2 <- summariseCohortAttrition(cdm$acetaminophen_2) plotCohortAttrition(summary_attrition_1) plotCohortAttrition(summary_attrition_2)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_cohort_table_requirements.html","id":"keep-only-records-from-cohorts-with-a-minimum-number-of-individuals","dir":"Articles","previous_headings":"","what":"Keep only records from cohorts with a minimum number of individuals","title":"Applying cohort table requirements","text":"Another useful functionality, particularly working multiple cohorts performing network study, provided requireMinCohortCount. keep cohorts minimum count, filtering records cohorts fewer number. example let’s create cohort every drug ingredient see Eunomia. can first get drug ingredient codes. can see make cohorts many small number individuals. apply minimum cohort count 500, end far fewer cohorts sufficient number study participants.","code":"medication_codes <- getDrugIngredientCodes(cdm = cdm, nameStyle = \"{concept_name}\") medication_codes #> #> - acetaminophen (7 codes) #> - albuterol (2 codes) #> - alendronate (2 codes) #> - alfentanil (1 codes) #> - alteplase (2 codes) #> - amiodarone (2 codes) #> along with 85 more codelists cdm$medications <- conceptCohort(cdm = cdm, conceptSet = medication_codes, name = \"medications\") cohortCount(cdm$medications) |> filter(number_subjects > 0) |> ggplot() + geom_histogram(aes(number_subjects), colour = \"black\", binwidth = 25) + xlab(\"Number of subjects\") + theme_bw() cdm$medications <- cdm$medications %>% requireMinCohortCount(minCohortCount = 500) cohortCount(cdm$medications) |> filter(number_subjects > 0) |> ggplot() + geom_histogram(aes(number_subjects), colour = \"black\", binwidth = 25) + xlim(0, NA) + xlab(\"Number of subjects\") + theme_bw()"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_require_demographics.html","id":"restrict-cohort-by-age","dir":"Articles","previous_headings":"","what":"Restrict cohort by age","title":"Applying demographic requirements to a cohort","text":"can choose specific age range individuals cohort using requireAge() CohortConstructor. Note default individuals filtered based age entered cohort.","code":"cdm$fracture <- cdm$fracture %>% requireAge(indexDate = \"cohort_start_date\", ageRange = list(c(18, 100))) summary_attrition <- summariseCohortAttrition(cdm$fracture) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_require_demographics.html","id":"restrict-cohort-by-sex","dir":"Articles","previous_headings":"","what":"Restrict cohort by sex","title":"Applying demographic requirements to a cohort","text":"can also specify sex criteria individuals cohort using requireSex() CohortConstructor.","code":"cdm$fracture <- cdm$fracture %>% requireSex(sex = \"Female\") summary_attrition <- summariseCohortAttrition(cdm$fracture) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_require_demographics.html","id":"restrict-cohort-by-number-of-prior-observations","dir":"Articles","previous_headings":"","what":"Restrict cohort by number of prior observations","title":"Applying demographic requirements to a cohort","text":"can also specify minimum number days prior observations individual using requirePriorObservation() CohortConstructor. well specifying minimum amount prior observation, can require mimimum amount follow-using requireFutureObservation() similar way.","code":"cdm$fracture <- cdm$fracture %>% requirePriorObservation(indexDate = \"cohort_start_date\", minPriorObservation = 365) summary_attrition <- summariseCohortAttrition(cdm$fracture) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_require_demographics.html","id":"applying-multiple-demographic-requirements-to-a-cohort","dir":"Articles","previous_headings":"","what":"Applying multiple demographic requirements to a cohort","title":"Applying demographic requirements to a cohort","text":"can implement multiple demographic requirements time using general requireDemographics() function.","code":"cdm$fracture <- conceptCohort(cdm = cdm, conceptSet = fracture_codes, name = \"fracture\") %>% requireDemographics(indexDate = \"cohort_start_date\", ageRange = c(18,100), sex = \"Female\", minPriorObservation = 365, minFutureObservation = 30) summary_attrition <- summariseCohortAttrition(cdm$fracture) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a04_require_intersections.html","id":"restrictions-on-cohort-presence","dir":"Articles","previous_headings":"","what":"Restrictions on cohort presence","title":"Applying requirements related to other cohorts, concept sets, or tables","text":"require individuals medication cohorts seen (seen) another cohort. can use requireCohortIntersect() function. , example, require individuals one intersections GI bleed cohort. flow chart illustrates changes cohort users acetaminophen restricted include individuals least one record GI bleed cohort start date acetaminophen. Instead requiring individuals record GI bleed cohort, instead require don’t. case can use requireCohortIntersect() function, time set intersections argument 0 require individuals’ absence cohort.","code":"cdm$warfarin_gi_bleed <- cdm$warfarin %>% requireCohortIntersect(intersections = c(1,Inf), targetCohortTable = \"gi_bleed\", targetCohortId = 1, indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"warfarin_gi_bleed\") summary_attrition <- summariseCohortAttrition(cdm$warfarin_gi_bleed) plotCohortAttrition(summary_attrition) cdm$warfarin_no_gi_bleed <- cdm$warfarin %>% requireCohortIntersect(intersections = 0, targetCohortTable = \"gi_bleed\", targetCohortId = 1, indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"warfarin_no_gi_bleed\") summary_attrition <- summariseCohortAttrition(cdm$warfarin_no_gi_bleed) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a04_require_intersections.html","id":"restrictions-on-concept-presence","dir":"Articles","previous_headings":"","what":"Restrictions on concept presence","title":"Applying requirements related to other cohorts, concept sets, or tables","text":"require individuals medication cohorts seen (seen) events related concept list. can use requireConceptIntersect() function, allowing us filter cohort based whether events GI bleeding entered cohort. flow chart illustrates changes cohort 1 restricted include individuals events GI bleeding least cohort start date. 2,296 individuals 8,765 records excluded. Instead requiring individuals events GI bleeding, instead require don’t events . case can use requireConceptIntersect() function, time set intersections argument 0 require individuals without past events GI bleeding.","code":"cdm$warfarin_gi_bleed <- cdm$warfarin %>% requireConceptIntersect(conceptSet = list(\"gi_bleed\" = 192671), indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"warfarin_gi_bleed\") summary_attrition <- summariseCohortAttrition(cdm$warfarin_gi_bleed) plotCohortAttrition(summary_attrition) cdm$warfarin_no_gi_bleed <- cdm$warfarin %>% requireConceptIntersect(intersections = 0, conceptSet = list(\"gi_bleed\" = 192671), indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"warfarin_no_gi_bleed\") summary_attrition <- summariseCohortAttrition(cdm$warfarin_no_gi_bleed) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a04_require_intersections.html","id":"restrictions-on-presence-in-clinical-tables","dir":"Articles","previous_headings":"","what":"Restrictions on presence in clinical tables","title":"Applying requirements related to other cohorts, concept sets, or tables","text":"can also impose requirements around individuals presence (absence) clinical tables OMOP CDM using requireTableIntersect() function. example reuire individuals warfarin cohort least one prior record visit occurrence table.","code":"cdm$warfarin_visit <- cdm$warfarin %>% requireTableIntersect(tableName = \"visit_occurrence\", indexDate = \"cohort_start_date\", window = c(-Inf, -1), name = \"warfarin_visit\") summary_attrition <- summariseCohortAttrition(cdm$warfarin_visit) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Generating a matched cohort","text":"CohortConstructor packages includes function obtain age sex matched cohort, generateMatchedCohortSet() function. vignette, explore usage function.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"create-mock-data","dir":"Articles","previous_headings":"Introduction","what":"Create mock data","title":"Generating a matched cohort","text":"first use mockDrugUtilisation() function DrugUtilisation package create mock data. use cohort1 explore generateMatchedCohortSet(), let us first use cohort_attrition() CDMConnector package explore cohort:","code":"library(CohortConstructor) library(dplyr) cdm <- mockCohortConstructor(nPerson = 1000) CDMConnector::cohort_set(cdm$cohort1)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"use-generatematchedcohortset-to-create-an-age-sex-matched-cohort","dir":"Articles","previous_headings":"","what":"Use generateMatchedCohortSet() to create an age-sex matched cohort","title":"Generating a matched cohort","text":"Let us first see example function works. usage, need provide cdm object, targetCohortName, name table containing cohort interest, name new generated tibble containing cohort matched cohort. also use argument targetCohortId specify want matched cohort cohort_definition_id = 1. Notice generated tibble, two cohorts: cohort_definition_id = 1 (original cohort), cohort_definition_id = 4 (matched cohort). target_cohort_name column indicates original cohort. match_sex match_year_of_birth adopt boolean values (TRUE/FALSE) indicating matched sex age, . match_status indicate original cohort (target) matched cohort (matched). target_cohort_id indicates cohort_id original cohort. Check exclusion criteria applied generate new cohorts using cohort_attrition() CDMConnector package: Briefly, original cohort, exclude first individuals match, individuals matching pair observation assigned cohort_start_date. matched cohort, start whole database first exclude individuals original cohort. Afterwards, exclude individuals match, individuals observation assigned cohort_start_date, finally remove many individuals required fulfill ratio. Notice matching pairs randomly assigned, probable every time execute function, generated cohorts change. Use set.seed() avoid .","code":"cdm$matched_cohort1 <- matchCohorts( cohort = cdm$cohort1, cohortId = 1, name = \"matched_cohort1\") CDMConnector::cohort_set(cdm$matched_cohort1) # Original cohort CDMConnector::cohort_attrition(cdm$matched_cohort1) %>% filter(cohort_definition_id == 1) # Matched cohort CDMConnector::cohort_attrition(cdm$matched_cohort1) %>% filter(cohort_definition_id == 4)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"matchsex-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"matchSex parameter","title":"Generating a matched cohort","text":"matchSex boolean parameter (TRUE/FALSE) indicating want match sex (TRUE) want (FALSE).","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"matchyear-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"matchYear parameter","title":"Generating a matched cohort","text":"matchYear another boolean parameter (TRUE/FALSE) indicating want match age (TRUE) want (FALSE). Notice matchSex = FALSE matchYear = FALSE, obtain unmatched comparator cohort.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"ratio-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"ratio parameter","title":"Generating a matched cohort","text":"default matching ratio 1:1 (ratio = 1). Use cohort_counts() CDMConnector check matching done desired. can modify ratio parameter tailor matched cohort. ratio can adopt values 1 Inf.","code":"CDMConnector::cohort_count(cdm$matched_cohort1) cdm$matched_cohort2 <- matchCohorts( cohort = cdm$cohort1, cohortId = 1, name = \"matched_cohort2\", ratio = Inf) CDMConnector::cohort_count(cdm$matched_cohort2)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"generate-matched-cohorts-simultaneously-across-multiple-cohorts","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"Generate matched cohorts simultaneously across multiple cohorts","title":"Generating a matched cohort","text":"functionalities can implemented across multiple cohorts simultaneously. Specify targetCohortId parameter cohorts interest. set NULL, cohorts present targetCohortName matched. Notice cohort (independent cohorts) matched cohort.","code":"cdm$matched_cohort3 <- matchCohorts( cohort = cdm$cohort1, cohortId = c(1,3), name = \"matched_cohort3\", ratio = 2) CDMConnector::cohort_set(cdm$matched_cohort3) %>% arrange(cohort_definition_id) CDMConnector::cohort_count(cdm$matched_cohort3) %>% arrange(cohort_definition_id)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"CohortConstructor benchmarking results","text":"Cohorts fundamental building block studies use OMOP CDM, identifying people satisfy one inclusion criteria duration time based clinical records. Currently cohorts typically built using CIRCE allows complex cohorts represented using JSON. JSON converted SQL execution database containing data mapped OMOP CDM. CIRCE JSON can created via ATLAS GUI programmatically via Capr R package. However, although powerful tool expressing operationalising cohort definitions, SQL generated can cumbersome especially complex cohort definitions, moreover cohorts instantiated independently, leading duplicated work. CohortConstructor package offers alternative approach, emphasizing cohort building pipeline format. first creates base cohorts applies specific inclusion criteria. Unlike “definition” approach, ::cohorts built independently, CohortConstructor follows “domain” approach, minimizes redundant queries large OMOP tables. details approach can found Introduction vignette. benchmarked package using nine phenotypes OHDSI Phenotype library cover range concept domains, entry inclusion criteria, cohort exit options. replicated cohorts using CodelistGenerator CohortConstructor assess computational time agreement CIRCE CohortConstructor.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"code-and-collaboration","dir":"Articles","previous_headings":"Introduction","what":"Code and collaboration","title":"CohortConstructor benchmarking results","text":"benchmarking code available BenchmarkCohortConstructor repository GitHub. interested running code database, feel free reach us assistance, can also update vignette results! :) benchmark script executed following four databases: CPRD Gold: primary care database UK, capturing data mostly Northern Ireland, Wales, Scotland clinics. benchmark utilized 100,000-person sample dataset, managed using PostgreSQL. CPRD Aurum: Another UK primary care database, primarily covering clinics England. database managed SQL Server. Coriva: sample approximately 400,000 patients Estonia National Health Insurance database, managed PostgreSQL. OHDSI SQL Server: mock OMOP CDM dataset provided OHDSI, hosted SQL Server. table presents number records OMOP tables used benchmark script participating databases.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"cohorts","dir":"Articles","previous_headings":"","what":"Cohorts","title":"CohortConstructor benchmarking results","text":"replicated following cohorts OHDSI phenotype library: COVID-19 (ID 56), inpatient hospitalisation (23), new users beta blockers nested essential hypertension (1049), transverse myelitis (63), major non cardiac surgery (1289), asthma without COPD (27), endometriosis procedure (722), new fluoroquinolone users (1043), acquired neutropenia unspecified leukopenia (213). COVID-19 cohort used evaluate performance common cohort stratifications. compare package CIRCE, created definitions Atlas, stratified age groups sex, available benchmark GitHub repository benchmark code.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"cohort-counts-and-overlap","dir":"Articles","previous_headings":"Cohorts","what":"Cohort counts and overlap","title":"CohortConstructor benchmarking results","text":"following table displays number records subjects cohort across participating databases: also computed overlap patients CIRCE CohortConstructor cohorts, results shown plot :","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"performance","dir":"Articles","previous_headings":"","what":"Performance","title":"CohortConstructor benchmarking results","text":"evaluate CohortConstructor performance generated CIRCE cohorts using functionalities provided CodelistGenerator CohortConstructor, measured computational time taken. Two different approaches CohortConstructor tested: definition: created cohorts seprately. domain: nine targeted cohorts created together set, following domain approach described Introduction vignette. Briefly, approach involves creating base cohorts , requiring one call involved OMOP table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"by-definition","dir":"Articles","previous_headings":"Performance","what":"By definition","title":"CohortConstructor benchmarking results","text":"following plot shows times taken create cohort using CIRCE CohortConstructor cohorts created separately.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"by-domain","dir":"Articles","previous_headings":"Performance","what":"By domain","title":"CohortConstructor benchmarking results","text":"table depicts total time took create nine cohorts using domain approach CohortConstructor.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"cohort-stratification","dir":"Articles","previous_headings":"Performance","what":"Cohort stratification","title":"CohortConstructor benchmarking results","text":"Cohorts often stratified studies. Atlas cohort definitions, stratum requires new CIRCE JSON instantiated, CohortConstructor allows stratifications generated overall cohort. following table shows time taken create age sex stratifications COVID-19 cohort CIRCE CohortConstructor.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"use-of-sql-indexes","dir":"Articles","previous_headings":"Performance","what":"Use of SQL indexes","title":"CohortConstructor benchmarking results","text":"Postgres SQL databases, package uses indexes conceptCohort default. evaluate much indexes reduce computation time, instantiated subset concept sets benchmark, without indexes. Four calls made conceptCohort, involving different number OMOP tables. combinations : Drug exposure Drug exposure + condition occurrence Drug exposure + condition occurrence + procedure occurrence Drug exposure + condition occurrence + procedure occurrence + measurement plot shows computation time without SQL indexes scenario:","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Edward Burn. Author, maintainer. Marti Catala. Author. Nuria Mercade-Besora. Author. Marta Alcalde-Herraiz. Author. Mike Du. Author. Yuchen Guo. Author. Xihang Chen. Author. Kim Lopez-Guell. Author. Elin Rowlands. Author.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Burn E, Catala M, Mercade-Besora N, Alcalde-Herraiz M, Du M, Guo Y, Chen X, Lopez-Guell K, Rowlands E (2024). CohortConstructor: Build Manipulate Study Cohorts Using Common Data Model. R package version 0.3.1.900, https://github.com/OHDSI/CohortConstructor, https://ohdsi.github.io/CohortConstructor/.","code":"@Manual{, title = {CohortConstructor: Build and Manipulate Study Cohorts Using a Common Data Model}, author = {Edward Burn and Marti Catala and Nuria Mercade-Besora and Marta Alcalde-Herraiz and Mike Du and Yuchen Guo and Xihang Chen and Kim Lopez-Guell and Elin Rowlands}, year = {2024}, note = {R package version 0.3.1.900, https://github.com/OHDSI/CohortConstructor}, url = {https://ohdsi.github.io/CohortConstructor/}, }"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"cohortconstructor-","dir":"","previous_headings":"","what":"Build and Manipulate Study Cohorts Using a Common Data Model","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"goal CohortConstructor support creation manipulation study cohorts data mapped OMOP CDM.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"package can installed CRAN: can install development version package GitHub:","code":"install.packages(\"CohortConstructor\") # install.packages(\"devtools\") devtools::install_github(\"ohdsi/CohortConstructor\")"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"creating-and-manipulating-cohorts","dir":"","previous_headings":"","what":"Creating and manipulating cohorts","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"illustrate functionality provided CohortConstructor let’s create cohort people fracture using Eunomia dataset. ’ll first load required packages create cdm reference data.","code":"library(omopgenerics) library(CDMConnector) library(PatientProfiles) library(dplyr) library(CohortConstructor) library(CohortCharacteristics) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdm_from_con(con, cdm_schema = \"main\", write_schema = c(prefix = \"my_study_\", schema = \"main\")) cdm #> #> ── # OMOP CDM reference (duckdb) of Synthea synthetic health database ────────── #> • omop tables: person, observation_period, visit_occurrence, visit_detail, #> condition_occurrence, drug_exposure, procedure_occurrence, device_exposure, #> measurement, observation, death, note, note_nlp, specimen, fact_relationship, #> location, care_site, provider, payer_plan_period, cost, drug_era, dose_era, #> condition_era, metadata, cdm_source, concept, vocabulary, domain, #> concept_class, concept_relationship, relationship, concept_synonym, #> concept_ancestor, source_to_concept_map, drug_strength #> • cohort tables: - #> • achilles tables: - #> • other tables: -"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"generating-concept-based-fracture-cohorts","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Generating concept-based fracture cohorts","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"first need identify codes used represent fractures interest. find ’ll use CodelistGenerator package (note, just find codes using synthetic data subset full vocabularies). Now can quickly create cohorts. need provide codes defined get cohort back, start setting cohort exit day event start (date fracture). creating initial cohort update exit set 180 days start (long individuals’ observation end date - , exit observation period end). can see starting cohorts, add additional restrictions, following associated settings, counts, attrition.","code":"library(CodelistGenerator) #> Warning: package 'CodelistGenerator' was built under R version 4.4.1 hip_fx_codes <- getCandidateCodes(cdm, \"hip fracture\") #> Limiting to domains of interest #> Getting concepts to include #> Adding descendants #> Search completed. Finishing up. #> ✔ 1 candidate concept identified #> #> Time taken: 0 minutes and 0 seconds forearm_fx_codes <- getCandidateCodes(cdm, \"forearm fracture\") #> Limiting to domains of interest #> Getting concepts to include #> Adding descendants #> Search completed. Finishing up. #> ✔ 1 candidate concept identified #> #> Time taken: 0 minutes and 0 seconds fx_codes <- newCodelist(list(\"hip_fracture\" = hip_fx_codes$concept_id, \"forearm_fracture\"= forearm_fx_codes$concept_id)) fx_codes #> #> ── 2 codelists ───────────────────────────────────────────────────────────────── #> #> - forearm_fracture (1 codes) #> - hip_fracture (1 codes) cdm$fractures <- cdm |> conceptCohort(conceptSet = fx_codes, exit = \"event_start_date\", name = \"fractures\") cdm$fractures <- cdm$fractures |> padCohortEnd(days = 180) settings(cdm$fractures) %>% glimpse() #> Rows: 2 #> Columns: 4 #> $ cohort_definition_id 1, 2 #> $ cohort_name \"forearm_fracture\", \"hip_fracture\" #> $ cdm_version \"5.3\", \"5.3\" #> $ vocabulary_version \"v5.0 18-JAN-19\", \"v5.0 18-JAN-19\" cohort_count(cdm$fractures) %>% glimpse() #> Rows: 2 #> Columns: 3 #> $ cohort_definition_id 1, 2 #> $ number_records 569, 138 #> $ number_subjects 510, 132 attrition(cdm$fractures) %>% glimpse() #> Rows: 4 #> Columns: 7 #> $ cohort_definition_id 1, 1, 2, 2 #> $ number_records 569, 569, 138, 138 #> $ number_subjects 510, 510, 132, 132 #> $ reason_id 1, 2, 1, 2 #> $ reason \"Initial qualifying events\", \"Pad cohort start da… #> $ excluded_records 0, 0, 0, 0 #> $ excluded_subjects 0, 0, 0, 0"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"create-an-overall-fracture-cohort","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Create an overall fracture cohort","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"far created three separate fracture cohorts. Let’s say also want cohort people fractures. union three cohorts create overall cohort like :","code":"cdm$fractures <- unionCohorts(cdm$fractures, cohortName = \"any_fracture\", keepOriginalCohorts = TRUE, name =\"fractures\") settings(cdm$fractures) #> # A tibble: 3 × 5 #> cohort_definition_id cohort_name cdm_version vocabulary_version gap #> #> 1 1 forearm_fracture 5.3 v5.0 18-JAN-19 NA #> 2 2 hip_fracture 5.3 v5.0 18-JAN-19 NA #> 3 3 any_fracture 0 cohortCount(cdm$fractures) #> # A tibble: 3 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 569 510 #> 2 2 138 132 #> 3 3 707 611"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"require-in-date-range","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Require in date range","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"created base fracture cohort, can start applying additional cohort requirements. example, first can require individuals’ cohort start date fall within certain date range. Now ’ve applied date restriction, can see cohort attributes updated","code":"cdm$fractures <- cdm$fractures %>% requireInDateRange(dateRange = as.Date(c(\"2000-01-01\", \"2020-01-01\"))) cohort_count(cdm$fractures) %>% glimpse() #> Rows: 3 #> Columns: 3 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 152, 62, 214 #> $ number_subjects 143, 60, 196 attrition(cdm$fractures) %>% filter(reason == \"cohort_start_date between 2000-01-01 & 2020-01-01\") %>% glimpse() #> Rows: 0 #> Columns: 7 #> $ cohort_definition_id #> $ number_records #> $ number_subjects #> $ reason_id #> $ reason #> $ excluded_records #> $ excluded_subjects "},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"applying-demographic-requirements","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Applying demographic requirements","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"can also add restrictions patient characteristics age (cohort start date default) sex. can see many individuals ’ve lost applying criteria.","code":"cdm$fractures <- cdm$fractures %>% requireDemographics(ageRange = list(c(40, 65)), sex = \"Female\") attrition(cdm$fractures) %>% filter(reason == \"Age requirement: 40 to 65\") %>% glimpse() #> Rows: 3 #> Columns: 7 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 64, 22, 86 #> $ number_subjects 62, 22, 83 #> $ reason_id 5, 5, 4 #> $ reason \"Age requirement: 40 to 65\", \"Age requirement: 40… #> $ excluded_records 88, 40, 128 #> $ excluded_subjects 81, 38, 113 attrition(cdm$fractures) %>% filter(reason == \"Sex requirement: Female\") %>% glimpse() #> Rows: 3 #> Columns: 7 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 37, 12, 49 #> $ number_subjects 36, 12, 48 #> $ reason_id 6, 6, 5 #> $ reason \"Sex requirement: Female\", \"Sex requirement: Fema… #> $ excluded_records 27, 10, 37 #> $ excluded_subjects 26, 10, 35"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"require-presence-in-another-cohort","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Require presence in another cohort","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"can also require individuals () another cohort window. example require study participants GI bleed cohort time prior entry fractures cohort.","code":"cdm$gibleed <- cdm |> conceptCohort(conceptSet = list(\"gibleed\" = 192671L), name = \"gibleed\") cdm$fractures <- cdm$fractures %>% requireCohortIntersect(targetCohortTable = \"gibleed\", intersections = 0, window = c(-Inf, 0)) attrition(cdm$fractures) %>% filter(reason == \"Not in cohort gibleed between -Inf & 0 days relative to cohort_start_date\") %>% glimpse() #> Rows: 3 #> Columns: 7 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 30, 10, 40 #> $ number_subjects 30, 10, 40 #> $ reason_id 9, 9, 8 #> $ reason \"Not in cohort gibleed between -Inf & 0 days rela… #> $ excluded_records 7, 2, 9 #> $ excluded_subjects 6, 2, 8 cdmDisconnect(cdm)"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"more-information","dir":"","previous_headings":"Creating and manipulating cohorts","what":"More information","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"CohortConstructor provides much functionality creating manipulating cohorts. See package vignettes details.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/CohortConstructor-package.html","id":null,"dir":"Reference","previous_headings":"","what":"CohortConstructor: Build and Manipulate Study Cohorts Using a Common Data Model — CohortConstructor-package","title":"CohortConstructor: Build and Manipulate Study Cohorts Using a Common Data Model — CohortConstructor-package","text":"Create manipulate study cohorts data mapped Observational Medical Outcomes Partnership Common Data Model.","code":""},{"path":[]},{"path":"https://ohdsi.github.io/CohortConstructor/reference/CohortConstructor-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"CohortConstructor: Build and Manipulate Study Cohorts Using a Common Data Model — CohortConstructor-package","text":"Maintainer: Edward Burn edward.burn@ndorms.ox.ac.uk (ORCID) Authors: Marti Catala marti.catalasabate@ndorms.ox.ac.uk (ORCID) Nuria Mercade-Besora nuria.mercadebesora@ndorms.ox.ac.uk (ORCID) Marta Alcalde-Herraiz marta.alcaldeherraiz@ndorms.ox.ac.uk (ORCID) Mike Du mike.du@ndorms.ox.ac.uk (ORCID) Yuchen Guo yuchen.guo@ndorms.ox.ac.uk (ORCID) Xihang Chen xihang.chen@ndorms.ox.ac.uk (ORCID) Kim Lopez-Guell kim.lopez@spc.ox.ac.uk (ORCID) Elin Rowlands elin.rowlands@ndorms.ox.ac.uk (ORCID)","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/benchmarkData.html","id":null,"dir":"Reference","previous_headings":"","what":"Benchmarking results — benchmarkData","title":"Benchmarking results — benchmarkData","text":"Benchmarking results","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/benchmarkData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Benchmarking results — benchmarkData","text":"","code":"benchmarkData"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/benchmarkData.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Benchmarking results — benchmarkData","text":"list results benchmarking","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cdmDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of cdm. — cdmDoc","title":"Helper for consistent documentation of cdm. — cdmDoc","text":"Helper consistent documentation cdm.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cdmDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of cdm. — cdmDoc","text":"cdm cdm reference.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of cohort. — cohortDoc","title":"Helper for consistent documentation of cohort. — cohortDoc","text":"Helper consistent documentation cohort.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of cohort. — cohortDoc","text":"cohort cohort table cdm reference.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortIdModifyDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of cohortId. — cohortIdModifyDoc","title":"Helper for consistent documentation of cohortId. — cohortIdModifyDoc","text":"Helper consistent documentation cohortId.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortIdModifyDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of cohortId. — cohortIdModifyDoc","text":"cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortIdSubsetDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of cohortId. — cohortIdSubsetDoc","title":"Helper for consistent documentation of cohortId. — cohortIdSubsetDoc","text":"Helper consistent documentation cohortId.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortIdSubsetDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of cohortId. — cohortIdSubsetDoc","text":"cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/collapseCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse cohort entries using a certain gap to concatenate records. — collapseCohorts","title":"Collapse cohort entries using a certain gap to concatenate records. — collapseCohorts","text":"collapseCohorts() concatenates cohort records, allowing number days one finishing next starting.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/collapseCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse cohort entries using a certain gap to concatenate records. — collapseCohorts","text":"","code":"collapseCohorts(cohort, cohortId = NULL, gap = 0, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/collapseCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse cohort entries using a certain gap to concatenate records. — collapseCohorts","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. gap Number days two subsequent cohort entries merged single cohort record. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/collapseCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse cohort entries using a certain gap to concatenate records. — collapseCohorts","text":"cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/columnDateDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of dateColumns and returnReason. — columnDateDoc","title":"Helper for consistent documentation of dateColumns and returnReason. — columnDateDoc","text":"Helper consistent documentation dateColumns returnReason.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/columnDateDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of dateColumns and returnReason. — columnDateDoc","text":"dateColumns Character vector indicating date columns cohort table consider. returnReason TRUE return column indicating dateColumns used.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptCohort.html","id":null,"dir":"Reference","previous_headings":"","what":"Create cohorts based on a concept set — conceptCohort","title":"Create cohorts based on a concept set — conceptCohort","text":"conceptCohort() creates cohort table patient records clinical tables OMOP CDM. following tables currently supported creating concept cohorts: condition_occurrence device_exposure drug_exposure measurement observation procedure_occurrence visit_occurrence Cohort duration based record start end (e.g. condition_start_date condition_end_date records coming condition_occurrence tables). resulting table satisfies requirements OMOP CDM cohort table: Overlapping records collapsed single cohort entry. record starts outside observation period silently ignored. record ends outside observation period trimmed end preceding observation period end date.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptCohort.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create cohorts based on a concept set — conceptCohort","text":"","code":"conceptCohort( cdm, conceptSet, name, exit = \"event_end_date\", useSourceFields = FALSE, subsetCohort = NULL, subsetCohortId = NULL )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptCohort.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create cohorts based on a concept set — conceptCohort","text":"cdm cdm reference. conceptSet conceptSet, can either codelist conceptSetExpression. name Name new cohort table created cdm object. exit cohort end date defined. Can either \"event_end_date\" \"event_start_date\". useSourceFields TRUE, source concept_id fields also used identifying relevant clinical records. FALSE, standard concept_id fields used. subsetCohort cohort table containing individuals cohorts generated. individuals table appear generated cohort. subsetCohortId Optional. Specifies cohort IDs subsetCohort table include. none provided, cohorts subsetCohort included.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptCohort.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create cohorts based on a concept set — conceptCohort","text":"cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptCohort.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create cohorts based on a concept set — conceptCohort","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(conditionOccurrence = TRUE) #> Note: method with signature ‘DBIConnection#Id’ chosen for function ‘dbExistsTable’, #> target signature ‘duckdb_connection#Id’. #> \"duckdb_connection#ANY\" would also be valid cohort <- conceptCohort(cdm = cdm, conceptSet = list(a = 1), name = \"cohort\") #> Warning: ! `codelist` contains numeric values, they are casted to integers. #> ✖ Domain NA (1 concept) excluded because it is not supported. #> ℹ No cohort entries found, returning empty cohort table. cohort |> attrition() #> # A tibble: 1 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 0 0 1 Initial qualify… #> # ℹ 2 more variables: excluded_records , excluded_subjects # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptSetDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of conceptSet. — conceptSetDoc","title":"Helper for consistent documentation of conceptSet. — conceptSetDoc","text":"Helper consistent documentation conceptSet.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptSetDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of conceptSet. — conceptSetDoc","text":"conceptSet conceptSet, can either codelist conceptSetExpression.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/demographicsCohort.html","id":null,"dir":"Reference","previous_headings":"","what":"Create cohorts based on patient demographics — demographicsCohort","title":"Create cohorts based on patient demographics — demographicsCohort","text":"demographicsCohort() creates cohort table based patient characteristics. individual satisfies criteria enter cohort. stop satisfying criteria cohort entry ends.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/demographicsCohort.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create cohorts based on patient demographics — demographicsCohort","text":"","code":"demographicsCohort( cdm, name, ageRange = NULL, sex = NULL, minPriorObservation = NULL )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/demographicsCohort.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create cohorts based on patient demographics — demographicsCohort","text":"cdm cdm reference. name Name new cohort table created cdm object. ageRange list vectors specifying minimum maximum age. sex Can \"\", \"Male\" \"Female\". minPriorObservation minimum number continuous prior observation days database.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/demographicsCohort.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create cohorts based on patient demographics — demographicsCohort","text":"cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/demographicsCohort.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create cohorts based on patient demographics — demographicsCohort","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cohort <- cdm |> demographicsCohort(name = \"cohort3\", ageRange = c(18,40), sex = \"Male\") #> ! cohort columns will be reordered to match the expected order: #> cohort_definition_id, subject_id, cohort_start_date, and cohort_end_date. #> ℹ Building new trimmed cohort #> Adding demographics information #> Creating initial cohort #> Trim sex #> Trim age #> ✔ Cohort trimmed attrition(cohort) #> # A tibble: 3 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 10 10 1 Initial qualify… #> 2 1 2 2 2 Sex requirement… #> 3 1 2 2 3 Age requirement… #> # ℹ 2 more variables: excluded_records , excluded_subjects # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtFirstDate.html","id":null,"dir":"Reference","previous_headings":"","what":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","title":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","text":"entryAtFirstDate() resets cohort start date based set specified column dates. first date occurs chosen.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtFirstDate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","text":"","code":"entryAtFirstDate( cohort, dateColumns, cohortId = NULL, returnReason = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtFirstDate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","text":"cohort cohort table cdm reference. dateColumns Character vector indicating date columns cohort table consider. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column indicating dateColumns used. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtFirstDate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtFirstDate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(tables = list( \"cohort\" = dplyr::tibble( cohort_definition_id = 1, subject_id = c(1, 2, 3, 4), cohort_start_date = as.Date(c(\"2000-06-03\", \"2000-01-01\", \"2015-01-15\", \"2000-12-09\")), cohort_end_date = as.Date(c(\"2001-09-01\", \"2001-01-12\", \"2015-02-15\", \"2002-12-09\")), date_1 = as.Date(c(\"2001-08-01\", \"2001-01-01\", \"2015-01-15\", \"2002-12-09\")), date_2 = as.Date(c(\"2001-08-01\", NA, \"2015-02-14\", \"2002-12-09\")) ) )) #> Warning: ! 9 column in cdm_source do not match expected column type: #> • `cdm_source_abbreviation` is logical but expected character #> • `cdm_holder` is logical but expected character #> • `source_description` is logical but expected character #> • `source_documentation_reference` is logical but expected character #> • `cdm_etl_reference` is logical but expected character #> • `source_release_date` is logical but expected date #> • `cdm_release_date` is logical but expected date #> • `cdm_version` is numeric but expected character #> • `vocabulary_version` is logical but expected character #> Warning: ! 3 column in concept do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date #> Warning: ! 1 column in vocabulary do not match expected column type: #> • `vocabulary_concept_id` is numeric but expected integer #> Warning: ! 5 column in concept_relationship do not match expected column type: #> • `concept_id_1` is numeric but expected integer #> • `concept_id_2` is numeric but expected integer #> • `valid_start_date` is logical but expected date #> • `valid_end_date` is logical but expected date #> • `invalid_reason` is logical but expected character #> Warning: ! 2 column in concept_synonym do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `language_concept_id` is numeric but expected integer #> Warning: ! 4 column in concept_ancestor do not match expected column type: #> • `ancestor_concept_id` is numeric but expected integer #> • `descendant_concept_id` is numeric but expected integer #> • `min_levels_of_separation` is numeric but expected integer #> • `max_levels_of_separation` is numeric but expected integer #> Warning: ! 9 column in drug_strength do not match expected column type: #> • `drug_concept_id` is numeric but expected integer #> • `ingredient_concept_id` is numeric but expected integer #> • `amount_unit_concept_id` is numeric but expected integer #> • `numerator_unit_concept_id` is numeric but expected integer #> • `denominator_value` is logical but expected numeric #> • `denominator_unit_concept_id` is numeric but expected integer #> • `box_size` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date cdm$cohort |> entryAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 11] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 2015-02-14 2015-02-15 #> 2 1 4 2002-12-09 2002-12-09 #> 3 1 1 2001-08-01 2001-09-01 #> 4 1 2 2001-01-01 2001-01-12 #> # ℹ 7 more variables: cohort_definition_name , #> # cohort_definition_description , definition_type_concept_id , #> # cohort_definition_syntax , subject_concept_id , #> # cohort_initiation_date , entry_reason # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtLastDate.html","id":null,"dir":"Reference","previous_headings":"","what":"Set cohort start date to the last of a set of column dates — entryAtLastDate","title":"Set cohort start date to the last of a set of column dates — entryAtLastDate","text":"entryAtLastDate() resets cohort end date based set specified column dates. last date chosen.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtLastDate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set cohort start date to the last of a set of column dates — entryAtLastDate","text":"","code":"entryAtLastDate( cohort, dateColumns, cohortId = NULL, returnReason = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtLastDate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set cohort start date to the last of a set of column dates — entryAtLastDate","text":"cohort cohort table cdm reference. dateColumns Character vector indicating date columns cohort table consider. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column indicating dateColumns used. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtLastDate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set cohort start date to the last of a set of column dates — entryAtLastDate","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtLastDate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set cohort start date to the last of a set of column dates — entryAtLastDate","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(tables = list( \"cohort\" = dplyr::tibble( cohort_definition_id = 1, subject_id = c(1, 2, 3, 4), cohort_start_date = as.Date(c(\"2000-06-03\", \"2000-01-01\", \"2015-01-15\", \"2000-12-09\")), cohort_end_date = as.Date(c(\"2001-09-01\", \"2001-01-12\", \"2015-02-15\", \"2002-12-09\")), date_1 = as.Date(c(\"2001-08-01\", \"2001-01-01\", \"2015-01-15\", \"2002-12-09\")), date_2 = as.Date(c(\"2001-08-01\", NA, \"2015-02-14\", \"2002-12-09\")) ) )) #> Warning: ! 9 column in cdm_source do not match expected column type: #> • `cdm_source_abbreviation` is logical but expected character #> • `cdm_holder` is logical but expected character #> • `source_description` is logical but expected character #> • `source_documentation_reference` is logical but expected character #> • `cdm_etl_reference` is logical but expected character #> • `source_release_date` is logical but expected date #> • `cdm_release_date` is logical but expected date #> • `cdm_version` is numeric but expected character #> • `vocabulary_version` is logical but expected character #> Warning: ! 3 column in concept do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date #> Warning: ! 1 column in vocabulary do not match expected column type: #> • `vocabulary_concept_id` is numeric but expected integer #> Warning: ! 5 column in concept_relationship do not match expected column type: #> • `concept_id_1` is numeric but expected integer #> • `concept_id_2` is numeric but expected integer #> • `valid_start_date` is logical but expected date #> • `valid_end_date` is logical but expected date #> • `invalid_reason` is logical but expected character #> Warning: ! 2 column in concept_synonym do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `language_concept_id` is numeric but expected integer #> Warning: ! 4 column in concept_ancestor do not match expected column type: #> • `ancestor_concept_id` is numeric but expected integer #> • `descendant_concept_id` is numeric but expected integer #> • `min_levels_of_separation` is numeric but expected integer #> • `max_levels_of_separation` is numeric but expected integer #> Warning: ! 9 column in drug_strength do not match expected column type: #> • `drug_concept_id` is numeric but expected integer #> • `ingredient_concept_id` is numeric but expected integer #> • `amount_unit_concept_id` is numeric but expected integer #> • `numerator_unit_concept_id` is numeric but expected integer #> • `denominator_value` is logical but expected numeric #> • `denominator_unit_concept_id` is numeric but expected integer #> • `box_size` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date cdm$cohort |> entryAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 11] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 2015-02-14 2015-02-15 #> 2 1 4 2002-12-09 2002-12-09 #> 3 1 2 2001-01-01 2001-01-12 #> 4 1 1 2001-08-01 2001-09-01 #> # ℹ 7 more variables: cohort_definition_name , #> # cohort_definition_description , definition_type_concept_id , #> # cohort_definition_syntax , subject_concept_id , #> # cohort_initiation_date , entry_reason # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtDeath.html","id":null,"dir":"Reference","previous_headings":"","what":"Set cohort end date to death date — exitAtDeath","title":"Set cohort end date to death date — exitAtDeath","text":"functions changes cohort end date subject's death date. case generates overlapping records cohort, overlapping entries merged.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtDeath.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set cohort end date to death date — exitAtDeath","text":"","code":"exitAtDeath( cohort, cohortId = NULL, requireDeath = FALSE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtDeath.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set cohort end date to death date — exitAtDeath","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. requireDeath TRUE, subjects without death record dropped, FALSE end date left . name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtDeath.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set cohort end date to death date — exitAtDeath","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtDeath.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set cohort end date to death date — exitAtDeath","text":"","code":"# \\donttest{ library(PatientProfiles) library(CohortConstructor) cdm <- mockPatientProfiles() cdm$cohort1 |> exitAtDeath() #> # Source: table [10 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 3 2 1918-06-14 1921-11-28 #> 2 1 9 1940-05-01 1945-06-29 #> 3 3 8 1921-10-07 1931-05-01 #> 4 3 7 1962-05-14 1964-03-08 #> 5 2 3 1939-07-24 1944-01-14 #> 6 2 5 1966-05-05 1970-11-15 #> 7 1 1 1943-11-26 1949-06-21 #> 8 2 4 1949-03-07 1951-05-08 #> 9 3 6 1966-09-27 1975-03-05 #> 10 1 10 1948-08-08 1952-03-27 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtFirstDate.html","id":null,"dir":"Reference","previous_headings":"","what":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","title":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","text":"exitAtFirstDate() resets cohort end date based set specified column dates. first date occurs chosen.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtFirstDate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","text":"","code":"exitAtFirstDate( cohort, dateColumns, cohortId = NULL, returnReason = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtFirstDate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","text":"cohort cohort table cdm reference. dateColumns Character vector indicating date columns cohort table consider. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column indicating dateColumns used. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtFirstDate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtFirstDate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(tables = list( \"cohort\" = dplyr::tibble( cohort_definition_id = 1, subject_id = c(1, 2, 3, 4), cohort_start_date = as.Date(c(\"2000-06-03\", \"2000-01-01\", \"2015-01-15\", \"2000-12-09\")), cohort_end_date = as.Date(c(\"2001-09-01\", \"2001-01-12\", \"2015-02-15\", \"2002-12-09\")), date_1 = as.Date(c(\"2001-08-01\", \"2001-01-01\", \"2015-01-15\", \"2002-12-09\")), date_2 = as.Date(c(\"2001-08-01\", NA, \"2015-04-15\", \"2002-12-09\")) ) )) #> Warning: ! 9 column in cdm_source do not match expected column type: #> • `cdm_source_abbreviation` is logical but expected character #> • `cdm_holder` is logical but expected character #> • `source_description` is logical but expected character #> • `source_documentation_reference` is logical but expected character #> • `cdm_etl_reference` is logical but expected character #> • `source_release_date` is logical but expected date #> • `cdm_release_date` is logical but expected date #> • `cdm_version` is numeric but expected character #> • `vocabulary_version` is logical but expected character #> Warning: ! 3 column in concept do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date #> Warning: ! 1 column in vocabulary do not match expected column type: #> • `vocabulary_concept_id` is numeric but expected integer #> Warning: ! 5 column in concept_relationship do not match expected column type: #> • `concept_id_1` is numeric but expected integer #> • `concept_id_2` is numeric but expected integer #> • `valid_start_date` is logical but expected date #> • `valid_end_date` is logical but expected date #> • `invalid_reason` is logical but expected character #> Warning: ! 2 column in concept_synonym do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `language_concept_id` is numeric but expected integer #> Warning: ! 4 column in concept_ancestor do not match expected column type: #> • `ancestor_concept_id` is numeric but expected integer #> • `descendant_concept_id` is numeric but expected integer #> • `min_levels_of_separation` is numeric but expected integer #> • `max_levels_of_separation` is numeric but expected integer #> Warning: ! 9 column in drug_strength do not match expected column type: #> • `drug_concept_id` is numeric but expected integer #> • `ingredient_concept_id` is numeric but expected integer #> • `amount_unit_concept_id` is numeric but expected integer #> • `numerator_unit_concept_id` is numeric but expected integer #> • `denominator_value` is logical but expected numeric #> • `denominator_unit_concept_id` is numeric but expected integer #> • `box_size` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date cdm$cohort |> exitAtFirstDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 11] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 2000-01-01 2001-01-01 #> 2 1 4 2000-12-09 2002-12-09 #> 3 1 1 2000-06-03 2001-08-01 #> 4 1 3 2015-01-15 2015-01-15 #> # ℹ 7 more variables: cohort_definition_name , #> # cohort_definition_description , definition_type_concept_id , #> # cohort_definition_syntax , subject_concept_id , #> # cohort_initiation_date , exit_reason # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtLastDate.html","id":null,"dir":"Reference","previous_headings":"","what":"Set cohort end date to the last of a set of column dates — exitAtLastDate","title":"Set cohort end date to the last of a set of column dates — exitAtLastDate","text":"exitAtLastDate() resets cohort end date based set specified column dates. last date occurs chosen.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtLastDate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set cohort end date to the last of a set of column dates — exitAtLastDate","text":"","code":"exitAtLastDate( cohort, dateColumns, cohortId = NULL, returnReason = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtLastDate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set cohort end date to the last of a set of column dates — exitAtLastDate","text":"cohort cohort table cdm reference. dateColumns Character vector indicating date columns cohort table consider. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column indicating dateColumns used. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtLastDate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set cohort end date to the last of a set of column dates — exitAtLastDate","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtLastDate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set cohort end date to the last of a set of column dates — exitAtLastDate","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(tables = list( \"cohort\" = dplyr::tibble( cohort_definition_id = 1, subject_id = c(1, 2, 3, 4), cohort_start_date = as.Date(c(\"2000-06-03\", \"2000-01-01\", \"2015-01-15\", \"2000-12-09\")), cohort_end_date = as.Date(c(\"2001-09-01\", \"2001-01-12\", \"2015-02-15\", \"2002-12-09\")), date_1 = as.Date(c(\"2001-08-01\", \"2001-01-01\", \"2015-01-15\", \"2002-12-09\")), date_2 = as.Date(c(\"2001-08-01\", NA, \"2015-04-15\", \"2002-12-09\")) ) )) #> Warning: ! 9 column in cdm_source do not match expected column type: #> • `cdm_source_abbreviation` is logical but expected character #> • `cdm_holder` is logical but expected character #> • `source_description` is logical but expected character #> • `source_documentation_reference` is logical but expected character #> • `cdm_etl_reference` is logical but expected character #> • `source_release_date` is logical but expected date #> • `cdm_release_date` is logical but expected date #> • `cdm_version` is numeric but expected character #> • `vocabulary_version` is logical but expected character #> Warning: ! 3 column in concept do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date #> Warning: ! 1 column in vocabulary do not match expected column type: #> • `vocabulary_concept_id` is numeric but expected integer #> Warning: ! 5 column in concept_relationship do not match expected column type: #> • `concept_id_1` is numeric but expected integer #> • `concept_id_2` is numeric but expected integer #> • `valid_start_date` is logical but expected date #> • `valid_end_date` is logical but expected date #> • `invalid_reason` is logical but expected character #> Warning: ! 2 column in concept_synonym do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `language_concept_id` is numeric but expected integer #> Warning: ! 4 column in concept_ancestor do not match expected column type: #> • `ancestor_concept_id` is numeric but expected integer #> • `descendant_concept_id` is numeric but expected integer #> • `min_levels_of_separation` is numeric but expected integer #> • `max_levels_of_separation` is numeric but expected integer #> Warning: ! 9 column in drug_strength do not match expected column type: #> • `drug_concept_id` is numeric but expected integer #> • `ingredient_concept_id` is numeric but expected integer #> • `amount_unit_concept_id` is numeric but expected integer #> • `numerator_unit_concept_id` is numeric but expected integer #> • `denominator_value` is logical but expected numeric #> • `denominator_unit_concept_id` is numeric but expected integer #> • `box_size` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date cdm$cohort |> exitAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 11] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 2015-01-15 2015-04-15 #> 2 1 4 2000-12-09 2002-12-09 #> 3 1 1 2000-06-03 2001-08-01 #> 4 1 2 2000-01-01 2001-01-01 #> # ℹ 7 more variables: cohort_definition_name , #> # cohort_definition_description , definition_type_concept_id , #> # cohort_definition_syntax , subject_concept_id , #> # cohort_initiation_date , exit_reason # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtObservationEnd.html","id":null,"dir":"Reference","previous_headings":"","what":"Set cohort end date to end of observation — exitAtObservationEnd","title":"Set cohort end date to end of observation — exitAtObservationEnd","text":"exitAtObservationEnd() resets cohort end date based set specified column dates. last date occurs chosen. functions changes cohort end date end date observation period corresponding cohort entry. case generates overlapping records cohort, overlapping entries merged.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtObservationEnd.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set cohort end date to end of observation — exitAtObservationEnd","text":"","code":"exitAtObservationEnd( cohort, cohortId = NULL, limitToCurrentPeriod = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtObservationEnd.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set cohort end date to end of observation — exitAtObservationEnd","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. limitToCurrentPeriod TRUE, limits cohort one entry per person, ending current observation period. FALSE, subsequent observation periods create new cohort entries. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtObservationEnd.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set cohort end date to end of observation — exitAtObservationEnd","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtObservationEnd.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set cohort end date to end of observation — exitAtObservationEnd","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> exitAtObservationEnd() #> # Source: table [6 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 9 2012-01-18 2012-06-30 #> 2 1 2 1964-09-18 1968-04-03 #> 3 1 4 1998-06-22 2013-05-12 #> 4 1 5 2007-10-19 2014-09-25 #> 5 1 3 1976-11-28 2000-04-25 #> 6 1 6 2003-10-31 2005-11-04 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/gapDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of gap. — gapDoc","title":"Helper for consistent documentation of gap. — gapDoc","text":"Helper consistent documentation gap.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/gapDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of gap. — gapDoc","text":"gap Number days two subsequent cohort entries merged single cohort record.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/intersectCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","title":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","text":"intersectCohorts() combines different cohort entries, records overlap combined kept. Cohort entries individual cohorts.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/intersectCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","text":"","code":"intersectCohorts( cohort, cohortId = NULL, gap = 0, returnNonOverlappingCohorts = FALSE, keepOriginalCohorts = FALSE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/intersectCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. gap Number days two subsequent cohort entries merged single cohort record. returnNonOverlappingCohorts Whether generated cohorts mutually exclusive . keepOriginalCohorts TRUE original cohorts return together new ones. FALSE new cohort returned. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/intersectCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/intersectCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort3 <- intersectCohorts( cohort = cdm$cohort2, name = \"cohort3\", ) settings(cdm$cohort3) #> # A tibble: 1 × 5 #> cohort_definition_id cohort_name gap cohort_1 cohort_2 #> #> 1 1 cohort_1_cohort_2 0 1 1 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/keepOriginalCohortsDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of keepOriginalCohorts. — keepOriginalCohortsDoc","title":"Helper for consistent documentation of keepOriginalCohorts. — keepOriginalCohortsDoc","text":"Helper consistent documentation keepOriginalCohorts.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/keepOriginalCohortsDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of keepOriginalCohorts. — keepOriginalCohortsDoc","text":"keepOriginalCohorts TRUE original cohorts return together new ones. FALSE new cohort returned.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/matchCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate a new cohort matched cohort — matchCohorts","title":"Generate a new cohort matched cohort — matchCohorts","text":"matchCohorts() generate new cohort matched individuals existing cohort. Individuals can matched based year birth sex.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/matchCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate a new cohort matched cohort — matchCohorts","text":"","code":"matchCohorts( cohort, cohortId = NULL, matchSex = TRUE, matchYearOfBirth = TRUE, ratio = 1, keepOriginalCohorts = FALSE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/matchCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate a new cohort matched cohort — matchCohorts","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. matchSex Whether match sex. matchYearOfBirth Whether match year birth. ratio Number allowed matches per individual target cohort. keepOriginalCohorts TRUE original cohorts return together new ones. FALSE new cohort returned. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/matchCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate a new cohort matched cohort — matchCohorts","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/matchCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate a new cohort matched cohort — matchCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) library(dplyr) #> #> Attaching package: ‘dplyr’ #> The following objects are masked from ‘package:stats’: #> #> filter, lag #> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union cdm <- mockCohortConstructor(nPerson = 200) cdm$new_matched_cohort <- cdm$cohort2 |> matchCohorts( name = \"new_matched_cohort\", cohortId = 2, matchSex = TRUE, matchYearOfBirth = TRUE, ratio = 1) #> Starting matching #> Warning: Multiple records per person detected. The matchCohorts() function is designed #> to operate under the assumption that there is only one record per person within #> each cohort. If this assumption is not met, each record will be treated #> independently. As a result, the same individual may be matched multiple times, #> leading to inconsistent and potentially misleading results. #> ℹ Creating copy of target cohort. #> • 1 cohort to be matched. #> ℹ Creating controls cohorts. #> ℹ Excluding cases from controls #> • Matching by gender_concept_id and year_of_birth #> • Removing controls that were not in observation at index date #> • Excluding target records whose pair is not in observation #> • Adjusting ratio #> Binding cohorts #> ✔ Done cdm$new_matched_cohort #> # Source: table [?? x 5] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date cluster_id #> #> 1 1 89 2002-04-17 2005-07-29 54 #> 2 1 150 2008-01-10 2008-11-21 113 #> 3 1 148 2006-09-04 2011-12-31 37 #> 4 1 67 2009-01-30 2010-03-12 78 #> 5 1 46 2014-12-28 2015-06-28 79 #> 6 1 47 1993-01-02 1994-03-22 89 #> 7 1 103 1979-10-16 1982-05-26 21 #> 8 1 9 2012-01-30 2012-04-08 101 #> 9 1 16 2007-05-18 2007-10-08 102 #> 10 1 110 2005-10-01 2006-06-12 99 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/measurementCohort.html","id":null,"dir":"Reference","previous_headings":"","what":"Create cohorts measurement based cohorts — measurementCohort","title":"Create cohorts measurement based cohorts — measurementCohort","text":"measurementCohort() creates cohorts based patient records contained measurement table. function extends conceptCohort() allows measurement values associated records specified. valueAsConcept valueAsNumber NULL requirements values associated measurement records using measurementCohort() lead result using conceptCohort() (long concepts measurement domain). one valueAsConcept valueAsNumber NULL records required values satisfy requirement specified. valueAsConcept valueAsNumber NULL, records required values fulfill either requirements","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/measurementCohort.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create cohorts measurement based cohorts — measurementCohort","text":"","code":"measurementCohort( cdm, conceptSet, name, valueAsConcept = NULL, valueAsNumber = NULL )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/measurementCohort.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create cohorts measurement based cohorts — measurementCohort","text":"cdm cdm reference. conceptSet conceptSet, can either codelist conceptSetExpression. name Name new cohort table created cdm object. valueAsConcept vector cohort IDs used filter measurements. measurements values value_as_concept_id column measurement table included. NULL entries independently value concept considered. valueAsNumber named list indicating range values unit correspond , follows: list(\"unit_concept_id\" = c(rangeValue1, rangeValue2)). NULL, entries independently value number included.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/measurementCohort.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create cohorts measurement based cohorts — measurementCohort","text":"cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/measurementCohort.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create cohorts measurement based cohorts — measurementCohort","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(con = NULL) cdm$concept <- cdm$concept |> dplyr::union_all( dplyr::tibble( concept_id = c(4326744, 4298393, 45770407, 8876, 4124457), concept_name = c(\"Blood pressure\", \"Systemic blood pressure\", \"Baseline blood pressure\", \"millimeter mercury column\", \"Normal range\"), domain_id = \"Measurement\", vocabulary_id = c(\"SNOMED\", \"SNOMED\", \"SNOMED\", \"UCUM\", \"SNOMED\"), standard_concept = \"S\", concept_class_id = c(\"Observable Entity\", \"Observable Entity\", \"Observable Entity\", \"Unit\", \"Qualifier Value\"), concept_code = NA, valid_start_date = NA, valid_end_date = NA, invalid_reason = NA ) ) cdm$measurement <- dplyr::tibble( measurement_id = 1:4, person_id = c(1, 1, 2, 3), measurement_concept_id = c(4326744, 4298393, 4298393, 45770407), measurement_date = as.Date(c(\"2000-07-01\", \"2000-12-11\", \"2002-09-08\", \"2015-02-19\")), measurement_type_concept_id = NA, value_as_number = c(100, 125, NA, NA), value_as_concept_id = c(0, 0, 0, 4124457), unit_concept_id = c(8876, 8876, 0, 0) ) cdm <- CDMConnector::copyCdmTo( con = DBI::dbConnect(duckdb::duckdb()), cdm = cdm, schema = \"main\") cdm$cohort <- measurementCohort( cdm = cdm, name = \"cohort\", conceptSet = list(\"normal_blood_pressure\" = c(4326744, 4298393, 45770407)), valueAsConcept = c(4124457), valueAsNumber = list(\"8876\" = c(70, 120)) ) #> Warning: ! `codelist` contains numeric values, they are casted to integers. #> ℹ Subsetting measurement table. #> ℹ Applying measurement requirements. #> Warning: ! 1 column in cohort do not match expected column type: #> • `subject_id` is numeric but expected integer #> ! cohort columns will be reordered to match the expected order: #> cohort_definition_id, subject_id, cohort_start_date, and cohort_end_date. #> ℹ Getting records in observation. #> Warning: ! 1 column in cohort do not match expected column type: #> • `subject_id` is numeric but expected integer #> Warning: ! 1 column in cohort do not match expected column type: #> • `subject_id` is numeric but expected integer #> Warning: ! 1 column in cohort do not match expected column type: #> • `subject_id` is numeric but expected integer #> ℹ Creating cohort attributes. #> Warning: ! 1 column in cohort do not match expected column type: #> • `subject_id` is numeric but expected integer #> ✔ Cohort cohort created. cdm$cohort #> # Source: table [0 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> # ℹ 4 variables: cohort_definition_id , subject_id , #> # cohort_start_date , cohort_end_date # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/mockCohortConstructor.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","title":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","text":"mockCohortConstructor() creates example dataset can used demonstrating testing package","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/mockCohortConstructor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","text":"","code":"mockCohortConstructor( nPerson = 10, conceptTable = NULL, tables = NULL, conceptId = NULL, conceptIdClass = NULL, drugExposure = FALSE, conditionOccurrence = FALSE, measurement = FALSE, death = FALSE, otherTables = NULL, con = DBI::dbConnect(duckdb::duckdb()), writeSchema = \"main\", seed = 123 )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/mockCohortConstructor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","text":"nPerson number person cdm conceptTable user defined concept table tables list tables include cdm conceptId list concept id conceptIdClass domain class conceptId drugExposure T/F include drug exposure table cdm conditionOccurrence T/F include condition occurrence cdm measurement T/F include measurement cdm death T/F include death table cdm otherTables takes list single tibble names include tables cdm con DBI connection create cdm mock object. writeSchema Name schema connection writing permissions. seed Seed passed omock::mockCdmFromTable","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/mockCohortConstructor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","text":"cdm object","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/mockCohortConstructor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm #> #> ── # OMOP CDM reference (duckdb) of mock database ────────────────────────────── #> • omop tables: person, observation_period, cdm_source, concept, vocabulary, #> concept_relationship, concept_synonym, concept_ancestor, drug_strength #> • cohort tables: cohort1, cohort2 #> • achilles tables: - #> • other tables: - # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/nameDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of name. — nameDoc","title":"Helper for consistent documentation of name. — nameDoc","text":"Helper consistent documentation name.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/nameDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of name. — nameDoc","text":"name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortEnd.html","id":null,"dir":"Reference","previous_headings":"","what":"Add days to cohort end — padCohortEnd","title":"Add days to cohort end — padCohortEnd","text":"padCohortEnd() Adds (subtracts) certain number days cohort end date. Note: days added means cohort end observation period end date, observation period end date used cohort exit. days added means cohort exit next cohort start overlapping cohort entries collapsed. days subtracted means cohort end cohort start cohort entry dropped.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortEnd.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add days to cohort end — padCohortEnd","text":"","code":"padCohortEnd(cohort, days, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortEnd.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add days to cohort end — padCohortEnd","text":"cohort cohort table cdm reference. days Number day add cohort end date. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortEnd.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add days to cohort end — padCohortEnd","text":"Cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortEnd.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add days to cohort end — padCohortEnd","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() # add 10 days to each cohort exit cdm$cohort1 |> padCohortEnd(days = 10) #> # Source: table [6 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 6 2003-10-31 2004-04-20 #> 2 1 9 2012-01-18 2012-03-18 #> 3 1 4 1998-06-22 2001-02-22 #> 4 1 2 1964-09-18 1965-09-09 #> 5 1 5 2007-10-19 2011-09-22 #> 6 1 3 1976-11-28 1987-03-08 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortStart.html","id":null,"dir":"Reference","previous_headings":"","what":"Add days to cohort start — padCohortStart","title":"Add days to cohort start — padCohortStart","text":"padCohortStart() Adds (subtracts) certain number days cohort start date. Note: days added means cohort start cohort end cohort entry dropped. subtracting day means cohort start observation period start cohort entry dropped.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortStart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add days to cohort start — padCohortStart","text":"","code":"padCohortStart(cohort, days, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortStart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add days to cohort start — padCohortStart","text":"cohort cohort table cdm reference. days Number day add cohort start date. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortStart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add days to cohort start — padCohortStart","text":"Cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortStart.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add days to cohort start — padCohortStart","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() # add 10 days to each cohort entry cdm$cohort1 |> padCohortStart(days = 10) #> # Source: table [10 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-28 1965-08-30 #> 2 1 3 1976-12-08 1977-03-11 #> 3 1 3 1977-03-22 1978-04-03 #> 4 1 3 1978-04-14 1987-02-26 #> 5 1 4 1998-07-02 2001-02-12 #> 6 1 5 2007-10-29 2008-11-10 #> 7 1 5 2008-11-21 2011-09-12 #> 8 1 6 2003-11-10 2003-11-14 #> 9 1 6 2003-11-25 2004-04-10 #> 10 1 9 2012-01-28 2012-03-08 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/reexports.html","id":null,"dir":"Reference","previous_headings":"","what":"Objects exported from other packages — reexports","title":"Objects exported from other packages — reexports","text":"objects imported packages. Follow links see documentation. omopgenerics attrition, bind, cohortCodelist, cohortCount, settings, tableName PatientProfiles endDateColumn, startDateColumn","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireAge.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on age — requireAge","title":"Restrict cohort on age — requireAge","text":"requireAge() filters cohort records, keeping records individuals satisfy specified age criteria.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireAge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on age — requireAge","text":"","code":"requireAge( cohort, ageRange, cohortId = NULL, indexDate = \"cohort_start_date\", name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireAge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on age — requireAge","text":"cohort cohort table cdm reference. ageRange list vectors specifying minimum maximum age. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireAge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on age — requireAge","text":"cohort table records individuals satisfying age requirement","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireAge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on age — requireAge","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> requireAge(indexDate = \"cohort_start_date\", ageRange = list(c(18, 65))) #> # Source: table [6 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 1978-04-04 1987-02-26 #> 2 1 5 2007-10-19 2008-11-10 #> 3 1 5 2008-11-11 2011-09-12 #> 4 1 6 2003-10-31 2003-11-14 #> 5 1 6 2003-11-15 2004-04-10 #> 6 1 9 2012-01-18 2012-03-08 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireCohortIntersect.html","id":null,"dir":"Reference","previous_headings":"","what":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","title":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","text":"requireCohortIntersect() filters cohort table based requirement individual seen (seen) another cohort time window around index date.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireCohortIntersect.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","text":"","code":"requireCohortIntersect( cohort, targetCohortTable, window, intersections = c(1, Inf), cohortId = NULL, targetCohortId = NULL, indexDate = \"cohort_start_date\", targetStartDate = \"cohort_start_date\", targetEndDate = \"cohort_end_date\", censorDate = NULL, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireCohortIntersect.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","text":"cohort cohort table cdm reference. targetCohortTable Name cohort want check intersect. window list vectors specifying minimum maximum days indexDate consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. targetCohortId Vector cohort definition ids include. indexDate Name column cohort contains date compute intersection. targetStartDate Start date reference cohort table. targetEndDate End date reference cohort table. NULL, incidence target event window considered intersection, otherwise prevalence event used intersection (overlap cohort event). censorDate Whether censor overlap events specific date column date cohort. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireCohortIntersect.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","text":"Cohort table isatisfying criteria kept","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireCohortIntersect.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> requireCohortIntersect(targetCohortTable = \"cohort2\", targetCohortId = 1, indexDate = \"cohort_start_date\", window = c(-Inf, 0)) #> # Source: table [10 x 5] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 5 2007-10-19 2008-11-10 #> 2 1 3 1977-03-12 1978-04-03 #> 3 1 3 1978-04-04 1987-02-26 #> 4 1 4 1998-06-22 2001-02-12 #> 5 1 2 1964-09-18 1965-08-30 #> 6 1 6 2003-11-15 2004-04-10 #> 7 1 3 1976-11-28 1977-03-11 #> 8 1 5 2008-11-11 2011-09-12 #> 9 1 9 2012-01-18 2012-03-08 #> 10 1 6 2003-10-31 2003-11-14 #> # ℹ 1 more variable: intersect_cohort # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireConceptIntersect.html","id":null,"dir":"Reference","previous_headings":"","what":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","title":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","text":"requireConceptIntersect() filters cohort table based requirement individual seen (seen) events related concept list time window around index date.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireConceptIntersect.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","text":"","code":"requireConceptIntersect( cohort, conceptSet, window, intersections = c(1, Inf), cohortId = NULL, indexDate = \"cohort_start_date\", targetStartDate = \"event_start_date\", targetEndDate = \"event_end_date\", censorDate = NULL, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireConceptIntersect.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","text":"cohort cohort table cdm reference. conceptSet conceptSet, can either codelist conceptSetExpression. window list vectors specifying minimum maximum days indexDate consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Name column cohort contains date compute intersection. targetStartDate Start date reference cohort table. targetEndDate End date reference cohort table. NULL, incidence target event window considered intersection, otherwise prevalence event used intersection (overlap cohort event). censorDate Whether censor overlap events specific date column date cohort. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireConceptIntersect.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","text":"Cohort table events concept list kept (without event negate = TRUE)","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireConceptIntersect.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(conditionOccurrence = TRUE) cdm$cohort2 <- requireConceptIntersect( cohort = cdm$cohort1, conceptSet = list(a = 194152), window = c(-Inf, 0), name = \"cohort2\") #> Warning: ! `codelist` contains numeric values, they are casted to integers. # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDeathFlag.html","id":null,"dir":"Reference","previous_headings":"","what":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","title":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","text":"requireDeathFlag() filters cohort table based requirement individual seen (seen) death time window around index date.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDeathFlag.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","text":"","code":"requireDeathFlag( cohort, window, cohortId = NULL, indexDate = \"cohort_start_date\", censorDate = NULL, negate = FALSE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDeathFlag.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","text":"cohort cohort table cdm reference. window list vectors specifying minimum maximum days indexDate consider events . cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Name column cohort contains date use time 0 window days. censorDate Whether censor overlap events specific date column date cohort. negate set TRUE, criteria applied exclusion rather inclusion (.e. require absence another cohort). name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDeathFlag.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","text":"Cohort table death event kept (without negate = TRUE)","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDeathFlag.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","text":"","code":"# \\donttest{ library(CDMConnector) #> #> Attaching package: ‘CDMConnector’ #> The following objects are masked from ‘package:CohortConstructor’: #> #> intersectCohorts, unionCohorts library(CohortConstructor) cdm <- mockCohortConstructor(death = TRUE) cdm$cohort1 <- cdm$cohort1 |> requireDeathFlag(window = list(c(0, Inf))) attrition(cdm$cohort1) #> # A tibble: 2 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 10 6 1 Initial qualify… #> 2 1 10 6 2 Death between 0… #> # ℹ 2 more variables: excluded_records , excluded_subjects # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographics.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on patient demographics — requireDemographics","title":"Restrict cohort on patient demographics — requireDemographics","text":"requireDemographics() filters cohort records, keeping records individuals satisfy specified demographic criteria.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographics.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on patient demographics — requireDemographics","text":"","code":"requireDemographics( cohort, cohortId = NULL, indexDate = \"cohort_start_date\", ageRange = list(c(0, 150)), sex = c(\"Both\"), minPriorObservation = 0, minFutureObservation = 0, requirementInteractions = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographics.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on patient demographics — requireDemographics","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . ageRange list vectors specifying minimum maximum age. sex Can \"\", \"Male\" \"Female\". minPriorObservation minimum number continuous prior observation days database. minFutureObservation minimum number continuous future observation days database. requirementInteractions TRUE, cohorts created combinations ageGroup, sex, daysPriorObservation. FALSE, first value specified factors used. Consequently, order values matters requirementInteractions FALSE. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographics.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on patient demographics — requireDemographics","text":"cohort table records individuals satisfying demographic requirements","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographics.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on patient demographics — requireDemographics","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> requireDemographics(indexDate = \"cohort_start_date\", ageRange = list(c(18, 65)), sex = \"Female\", minPriorObservation = 365) #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 13 1991-04-14 1992-10-21 #> 2 1 13 1992-11-03 2000-11-27 #> 3 1 16 2005-12-28 2008-06-11 #> 4 1 17 2009-06-18 2013-02-01 #> 5 1 27 1992-04-16 1993-09-30 #> 6 1 27 1993-10-01 2003-08-01 #> 7 1 41 2000-07-02 2000-11-21 #> 8 1 41 2000-11-22 2010-05-13 #> 9 1 53 1997-03-26 1998-02-22 #> 10 1 53 1998-02-23 2001-04-23 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographicsDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of arguments in requireDemographics. — requireDemographicsDoc","title":"Helper for consistent documentation of arguments in requireDemographics. — requireDemographicsDoc","text":"Helper consistent documentation arguments requireDemographics.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographicsDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of arguments in requireDemographics. — requireDemographicsDoc","text":"ageRange list vectors specifying minimum maximum age. sex Can \"\", \"Male\" \"Female\". minPriorObservation minimum number continuous prior observation days database. minFutureObservation minimum number continuous future observation days database. indexDate Variable cohort contains date compute demographics characteristics restrict . requirementInteractions TRUE, cohorts created combinations ageGroup, sex, daysPriorObservation. FALSE, first value specified factors used. Consequently, order values matters requirementInteractions FALSE.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireFutureObservation.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on future observation — requireFutureObservation","title":"Restrict cohort on future observation — requireFutureObservation","text":"requireFutureObservation() filters cohort records, keeping records individuals satisfy specified future observation criteria.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireFutureObservation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on future observation — requireFutureObservation","text":"","code":"requireFutureObservation( cohort, minFutureObservation, cohortId = NULL, indexDate = \"cohort_start_date\", name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireFutureObservation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on future observation — requireFutureObservation","text":"cohort cohort table cdm reference. minFutureObservation minimum number continuous future observation days database. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireFutureObservation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on future observation — requireFutureObservation","text":"cohort table records individuals satisfying future observation requirement","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireFutureObservation.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on future observation — requireFutureObservation","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> requireFutureObservation(indexDate = \"cohort_start_date\", minFutureObservation = 30) #> # Source: table [10 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-18 1965-08-30 #> 2 1 3 1976-11-28 1977-03-11 #> 3 1 4 1998-06-22 2001-02-12 #> 4 1 5 2008-11-11 2011-09-12 #> 5 1 6 2003-11-15 2004-04-10 #> 6 1 9 2012-01-18 2012-03-08 #> 7 1 3 1978-04-04 1987-02-26 #> 8 1 5 2007-10-19 2008-11-10 #> 9 1 6 2003-10-31 2003-11-14 #> 10 1 3 1977-03-12 1978-04-03 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireInDateRange.html","id":null,"dir":"Reference","previous_headings":"","what":"Require that an index date is within a date range — requireInDateRange","title":"Require that an index date is within a date range — requireInDateRange","text":"requireInDateRange() filters cohort records, keeping index date within specified date range.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireInDateRange.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Require that an index date is within a date range — requireInDateRange","text":"","code":"requireInDateRange( cohort, dateRange, cohortId = NULL, indexDate = \"cohort_start_date\", name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireInDateRange.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Require that an index date is within a date range — requireInDateRange","text":"cohort cohort table cdm reference. dateRange date vector minimum maximum dates index date must observed. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Name column cohort contains date interest. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireInDateRange.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Require that an index date is within a date range — requireInDateRange","text":"cohort table cohort entries outside date range dropped","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireInDateRange.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Require that an index date is within a date range — requireInDateRange","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> requireInDateRange(indexDate = \"cohort_start_date\", dateRange = as.Date(c(\"2010-01-01\", \"2019-01-01\"))) #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 9 2011-12-20 2011-12-20 #> 2 1 9 2011-12-21 2011-12-29 #> 3 1 9 2011-12-30 2012-04-02 #> 4 1 15 2018-03-20 2018-04-01 #> 5 1 22 2013-01-01 2013-03-07 #> 6 1 25 2018-01-10 2018-03-13 #> 7 1 25 2018-03-14 2018-03-22 #> 8 1 25 2018-03-23 2018-06-26 #> 9 1 25 2018-06-27 2018-11-13 #> 10 1 31 2012-09-03 2013-02-18 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIntersectDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of arguments in requireIntersect functions. — requireIntersectDoc","title":"Helper for consistent documentation of arguments in requireIntersect functions. — requireIntersectDoc","text":"Helper consistent documentation arguments requireIntersect functions.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIntersectDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of arguments in requireIntersect functions. — requireIntersectDoc","text":"indexDate Name column cohort contains date compute intersection. intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . targetStartDate Start date reference cohort table. targetEndDate End date reference cohort table. NULL, incidence target event window considered intersection, otherwise prevalence event used intersection (overlap cohort event). censorDate Whether censor overlap events specific date column date cohort. targetCohortTable Name cohort want check intersect. targetCohortId Vector cohort definition ids include. tableName Name table check intersect.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsEntry.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort to specific entry — requireIsEntry","title":"Restrict cohort to specific entry — requireIsEntry","text":"requireIsFirstEntry() filters cohort records, keeping first cohort entry per person.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsEntry.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort to specific entry — requireIsEntry","text":"","code":"requireIsEntry(cohort, entryRange, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsEntry.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort to specific entry — requireIsEntry","text":"cohort cohort table cdm reference. entryRange Range entries include. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsEntry.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort to specific entry — requireIsEntry","text":"cohort table cdm reference.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsEntry.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort to specific entry — requireIsEntry","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 <- requireIsEntry(cdm$cohort1, c(1, Inf)) # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsFirstEntry.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort to first entry — requireIsFirstEntry","title":"Restrict cohort to first entry — requireIsFirstEntry","text":"requireIsFirstEntry() filters cohort records, keeping first cohort entry per person.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsFirstEntry.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort to first entry — requireIsFirstEntry","text":"","code":"requireIsFirstEntry(cohort, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsFirstEntry.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort to first entry — requireIsFirstEntry","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort restriction.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsFirstEntry.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort to first entry — requireIsFirstEntry","text":"cohort table cdm reference.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsFirstEntry.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort to first entry — requireIsFirstEntry","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 <- requireIsFirstEntry(cdm$cohort1) # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsLastEntry.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort to last entry per person — requireIsLastEntry","title":"Restrict cohort to last entry per person — requireIsLastEntry","text":"requireIsLastEntry() filters cohort records, keeping last cohort entry per person.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsLastEntry.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort to last entry per person — requireIsLastEntry","text":"","code":"requireIsLastEntry(cohort, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsLastEntry.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort to last entry per person — requireIsLastEntry","text":"cohort cohort table cdm reference. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort restriction.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsLastEntry.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort to last entry per person — requireIsLastEntry","text":"cohort table cdm reference.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsLastEntry.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort to last entry per person — requireIsLastEntry","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 <- requireIsLastEntry(cdm$cohort1) # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireMinCohortCount.html","id":null,"dir":"Reference","previous_headings":"","what":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","title":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","text":"requireMinCohortCount() filters existing cohort table, keeping records cohorts minimum number individuals","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireMinCohortCount.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","text":"","code":"requireMinCohortCount( cohort, minCohortCount, cohortId = NULL, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireMinCohortCount.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","text":"cohort cohort table cdm reference. minCohortCount minimum count sbjects cohort included. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireMinCohortCount.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","text":"Cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireMinCohortCount.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> requireMinCohortCount(5) #> Warning: There was 1 warning in `dplyr::summarise()`. #> ℹ In argument: `reason_id = max(.data$reason_id)`. #> Caused by warning in `max()`: #> ! no non-missing arguments to max; returning -Inf #> Warning: ! 1 casted column in cohort1 (cohort_attrition) as do not match expected column #> type: #> • `reason_id` from numeric to integer #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 4 1998-12-14 2002-02-14 #> 2 1 6 2003-04-11 2004-02-23 #> 3 1 7 2004-07-31 2004-11-23 #> 4 1 7 2004-11-24 2005-11-05 #> 5 1 7 2005-11-06 2012-01-12 #> 6 1 8 2009-09-13 2012-04-22 #> 7 1 9 2011-12-20 2011-12-20 #> 8 1 9 2011-12-21 2011-12-29 #> 9 1 9 2011-12-30 2012-04-02 #> 10 1 12 2000-11-15 2013-03-04 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requirePriorObservation.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on prior observation — requirePriorObservation","title":"Restrict cohort on prior observation — requirePriorObservation","text":"requirePriorObservation() filters cohort records, keeping records individuals satisfy specified prior observation criteria.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requirePriorObservation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on prior observation — requirePriorObservation","text":"","code":"requirePriorObservation( cohort, minPriorObservation, cohortId = NULL, indexDate = \"cohort_start_date\", name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requirePriorObservation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on prior observation — requirePriorObservation","text":"cohort cohort table cdm reference. minPriorObservation minimum number continuous prior observation days database. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requirePriorObservation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on prior observation — requirePriorObservation","text":"cohort table records individuals satisfying prior observation requirement","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requirePriorObservation.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on prior observation — requirePriorObservation","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> requirePriorObservation(indexDate = \"cohort_start_date\", minPriorObservation = 365) #> # Source: table [6 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-18 1965-08-30 #> 2 1 3 1976-11-28 1977-03-11 #> 3 1 3 1977-03-12 1978-04-03 #> 4 1 3 1978-04-04 1987-02-26 #> 5 1 4 1998-06-22 2001-02-12 #> 6 1 5 2008-11-11 2011-09-12 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireSex.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on sex — requireSex","title":"Restrict cohort on sex — requireSex","text":"requireSex() filters cohort records, keeping records individuals satisfy specified sex criteria.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireSex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on sex — requireSex","text":"","code":"requireSex(cohort, sex, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireSex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on sex — requireSex","text":"cohort cohort table cdm reference. sex Can \"\", \"Male\" \"Female\". cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireSex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on sex — requireSex","text":"cohort table records individuals satisfying sex requirement","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireSex.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on sex — requireSex","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> requireSex(sex = \"Female\") #> # Source: table [8 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-18 1965-08-30 #> 2 1 3 1976-11-28 1977-03-11 #> 3 1 3 1977-03-12 1978-04-03 #> 4 1 3 1978-04-04 1987-02-26 #> 5 1 4 1998-06-22 2001-02-12 #> 6 1 5 2007-10-19 2008-11-10 #> 7 1 5 2008-11-11 2011-09-12 #> 8 1 9 2012-01-18 2012-03-08 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireTableIntersect.html","id":null,"dir":"Reference","previous_headings":"","what":"Require cohort subjects are present in another clinical table — requireTableIntersect","title":"Require cohort subjects are present in another clinical table — requireTableIntersect","text":"requireTableIntersect() filters cohort table based requirement individual seen (seen) record (records) clinical table time window around index date.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireTableIntersect.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Require cohort subjects are present in another clinical table — requireTableIntersect","text":"","code":"requireTableIntersect( cohort, tableName, window, intersections = c(1, Inf), cohortId = NULL, indexDate = \"cohort_start_date\", targetStartDate = startDateColumn(tableName), targetEndDate = endDateColumn(tableName), censorDate = NULL, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireTableIntersect.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Require cohort subjects are present in another clinical table — requireTableIntersect","text":"cohort cohort table cdm reference. tableName Name table check intersect. window list vectors specifying minimum maximum days indexDate consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Name column cohort contains date compute intersection. targetStartDate Start date reference cohort table. targetEndDate End date reference cohort table. NULL, incidence target event window considered intersection, otherwise prevalence event used intersection (overlap cohort event). censorDate Whether censor overlap events specific date column date cohort. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireTableIntersect.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Require cohort subjects are present in another clinical table — requireTableIntersect","text":"Cohort table table kept (table negate = TRUE)","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireTableIntersect.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Require cohort subjects are present in another clinical table — requireTableIntersect","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(drugExposure = TRUE) cdm$cohort1 |> requireTableIntersect(tableName = \"drug_exposure\", indexDate = \"cohort_start_date\", window = c(-Inf, 0)) #> # Source: table [10 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-18 1965-08-30 #> 2 1 3 1976-11-28 1977-03-11 #> 3 1 3 1977-03-12 1978-04-03 #> 4 1 3 1978-04-04 1987-02-26 #> 5 1 4 1998-06-22 2001-02-12 #> 6 1 5 2007-10-19 2008-11-10 #> 7 1 5 2008-11-11 2011-09-12 #> 8 1 6 2003-10-31 2003-11-14 #> 9 1 6 2003-11-15 2004-04-10 #> 10 1 9 2012-01-18 2012-03-08 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/sampleCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Sample a cohort table for a given number of individuals. — sampleCohorts","title":"Sample a cohort table for a given number of individuals. — sampleCohorts","text":"sampleCohorts() samples existing cohort table given number people. records individuals preserved.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/sampleCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sample a cohort table for a given number of individuals. — sampleCohorts","text":"","code":"sampleCohorts(cohort, n, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/sampleCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Sample a cohort table for a given number of individuals. — sampleCohorts","text":"cohort cohort table cdm reference. n Number people sampled included cohort. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/sampleCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Sample a cohort table for a given number of individuals. — sampleCohorts","text":"Cohort table specified cohorts sampled.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/sampleCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Sample a cohort table for a given number of individuals. — sampleCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort2 |> sampleCohorts(cohortId = 1, n = 10) #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 15 2018-03-20 2018-04-01 #> 2 1 21 1981-04-20 1986-09-10 #> 3 1 23 2000-10-08 2001-06-04 #> 4 1 23 2001-06-05 2003-08-26 #> 5 1 38 1978-07-24 1979-07-04 #> 6 1 38 1979-07-05 1982-01-31 #> 7 1 51 1979-04-13 1982-12-04 #> 8 1 51 1982-12-05 2003-05-24 #> 9 1 52 1991-10-19 1992-12-11 #> 10 1 62 2007-12-22 2008-12-08 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/stratifyCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new cohort table from stratifying an existing one — stratifyCohorts","title":"Create a new cohort table from stratifying an existing one — stratifyCohorts","text":"stratifyCohorts() creates new cohorts, splitting existing cohort based specified columns stratify .","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/stratifyCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new cohort table from stratifying an existing one — stratifyCohorts","text":"","code":"stratifyCohorts( cohort, strata, cohortId = NULL, removeStrata = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/stratifyCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new cohort table from stratifying an existing one — stratifyCohorts","text":"cohort cohort table cdm reference. strata strata list point columns cohort table. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. removeStrata Whether remove strata columns final cohort table. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/stratifyCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new cohort table from stratifying an existing one — stratifyCohorts","text":"Cohort table stratified.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/stratifyCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new cohort table from stratifying an existing one — stratifyCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) library(PatientProfiles) cdm <- mockCohortConstructor() cdm$my_cohort <- cdm$cohort1 |> addAge(ageGroup = list(\"child\" = c(0, 17), \"adult\" = c(18, Inf))) |> addSex(name = \"my_cohort\") |> stratifyCohorts( strata = list(\"sex\", c(\"sex\", \"age_group\")), name = \"my_cohort\" ) cdm$my_cohort #> # Source: table [?? x 5] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date age #> #> 1 1 2 1964-09-18 1965-08-30 9 #> 2 1 3 1978-04-04 1987-02-26 19 #> 3 1 4 1998-06-22 2001-02-12 16 #> 4 1 5 2007-10-19 2008-11-10 44 #> 5 2 6 2003-11-15 2004-04-10 35 #> 6 1 9 2012-01-18 2012-03-08 27 #> 7 1 3 1977-03-12 1978-04-03 17 #> 8 1 5 2008-11-11 2011-09-12 45 #> 9 2 6 2003-10-31 2003-11-14 35 #> 10 1 3 1976-11-28 1977-03-11 17 #> # ℹ more rows settings(cdm$my_cohort) #> # A tibble: 6 × 8 #> cohort_definition_id cohort_name target_cohort_id target_cohort_name #> #> 1 1 cohort_1_female 1 cohort_1 #> 2 2 cohort_1_male 1 cohort_1 #> 3 3 cohort_1_female_adult 1 cohort_1 #> 4 4 cohort_1_female_child 1 cohort_1 #> 5 5 cohort_1_male_adult 1 cohort_1 #> 6 6 cohort_1_male_child 1 cohort_1 #> # ℹ 4 more variables: target_cohort_table_name , strata_columns , #> # sex , age_group attrition(cdm$my_cohort) #> # A tibble: 16 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 10 6 1 Initial qualif… #> 2 1 8 6 2 filter strata:… #> 3 2 10 6 1 Initial qualif… #> 4 2 2 1 2 filter strata:… #> 5 3 10 6 1 Initial qualif… #> 6 3 8 6 2 filter strata:… #> 7 3 4 3 3 filter strata:… #> 8 4 10 6 1 Initial qualif… #> 9 4 8 6 2 filter strata:… #> 10 4 4 3 3 filter strata:… #> 11 5 10 6 1 Initial qualif… #> 12 5 2 1 2 filter strata:… #> 13 5 2 1 3 filter strata:… #> 14 6 10 6 1 Initial qualif… #> 15 6 2 1 2 filter strata:… #> 16 6 0 0 3 filter strata:… #> # ℹ 2 more variables: excluded_records , excluded_subjects # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","title":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","text":"subsetCohorts() filters existing cohort table, keeping records cohorts specified.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","text":"","code":"subsetCohorts(cohort, cohortId, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","text":"Cohort table cohorts cohortId.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> subsetCohorts(cohortId = 1) #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 4 1998-12-14 2002-02-14 #> 2 1 6 2003-04-11 2004-02-23 #> 3 1 7 2004-07-31 2004-11-23 #> 4 1 7 2004-11-24 2005-11-05 #> 5 1 7 2005-11-06 2012-01-12 #> 6 1 8 2009-09-13 2012-04-22 #> 7 1 9 2011-12-20 2011-12-20 #> 8 1 9 2011-12-21 2011-12-29 #> 9 1 9 2011-12-30 2012-04-02 #> 10 1 12 2000-11-15 2013-03-04 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimDemographics.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on patient demographics — trimDemographics","title":"Restrict cohort on patient demographics — trimDemographics","text":"trimDemographics() resets cohort start end date based specified demographic criteria satisfied.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimDemographics.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on patient demographics — trimDemographics","text":"","code":"trimDemographics( cohort, cohortId = NULL, ageRange = NULL, sex = NULL, minPriorObservation = NULL, minFutureObservation = NULL, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimDemographics.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on patient demographics — trimDemographics","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. ageRange list vectors specifying minimum maximum age. sex Can \"\", \"Male\" \"Female\". minPriorObservation minimum number continuous prior observation days database. minFutureObservation minimum number continuous future observation days database. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimDemographics.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on patient demographics — trimDemographics","text":"cohort table records individuals satisfying demographic requirements","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimDemographics.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on patient demographics — trimDemographics","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> trimDemographics(ageRange = list(c(10, 30))) #> ℹ Building new trimmed cohort #> Adding demographics information #> Creating initial cohort #> Trim age #> ✔ Cohort trimmed #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 38 1979-07-05 1981-02-09 #> 2 1 43 1990-02-26 1995-03-03 #> 3 1 51 1982-12-05 1997-10-16 #> 4 1 53 1998-02-23 1998-12-09 #> 5 1 74 2007-11-14 2008-11-21 #> 6 1 78 2001-08-27 2005-04-11 #> 7 1 38 1978-07-24 1979-07-04 #> 8 1 51 1979-04-13 1982-12-04 #> 9 1 53 1997-03-26 1998-02-22 #> 10 1 74 2007-06-26 2007-11-13 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimToDateRange.html","id":null,"dir":"Reference","previous_headings":"","what":"Trim cohort dates to be within a date range — trimToDateRange","title":"Trim cohort dates to be within a date range — trimToDateRange","text":"trimToDateRange() resets cohort start end date based specified date range.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimToDateRange.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Trim cohort dates to be within a date range — trimToDateRange","text":"","code":"trimToDateRange( cohort, dateRange, cohortId = NULL, startDate = \"cohort_start_date\", endDate = \"cohort_end_date\", name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimToDateRange.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Trim cohort dates to be within a date range — trimToDateRange","text":"cohort cohort table cdm reference. dateRange window time index date must observed. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. startDate Variable earliest date. endDate Variable latest date. name Name new cohort restriction.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimToDateRange.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Trim cohort dates to be within a date range — trimToDateRange","text":"cohort table record timings updated within date range. records time outside range dropped.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimToDateRange.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Trim cohort dates to be within a date range — trimToDateRange","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> trimToDateRange(startDate = \"cohort_start_date\", endDate = \"cohort_end_date\", dateRange = as.Date(c(\"2015-01-01\", \"2015-12-31\"))) #> # Source: table [0 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> # ℹ 4 variables: cohort_definition_id , subject_id , #> # cohort_start_date , cohort_end_date # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/unionCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate cohort from the union of different cohorts — unionCohorts","title":"Generate cohort from the union of different cohorts — unionCohorts","text":"unionCohorts() combines different cohort entries, records overlap combined kept. Cohort entries individual either cohorts.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/unionCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate cohort from the union of different cohorts — unionCohorts","text":"","code":"unionCohorts( cohort, cohortId = NULL, gap = 0, cohortName = NULL, keepOriginalCohorts = FALSE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/unionCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate cohort from the union of different cohorts — unionCohorts","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. gap Number days two subsequent cohort entries merged single cohort record. cohortName Name returned cohort. NULL, cohort name created collapsing individual cohort names, separated \"_\". keepOriginalCohorts TRUE original cohorts return together new ones. FALSE new cohort returned. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/unionCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate cohort from the union of different cohorts — unionCohorts","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/unionCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate cohort from the union of different cohorts — unionCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort2 <- cdm$cohort2 |> unionCohorts() #> Warning: `union_cohorts()` was deprecated in CDMConnector 1.1.0. #> ℹ Please use `cohort_union()` instead. settings(cdm$cohort2) #> Error in UseMethod(\"settings\"): no applicable method for 'settings' applied to an object of class \"c('cdm_table', 'GeneratedCohortSet', 'tbl_duckdb_connection', 'tbl_dbi', 'tbl_sql', 'tbl_lazy', 'tbl')\" # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/windowDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of window. — windowDoc","title":"Helper for consistent documentation of window. — windowDoc","text":"Helper consistent documentation window.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/windowDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of window. — windowDoc","text":"window list vectors specifying minimum maximum days indexDate consider events .","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/yearCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","title":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","text":"yearCohorts() splits cohort multiple cohorts, one year.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/yearCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","text":"","code":"yearCohorts(cohort, years, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/yearCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","text":"cohort cohort table cdm reference. years Numeric vector years use restrict observation .. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/yearCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/yearCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 <- cdm$cohort1 |> yearCohorts(years = 2000:2002) settings(cdm$cohort1) #> # A tibble: 3 × 5 #> cohort_definition_id cohort_name target_cohort_definition_id year #> #> 1 1 cohort_1_2000 1 2000 #> 2 2 cohort_1_2001 1 2001 #> 3 3 cohort_1_2002 1 2002 #> # ℹ 1 more variable: target_cohort_name # }"}] +[{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"Apache License","title":"Apache License","text":"Version 2.0, January 2004 ","code":""},{"path":[]},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_1-definitions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"1. Definitions","title":"Apache License","text":"“License” shall mean terms conditions use, reproduction, distribution defined Sections 1 9 document. “Licensor” shall mean copyright owner entity authorized copyright owner granting License. “Legal Entity” shall mean union acting entity entities control, controlled , common control entity. purposes definition, “control” means () power, direct indirect, cause direction management entity, whether contract otherwise, (ii) ownership fifty percent (50%) outstanding shares, (iii) beneficial ownership entity. “” (“”) shall mean individual Legal Entity exercising permissions granted License. “Source” form shall mean preferred form making modifications, including limited software source code, documentation source, configuration files. “Object” form shall mean form resulting mechanical transformation translation Source form, including limited compiled object code, generated documentation, conversions media types. “Work” shall mean work authorship, whether Source Object form, made available License, indicated copyright notice included attached work (example provided Appendix ). “Derivative Works” shall mean work, whether Source Object form, based (derived ) Work editorial revisions, annotations, elaborations, modifications represent, whole, original work authorship. purposes License, Derivative Works shall include works remain separable , merely link (bind name) interfaces , Work Derivative Works thereof. “Contribution” shall mean work authorship, including original version Work modifications additions Work Derivative Works thereof, intentionally submitted Licensor inclusion Work copyright owner individual Legal Entity authorized submit behalf copyright owner. purposes definition, “submitted” means form electronic, verbal, written communication sent Licensor representatives, including limited communication electronic mailing lists, source code control systems, issue tracking systems managed , behalf , Licensor purpose discussing improving Work, excluding communication conspicuously marked otherwise designated writing copyright owner “Contribution.” “Contributor” shall mean Licensor individual Legal Entity behalf Contribution received Licensor subsequently incorporated within Work.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_2-grant-of-copyright-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"2. Grant of Copyright License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable copyright license reproduce, prepare Derivative Works , publicly display, publicly perform, sublicense, distribute Work Derivative Works Source Object form.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_3-grant-of-patent-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"3. Grant of Patent License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable (except stated section) patent license make, made, use, offer sell, sell, import, otherwise transfer Work, license applies patent claims licensable Contributor necessarily infringed Contribution(s) alone combination Contribution(s) Work Contribution(s) submitted. institute patent litigation entity (including cross-claim counterclaim lawsuit) alleging Work Contribution incorporated within Work constitutes direct contributory patent infringement, patent licenses granted License Work shall terminate date litigation filed.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_4-redistribution","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"4. Redistribution","title":"Apache License","text":"may reproduce distribute copies Work Derivative Works thereof medium, without modifications, Source Object form, provided meet following conditions: () must give recipients Work Derivative Works copy License; (b) must cause modified files carry prominent notices stating changed files; (c) must retain, Source form Derivative Works distribute, copyright, patent, trademark, attribution notices Source form Work, excluding notices pertain part Derivative Works; (d) Work includes “NOTICE” text file part distribution, Derivative Works distribute must include readable copy attribution notices contained within NOTICE file, excluding notices pertain part Derivative Works, least one following places: within NOTICE text file distributed part Derivative Works; within Source form documentation, provided along Derivative Works; , within display generated Derivative Works, wherever third-party notices normally appear. contents NOTICE file informational purposes modify License. may add attribution notices within Derivative Works distribute, alongside addendum NOTICE text Work, provided additional attribution notices construed modifying License. may add copyright statement modifications may provide additional different license terms conditions use, reproduction, distribution modifications, Derivative Works whole, provided use, reproduction, distribution Work otherwise complies conditions stated License.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_5-submission-of-contributions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"5. Submission of Contributions","title":"Apache License","text":"Unless explicitly state otherwise, Contribution intentionally submitted inclusion Work Licensor shall terms conditions License, without additional terms conditions. Notwithstanding , nothing herein shall supersede modify terms separate license agreement may executed Licensor regarding Contributions.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_6-trademarks","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"6. Trademarks","title":"Apache License","text":"License grant permission use trade names, trademarks, service marks, product names Licensor, except required reasonable customary use describing origin Work reproducing content NOTICE file.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_7-disclaimer-of-warranty","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"7. Disclaimer of Warranty","title":"Apache License","text":"Unless required applicable law agreed writing, Licensor provides Work (Contributor provides Contributions) “” BASIS, WITHOUT WARRANTIES CONDITIONS KIND, either express implied, including, without limitation, warranties conditions TITLE, NON-INFRINGEMENT, MERCHANTABILITY, FITNESS PARTICULAR PURPOSE. solely responsible determining appropriateness using redistributing Work assume risks associated exercise permissions License.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_8-limitation-of-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"8. Limitation of Liability","title":"Apache License","text":"event legal theory, whether tort (including negligence), contract, otherwise, unless required applicable law (deliberate grossly negligent acts) agreed writing, shall Contributor liable damages, including direct, indirect, special, incidental, consequential damages character arising result License use inability use Work (including limited damages loss goodwill, work stoppage, computer failure malfunction, commercial damages losses), even Contributor advised possibility damages.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"id_9-accepting-warranty-or-additional-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"9. Accepting Warranty or Additional Liability","title":"Apache License","text":"redistributing Work Derivative Works thereof, may choose offer, charge fee , acceptance support, warranty, indemnity, liability obligations /rights consistent License. However, accepting obligations, may act behalf sole responsibility, behalf Contributor, agree indemnify, defend, hold Contributor harmless liability incurred , claims asserted , Contributor reason accepting warranty additional liability. END TERMS CONDITIONS","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/LICENSE.html","id":"appendix-how-to-apply-the-apache-license-to-your-work","dir":"","previous_headings":"","what":"APPENDIX: How to apply the Apache License to your work","title":"Apache License","text":"apply Apache License work, attach following boilerplate notice, fields enclosed brackets [] replaced identifying information. (Don’t include brackets!) text enclosed appropriate comment syntax file format. also recommend file class name description purpose included “printed page” copyright notice easier identification within third-party archives.","code":"Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a00_introduction.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Introduction","text":"CohortConstructor package designed support cohort building pipelines. using package general workflow first build set base cohorts subsequently apply inclusion criteria derive final study cohorts interest. Base cohorts built domain (rather cohort definition) one base cohort many study cohorts can derived.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a00_introduction.html","id":"building-a-cohort-set-by-domain","dir":"Articles","previous_headings":"","what":"Building a cohort set by domain","title":"Introduction","text":"Let´s say want build 5 cohorts 3 (asthma, copd, diabetes) defined based concepts seen condition occurrence table 2 (acetaminophen warfarin) based concepts recorded drug exposure table. can build cohorts independently, one . However, approach mean repeating 3 joins condition occurrence tables 2 joins drug exposure table (concepts concept sets). make less computationally expensive, instead create cohorts domain. case instead make one join condition occurrence table one drug exposure (using concept sets together).","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a00_introduction.html","id":"deriving-study-cohorts-from-base-cohorts","dir":"Articles","previous_headings":"","what":"Deriving study cohorts from base cohorts","title":"Introduction","text":"making study cohorts often concept sets define clinical event along various study-specific inclusion criteria, example criteria around amount prior observation age. Often may sensitivity analysis concept set remains inclusion criteria change. situations can make cohorts one--one. However, can lead duplication can see example identify asthma records multiple times. alternative approach build base cohort, case based asthma records, derive multiple cohorts different inclusion criteria applied.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a00_introduction.html","id":"considerations-when-building-cohorts","dir":"Articles","previous_headings":"","what":"Considerations when building cohorts","title":"Introduction","text":"CohortConstructor provides means building cohorts via pipeline, cohorts created application sequence functions. important note order sequence often important implications. example just one individual three recorded diagnoses asthma. One diagnosis 2008 two 2009, last coming individual´s 18th birthday. three cohort pipelines shown restrictions around calendar dates, age, record first. cohort pipeline , however, individual included final cohort, third diagnosis used cohort start. pipeline B C individual excluded.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a01_building_base_cohorts.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Building base cohorts","text":"Let’s first create cdm reference Eunomia synthetic data.","code":"library(CDMConnector) library(CodelistGenerator) library(PatientProfiles) library(CohortConstructor) library(dplyr) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdm_from_con(con, cdm_schema = \"main\", write_schema = c(prefix = \"my_study_\", schema = \"main\"))"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a01_building_base_cohorts.html","id":"concept-based-cohort-creation","dir":"Articles","previous_headings":"","what":"Concept based cohort creation","title":"Building base cohorts","text":"way defining base cohorts identify clinical records codes pre-specified list. example ’ll first find codes diclofenac acetaminophen. Now codes interest, ’ll make cohorts cohort exit defined event start date (drug exposure end date).","code":"drug_codes <- getDrugIngredientCodes(cdm, name = c(\"acetaminophen\", \"amoxicillin\", \"diclofenac\", \"simvastatin\", \"warfarin\")) drug_codes #> #> - 11289_warfarin (2 codes) #> - 161_acetaminophen (7 codes) #> - 3355_diclofenac (1 codes) #> - 36567_simvastatin (2 codes) #> - 723_amoxicillin (4 codes) cdm$drugs <- conceptCohort(cdm, conceptSet = drug_codes, exit = \"event_end_date\", name = \"drugs\") settings(cdm$drugs) #> # A tibble: 5 × 4 #> cohort_definition_id cohort_name cdm_version vocabulary_version #> #> 1 1 11289_warfarin 5.3 v5.0 18-JAN-19 #> 2 2 161_acetaminophen 5.3 v5.0 18-JAN-19 #> 3 3 3355_diclofenac 5.3 v5.0 18-JAN-19 #> 4 4 36567_simvastatin 5.3 v5.0 18-JAN-19 #> 5 5 723_amoxicillin 5.3 v5.0 18-JAN-19 cohortCount(cdm$drugs) #> # A tibble: 5 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 137 137 #> 2 2 13908 2679 #> 3 3 830 830 #> 4 4 182 182 #> 5 5 4307 2130 attrition(cdm$drugs) #> # A tibble: 20 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 137 137 1 Initial qualif… #> 2 1 137 137 2 Record start <… #> 3 1 137 137 3 Record in obse… #> 4 1 137 137 4 Collapse overl… #> 5 2 14205 2679 1 Initial qualif… #> 6 2 14205 2679 2 Record start <… #> 7 2 14205 2679 3 Record in obse… #> 8 2 13908 2679 4 Collapse overl… #> 9 3 850 850 1 Initial qualif… #> 10 3 850 850 2 Record start <… #> 11 3 830 830 3 Record in obse… #> 12 3 830 830 4 Collapse overl… #> 13 4 182 182 1 Initial qualif… #> 14 4 182 182 2 Record start <… #> 15 4 182 182 3 Record in obse… #> 16 4 182 182 4 Collapse overl… #> 17 5 4309 2130 1 Initial qualif… #> 18 5 4309 2130 2 Record start <… #> 19 5 4309 2130 3 Record in obse… #> 20 5 4307 2130 4 Collapse overl… #> # ℹ 2 more variables: excluded_records , excluded_subjects "},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a01_building_base_cohorts.html","id":"demographic-based-cohort-creation","dir":"Articles","previous_headings":"","what":"Demographic based cohort creation","title":"Building base cohorts","text":"One base cohort can create based around patient demographics. example create cohort people enter 18th birthday leave day 66th birthday.","code":"cdm$working_age_cohort <- demographicsCohort(cdm = cdm, ageRange = c(18, 65), name = \"working_age_cohort\")"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_cohort_table_requirements.html","id":"keep-only-the-first-record-per-person","dir":"Articles","previous_headings":"","what":"Keep only the first record per person","title":"Applying cohort table requirements","text":"can see starting cohort individuals multiple entries use acetaminophen. However, keep earliest cohort entry using requireIsFirstEntry() CohortConstructor. number individuals remains unchanged, records individual’s first excluded. wanted keep latest record per person instead earliest use requireIsLastEntry() instead. want keep range records per person can use requireIsEntry() function.","code":"cdm$acetaminophen <- cdm$acetaminophen |> requireIsFirstEntry() summary_attrition <- summariseCohortAttrition(cdm$acetaminophen) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_cohort_table_requirements.html","id":"keep-only-records-within-a-date-range","dir":"Articles","previous_headings":"","what":"Keep only records within a date range","title":"Applying cohort table requirements","text":"Individuals may contribute multiple records extended periods. can filter records fall outside specified date range using requireInDateRange function.","code":"cdm$acetaminophen <- conceptCohort(cdm = cdm, conceptSet = acetaminophen_codes, name = \"acetaminophen\") cdm$acetaminophen <- cdm$acetaminophen |> requireInDateRange(dateRange = as.Date(c(\"2010-01-01\", \"2015-01-01\"))) summary_attrition <- summariseCohortAttrition(cdm$acetaminophen) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_cohort_table_requirements.html","id":"applying-multiple-cohort-requirements","dir":"Articles","previous_headings":"","what":"Applying multiple cohort requirements","title":"Applying cohort table requirements","text":"Multiple restrictions can applied cohort, however important note order requirements applied often matter. see attrition apply entry requirement date requirement. case cohort people first ever record acetaminophen occurs study period. see attrition apply date requirement entry requirement. case cohort people first record acetaminophen study period, although necessarily first record ever.","code":"cdm$acetaminophen_1 <- conceptCohort(cdm = cdm, conceptSet = acetaminophen_codes, name = \"acetaminophen_1\") |> requireIsFirstEntry() |> requireInDateRange(dateRange = as.Date(c(\"2010-01-01\", \"2016-01-01\"))) cdm$acetaminophen_2 <- conceptCohort(cdm = cdm, conceptSet = acetaminophen_codes, name = \"acetaminophen_2\") |> requireInDateRange(dateRange = as.Date(c(\"2010-01-01\", \"2016-01-01\"))) |> requireIsFirstEntry() summary_attrition_1 <- summariseCohortAttrition(cdm$acetaminophen_1) summary_attrition_2 <- summariseCohortAttrition(cdm$acetaminophen_2) plotCohortAttrition(summary_attrition_1) plotCohortAttrition(summary_attrition_2)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_cohort_table_requirements.html","id":"keep-only-records-from-cohorts-with-a-minimum-number-of-individuals","dir":"Articles","previous_headings":"","what":"Keep only records from cohorts with a minimum number of individuals","title":"Applying cohort table requirements","text":"Another useful functionality, particularly working multiple cohorts performing network study, provided requireMinCohortCount. keep cohorts minimum count, filtering records cohorts fewer number. example let’s create cohort every drug ingredient see Eunomia. can first get drug ingredient codes. can see make cohorts many small number individuals. apply minimum cohort count 500, end far fewer cohorts sufficient number study participants.","code":"medication_codes <- getDrugIngredientCodes(cdm = cdm, nameStyle = \"{concept_name}\") medication_codes #> #> - acetaminophen (7 codes) #> - albuterol (2 codes) #> - alendronate (2 codes) #> - alfentanil (1 codes) #> - alteplase (2 codes) #> - amiodarone (2 codes) #> along with 85 more codelists cdm$medications <- conceptCohort(cdm = cdm, conceptSet = medication_codes, name = \"medications\") cohortCount(cdm$medications) |> filter(number_subjects > 0) |> ggplot() + geom_histogram(aes(number_subjects), colour = \"black\", binwidth = 25) + xlab(\"Number of subjects\") + theme_bw() cdm$medications <- cdm$medications |> requireMinCohortCount(minCohortCount = 500) cohortCount(cdm$medications) |> filter(number_subjects > 0) |> ggplot() + geom_histogram(aes(number_subjects), colour = \"black\", binwidth = 25) + xlim(0, NA) + xlab(\"Number of subjects\") + theme_bw()"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_require_demographics.html","id":"restrict-cohort-by-age","dir":"Articles","previous_headings":"","what":"Restrict cohort by age","title":"Applying demographic requirements to a cohort","text":"can choose specific age range individuals cohort using requireAge() CohortConstructor. Note default individuals filtered based age entered cohort.","code":"cdm$fracture <- cdm$fracture |> requireAge(indexDate = \"cohort_start_date\", ageRange = list(c(18, 100))) summary_attrition <- summariseCohortAttrition(cdm$fracture) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_require_demographics.html","id":"restrict-cohort-by-sex","dir":"Articles","previous_headings":"","what":"Restrict cohort by sex","title":"Applying demographic requirements to a cohort","text":"can also specify sex criteria individuals cohort using requireSex() CohortConstructor.","code":"cdm$fracture <- cdm$fracture |> requireSex(sex = \"Female\") summary_attrition <- summariseCohortAttrition(cdm$fracture) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_require_demographics.html","id":"restrict-cohort-by-number-of-prior-observations","dir":"Articles","previous_headings":"","what":"Restrict cohort by number of prior observations","title":"Applying demographic requirements to a cohort","text":"can also specify minimum number days prior observations individual using requirePriorObservation() CohortConstructor. well specifying minimum amount prior observation, can require mimimum amount follow-using requireFutureObservation() similar way.","code":"cdm$fracture <- cdm$fracture |> requirePriorObservation(indexDate = \"cohort_start_date\", minPriorObservation = 365) summary_attrition <- summariseCohortAttrition(cdm$fracture) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_require_demographics.html","id":"applying-multiple-demographic-requirements-to-a-cohort","dir":"Articles","previous_headings":"","what":"Applying multiple demographic requirements to a cohort","title":"Applying demographic requirements to a cohort","text":"can implement multiple demographic requirements time using general requireDemographics() function.","code":"cdm$fracture <- conceptCohort(cdm = cdm, conceptSet = fracture_codes, name = \"fracture\") |> requireDemographics(indexDate = \"cohort_start_date\", ageRange = c(18,100), sex = \"Female\", minPriorObservation = 365, minFutureObservation = 30) summary_attrition <- summariseCohortAttrition(cdm$fracture) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a04_require_intersections.html","id":"restrictions-on-cohort-presence","dir":"Articles","previous_headings":"","what":"Restrictions on cohort presence","title":"Applying requirements related to other cohorts, concept sets, or tables","text":"require individuals medication cohorts seen (seen) another cohort. can use requireCohortIntersect() function. , example, require individuals one intersections GI bleed cohort. flow chart illustrates changes cohort users acetaminophen restricted include individuals least one record GI bleed cohort start date acetaminophen. Instead requiring individuals record GI bleed cohort, instead require don’t. case can use requireCohortIntersect() function, time set intersections argument 0 require individuals’ absence cohort.","code":"cdm$warfarin_gi_bleed <- cdm$warfarin |> requireCohortIntersect(intersections = c(1,Inf), targetCohortTable = \"gi_bleed\", targetCohortId = 1, indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"warfarin_gi_bleed\") summary_attrition <- summariseCohortAttrition(cdm$warfarin_gi_bleed) plotCohortAttrition(summary_attrition) cdm$warfarin_no_gi_bleed <- cdm$warfarin |> requireCohortIntersect(intersections = 0, targetCohortTable = \"gi_bleed\", targetCohortId = 1, indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"warfarin_no_gi_bleed\") summary_attrition <- summariseCohortAttrition(cdm$warfarin_no_gi_bleed) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a04_require_intersections.html","id":"restrictions-on-concept-presence","dir":"Articles","previous_headings":"","what":"Restrictions on concept presence","title":"Applying requirements related to other cohorts, concept sets, or tables","text":"require individuals medication cohorts seen (seen) events related concept list. can use requireConceptIntersect() function, allowing us filter cohort based whether events GI bleeding entered cohort. flow chart illustrates changes cohort 1 restricted include individuals events GI bleeding least cohort start date. 2,296 individuals 8,765 records excluded. Instead requiring individuals events GI bleeding, instead require don’t events . case can use requireConceptIntersect() function, time set intersections argument 0 require individuals without past events GI bleeding.","code":"cdm$warfarin_gi_bleed <- cdm$warfarin |> requireConceptIntersect(conceptSet = list(\"gi_bleed\" = 192671), indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"warfarin_gi_bleed\") summary_attrition <- summariseCohortAttrition(cdm$warfarin_gi_bleed) plotCohortAttrition(summary_attrition) cdm$warfarin_no_gi_bleed <- cdm$warfarin |> requireConceptIntersect(intersections = 0, conceptSet = list(\"gi_bleed\" = 192671), indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"warfarin_no_gi_bleed\") summary_attrition <- summariseCohortAttrition(cdm$warfarin_no_gi_bleed) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a04_require_intersections.html","id":"restrictions-on-presence-in-clinical-tables","dir":"Articles","previous_headings":"","what":"Restrictions on presence in clinical tables","title":"Applying requirements related to other cohorts, concept sets, or tables","text":"can also impose requirements around individuals presence (absence) clinical tables OMOP CDM using requireTableIntersect() function. example reuire individuals warfarin cohort least one prior record visit occurrence table.","code":"cdm$warfarin_visit <- cdm$warfarin |> requireTableIntersect(tableName = \"visit_occurrence\", indexDate = \"cohort_start_date\", window = c(-Inf, -1), name = \"warfarin_visit\") summary_attrition <- summariseCohortAttrition(cdm$warfarin_visit) plotCohortAttrition(summary_attrition)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Generating a matched cohort","text":"CohortConstructor packages includes function obtain age sex matched cohort, generateMatchedCohortSet() function. vignette, explore usage function.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"create-mock-data","dir":"Articles","previous_headings":"Introduction","what":"Create mock data","title":"Generating a matched cohort","text":"first use mockDrugUtilisation() function DrugUtilisation package create mock data. use cohort1 explore generateMatchedCohortSet(), let us first use cohort_attrition() CDMConnector package explore cohort:","code":"library(CohortConstructor) library(dplyr) cdm <- mockCohortConstructor(nPerson = 1000) CDMConnector::cohort_set(cdm$cohort1)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"use-generatematchedcohortset-to-create-an-age-sex-matched-cohort","dir":"Articles","previous_headings":"","what":"Use generateMatchedCohortSet() to create an age-sex matched cohort","title":"Generating a matched cohort","text":"Let us first see example function works. usage, need provide cdm object, targetCohortName, name table containing cohort interest, name new generated tibble containing cohort matched cohort. also use argument targetCohortId specify want matched cohort cohort_definition_id = 1. Notice generated tibble, two cohorts: cohort_definition_id = 1 (original cohort), cohort_definition_id = 4 (matched cohort). target_cohort_name column indicates original cohort. match_sex match_year_of_birth adopt boolean values (TRUE/FALSE) indicating matched sex age, . match_status indicate original cohort (target) matched cohort (matched). target_cohort_id indicates cohort_id original cohort. Check exclusion criteria applied generate new cohorts using cohort_attrition() CDMConnector package: Briefly, original cohort, exclude first individuals match, individuals matching pair observation assigned cohort_start_date. matched cohort, start whole database first exclude individuals original cohort. Afterwards, exclude individuals match, individuals observation assigned cohort_start_date, finally remove many individuals required fulfill ratio. Notice matching pairs randomly assigned, probable every time execute function, generated cohorts change. Use set.seed() avoid .","code":"cdm$matched_cohort1 <- matchCohorts( cohort = cdm$cohort1, cohortId = 1, name = \"matched_cohort1\") CDMConnector::cohort_set(cdm$matched_cohort1) # Original cohort CDMConnector::cohort_attrition(cdm$matched_cohort1) |> filter(cohort_definition_id == 1) # Matched cohort CDMConnector::cohort_attrition(cdm$matched_cohort1) |> filter(cohort_definition_id == 4)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"matchsex-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"matchSex parameter","title":"Generating a matched cohort","text":"matchSex boolean parameter (TRUE/FALSE) indicating want match sex (TRUE) want (FALSE).","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"matchyear-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"matchYear parameter","title":"Generating a matched cohort","text":"matchYear another boolean parameter (TRUE/FALSE) indicating want match age (TRUE) want (FALSE). Notice matchSex = FALSE matchYear = FALSE, obtain unmatched comparator cohort.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"ratio-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"ratio parameter","title":"Generating a matched cohort","text":"default matching ratio 1:1 (ratio = 1). Use cohort_counts() CDMConnector check matching done desired. can modify ratio parameter tailor matched cohort. ratio can adopt values 1 Inf.","code":"CDMConnector::cohort_count(cdm$matched_cohort1) cdm$matched_cohort2 <- matchCohorts( cohort = cdm$cohort1, cohortId = 1, name = \"matched_cohort2\", ratio = Inf) CDMConnector::cohort_count(cdm$matched_cohort2)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a10_match_cohorts.html","id":"generate-matched-cohorts-simultaneously-across-multiple-cohorts","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"Generate matched cohorts simultaneously across multiple cohorts","title":"Generating a matched cohort","text":"functionalities can implemented across multiple cohorts simultaneously. Specify targetCohortId parameter cohorts interest. set NULL, cohorts present targetCohortName matched. Notice cohort (independent cohorts) matched cohort.","code":"cdm$matched_cohort3 <- matchCohorts( cohort = cdm$cohort1, cohortId = c(1,3), name = \"matched_cohort3\", ratio = 2) CDMConnector::cohort_set(cdm$matched_cohort3) |> arrange(cohort_definition_id) CDMConnector::cohort_count(cdm$matched_cohort3) |> arrange(cohort_definition_id)"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"CohortConstructor benchmarking results","text":"Cohorts fundamental building block studies use OMOP CDM, identifying people satisfy one inclusion criteria duration time based clinical records. Currently cohorts typically built using CIRCE allows complex cohorts represented using JSON. JSON converted SQL execution database containing data mapped OMOP CDM. CIRCE JSON can created via ATLAS GUI programmatically via Capr R package. However, although powerful tool expressing operationalising cohort definitions, SQL generated can cumbersome especially complex cohort definitions, moreover cohorts instantiated independently, leading duplicated work. CohortConstructor package offers alternative approach, emphasizing cohort building pipeline format. first creates base cohorts applies specific inclusion criteria. Unlike “definition” approach, ::cohorts built independently, CohortConstructor follows “domain” approach, minimizes redundant queries large OMOP tables. details approach can found Introduction vignette. benchmarked package using nine phenotypes OHDSI Phenotype library cover range concept domains, entry inclusion criteria, cohort exit options. replicated cohorts using CodelistGenerator CohortConstructor assess computational time agreement CIRCE CohortConstructor.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"code-and-collaboration","dir":"Articles","previous_headings":"Introduction","what":"Code and collaboration","title":"CohortConstructor benchmarking results","text":"benchmarking code available BenchmarkCohortConstructor repository GitHub. interested running code database, feel free reach us assistance, can also update vignette results! :) benchmark script executed following four databases: CPRD Gold: primary care database UK, capturing data mostly Northern Ireland, Wales, Scotland clinics. benchmark utilized 100,000-person sample dataset, managed using PostgreSQL. CPRD Aurum: Another UK primary care database, primarily covering clinics England. database managed SQL Server. Coriva: sample approximately 400,000 patients Estonia National Health Insurance database, managed PostgreSQL. OHDSI SQL Server: mock OMOP CDM dataset provided OHDSI, hosted SQL Server. table presents number records OMOP tables used benchmark script participating databases.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"cohorts","dir":"Articles","previous_headings":"","what":"Cohorts","title":"CohortConstructor benchmarking results","text":"replicated following cohorts OHDSI phenotype library: COVID-19 (ID 56), inpatient hospitalisation (23), new users beta blockers nested essential hypertension (1049), transverse myelitis (63), major non cardiac surgery (1289), asthma without COPD (27), endometriosis procedure (722), new fluoroquinolone users (1043), acquired neutropenia unspecified leukopenia (213). COVID-19 cohort used evaluate performance common cohort stratifications. compare package CIRCE, created definitions Atlas, stratified age groups sex, available benchmark GitHub repository benchmark code.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"cohort-counts-and-overlap","dir":"Articles","previous_headings":"Cohorts","what":"Cohort counts and overlap","title":"CohortConstructor benchmarking results","text":"following table displays number records subjects cohort across participating databases: also computed overlap patients CIRCE CohortConstructor cohorts, results shown plot :","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"performance","dir":"Articles","previous_headings":"","what":"Performance","title":"CohortConstructor benchmarking results","text":"evaluate CohortConstructor performance generated CIRCE cohorts using functionalities provided CodelistGenerator CohortConstructor, measured computational time taken. Two different approaches CohortConstructor tested: definition: created cohorts seprately. domain: nine targeted cohorts created together set, following domain approach described Introduction vignette. Briefly, approach involves creating base cohorts , requiring one call involved OMOP table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"by-definition","dir":"Articles","previous_headings":"Performance","what":"By definition","title":"CohortConstructor benchmarking results","text":"following plot shows times taken create cohort using CIRCE CohortConstructor cohorts created separately.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"by-domain","dir":"Articles","previous_headings":"Performance","what":"By domain","title":"CohortConstructor benchmarking results","text":"table depicts total time took create nine cohorts using domain approach CohortConstructor.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"cohort-stratification","dir":"Articles","previous_headings":"Performance","what":"Cohort stratification","title":"CohortConstructor benchmarking results","text":"Cohorts often stratified studies. Atlas cohort definitions, stratum requires new CIRCE JSON instantiated, CohortConstructor allows stratifications generated overall cohort. following table shows time taken create age sex stratifications COVID-19 cohort CIRCE CohortConstructor.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a11_benchmark.html","id":"use-of-sql-indexes","dir":"Articles","previous_headings":"Performance","what":"Use of SQL indexes","title":"CohortConstructor benchmarking results","text":"Postgres SQL databases, package uses indexes conceptCohort default. evaluate much indexes reduce computation time, instantiated subset concept sets benchmark, without indexes. Four calls made conceptCohort, involving different number OMOP tables. combinations : Drug exposure Drug exposure + condition occurrence Drug exposure + condition occurrence + procedure occurrence Drug exposure + condition occurrence + procedure occurrence + measurement plot shows computation time without SQL indexes scenario:","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Edward Burn. Author, maintainer. Marti Catala. Author. Nuria Mercade-Besora. Author. Marta Alcalde-Herraiz. Author. Mike Du. Author. Yuchen Guo. Author. Xihang Chen. Author. Kim Lopez-Guell. Author. Elin Rowlands. Author.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Burn E, Catala M, Mercade-Besora N, Alcalde-Herraiz M, Du M, Guo Y, Chen X, Lopez-Guell K, Rowlands E (2024). CohortConstructor: Build Manipulate Study Cohorts Using Common Data Model. R package version 0.3.1.900, https://github.com/OHDSI/CohortConstructor, https://ohdsi.github.io/CohortConstructor/.","code":"@Manual{, title = {CohortConstructor: Build and Manipulate Study Cohorts Using a Common Data Model}, author = {Edward Burn and Marti Catala and Nuria Mercade-Besora and Marta Alcalde-Herraiz and Mike Du and Yuchen Guo and Xihang Chen and Kim Lopez-Guell and Elin Rowlands}, year = {2024}, note = {R package version 0.3.1.900, https://github.com/OHDSI/CohortConstructor}, url = {https://ohdsi.github.io/CohortConstructor/}, }"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"cohortconstructor-","dir":"","previous_headings":"","what":"Build and Manipulate Study Cohorts Using a Common Data Model","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"goal CohortConstructor support creation manipulation study cohorts data mapped OMOP CDM.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"package can installed CRAN: can install development version package GitHub:","code":"install.packages(\"CohortConstructor\") # install.packages(\"devtools\") devtools::install_github(\"ohdsi/CohortConstructor\")"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"creating-and-manipulating-cohorts","dir":"","previous_headings":"","what":"Creating and manipulating cohorts","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"illustrate functionality provided CohortConstructor let’s create cohort people fracture using Eunomia dataset. ’ll first load required packages create cdm reference data.","code":"library(omopgenerics) library(CDMConnector) library(PatientProfiles) library(dplyr) library(CohortConstructor) library(CohortCharacteristics) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdm_from_con(con, cdm_schema = \"main\", write_schema = c(prefix = \"my_study_\", schema = \"main\")) #> Note: method with signature 'DBIConnection#Id' chosen for function 'dbExistsTable', #> target signature 'duckdb_connection#Id'. #> \"duckdb_connection#ANY\" would also be valid cdm #> #> ── # OMOP CDM reference (duckdb) of Synthea synthetic health database ────────── #> • omop tables: person, observation_period, visit_occurrence, visit_detail, #> condition_occurrence, drug_exposure, procedure_occurrence, device_exposure, #> measurement, observation, death, note, note_nlp, specimen, fact_relationship, #> location, care_site, provider, payer_plan_period, cost, drug_era, dose_era, #> condition_era, metadata, cdm_source, concept, vocabulary, domain, #> concept_class, concept_relationship, relationship, concept_synonym, #> concept_ancestor, source_to_concept_map, drug_strength #> • cohort tables: - #> • achilles tables: - #> • other tables: -"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"generating-concept-based-fracture-cohorts","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Generating concept-based fracture cohorts","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"first need identify codes used represent fractures interest. find ’ll use CodelistGenerator package (note, just find codes using synthetic data subset full vocabularies). Now can quickly create cohorts. need provide codes defined get cohort back, start setting cohort exit day event start (date fracture). creating initial cohort update exit set 180 days start (long individuals’ observation end date - , exit observation period end). can see starting cohorts, add additional restrictions, following associated settings, counts, attrition.","code":"library(CodelistGenerator) hip_fx_codes <- getCandidateCodes(cdm, \"hip fracture\") #> Limiting to domains of interest #> Getting concepts to include #> Adding descendants #> Search completed. Finishing up. #> ✔ 1 candidate concept identified #> #> Time taken: 0 minutes and 0 seconds forearm_fx_codes <- getCandidateCodes(cdm, \"forearm fracture\") #> Limiting to domains of interest #> Getting concepts to include #> Adding descendants #> Search completed. Finishing up. #> ✔ 1 candidate concept identified #> #> Time taken: 0 minutes and 0 seconds fx_codes <- newCodelist(list(\"hip_fracture\" = hip_fx_codes$concept_id, \"forearm_fracture\"= forearm_fx_codes$concept_id)) fx_codes #> #> ── 2 codelists ───────────────────────────────────────────────────────────────── #> #> - forearm_fracture (1 codes) #> - hip_fracture (1 codes) cdm$fractures <- cdm |> conceptCohort(conceptSet = fx_codes, exit = \"event_start_date\", name = \"fractures\") cdm$fractures <- cdm$fractures |> padCohortEnd(days = 180) settings(cdm$fractures) |> glimpse() #> Rows: 2 #> Columns: 4 #> $ cohort_definition_id 1, 2 #> $ cohort_name \"forearm_fracture\", \"hip_fracture\" #> $ cdm_version \"5.3\", \"5.3\" #> $ vocabulary_version \"v5.0 18-JAN-19\", \"v5.0 18-JAN-19\" cohort_count(cdm$fractures) |> glimpse() #> Rows: 2 #> Columns: 3 #> $ cohort_definition_id 1, 2 #> $ number_records 569, 138 #> $ number_subjects 510, 132 attrition(cdm$fractures) |> glimpse() #> Rows: 4 #> Columns: 7 #> $ cohort_definition_id 1, 1, 2, 2 #> $ number_records 569, 569, 138, 138 #> $ number_subjects 510, 510, 132, 132 #> $ reason_id 1, 2, 1, 2 #> $ reason \"Initial qualifying events\", \"Pad cohort start da… #> $ excluded_records 0, 0, 0, 0 #> $ excluded_subjects 0, 0, 0, 0"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"create-an-overall-fracture-cohort","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Create an overall fracture cohort","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"far created three separate fracture cohorts. Let’s say also want cohort people fractures. union three cohorts create overall cohort like :","code":"cdm$fractures <- unionCohorts(cdm$fractures, cohortName = \"any_fracture\", keepOriginalCohorts = TRUE, name =\"fractures\") settings(cdm$fractures) #> # A tibble: 3 × 5 #> cohort_definition_id cohort_name cdm_version vocabulary_version gap #> #> 1 1 forearm_fracture 5.3 v5.0 18-JAN-19 NA #> 2 2 hip_fracture 5.3 v5.0 18-JAN-19 NA #> 3 3 any_fracture 0 cohortCount(cdm$fractures) #> # A tibble: 3 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 569 510 #> 2 2 138 132 #> 3 3 707 611"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"require-in-date-range","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Require in date range","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"created base fracture cohort, can start applying additional cohort requirements. example, first can require individuals’ cohort start date fall within certain date range. Now ’ve applied date restriction, can see cohort attributes updated","code":"cdm$fractures <- cdm$fractures |> requireInDateRange(dateRange = as.Date(c(\"2000-01-01\", \"2020-01-01\"))) cohort_count(cdm$fractures) |> glimpse() #> Rows: 3 #> Columns: 3 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 152, 62, 214 #> $ number_subjects 143, 60, 196 attrition(cdm$fractures) |> filter(reason == \"cohort_start_date between 2000-01-01 & 2020-01-01\") |> glimpse() #> Rows: 0 #> Columns: 7 #> $ cohort_definition_id #> $ number_records #> $ number_subjects #> $ reason_id #> $ reason #> $ excluded_records #> $ excluded_subjects "},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"applying-demographic-requirements","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Applying demographic requirements","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"can also add restrictions patient characteristics age (cohort start date default) sex. can see many individuals ’ve lost applying criteria.","code":"cdm$fractures <- cdm$fractures |> requireDemographics(ageRange = list(c(40, 65)), sex = \"Female\") attrition(cdm$fractures) |> filter(reason == \"Age requirement: 40 to 65\") |> glimpse() #> Rows: 3 #> Columns: 7 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 64, 22, 86 #> $ number_subjects 62, 22, 83 #> $ reason_id 5, 5, 4 #> $ reason \"Age requirement: 40 to 65\", \"Age requirement: 40… #> $ excluded_records 88, 40, 128 #> $ excluded_subjects 81, 38, 113 attrition(cdm$fractures) |> filter(reason == \"Sex requirement: Female\") |> glimpse() #> Rows: 3 #> Columns: 7 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 37, 12, 49 #> $ number_subjects 36, 12, 48 #> $ reason_id 6, 6, 5 #> $ reason \"Sex requirement: Female\", \"Sex requirement: Fema… #> $ excluded_records 27, 10, 37 #> $ excluded_subjects 26, 10, 35"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"require-presence-in-another-cohort","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Require presence in another cohort","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"can also require individuals () another cohort window. example require study participants GI bleed cohort time prior entry fractures cohort.","code":"cdm$gibleed <- cdm |> conceptCohort(conceptSet = list(\"gibleed\" = 192671L), name = \"gibleed\") cdm$fractures <- cdm$fractures |> requireCohortIntersect(targetCohortTable = \"gibleed\", intersections = 0, window = c(-Inf, 0)) attrition(cdm$fractures) |> filter(reason == \"Not in cohort gibleed between -Inf & 0 days relative to cohort_start_date\") |> glimpse() #> Rows: 3 #> Columns: 7 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 30, 10, 40 #> $ number_subjects 30, 10, 40 #> $ reason_id 9, 9, 8 #> $ reason \"Not in cohort gibleed between -Inf & 0 days rela… #> $ excluded_records 7, 2, 9 #> $ excluded_subjects 6, 2, 8 cdmDisconnect(cdm)"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"more-information","dir":"","previous_headings":"Creating and manipulating cohorts","what":"More information","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"CohortConstructor provides much functionality creating manipulating cohorts. See package vignettes details.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/CohortConstructor-package.html","id":null,"dir":"Reference","previous_headings":"","what":"CohortConstructor: Build and Manipulate Study Cohorts Using a Common Data Model — CohortConstructor-package","title":"CohortConstructor: Build and Manipulate Study Cohorts Using a Common Data Model — CohortConstructor-package","text":"Create manipulate study cohorts data mapped Observational Medical Outcomes Partnership Common Data Model.","code":""},{"path":[]},{"path":"https://ohdsi.github.io/CohortConstructor/reference/CohortConstructor-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"CohortConstructor: Build and Manipulate Study Cohorts Using a Common Data Model — CohortConstructor-package","text":"Maintainer: Edward Burn edward.burn@ndorms.ox.ac.uk (ORCID) Authors: Marti Catala marti.catalasabate@ndorms.ox.ac.uk (ORCID) Nuria Mercade-Besora nuria.mercadebesora@ndorms.ox.ac.uk (ORCID) Marta Alcalde-Herraiz marta.alcaldeherraiz@ndorms.ox.ac.uk (ORCID) Mike Du mike.du@ndorms.ox.ac.uk (ORCID) Yuchen Guo yuchen.guo@ndorms.ox.ac.uk (ORCID) Xihang Chen xihang.chen@ndorms.ox.ac.uk (ORCID) Kim Lopez-Guell kim.lopez@spc.ox.ac.uk (ORCID) Elin Rowlands elin.rowlands@ndorms.ox.ac.uk (ORCID)","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/benchmarkData.html","id":null,"dir":"Reference","previous_headings":"","what":"Benchmarking results — benchmarkData","title":"Benchmarking results — benchmarkData","text":"Benchmarking results","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/benchmarkData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Benchmarking results — benchmarkData","text":"","code":"benchmarkData"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/benchmarkData.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Benchmarking results — benchmarkData","text":"list results benchmarking","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cdmDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of cdm. — cdmDoc","title":"Helper for consistent documentation of cdm. — cdmDoc","text":"Helper consistent documentation cdm.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cdmDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of cdm. — cdmDoc","text":"cdm cdm reference.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of cohort. — cohortDoc","title":"Helper for consistent documentation of cohort. — cohortDoc","text":"Helper consistent documentation cohort.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of cohort. — cohortDoc","text":"cohort cohort table cdm reference.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortIdModifyDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of cohortId. — cohortIdModifyDoc","title":"Helper for consistent documentation of cohortId. — cohortIdModifyDoc","text":"Helper consistent documentation cohortId.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortIdModifyDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of cohortId. — cohortIdModifyDoc","text":"cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortIdSubsetDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of cohortId. — cohortIdSubsetDoc","title":"Helper for consistent documentation of cohortId. — cohortIdSubsetDoc","text":"Helper consistent documentation cohortId.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/cohortIdSubsetDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of cohortId. — cohortIdSubsetDoc","text":"cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/collapseCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse cohort entries using a certain gap to concatenate records. — collapseCohorts","title":"Collapse cohort entries using a certain gap to concatenate records. — collapseCohorts","text":"collapseCohorts() concatenates cohort records, allowing number days one finishing next starting.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/collapseCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse cohort entries using a certain gap to concatenate records. — collapseCohorts","text":"","code":"collapseCohorts(cohort, cohortId = NULL, gap = 0, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/collapseCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse cohort entries using a certain gap to concatenate records. — collapseCohorts","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. gap Number days two subsequent cohort entries merged single cohort record. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/collapseCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse cohort entries using a certain gap to concatenate records. — collapseCohorts","text":"cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/columnDateDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of dateColumns and returnReason. — columnDateDoc","title":"Helper for consistent documentation of dateColumns and returnReason. — columnDateDoc","text":"Helper consistent documentation dateColumns returnReason.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/columnDateDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of dateColumns and returnReason. — columnDateDoc","text":"dateColumns Character vector indicating date columns cohort table consider. returnReason TRUE return column indicating dateColumns used.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptCohort.html","id":null,"dir":"Reference","previous_headings":"","what":"Create cohorts based on a concept set — conceptCohort","title":"Create cohorts based on a concept set — conceptCohort","text":"conceptCohort() creates cohort table patient records clinical tables OMOP CDM. following tables currently supported creating concept cohorts: condition_occurrence device_exposure drug_exposure measurement observation procedure_occurrence visit_occurrence Cohort duration based record start end (e.g. condition_start_date condition_end_date records coming condition_occurrence tables). resulting table satisfies requirements OMOP CDM cohort table: Overlapping records collapsed single cohort entry. record starts outside observation period silently ignored. record ends outside observation period trimmed end preceding observation period end date.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptCohort.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create cohorts based on a concept set — conceptCohort","text":"","code":"conceptCohort( cdm, conceptSet, name, exit = \"event_end_date\", useSourceFields = FALSE, subsetCohort = NULL, subsetCohortId = NULL )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptCohort.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create cohorts based on a concept set — conceptCohort","text":"cdm cdm reference. conceptSet conceptSet, can either codelist conceptSetExpression. name Name new cohort table created cdm object. exit cohort end date defined. Can either \"event_end_date\" \"event_start_date\". useSourceFields TRUE, source concept_id fields also used identifying relevant clinical records. FALSE, standard concept_id fields used. subsetCohort cohort table containing individuals cohorts generated. individuals table appear generated cohort. subsetCohortId Optional. Specifies cohort IDs subsetCohort table include. none provided, cohorts subsetCohort included.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptCohort.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create cohorts based on a concept set — conceptCohort","text":"cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptCohort.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create cohorts based on a concept set — conceptCohort","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(conditionOccurrence = TRUE) #> Note: method with signature ‘DBIConnection#Id’ chosen for function ‘dbExistsTable’, #> target signature ‘duckdb_connection#Id’. #> \"duckdb_connection#ANY\" would also be valid cohort <- conceptCohort(cdm = cdm, conceptSet = list(a = 1), name = \"cohort\") #> Warning: ! `codelist` contains numeric values, they are casted to integers. #> ✖ Domain NA (1 concept) excluded because it is not supported. #> ℹ No cohort entries found, returning empty cohort table. cohort |> attrition() #> # A tibble: 1 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 0 0 1 Initial qualify… #> # ℹ 2 more variables: excluded_records , excluded_subjects # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptSetDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of conceptSet. — conceptSetDoc","title":"Helper for consistent documentation of conceptSet. — conceptSetDoc","text":"Helper consistent documentation conceptSet.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/conceptSetDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of conceptSet. — conceptSetDoc","text":"conceptSet conceptSet, can either codelist conceptSetExpression.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/demographicsCohort.html","id":null,"dir":"Reference","previous_headings":"","what":"Create cohorts based on patient demographics — demographicsCohort","title":"Create cohorts based on patient demographics — demographicsCohort","text":"demographicsCohort() creates cohort table based patient characteristics. individual satisfies criteria enter cohort. stop satisfying criteria cohort entry ends.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/demographicsCohort.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create cohorts based on patient demographics — demographicsCohort","text":"","code":"demographicsCohort( cdm, name, ageRange = NULL, sex = NULL, minPriorObservation = NULL )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/demographicsCohort.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create cohorts based on patient demographics — demographicsCohort","text":"cdm cdm reference. name Name new cohort table created cdm object. ageRange list vectors specifying minimum maximum age. sex Can \"\", \"Male\" \"Female\". minPriorObservation minimum number continuous prior observation days database.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/demographicsCohort.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create cohorts based on patient demographics — demographicsCohort","text":"cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/demographicsCohort.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create cohorts based on patient demographics — demographicsCohort","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cohort <- cdm |> demographicsCohort(name = \"cohort3\", ageRange = c(18,40), sex = \"Male\") #> ! cohort columns will be reordered to match the expected order: #> cohort_definition_id, subject_id, cohort_start_date, and cohort_end_date. #> ℹ Building new trimmed cohort #> Adding demographics information #> Creating initial cohort #> Trim sex #> Trim age #> ✔ Cohort trimmed attrition(cohort) #> # A tibble: 3 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 10 10 1 Initial qualify… #> 2 1 2 2 2 Sex requirement… #> 3 1 2 2 3 Age requirement… #> # ℹ 2 more variables: excluded_records , excluded_subjects # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtFirstDate.html","id":null,"dir":"Reference","previous_headings":"","what":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","title":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","text":"entryAtFirstDate() resets cohort start date based set specified column dates. first date occurs chosen.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtFirstDate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","text":"","code":"entryAtFirstDate( cohort, dateColumns, cohortId = NULL, returnReason = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtFirstDate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","text":"cohort cohort table cdm reference. dateColumns Character vector indicating date columns cohort table consider. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column indicating dateColumns used. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtFirstDate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtFirstDate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Update cohort start date to be the first date from of a set of column dates — entryAtFirstDate","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(tables = list( \"cohort\" = dplyr::tibble( cohort_definition_id = 1, subject_id = c(1, 2, 3, 4), cohort_start_date = as.Date(c(\"2000-06-03\", \"2000-01-01\", \"2015-01-15\", \"2000-12-09\")), cohort_end_date = as.Date(c(\"2001-09-01\", \"2001-01-12\", \"2015-02-15\", \"2002-12-09\")), date_1 = as.Date(c(\"2001-08-01\", \"2001-01-01\", \"2015-01-15\", \"2002-12-09\")), date_2 = as.Date(c(\"2001-08-01\", NA, \"2015-02-14\", \"2002-12-09\")) ) )) #> Warning: ! 9 column in cdm_source do not match expected column type: #> • `cdm_source_abbreviation` is logical but expected character #> • `cdm_holder` is logical but expected character #> • `source_description` is logical but expected character #> • `source_documentation_reference` is logical but expected character #> • `cdm_etl_reference` is logical but expected character #> • `source_release_date` is logical but expected date #> • `cdm_release_date` is logical but expected date #> • `cdm_version` is numeric but expected character #> • `vocabulary_version` is logical but expected character #> Warning: ! 3 column in concept do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date #> Warning: ! 1 column in vocabulary do not match expected column type: #> • `vocabulary_concept_id` is numeric but expected integer #> Warning: ! 5 column in concept_relationship do not match expected column type: #> • `concept_id_1` is numeric but expected integer #> • `concept_id_2` is numeric but expected integer #> • `valid_start_date` is logical but expected date #> • `valid_end_date` is logical but expected date #> • `invalid_reason` is logical but expected character #> Warning: ! 2 column in concept_synonym do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `language_concept_id` is numeric but expected integer #> Warning: ! 4 column in concept_ancestor do not match expected column type: #> • `ancestor_concept_id` is numeric but expected integer #> • `descendant_concept_id` is numeric but expected integer #> • `min_levels_of_separation` is numeric but expected integer #> • `max_levels_of_separation` is numeric but expected integer #> Warning: ! 9 column in drug_strength do not match expected column type: #> • `drug_concept_id` is numeric but expected integer #> • `ingredient_concept_id` is numeric but expected integer #> • `amount_unit_concept_id` is numeric but expected integer #> • `numerator_unit_concept_id` is numeric but expected integer #> • `denominator_value` is logical but expected numeric #> • `denominator_unit_concept_id` is numeric but expected integer #> • `box_size` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date cdm$cohort |> entryAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 11] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 2015-02-14 2015-02-15 #> 2 1 2 2001-01-01 2001-01-12 #> 3 1 1 2001-08-01 2001-09-01 #> 4 1 4 2002-12-09 2002-12-09 #> # ℹ 7 more variables: cohort_definition_name , #> # cohort_definition_description , definition_type_concept_id , #> # cohort_definition_syntax , subject_concept_id , #> # cohort_initiation_date , entry_reason # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtLastDate.html","id":null,"dir":"Reference","previous_headings":"","what":"Set cohort start date to the last of a set of column dates — entryAtLastDate","title":"Set cohort start date to the last of a set of column dates — entryAtLastDate","text":"entryAtLastDate() resets cohort end date based set specified column dates. last date chosen.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtLastDate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set cohort start date to the last of a set of column dates — entryAtLastDate","text":"","code":"entryAtLastDate( cohort, dateColumns, cohortId = NULL, returnReason = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtLastDate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set cohort start date to the last of a set of column dates — entryAtLastDate","text":"cohort cohort table cdm reference. dateColumns Character vector indicating date columns cohort table consider. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column indicating dateColumns used. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtLastDate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set cohort start date to the last of a set of column dates — entryAtLastDate","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/entryAtLastDate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set cohort start date to the last of a set of column dates — entryAtLastDate","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(tables = list( \"cohort\" = dplyr::tibble( cohort_definition_id = 1, subject_id = c(1, 2, 3, 4), cohort_start_date = as.Date(c(\"2000-06-03\", \"2000-01-01\", \"2015-01-15\", \"2000-12-09\")), cohort_end_date = as.Date(c(\"2001-09-01\", \"2001-01-12\", \"2015-02-15\", \"2002-12-09\")), date_1 = as.Date(c(\"2001-08-01\", \"2001-01-01\", \"2015-01-15\", \"2002-12-09\")), date_2 = as.Date(c(\"2001-08-01\", NA, \"2015-02-14\", \"2002-12-09\")) ) )) #> Warning: ! 9 column in cdm_source do not match expected column type: #> • `cdm_source_abbreviation` is logical but expected character #> • `cdm_holder` is logical but expected character #> • `source_description` is logical but expected character #> • `source_documentation_reference` is logical but expected character #> • `cdm_etl_reference` is logical but expected character #> • `source_release_date` is logical but expected date #> • `cdm_release_date` is logical but expected date #> • `cdm_version` is numeric but expected character #> • `vocabulary_version` is logical but expected character #> Warning: ! 3 column in concept do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date #> Warning: ! 1 column in vocabulary do not match expected column type: #> • `vocabulary_concept_id` is numeric but expected integer #> Warning: ! 5 column in concept_relationship do not match expected column type: #> • `concept_id_1` is numeric but expected integer #> • `concept_id_2` is numeric but expected integer #> • `valid_start_date` is logical but expected date #> • `valid_end_date` is logical but expected date #> • `invalid_reason` is logical but expected character #> Warning: ! 2 column in concept_synonym do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `language_concept_id` is numeric but expected integer #> Warning: ! 4 column in concept_ancestor do not match expected column type: #> • `ancestor_concept_id` is numeric but expected integer #> • `descendant_concept_id` is numeric but expected integer #> • `min_levels_of_separation` is numeric but expected integer #> • `max_levels_of_separation` is numeric but expected integer #> Warning: ! 9 column in drug_strength do not match expected column type: #> • `drug_concept_id` is numeric but expected integer #> • `ingredient_concept_id` is numeric but expected integer #> • `amount_unit_concept_id` is numeric but expected integer #> • `numerator_unit_concept_id` is numeric but expected integer #> • `denominator_value` is logical but expected numeric #> • `denominator_unit_concept_id` is numeric but expected integer #> • `box_size` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date cdm$cohort |> entryAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 11] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 2015-02-14 2015-02-15 #> 2 1 2 2001-01-01 2001-01-12 #> 3 1 1 2001-08-01 2001-09-01 #> 4 1 4 2002-12-09 2002-12-09 #> # ℹ 7 more variables: cohort_definition_name , #> # cohort_definition_description , definition_type_concept_id , #> # cohort_definition_syntax , subject_concept_id , #> # cohort_initiation_date , entry_reason # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtDeath.html","id":null,"dir":"Reference","previous_headings":"","what":"Set cohort end date to death date — exitAtDeath","title":"Set cohort end date to death date — exitAtDeath","text":"functions changes cohort end date subject's death date. case generates overlapping records cohort, overlapping entries merged.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtDeath.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set cohort end date to death date — exitAtDeath","text":"","code":"exitAtDeath( cohort, cohortId = NULL, requireDeath = FALSE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtDeath.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set cohort end date to death date — exitAtDeath","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. requireDeath TRUE, subjects without death record dropped, FALSE end date left . name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtDeath.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set cohort end date to death date — exitAtDeath","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtDeath.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set cohort end date to death date — exitAtDeath","text":"","code":"# \\donttest{ library(PatientProfiles) library(CohortConstructor) cdm <- mockPatientProfiles() cdm$cohort1 |> exitAtDeath() #> # Source: table [10 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 2 3 1939-07-24 1944-01-14 #> 2 2 5 1966-05-05 1970-11-15 #> 3 1 1 1943-11-26 1949-06-21 #> 4 2 4 1949-03-07 1951-05-08 #> 5 3 6 1966-09-27 1975-03-05 #> 6 1 10 1948-08-08 1952-03-27 #> 7 1 9 1940-05-01 1945-06-29 #> 8 3 8 1921-10-07 1931-05-01 #> 9 3 2 1918-06-14 1921-11-28 #> 10 3 7 1962-05-14 1964-03-08 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtFirstDate.html","id":null,"dir":"Reference","previous_headings":"","what":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","title":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","text":"exitAtFirstDate() resets cohort end date based set specified column dates. first date occurs chosen.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtFirstDate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","text":"","code":"exitAtFirstDate( cohort, dateColumns, cohortId = NULL, returnReason = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtFirstDate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","text":"cohort cohort table cdm reference. dateColumns Character vector indicating date columns cohort table consider. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column indicating dateColumns used. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtFirstDate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtFirstDate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set cohort end date to the first of a set of column dates — exitAtFirstDate","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(tables = list( \"cohort\" = dplyr::tibble( cohort_definition_id = 1, subject_id = c(1, 2, 3, 4), cohort_start_date = as.Date(c(\"2000-06-03\", \"2000-01-01\", \"2015-01-15\", \"2000-12-09\")), cohort_end_date = as.Date(c(\"2001-09-01\", \"2001-01-12\", \"2015-02-15\", \"2002-12-09\")), date_1 = as.Date(c(\"2001-08-01\", \"2001-01-01\", \"2015-01-15\", \"2002-12-09\")), date_2 = as.Date(c(\"2001-08-01\", NA, \"2015-04-15\", \"2002-12-09\")) ) )) #> Warning: ! 9 column in cdm_source do not match expected column type: #> • `cdm_source_abbreviation` is logical but expected character #> • `cdm_holder` is logical but expected character #> • `source_description` is logical but expected character #> • `source_documentation_reference` is logical but expected character #> • `cdm_etl_reference` is logical but expected character #> • `source_release_date` is logical but expected date #> • `cdm_release_date` is logical but expected date #> • `cdm_version` is numeric but expected character #> • `vocabulary_version` is logical but expected character #> Warning: ! 3 column in concept do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date #> Warning: ! 1 column in vocabulary do not match expected column type: #> • `vocabulary_concept_id` is numeric but expected integer #> Warning: ! 5 column in concept_relationship do not match expected column type: #> • `concept_id_1` is numeric but expected integer #> • `concept_id_2` is numeric but expected integer #> • `valid_start_date` is logical but expected date #> • `valid_end_date` is logical but expected date #> • `invalid_reason` is logical but expected character #> Warning: ! 2 column in concept_synonym do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `language_concept_id` is numeric but expected integer #> Warning: ! 4 column in concept_ancestor do not match expected column type: #> • `ancestor_concept_id` is numeric but expected integer #> • `descendant_concept_id` is numeric but expected integer #> • `min_levels_of_separation` is numeric but expected integer #> • `max_levels_of_separation` is numeric but expected integer #> Warning: ! 9 column in drug_strength do not match expected column type: #> • `drug_concept_id` is numeric but expected integer #> • `ingredient_concept_id` is numeric but expected integer #> • `amount_unit_concept_id` is numeric but expected integer #> • `numerator_unit_concept_id` is numeric but expected integer #> • `denominator_value` is logical but expected numeric #> • `denominator_unit_concept_id` is numeric but expected integer #> • `box_size` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date cdm$cohort |> exitAtFirstDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 11] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 2015-01-15 2015-01-15 #> 2 1 2 2000-01-01 2001-01-01 #> 3 1 4 2000-12-09 2002-12-09 #> 4 1 1 2000-06-03 2001-08-01 #> # ℹ 7 more variables: cohort_definition_name , #> # cohort_definition_description , definition_type_concept_id , #> # cohort_definition_syntax , subject_concept_id , #> # cohort_initiation_date , exit_reason # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtLastDate.html","id":null,"dir":"Reference","previous_headings":"","what":"Set cohort end date to the last of a set of column dates — exitAtLastDate","title":"Set cohort end date to the last of a set of column dates — exitAtLastDate","text":"exitAtLastDate() resets cohort end date based set specified column dates. last date occurs chosen.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtLastDate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set cohort end date to the last of a set of column dates — exitAtLastDate","text":"","code":"exitAtLastDate( cohort, dateColumns, cohortId = NULL, returnReason = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtLastDate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set cohort end date to the last of a set of column dates — exitAtLastDate","text":"cohort cohort table cdm reference. dateColumns Character vector indicating date columns cohort table consider. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column indicating dateColumns used. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtLastDate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set cohort end date to the last of a set of column dates — exitAtLastDate","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtLastDate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set cohort end date to the last of a set of column dates — exitAtLastDate","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(tables = list( \"cohort\" = dplyr::tibble( cohort_definition_id = 1, subject_id = c(1, 2, 3, 4), cohort_start_date = as.Date(c(\"2000-06-03\", \"2000-01-01\", \"2015-01-15\", \"2000-12-09\")), cohort_end_date = as.Date(c(\"2001-09-01\", \"2001-01-12\", \"2015-02-15\", \"2002-12-09\")), date_1 = as.Date(c(\"2001-08-01\", \"2001-01-01\", \"2015-01-15\", \"2002-12-09\")), date_2 = as.Date(c(\"2001-08-01\", NA, \"2015-04-15\", \"2002-12-09\")) ) )) #> Warning: ! 9 column in cdm_source do not match expected column type: #> • `cdm_source_abbreviation` is logical but expected character #> • `cdm_holder` is logical but expected character #> • `source_description` is logical but expected character #> • `source_documentation_reference` is logical but expected character #> • `cdm_etl_reference` is logical but expected character #> • `source_release_date` is logical but expected date #> • `cdm_release_date` is logical but expected date #> • `cdm_version` is numeric but expected character #> • `vocabulary_version` is logical but expected character #> Warning: ! 3 column in concept do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date #> Warning: ! 1 column in vocabulary do not match expected column type: #> • `vocabulary_concept_id` is numeric but expected integer #> Warning: ! 5 column in concept_relationship do not match expected column type: #> • `concept_id_1` is numeric but expected integer #> • `concept_id_2` is numeric but expected integer #> • `valid_start_date` is logical but expected date #> • `valid_end_date` is logical but expected date #> • `invalid_reason` is logical but expected character #> Warning: ! 2 column in concept_synonym do not match expected column type: #> • `concept_id` is numeric but expected integer #> • `language_concept_id` is numeric but expected integer #> Warning: ! 4 column in concept_ancestor do not match expected column type: #> • `ancestor_concept_id` is numeric but expected integer #> • `descendant_concept_id` is numeric but expected integer #> • `min_levels_of_separation` is numeric but expected integer #> • `max_levels_of_separation` is numeric but expected integer #> Warning: ! 9 column in drug_strength do not match expected column type: #> • `drug_concept_id` is numeric but expected integer #> • `ingredient_concept_id` is numeric but expected integer #> • `amount_unit_concept_id` is numeric but expected integer #> • `numerator_unit_concept_id` is numeric but expected integer #> • `denominator_value` is logical but expected numeric #> • `denominator_unit_concept_id` is numeric but expected integer #> • `box_size` is numeric but expected integer #> • `valid_start_date` is character but expected date #> • `valid_end_date` is character but expected date cdm$cohort |> exitAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 11] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 2000-01-01 2001-01-01 #> 2 1 3 2015-01-15 2015-04-15 #> 3 1 4 2000-12-09 2002-12-09 #> 4 1 1 2000-06-03 2001-08-01 #> # ℹ 7 more variables: cohort_definition_name , #> # cohort_definition_description , definition_type_concept_id , #> # cohort_definition_syntax , subject_concept_id , #> # cohort_initiation_date , exit_reason # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtObservationEnd.html","id":null,"dir":"Reference","previous_headings":"","what":"Set cohort end date to end of observation — exitAtObservationEnd","title":"Set cohort end date to end of observation — exitAtObservationEnd","text":"exitAtObservationEnd() resets cohort end date based set specified column dates. last date occurs chosen. functions changes cohort end date end date observation period corresponding cohort entry. case generates overlapping records cohort, overlapping entries merged.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtObservationEnd.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set cohort end date to end of observation — exitAtObservationEnd","text":"","code":"exitAtObservationEnd( cohort, cohortId = NULL, limitToCurrentPeriod = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtObservationEnd.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set cohort end date to end of observation — exitAtObservationEnd","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. limitToCurrentPeriod TRUE, limits cohort one entry per person, ending current observation period. FALSE, subsequent observation periods create new cohort entries. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtObservationEnd.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set cohort end date to end of observation — exitAtObservationEnd","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/exitAtObservationEnd.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set cohort end date to end of observation — exitAtObservationEnd","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> exitAtObservationEnd() #> # Source: table [6 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 5 2007-10-19 2014-09-25 #> 2 1 3 1976-11-28 2000-04-25 #> 3 1 6 2003-10-31 2005-11-04 #> 4 1 9 2012-01-18 2012-06-30 #> 5 1 2 1964-09-18 1968-04-03 #> 6 1 4 1998-06-22 2013-05-12 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/gapDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of gap. — gapDoc","title":"Helper for consistent documentation of gap. — gapDoc","text":"Helper consistent documentation gap.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/gapDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of gap. — gapDoc","text":"gap Number days two subsequent cohort entries merged single cohort record.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/intersectCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","title":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","text":"intersectCohorts() combines different cohort entries, records overlap combined kept. Cohort entries individual cohorts.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/intersectCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","text":"","code":"intersectCohorts( cohort, cohortId = NULL, gap = 0, returnNonOverlappingCohorts = FALSE, keepOriginalCohorts = FALSE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/intersectCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. gap Number days two subsequent cohort entries merged single cohort record. returnNonOverlappingCohorts Whether generated cohorts mutually exclusive . keepOriginalCohorts TRUE original cohorts return together new ones. FALSE new cohort returned. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/intersectCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/intersectCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate a combination cohort set between the intersection of different cohorts. — intersectCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort3 <- intersectCohorts( cohort = cdm$cohort2, name = \"cohort3\", ) settings(cdm$cohort3) #> # A tibble: 1 × 5 #> cohort_definition_id cohort_name gap cohort_1 cohort_2 #> #> 1 1 cohort_1_cohort_2 0 1 1 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/keepOriginalCohortsDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of keepOriginalCohorts. — keepOriginalCohortsDoc","title":"Helper for consistent documentation of keepOriginalCohorts. — keepOriginalCohortsDoc","text":"Helper consistent documentation keepOriginalCohorts.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/keepOriginalCohortsDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of keepOriginalCohorts. — keepOriginalCohortsDoc","text":"keepOriginalCohorts TRUE original cohorts return together new ones. FALSE new cohort returned.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/matchCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate a new cohort matched cohort — matchCohorts","title":"Generate a new cohort matched cohort — matchCohorts","text":"matchCohorts() generate new cohort matched individuals existing cohort. Individuals can matched based year birth sex.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/matchCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate a new cohort matched cohort — matchCohorts","text":"","code":"matchCohorts( cohort, cohortId = NULL, matchSex = TRUE, matchYearOfBirth = TRUE, ratio = 1, keepOriginalCohorts = FALSE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/matchCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate a new cohort matched cohort — matchCohorts","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. matchSex Whether match sex. matchYearOfBirth Whether match year birth. ratio Number allowed matches per individual target cohort. keepOriginalCohorts TRUE original cohorts return together new ones. FALSE new cohort returned. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/matchCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate a new cohort matched cohort — matchCohorts","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/matchCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate a new cohort matched cohort — matchCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) library(dplyr) #> #> Attaching package: ‘dplyr’ #> The following objects are masked from ‘package:stats’: #> #> filter, lag #> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union cdm <- mockCohortConstructor(nPerson = 200) cdm$new_matched_cohort <- cdm$cohort2 |> matchCohorts( name = \"new_matched_cohort\", cohortId = 2, matchSex = TRUE, matchYearOfBirth = TRUE, ratio = 1) #> Starting matching #> Warning: Multiple records per person detected. The matchCohorts() function is designed #> to operate under the assumption that there is only one record per person within #> each cohort. If this assumption is not met, each record will be treated #> independently. As a result, the same individual may be matched multiple times, #> leading to inconsistent and potentially misleading results. #> ℹ Creating copy of target cohort. #> • 1 cohort to be matched. #> ℹ Creating controls cohorts. #> ℹ Excluding cases from controls #> • Matching by gender_concept_id and year_of_birth #> • Removing controls that were not in observation at index date #> • Excluding target records whose pair is not in observation #> • Adjusting ratio #> Binding cohorts #> ✔ Done cdm$new_matched_cohort #> # Source: table [?? x 5] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date cluster_id #> #> 1 1 166 2017-05-16 2017-09-25 59 #> 2 1 103 1979-10-16 1982-05-26 21 #> 3 1 110 2005-10-01 2006-06-12 99 #> 4 1 19 2015-04-24 2015-09-01 108 #> 5 1 33 1993-05-10 1997-04-01 14 #> 6 1 39 2004-08-08 2006-11-19 44 #> 7 1 16 2007-05-18 2007-10-08 102 #> 8 1 80 2000-12-22 2002-04-17 18 #> 9 1 91 1995-05-16 2002-02-02 42 #> 10 1 67 2009-01-30 2010-03-12 78 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/measurementCohort.html","id":null,"dir":"Reference","previous_headings":"","what":"Create cohorts measurement based cohorts — measurementCohort","title":"Create cohorts measurement based cohorts — measurementCohort","text":"measurementCohort() creates cohorts based patient records contained measurement table. function extends conceptCohort() allows measurement values associated records specified. valueAsConcept valueAsNumber NULL requirements values associated measurement records using measurementCohort() lead result using conceptCohort() (long concepts measurement domain). one valueAsConcept valueAsNumber NULL records required values satisfy requirement specified. valueAsConcept valueAsNumber NULL, records required values fulfill either requirements","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/measurementCohort.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create cohorts measurement based cohorts — measurementCohort","text":"","code":"measurementCohort( cdm, conceptSet, name, valueAsConcept = NULL, valueAsNumber = NULL )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/measurementCohort.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create cohorts measurement based cohorts — measurementCohort","text":"cdm cdm reference. conceptSet conceptSet, can either codelist conceptSetExpression. name Name new cohort table created cdm object. valueAsConcept vector cohort IDs used filter measurements. measurements values value_as_concept_id column measurement table included. NULL entries independently value concept considered. valueAsNumber named list indicating range values unit correspond , follows: list(\"unit_concept_id\" = c(rangeValue1, rangeValue2)). NULL, entries independently value number included.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/measurementCohort.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create cohorts measurement based cohorts — measurementCohort","text":"cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/measurementCohort.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create cohorts measurement based cohorts — measurementCohort","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(con = NULL) cdm$concept <- cdm$concept |> dplyr::union_all( dplyr::tibble( concept_id = c(4326744, 4298393, 45770407, 8876, 4124457), concept_name = c(\"Blood pressure\", \"Systemic blood pressure\", \"Baseline blood pressure\", \"millimeter mercury column\", \"Normal range\"), domain_id = \"Measurement\", vocabulary_id = c(\"SNOMED\", \"SNOMED\", \"SNOMED\", \"UCUM\", \"SNOMED\"), standard_concept = \"S\", concept_class_id = c(\"Observable Entity\", \"Observable Entity\", \"Observable Entity\", \"Unit\", \"Qualifier Value\"), concept_code = NA, valid_start_date = NA, valid_end_date = NA, invalid_reason = NA ) ) cdm$measurement <- dplyr::tibble( measurement_id = 1:4, person_id = c(1, 1, 2, 3), measurement_concept_id = c(4326744, 4298393, 4298393, 45770407), measurement_date = as.Date(c(\"2000-07-01\", \"2000-12-11\", \"2002-09-08\", \"2015-02-19\")), measurement_type_concept_id = NA, value_as_number = c(100, 125, NA, NA), value_as_concept_id = c(0, 0, 0, 4124457), unit_concept_id = c(8876, 8876, 0, 0) ) cdm <- CDMConnector::copyCdmTo( con = DBI::dbConnect(duckdb::duckdb()), cdm = cdm, schema = \"main\") cdm$cohort <- measurementCohort( cdm = cdm, name = \"cohort\", conceptSet = list(\"normal_blood_pressure\" = c(4326744, 4298393, 45770407)), valueAsConcept = c(4124457), valueAsNumber = list(\"8876\" = c(70, 120)) ) #> Warning: ! `codelist` contains numeric values, they are casted to integers. #> ℹ Subsetting measurement table. #> ℹ Applying measurement requirements. #> Warning: ! 1 column in cohort do not match expected column type: #> • `subject_id` is numeric but expected integer #> ! cohort columns will be reordered to match the expected order: #> cohort_definition_id, subject_id, cohort_start_date, and cohort_end_date. #> ℹ Getting records in observation. #> Warning: ! 1 column in cohort do not match expected column type: #> • `subject_id` is numeric but expected integer #> Warning: ! 1 column in cohort do not match expected column type: #> • `subject_id` is numeric but expected integer #> Warning: ! 1 column in cohort do not match expected column type: #> • `subject_id` is numeric but expected integer #> ℹ Creating cohort attributes. #> Warning: ! 1 column in cohort do not match expected column type: #> • `subject_id` is numeric but expected integer #> ✔ Cohort cohort created. cdm$cohort #> # Source: table [0 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> # ℹ 4 variables: cohort_definition_id , subject_id , #> # cohort_start_date , cohort_end_date # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/mockCohortConstructor.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","title":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","text":"mockCohortConstructor() creates example dataset can used demonstrating testing package","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/mockCohortConstructor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","text":"","code":"mockCohortConstructor( nPerson = 10, conceptTable = NULL, tables = NULL, conceptId = NULL, conceptIdClass = NULL, drugExposure = FALSE, conditionOccurrence = FALSE, measurement = FALSE, death = FALSE, otherTables = NULL, con = DBI::dbConnect(duckdb::duckdb()), writeSchema = \"main\", seed = 123 )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/mockCohortConstructor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","text":"nPerson number person cdm conceptTable user defined concept table tables list tables include cdm conceptId list concept id conceptIdClass domain class conceptId drugExposure T/F include drug exposure table cdm conditionOccurrence T/F include condition occurrence cdm measurement T/F include measurement cdm death T/F include death table cdm otherTables takes list single tibble names include tables cdm con DBI connection create cdm mock object. writeSchema Name schema connection writing permissions. seed Seed passed omock::mockCdmFromTable","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/mockCohortConstructor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","text":"cdm object","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/mockCohortConstructor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to create a mock cdm reference for CohortConstructor — mockCohortConstructor","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm #> #> ── # OMOP CDM reference (duckdb) of mock database ────────────────────────────── #> • omop tables: person, observation_period, cdm_source, concept, vocabulary, #> concept_relationship, concept_synonym, concept_ancestor, drug_strength #> • cohort tables: cohort1, cohort2 #> • achilles tables: - #> • other tables: - # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/nameDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of name. — nameDoc","title":"Helper for consistent documentation of name. — nameDoc","text":"Helper consistent documentation name.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/nameDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of name. — nameDoc","text":"name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortEnd.html","id":null,"dir":"Reference","previous_headings":"","what":"Add days to cohort end — padCohortEnd","title":"Add days to cohort end — padCohortEnd","text":"padCohortEnd() Adds (subtracts) certain number days cohort end date. Note: days added means cohort end observation period end date, observation period end date used cohort exit. days added means cohort exit next cohort start overlapping cohort entries collapsed. days subtracted means cohort end cohort start cohort entry dropped.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortEnd.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add days to cohort end — padCohortEnd","text":"","code":"padCohortEnd(cohort, days, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortEnd.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add days to cohort end — padCohortEnd","text":"cohort cohort table cdm reference. days Number day add cohort end date. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortEnd.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add days to cohort end — padCohortEnd","text":"Cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortEnd.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add days to cohort end — padCohortEnd","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() # add 10 days to each cohort exit cdm$cohort1 |> padCohortEnd(days = 10) #> # Source: table [6 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 9 2012-01-18 2012-03-18 #> 2 1 4 1998-06-22 2001-02-22 #> 3 1 2 1964-09-18 1965-09-09 #> 4 1 5 2007-10-19 2011-09-22 #> 5 1 3 1976-11-28 1987-03-08 #> 6 1 6 2003-10-31 2004-04-20 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortStart.html","id":null,"dir":"Reference","previous_headings":"","what":"Add days to cohort start — padCohortStart","title":"Add days to cohort start — padCohortStart","text":"padCohortStart() Adds (subtracts) certain number days cohort start date. Note: days added means cohort start cohort end cohort entry dropped. subtracting day means cohort start observation period start cohort entry dropped.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortStart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add days to cohort start — padCohortStart","text":"","code":"padCohortStart(cohort, days, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortStart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add days to cohort start — padCohortStart","text":"cohort cohort table cdm reference. days Number day add cohort start date. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortStart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add days to cohort start — padCohortStart","text":"Cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/padCohortStart.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add days to cohort start — padCohortStart","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() # add 10 days to each cohort entry cdm$cohort1 |> padCohortStart(days = 10) #> # Source: table [10 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-28 1965-08-30 #> 2 1 3 1976-12-08 1977-03-11 #> 3 1 3 1977-03-22 1978-04-03 #> 4 1 3 1978-04-14 1987-02-26 #> 5 1 4 1998-07-02 2001-02-12 #> 6 1 5 2007-10-29 2008-11-10 #> 7 1 5 2008-11-21 2011-09-12 #> 8 1 6 2003-11-10 2003-11-14 #> 9 1 6 2003-11-25 2004-04-10 #> 10 1 9 2012-01-28 2012-03-08 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/reexports.html","id":null,"dir":"Reference","previous_headings":"","what":"Objects exported from other packages — reexports","title":"Objects exported from other packages — reexports","text":"objects imported packages. Follow links see documentation. omopgenerics attrition, bind, cohortCodelist, cohortCount, settings, tableName PatientProfiles endDateColumn, startDateColumn","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireAge.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on age — requireAge","title":"Restrict cohort on age — requireAge","text":"requireAge() filters cohort records, keeping records individuals satisfy specified age criteria.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireAge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on age — requireAge","text":"","code":"requireAge( cohort, ageRange, cohortId = NULL, indexDate = \"cohort_start_date\", name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireAge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on age — requireAge","text":"cohort cohort table cdm reference. ageRange list vectors specifying minimum maximum age. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireAge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on age — requireAge","text":"cohort table records individuals satisfying age requirement","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireAge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on age — requireAge","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> requireAge(indexDate = \"cohort_start_date\", ageRange = list(c(18, 65))) #> # Source: table [6 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 1978-04-04 1987-02-26 #> 2 1 5 2007-10-19 2008-11-10 #> 3 1 5 2008-11-11 2011-09-12 #> 4 1 6 2003-10-31 2003-11-14 #> 5 1 6 2003-11-15 2004-04-10 #> 6 1 9 2012-01-18 2012-03-08 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireCohortIntersect.html","id":null,"dir":"Reference","previous_headings":"","what":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","title":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","text":"requireCohortIntersect() filters cohort table based requirement individual seen (seen) another cohort time window around index date.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireCohortIntersect.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","text":"","code":"requireCohortIntersect( cohort, targetCohortTable, window, intersections = c(1, Inf), cohortId = NULL, targetCohortId = NULL, indexDate = \"cohort_start_date\", targetStartDate = \"cohort_start_date\", targetEndDate = \"cohort_end_date\", censorDate = NULL, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireCohortIntersect.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","text":"cohort cohort table cdm reference. targetCohortTable Name cohort want check intersect. window list vectors specifying minimum maximum days indexDate consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. targetCohortId Vector cohort definition ids include. indexDate Name column cohort contains date compute intersection. targetStartDate Start date reference cohort table. targetEndDate End date reference cohort table. NULL, incidence target event window considered intersection, otherwise prevalence event used intersection (overlap cohort event). censorDate Whether censor overlap events specific date column date cohort. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireCohortIntersect.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","text":"Cohort table isatisfying criteria kept","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireCohortIntersect.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Require cohort subjects are present (or absence) in another cohort — requireCohortIntersect","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> requireCohortIntersect(targetCohortTable = \"cohort2\", targetCohortId = 1, indexDate = \"cohort_start_date\", window = c(-Inf, 0)) #> # Source: table [10 x 5] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-18 1965-08-30 #> 2 1 3 1978-04-04 1987-02-26 #> 3 1 5 2007-10-19 2008-11-10 #> 4 1 3 1977-03-12 1978-04-03 #> 5 1 4 1998-06-22 2001-02-12 #> 6 1 5 2008-11-11 2011-09-12 #> 7 1 9 2012-01-18 2012-03-08 #> 8 1 6 2003-10-31 2003-11-14 #> 9 1 6 2003-11-15 2004-04-10 #> 10 1 3 1976-11-28 1977-03-11 #> # ℹ 1 more variable: intersect_cohort # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireConceptIntersect.html","id":null,"dir":"Reference","previous_headings":"","what":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","title":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","text":"requireConceptIntersect() filters cohort table based requirement individual seen (seen) events related concept list time window around index date.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireConceptIntersect.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","text":"","code":"requireConceptIntersect( cohort, conceptSet, window, intersections = c(1, Inf), cohortId = NULL, indexDate = \"cohort_start_date\", targetStartDate = \"event_start_date\", targetEndDate = \"event_end_date\", censorDate = NULL, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireConceptIntersect.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","text":"cohort cohort table cdm reference. conceptSet conceptSet, can either codelist conceptSetExpression. window list vectors specifying minimum maximum days indexDate consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Name column cohort contains date compute intersection. targetStartDate Start date reference cohort table. targetEndDate End date reference cohort table. NULL, incidence target event window considered intersection, otherwise prevalence event used intersection (overlap cohort event). censorDate Whether censor overlap events specific date column date cohort. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireConceptIntersect.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","text":"Cohort table events concept list kept (without event negate = TRUE)","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireConceptIntersect.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Require cohort subjects to have (or not have) events of a concept list — requireConceptIntersect","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(conditionOccurrence = TRUE) cdm$cohort2 <- requireConceptIntersect( cohort = cdm$cohort1, conceptSet = list(a = 194152), window = c(-Inf, 0), name = \"cohort2\") #> Warning: ! `codelist` contains numeric values, they are casted to integers. # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDeathFlag.html","id":null,"dir":"Reference","previous_headings":"","what":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","title":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","text":"requireDeathFlag() filters cohort table based requirement individual seen (seen) death time window around index date.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDeathFlag.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","text":"","code":"requireDeathFlag( cohort, window, cohortId = NULL, indexDate = \"cohort_start_date\", censorDate = NULL, negate = FALSE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDeathFlag.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","text":"cohort cohort table cdm reference. window list vectors specifying minimum maximum days indexDate consider events . cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Name column cohort contains date use time 0 window days. censorDate Whether censor overlap events specific date column date cohort. negate set TRUE, criteria applied exclusion rather inclusion (.e. require absence another cohort). name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDeathFlag.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","text":"Cohort table death event kept (without negate = TRUE)","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDeathFlag.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Require cohort subjects have (or do not have) a death record — requireDeathFlag","text":"","code":"# \\donttest{ library(CDMConnector) #> #> Attaching package: ‘CDMConnector’ #> The following objects are masked from ‘package:CohortConstructor’: #> #> intersectCohorts, unionCohorts library(CohortConstructor) cdm <- mockCohortConstructor(death = TRUE) cdm$cohort1 <- cdm$cohort1 |> requireDeathFlag(window = list(c(0, Inf))) attrition(cdm$cohort1) #> # A tibble: 2 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 10 6 1 Initial qualify… #> 2 1 10 6 2 Death between 0… #> # ℹ 2 more variables: excluded_records , excluded_subjects # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographics.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on patient demographics — requireDemographics","title":"Restrict cohort on patient demographics — requireDemographics","text":"requireDemographics() filters cohort records, keeping records individuals satisfy specified demographic criteria.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographics.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on patient demographics — requireDemographics","text":"","code":"requireDemographics( cohort, cohortId = NULL, indexDate = \"cohort_start_date\", ageRange = list(c(0, 150)), sex = c(\"Both\"), minPriorObservation = 0, minFutureObservation = 0, requirementInteractions = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographics.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on patient demographics — requireDemographics","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . ageRange list vectors specifying minimum maximum age. sex Can \"\", \"Male\" \"Female\". minPriorObservation minimum number continuous prior observation days database. minFutureObservation minimum number continuous future observation days database. requirementInteractions TRUE, cohorts created combinations ageGroup, sex, daysPriorObservation. FALSE, first value specified factors used. Consequently, order values matters requirementInteractions FALSE. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographics.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on patient demographics — requireDemographics","text":"cohort table records individuals satisfying demographic requirements","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographics.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on patient demographics — requireDemographics","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> requireDemographics(indexDate = \"cohort_start_date\", ageRange = list(c(18, 65)), sex = \"Female\", minPriorObservation = 365) #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 13 1991-04-14 1992-10-21 #> 2 1 13 1992-11-03 2000-11-27 #> 3 1 16 2005-12-28 2008-06-11 #> 4 1 17 2009-06-18 2013-02-01 #> 5 1 27 1992-04-16 1993-09-30 #> 6 1 27 1993-10-01 2003-08-01 #> 7 1 41 2000-07-02 2000-11-21 #> 8 1 41 2000-11-22 2010-05-13 #> 9 1 53 1997-03-26 1998-02-22 #> 10 1 53 1998-02-23 2001-04-23 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographicsDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of arguments in requireDemographics. — requireDemographicsDoc","title":"Helper for consistent documentation of arguments in requireDemographics. — requireDemographicsDoc","text":"Helper consistent documentation arguments requireDemographics.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireDemographicsDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of arguments in requireDemographics. — requireDemographicsDoc","text":"ageRange list vectors specifying minimum maximum age. sex Can \"\", \"Male\" \"Female\". minPriorObservation minimum number continuous prior observation days database. minFutureObservation minimum number continuous future observation days database. indexDate Variable cohort contains date compute demographics characteristics restrict . requirementInteractions TRUE, cohorts created combinations ageGroup, sex, daysPriorObservation. FALSE, first value specified factors used. Consequently, order values matters requirementInteractions FALSE.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireFutureObservation.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on future observation — requireFutureObservation","title":"Restrict cohort on future observation — requireFutureObservation","text":"requireFutureObservation() filters cohort records, keeping records individuals satisfy specified future observation criteria.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireFutureObservation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on future observation — requireFutureObservation","text":"","code":"requireFutureObservation( cohort, minFutureObservation, cohortId = NULL, indexDate = \"cohort_start_date\", name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireFutureObservation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on future observation — requireFutureObservation","text":"cohort cohort table cdm reference. minFutureObservation minimum number continuous future observation days database. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireFutureObservation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on future observation — requireFutureObservation","text":"cohort table records individuals satisfying future observation requirement","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireFutureObservation.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on future observation — requireFutureObservation","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> requireFutureObservation(indexDate = \"cohort_start_date\", minFutureObservation = 30) #> # Source: table [10 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-18 1965-08-30 #> 2 1 3 1976-11-28 1977-03-11 #> 3 1 4 1998-06-22 2001-02-12 #> 4 1 5 2008-11-11 2011-09-12 #> 5 1 6 2003-11-15 2004-04-10 #> 6 1 9 2012-01-18 2012-03-08 #> 7 1 3 1978-04-04 1987-02-26 #> 8 1 5 2007-10-19 2008-11-10 #> 9 1 6 2003-10-31 2003-11-14 #> 10 1 3 1977-03-12 1978-04-03 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireInDateRange.html","id":null,"dir":"Reference","previous_headings":"","what":"Require that an index date is within a date range — requireInDateRange","title":"Require that an index date is within a date range — requireInDateRange","text":"requireInDateRange() filters cohort records, keeping index date within specified date range.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireInDateRange.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Require that an index date is within a date range — requireInDateRange","text":"","code":"requireInDateRange( cohort, dateRange, cohortId = NULL, indexDate = \"cohort_start_date\", name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireInDateRange.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Require that an index date is within a date range — requireInDateRange","text":"cohort cohort table cdm reference. dateRange date vector minimum maximum dates index date must observed. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Name column cohort contains date interest. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireInDateRange.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Require that an index date is within a date range — requireInDateRange","text":"cohort table cohort entries outside date range dropped","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireInDateRange.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Require that an index date is within a date range — requireInDateRange","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> requireInDateRange(indexDate = \"cohort_start_date\", dateRange = as.Date(c(\"2010-01-01\", \"2019-01-01\"))) #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 9 2011-12-20 2011-12-20 #> 2 1 9 2011-12-21 2011-12-29 #> 3 1 9 2011-12-30 2012-04-02 #> 4 1 15 2018-03-20 2018-04-01 #> 5 1 22 2013-01-01 2013-03-07 #> 6 1 25 2018-01-10 2018-03-13 #> 7 1 25 2018-03-14 2018-03-22 #> 8 1 25 2018-03-23 2018-06-26 #> 9 1 25 2018-06-27 2018-11-13 #> 10 1 31 2012-09-03 2013-02-18 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIntersectDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of arguments in requireIntersect functions. — requireIntersectDoc","title":"Helper for consistent documentation of arguments in requireIntersect functions. — requireIntersectDoc","text":"Helper consistent documentation arguments requireIntersect functions.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIntersectDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of arguments in requireIntersect functions. — requireIntersectDoc","text":"indexDate Name column cohort contains date compute intersection. intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . targetStartDate Start date reference cohort table. targetEndDate End date reference cohort table. NULL, incidence target event window considered intersection, otherwise prevalence event used intersection (overlap cohort event). censorDate Whether censor overlap events specific date column date cohort. targetCohortTable Name cohort want check intersect. targetCohortId Vector cohort definition ids include. tableName Name table check intersect.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsEntry.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort to specific entry — requireIsEntry","title":"Restrict cohort to specific entry — requireIsEntry","text":"requireIsFirstEntry() filters cohort records, keeping first cohort entry per person.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsEntry.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort to specific entry — requireIsEntry","text":"","code":"requireIsEntry(cohort, entryRange, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsEntry.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort to specific entry — requireIsEntry","text":"cohort cohort table cdm reference. entryRange Range entries include. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsEntry.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort to specific entry — requireIsEntry","text":"cohort table cdm reference.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsEntry.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort to specific entry — requireIsEntry","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 <- requireIsEntry(cdm$cohort1, c(1, Inf)) # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsFirstEntry.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort to first entry — requireIsFirstEntry","title":"Restrict cohort to first entry — requireIsFirstEntry","text":"requireIsFirstEntry() filters cohort records, keeping first cohort entry per person.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsFirstEntry.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort to first entry — requireIsFirstEntry","text":"","code":"requireIsFirstEntry(cohort, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsFirstEntry.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort to first entry — requireIsFirstEntry","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort restriction.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsFirstEntry.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort to first entry — requireIsFirstEntry","text":"cohort table cdm reference.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsFirstEntry.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort to first entry — requireIsFirstEntry","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 <- requireIsFirstEntry(cdm$cohort1) # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsLastEntry.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort to last entry per person — requireIsLastEntry","title":"Restrict cohort to last entry per person — requireIsLastEntry","text":"requireIsLastEntry() filters cohort records, keeping last cohort entry per person.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsLastEntry.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort to last entry per person — requireIsLastEntry","text":"","code":"requireIsLastEntry(cohort, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsLastEntry.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort to last entry per person — requireIsLastEntry","text":"cohort cohort table cdm reference. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort restriction.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsLastEntry.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort to last entry per person — requireIsLastEntry","text":"cohort table cdm reference.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireIsLastEntry.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort to last entry per person — requireIsLastEntry","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 <- requireIsLastEntry(cdm$cohort1) # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireMinCohortCount.html","id":null,"dir":"Reference","previous_headings":"","what":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","title":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","text":"requireMinCohortCount() filters existing cohort table, keeping records cohorts minimum number individuals","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireMinCohortCount.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","text":"","code":"requireMinCohortCount( cohort, minCohortCount, cohortId = NULL, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireMinCohortCount.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","text":"cohort cohort table cdm reference. minCohortCount minimum count sbjects cohort included. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireMinCohortCount.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","text":"Cohort table","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireMinCohortCount.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Filter cohorts to keep only records for those with a minimum amount of subjects — requireMinCohortCount","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> requireMinCohortCount(5) #> Warning: There was 1 warning in `dplyr::summarise()`. #> ℹ In argument: `reason_id = max(.data$reason_id)`. #> Caused by warning in `max()`: #> ! no non-missing arguments to max; returning -Inf #> Warning: ! 1 casted column in cohort1 (cohort_attrition) as do not match expected column #> type: #> • `reason_id` from numeric to integer #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 4 1998-12-14 2002-02-14 #> 2 1 6 2003-04-11 2004-02-23 #> 3 1 7 2004-07-31 2004-11-23 #> 4 1 7 2004-11-24 2005-11-05 #> 5 1 7 2005-11-06 2012-01-12 #> 6 1 8 2009-09-13 2012-04-22 #> 7 1 9 2011-12-20 2011-12-20 #> 8 1 9 2011-12-21 2011-12-29 #> 9 1 9 2011-12-30 2012-04-02 #> 10 1 12 2000-11-15 2013-03-04 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requirePriorObservation.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on prior observation — requirePriorObservation","title":"Restrict cohort on prior observation — requirePriorObservation","text":"requirePriorObservation() filters cohort records, keeping records individuals satisfy specified prior observation criteria.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requirePriorObservation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on prior observation — requirePriorObservation","text":"","code":"requirePriorObservation( cohort, minPriorObservation, cohortId = NULL, indexDate = \"cohort_start_date\", name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requirePriorObservation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on prior observation — requirePriorObservation","text":"cohort cohort table cdm reference. minPriorObservation minimum number continuous prior observation days database. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requirePriorObservation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on prior observation — requirePriorObservation","text":"cohort table records individuals satisfying prior observation requirement","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requirePriorObservation.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on prior observation — requirePriorObservation","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> requirePriorObservation(indexDate = \"cohort_start_date\", minPriorObservation = 365) #> # Source: table [6 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-18 1965-08-30 #> 2 1 3 1976-11-28 1977-03-11 #> 3 1 3 1977-03-12 1978-04-03 #> 4 1 3 1978-04-04 1987-02-26 #> 5 1 4 1998-06-22 2001-02-12 #> 6 1 5 2008-11-11 2011-09-12 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireSex.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on sex — requireSex","title":"Restrict cohort on sex — requireSex","text":"requireSex() filters cohort records, keeping records individuals satisfy specified sex criteria.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireSex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on sex — requireSex","text":"","code":"requireSex(cohort, sex, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireSex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on sex — requireSex","text":"cohort cohort table cdm reference. sex Can \"\", \"Male\" \"Female\". cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireSex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on sex — requireSex","text":"cohort table records individuals satisfying sex requirement","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireSex.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on sex — requireSex","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> requireSex(sex = \"Female\") #> # Source: table [8 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-18 1965-08-30 #> 2 1 3 1976-11-28 1977-03-11 #> 3 1 3 1977-03-12 1978-04-03 #> 4 1 3 1978-04-04 1987-02-26 #> 5 1 4 1998-06-22 2001-02-12 #> 6 1 5 2007-10-19 2008-11-10 #> 7 1 5 2008-11-11 2011-09-12 #> 8 1 9 2012-01-18 2012-03-08 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireTableIntersect.html","id":null,"dir":"Reference","previous_headings":"","what":"Require cohort subjects are present in another clinical table — requireTableIntersect","title":"Require cohort subjects are present in another clinical table — requireTableIntersect","text":"requireTableIntersect() filters cohort table based requirement individual seen (seen) record (records) clinical table time window around index date.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireTableIntersect.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Require cohort subjects are present in another clinical table — requireTableIntersect","text":"","code":"requireTableIntersect( cohort, tableName, window, intersections = c(1, Inf), cohortId = NULL, indexDate = \"cohort_start_date\", targetStartDate = startDateColumn(tableName), targetEndDate = endDateColumn(tableName), censorDate = NULL, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireTableIntersect.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Require cohort subjects are present in another clinical table — requireTableIntersect","text":"cohort cohort table cdm reference. tableName Name table check intersect. window list vectors specifying minimum maximum days indexDate consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Name column cohort contains date compute intersection. targetStartDate Start date reference cohort table. targetEndDate End date reference cohort table. NULL, incidence target event window considered intersection, otherwise prevalence event used intersection (overlap cohort event). censorDate Whether censor overlap events specific date column date cohort. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireTableIntersect.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Require cohort subjects are present in another clinical table — requireTableIntersect","text":"Cohort table table kept (table negate = TRUE)","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/requireTableIntersect.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Require cohort subjects are present in another clinical table — requireTableIntersect","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(drugExposure = TRUE) cdm$cohort1 |> requireTableIntersect(tableName = \"drug_exposure\", indexDate = \"cohort_start_date\", window = c(-Inf, 0)) #> # Source: table [10 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 1964-09-18 1965-08-30 #> 2 1 3 1976-11-28 1977-03-11 #> 3 1 3 1977-03-12 1978-04-03 #> 4 1 3 1978-04-04 1987-02-26 #> 5 1 4 1998-06-22 2001-02-12 #> 6 1 5 2007-10-19 2008-11-10 #> 7 1 5 2008-11-11 2011-09-12 #> 8 1 6 2003-10-31 2003-11-14 #> 9 1 6 2003-11-15 2004-04-10 #> 10 1 9 2012-01-18 2012-03-08 # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/sampleCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Sample a cohort table for a given number of individuals. — sampleCohorts","title":"Sample a cohort table for a given number of individuals. — sampleCohorts","text":"sampleCohorts() samples existing cohort table given number people. records individuals preserved.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/sampleCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sample a cohort table for a given number of individuals. — sampleCohorts","text":"","code":"sampleCohorts(cohort, n, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/sampleCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Sample a cohort table for a given number of individuals. — sampleCohorts","text":"cohort cohort table cdm reference. n Number people sampled included cohort. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/sampleCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Sample a cohort table for a given number of individuals. — sampleCohorts","text":"Cohort table specified cohorts sampled.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/sampleCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Sample a cohort table for a given number of individuals. — sampleCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort2 |> sampleCohorts(cohortId = 1, n = 10) #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 12 2000-11-15 2013-03-04 #> 2 1 15 2018-03-20 2018-04-01 #> 3 1 23 2000-10-08 2001-06-04 #> 4 1 23 2001-06-05 2003-08-26 #> 5 1 26 1984-05-16 1993-10-28 #> 6 1 31 2012-09-03 2013-02-18 #> 7 1 31 2013-02-19 2013-03-28 #> 8 1 31 2013-03-29 2014-04-29 #> 9 1 32 1982-10-28 1984-05-05 #> 10 1 32 1984-05-06 1989-01-03 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/stratifyCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a new cohort table from stratifying an existing one — stratifyCohorts","title":"Create a new cohort table from stratifying an existing one — stratifyCohorts","text":"stratifyCohorts() creates new cohorts, splitting existing cohort based specified columns stratify .","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/stratifyCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a new cohort table from stratifying an existing one — stratifyCohorts","text":"","code":"stratifyCohorts( cohort, strata, cohortId = NULL, removeStrata = TRUE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/stratifyCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a new cohort table from stratifying an existing one — stratifyCohorts","text":"cohort cohort table cdm reference. strata strata list point columns cohort table. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. removeStrata Whether remove strata columns final cohort table. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/stratifyCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a new cohort table from stratifying an existing one — stratifyCohorts","text":"Cohort table stratified.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/stratifyCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a new cohort table from stratifying an existing one — stratifyCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) library(PatientProfiles) cdm <- mockCohortConstructor() cdm$my_cohort <- cdm$cohort1 |> addAge(ageGroup = list(\"child\" = c(0, 17), \"adult\" = c(18, Inf))) |> addSex(name = \"my_cohort\") |> stratifyCohorts( strata = list(\"sex\", c(\"sex\", \"age_group\")), name = \"my_cohort\" ) cdm$my_cohort #> # Source: table [?? x 5] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date age #> #> 1 1 2 1964-09-18 1965-08-30 9 #> 2 1 3 1976-11-28 1977-03-11 17 #> 3 1 4 1998-06-22 2001-02-12 16 #> 4 1 5 2008-11-11 2011-09-12 45 #> 5 2 6 2003-11-15 2004-04-10 35 #> 6 1 9 2012-01-18 2012-03-08 27 #> 7 1 3 1978-04-04 1987-02-26 19 #> 8 1 5 2007-10-19 2008-11-10 44 #> 9 2 6 2003-10-31 2003-11-14 35 #> 10 1 3 1977-03-12 1978-04-03 17 #> # ℹ more rows settings(cdm$my_cohort) #> # A tibble: 6 × 8 #> cohort_definition_id cohort_name target_cohort_id target_cohort_name #> #> 1 1 cohort_1_female 1 cohort_1 #> 2 2 cohort_1_male 1 cohort_1 #> 3 3 cohort_1_female_adult 1 cohort_1 #> 4 4 cohort_1_female_child 1 cohort_1 #> 5 5 cohort_1_male_adult 1 cohort_1 #> 6 6 cohort_1_male_child 1 cohort_1 #> # ℹ 4 more variables: target_cohort_table_name , strata_columns , #> # sex , age_group attrition(cdm$my_cohort) #> # A tibble: 16 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 10 6 1 Initial qualif… #> 2 1 8 6 2 filter strata:… #> 3 2 10 6 1 Initial qualif… #> 4 2 2 1 2 filter strata:… #> 5 3 10 6 1 Initial qualif… #> 6 3 8 6 2 filter strata:… #> 7 3 4 3 3 filter strata:… #> 8 4 10 6 1 Initial qualif… #> 9 4 8 6 2 filter strata:… #> 10 4 4 3 3 filter strata:… #> 11 5 10 6 1 Initial qualif… #> 12 5 2 1 2 filter strata:… #> 13 5 2 1 3 filter strata:… #> 14 6 10 6 1 Initial qualif… #> 15 6 2 1 2 filter strata:… #> 16 6 0 0 3 filter strata:… #> # ℹ 2 more variables: excluded_records , excluded_subjects # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","title":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","text":"subsetCohorts() filters existing cohort table, keeping records cohorts specified.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","text":"","code":"subsetCohorts(cohort, cohortId, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","text":"Cohort table cohorts cohortId.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate a cohort table keeping a subset of cohorts. — subsetCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> subsetCohorts(cohortId = 1) #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 4 1998-12-14 2002-02-14 #> 2 1 6 2003-04-11 2004-02-23 #> 3 1 7 2004-07-31 2004-11-23 #> 4 1 7 2004-11-24 2005-11-05 #> 5 1 7 2005-11-06 2012-01-12 #> 6 1 8 2009-09-13 2012-04-22 #> 7 1 9 2011-12-20 2011-12-20 #> 8 1 9 2011-12-21 2011-12-29 #> 9 1 9 2011-12-30 2012-04-02 #> 10 1 12 2000-11-15 2013-03-04 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimDemographics.html","id":null,"dir":"Reference","previous_headings":"","what":"Restrict cohort on patient demographics — trimDemographics","title":"Restrict cohort on patient demographics — trimDemographics","text":"trimDemographics() resets cohort start end date based specified demographic criteria satisfied.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimDemographics.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Restrict cohort on patient demographics — trimDemographics","text":"","code":"trimDemographics( cohort, cohortId = NULL, ageRange = NULL, sex = NULL, minPriorObservation = NULL, minFutureObservation = NULL, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimDemographics.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Restrict cohort on patient demographics — trimDemographics","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts modify (cohort_definition_id cohort_name). NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. ageRange list vectors specifying minimum maximum age. sex Can \"\", \"Male\" \"Female\". minPriorObservation minimum number continuous prior observation days database. minFutureObservation minimum number continuous future observation days database. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimDemographics.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Restrict cohort on patient demographics — trimDemographics","text":"cohort table records individuals satisfying demographic requirements","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimDemographics.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Restrict cohort on patient demographics — trimDemographics","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> trimDemographics(ageRange = list(c(10, 30))) #> ℹ Building new trimmed cohort #> Adding demographics information #> Creating initial cohort #> Trim age #> ✔ Cohort trimmed #> # Source: table [?? x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 4 1998-12-14 2002-02-14 #> 2 1 9 2011-12-30 2012-04-02 #> 3 1 21 1985-08-16 1986-09-10 #> 4 1 26 1984-05-16 1989-03-22 #> 5 1 35 2007-05-13 2010-07-22 #> 6 1 39 2000-03-07 2009-03-17 #> 7 1 41 2000-11-22 2000-12-09 #> 8 1 69 2003-01-14 2003-05-28 #> 9 1 71 2009-02-01 2009-09-05 #> 10 1 83 2007-05-29 2008-05-01 #> # ℹ more rows # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimToDateRange.html","id":null,"dir":"Reference","previous_headings":"","what":"Trim cohort dates to be within a date range — trimToDateRange","title":"Trim cohort dates to be within a date range — trimToDateRange","text":"trimToDateRange() resets cohort start end date based specified date range.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimToDateRange.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Trim cohort dates to be within a date range — trimToDateRange","text":"","code":"trimToDateRange( cohort, dateRange, cohortId = NULL, startDate = \"cohort_start_date\", endDate = \"cohort_end_date\", name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimToDateRange.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Trim cohort dates to be within a date range — trimToDateRange","text":"cohort cohort table cdm reference. dateRange window time index date must observed. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. startDate Variable earliest date. endDate Variable latest date. name Name new cohort restriction.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimToDateRange.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Trim cohort dates to be within a date range — trimToDateRange","text":"cohort table record timings updated within date range. records time outside range dropped.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/trimToDateRange.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Trim cohort dates to be within a date range — trimToDateRange","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor() cdm$cohort1 |> trimToDateRange(startDate = \"cohort_start_date\", endDate = \"cohort_end_date\", dateRange = as.Date(c(\"2015-01-01\", \"2015-12-31\"))) #> # Source: table [0 x 4] #> # Database: DuckDB v1.1.1 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:] #> # ℹ 4 variables: cohort_definition_id , subject_id , #> # cohort_start_date , cohort_end_date # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/unionCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate cohort from the union of different cohorts — unionCohorts","title":"Generate cohort from the union of different cohorts — unionCohorts","text":"unionCohorts() combines different cohort entries, records overlap combined kept. Cohort entries individual either cohorts.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/unionCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate cohort from the union of different cohorts — unionCohorts","text":"","code":"unionCohorts( cohort, cohortId = NULL, gap = 0, cohortName = NULL, keepOriginalCohorts = FALSE, name = tableName(cohort) )"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/unionCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate cohort from the union of different cohorts — unionCohorts","text":"cohort cohort table cdm reference. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. gap Number days two subsequent cohort entries merged single cohort record. cohortName Name returned cohort. NULL, cohort name created collapsing individual cohort names, separated \"_\". keepOriginalCohorts TRUE original cohorts return together new ones. FALSE new cohort returned. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/unionCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate cohort from the union of different cohorts — unionCohorts","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/unionCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate cohort from the union of different cohorts — unionCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort2 <- cdm$cohort2 |> unionCohorts() #> Warning: `union_cohorts()` was deprecated in CDMConnector 1.1.0. #> ℹ Please use `cohort_union()` instead. settings(cdm$cohort2) #> Error in UseMethod(\"settings\"): no applicable method for 'settings' applied to an object of class \"c('cdm_table', 'GeneratedCohortSet', 'tbl_duckdb_connection', 'tbl_dbi', 'tbl_sql', 'tbl_lazy', 'tbl')\" # }"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/windowDoc.html","id":null,"dir":"Reference","previous_headings":"","what":"Helper for consistent documentation of window. — windowDoc","title":"Helper for consistent documentation of window. — windowDoc","text":"Helper consistent documentation window.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/windowDoc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Helper for consistent documentation of window. — windowDoc","text":"window list vectors specifying minimum maximum days indexDate consider events .","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/yearCohorts.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","title":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","text":"yearCohorts() splits cohort multiple cohorts, one year.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/yearCohorts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","text":"","code":"yearCohorts(cohort, years, cohortId = NULL, name = tableName(cohort))"},{"path":"https://ohdsi.github.io/CohortConstructor/reference/yearCohorts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","text":"cohort cohort table cdm reference. years Numeric vector years use restrict observation .. cohortId Vector identifying cohorts include (cohort_definition_id cohort_name). Cohorts included removed cohort set. name Name new cohort table created cdm object.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/yearCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","text":"cohort table.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/yearCohorts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Generate a new cohort table restricting cohort entries to certain years — yearCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 <- cdm$cohort1 |> yearCohorts(years = 2000:2002) settings(cdm$cohort1) #> # A tibble: 3 × 5 #> cohort_definition_id cohort_name target_cohort_definition_id year #> #> 1 1 cohort_1_2000 1 2000 #> 2 2 cohort_1_2001 1 2001 #> 3 3 cohort_1_2002 1 2002 #> # ℹ 1 more variable: target_cohort_name # }"}]