diff --git a/apple-touch-icon-120x120.png b/apple-touch-icon-120x120.png index 8db26e75..bf7df8e9 100644 Binary files a/apple-touch-icon-120x120.png and b/apple-touch-icon-120x120.png differ diff --git a/apple-touch-icon-152x152.png b/apple-touch-icon-152x152.png index 54d6449c..89afe298 100644 Binary files a/apple-touch-icon-152x152.png and b/apple-touch-icon-152x152.png differ diff --git a/apple-touch-icon-180x180.png b/apple-touch-icon-180x180.png index c626b8de..1006707a 100644 Binary files a/apple-touch-icon-180x180.png and b/apple-touch-icon-180x180.png differ diff --git a/apple-touch-icon-60x60.png b/apple-touch-icon-60x60.png index d96a65a5..944a1aca 100644 Binary files a/apple-touch-icon-60x60.png and b/apple-touch-icon-60x60.png differ diff --git a/apple-touch-icon-76x76.png b/apple-touch-icon-76x76.png index 63101a42..47c78d7b 100644 Binary files a/apple-touch-icon-76x76.png and b/apple-touch-icon-76x76.png differ diff --git a/apple-touch-icon.png b/apple-touch-icon.png index 6366c56b..9f715dfe 100644 Binary files a/apple-touch-icon.png and b/apple-touch-icon.png differ diff --git a/articles/a01_building_base_cohorts.html b/articles/a01_building_base_cohorts.html index 4363096c..d48cff61 100644 --- a/articles/a01_building_base_cohorts.html +++ b/articles/a01_building_base_cohorts.html @@ -134,7 +134,7 @@

Demographic based cohort creation median_start_age = median(age), max_start_age = max(age)) #> # Source: SQL [1 x 3] -#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0//tmp/RtmpKulc3O/file19bb35f0898c.duckdb] +#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0//tmp/RtmptkC7Ks/file19c02fb323c4.duckdb] #> min_start_age median_start_age max_start_age #> <int> <dbl> <int> #> 1 17 18 18 @@ -146,7 +146,7 @@

Demographic based cohort creation median_start_age = median(age), max_start_age = max(age)) #> # Source: SQL [1 x 3] -#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0//tmp/RtmpKulc3O/file19bb35f0898c.duckdb] +#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0//tmp/RtmptkC7Ks/file19c02fb323c4.duckdb] #> min_start_age median_start_age max_start_age #> <int> <dbl> <int> #> 1 31 57 65 diff --git a/favicon-16x16.png b/favicon-16x16.png index a5f965c0..c0dfa9de 100644 Binary files a/favicon-16x16.png and b/favicon-16x16.png differ diff --git a/favicon-32x32.png b/favicon-32x32.png index 5d0cb0fa..ed2b309e 100644 Binary files a/favicon-32x32.png and b/favicon-32x32.png differ diff --git a/pkgdown.yml b/pkgdown.yml index 9fb8c1f8..07362277 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -7,7 +7,7 @@ articles: a02_applying_cohort_restrictions: a02_applying_cohort_restrictions.html a03_age_sex_matching: a03_age_sex_matching.html a04_cohort_manipulations: a04_cohort_manipulations.html -last_built: 2024-06-11T19:53Z +last_built: 2024-06-12T06:17Z 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 0d0e693d..79c48551 100644 --- a/reference/entryAtFirstDate.html +++ b/reference/entryAtFirstDate.html @@ -115,10 +115,10 @@

Examples#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date entry_reason #> <dbl> <dbl> <date> <date> <chr> -#> 1 1 1 2001-08-01 2001-09-01 date_2; dat… +#> 1 1 1 2001-08-01 2001-09-01 date_1; dat… #> 2 1 2 2001-01-01 2001-01-12 date_1 -#> 3 1 4 2002-12-09 2002-12-09 date_2; dat… -#> 4 1 3 2015-02-14 2015-02-15 date_2 +#> 3 1 3 2015-02-14 2015-02-15 date_2 +#> 4 1 4 2002-12-09 2002-12-09 date_1; dat… # } diff --git a/reference/entryAtLastDate.html b/reference/entryAtLastDate.html index 7b49f56f..61c51d66 100644 --- a/reference/entryAtLastDate.html +++ b/reference/entryAtLastDate.html @@ -113,9 +113,9 @@

Examples#> cohort_definition_id subject_id cohort_start_date cohort_end_date entry_reason #> <dbl> <dbl> <date> <date> <chr> #> 1 1 3 2015-02-14 2015-02-15 date_2 -#> 2 1 4 2002-12-09 2002-12-09 date_2; dat… -#> 3 1 2 2001-01-01 2001-01-12 date_1 -#> 4 1 1 2001-08-01 2001-09-01 date_2; dat… +#> 2 1 2 2001-01-01 2001-01-12 date_1 +#> 3 1 4 2002-12-09 2002-12-09 date_1; dat… +#> 4 1 1 2001-08-01 2001-09-01 date_1; dat… # } diff --git a/reference/exitAtDeath.html b/reference/exitAtDeath.html index 9d491054..fcf2cd61 100644 --- a/reference/exitAtDeath.html +++ b/reference/exitAtDeath.html @@ -105,16 +105,16 @@

Examples#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 2 1 1951-11-28 2019-01-16 -#> 2 1 6 2006-12-25 2022-11-01 -#> 3 2 2 1998-11-05 2008-01-27 +#> 1 2 2 1998-11-05 2008-01-27 +#> 2 2 1 1951-11-28 2019-01-16 +#> 3 1 6 2006-12-25 2022-11-01 #> 4 2 8 1954-07-05 1955-07-17 #> 5 2 5 2113-08-18 2144-11-05 #> 6 3 7 2029-01-30 2050-08-27 -#> 7 2 3 1993-12-06 1997-05-26 -#> 8 1 4 2017-04-18 2077-11-07 -#> 9 2 9 2109-11-07 2115-08-03 -#> 10 3 10 2003-01-05 2060-02-27 +#> 7 3 10 2003-01-05 2060-02-27 +#> 8 2 3 1993-12-06 1997-05-26 +#> 9 1 4 2017-04-18 2077-11-07 +#> 10 2 9 2109-11-07 2115-08-03 # } diff --git a/reference/exitAtFirstDate.html b/reference/exitAtFirstDate.html index 869d4ee0..def12629 100644 --- a/reference/exitAtFirstDate.html +++ b/reference/exitAtFirstDate.html @@ -115,9 +115,9 @@

Examples#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date exit_reason #> <dbl> <dbl> <date> <date> <chr> -#> 1 1 2 2000-01-01 2001-01-01 date_1 -#> 2 1 1 2000-06-03 2001-08-01 date_1; dat… -#> 3 1 4 2000-12-09 2002-12-09 date_1; dat… +#> 1 1 4 2000-12-09 2002-12-09 date_2; dat… +#> 2 1 2 2000-01-01 2001-01-01 date_1 +#> 3 1 1 2000-06-03 2001-08-01 date_2; dat… #> 4 1 3 2015-01-15 2015-01-15 date_1 # } diff --git a/reference/exitAtObservationEnd.html b/reference/exitAtObservationEnd.html index 1ba66e10..5b5a256a 100644 --- a/reference/exitAtObservationEnd.html +++ b/reference/exitAtObservationEnd.html @@ -101,12 +101,12 @@

Examples#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 1 4 1996-06-30 2013-12-31 -#> 2 1 2 2000-05-04 2003-06-15 +#> 1 1 2 2000-05-04 2003-06-15 +#> 2 1 7 2014-03-07 2014-04-09 #> 3 1 1 2001-05-30 2013-06-29 -#> 4 1 3 2015-01-27 2015-10-11 -#> 5 1 5 2012-03-20 2013-02-10 -#> 6 1 7 2014-03-07 2014-04-09 +#> 4 1 5 2012-03-20 2013-02-10 +#> 5 1 3 2015-01-27 2015-10-11 +#> 6 1 4 1996-06-30 2013-12-31 # } diff --git a/reference/matchCohorts.html b/reference/matchCohorts.html index 1f1b28ce..180d748e 100644 --- a/reference/matchCohorts.html +++ b/reference/matchCohorts.html @@ -141,16 +141,16 @@

Examples#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date cluster_id #> <int> <int> <date> <date> <dbl> -#> 1 1 19 2003-06-22 2005-07-21 36 -#> 2 1 84 1995-08-28 1999-04-05 42 -#> 3 1 121 2010-01-06 2012-12-04 47 -#> 4 1 24 2016-12-17 2016-12-29 59 -#> 5 1 119 1978-01-10 1982-09-07 66 -#> 6 1 120 2009-02-07 2009-12-14 80 -#> 7 1 62 2017-01-18 2017-04-26 73 -#> 8 1 118 1975-11-28 1981-05-30 6 -#> 9 1 56 2007-09-28 2008-07-15 18 -#> 10 1 63 2008-05-20 2008-08-22 19 +#> 1 1 118 1975-11-28 1981-05-30 6 +#> 2 1 56 2007-09-28 2008-07-15 18 +#> 3 1 63 2008-05-20 2008-08-22 19 +#> 4 1 20 1990-06-07 1993-11-05 26 +#> 5 1 19 2003-06-22 2005-07-21 35 +#> 6 1 84 1999-04-06 2000-04-12 42 +#> 7 1 121 2007-10-25 2010-01-05 46 +#> 8 1 94 2017-11-01 2018-07-05 59 +#> 9 1 5 2012-07-03 2012-09-24 77 +#> 10 1 120 2009-02-07 2009-12-14 79 #> # ℹ more rows # } diff --git a/reference/sampleCohorts.html b/reference/sampleCohorts.html index 9300d597..d2d6b085 100644 --- a/reference/sampleCohorts.html +++ b/reference/sampleCohorts.html @@ -96,16 +96,16 @@

Examples#> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> -#> 1 1 23 2001-02-04 2004-06-17 -#> 2 1 26 2007-02-24 2010-05-06 -#> 3 1 31 2013-03-29 2014-02-09 -#> 4 1 33 2017-01-20 2017-03-02 -#> 5 1 33 2017-03-03 2017-06-07 -#> 6 1 35 2018-01-07 2018-02-19 -#> 7 1 35 2018-02-20 2018-03-22 -#> 8 1 44 1983-03-22 1983-07-04 -#> 9 1 44 1983-07-05 1983-11-16 -#> 10 1 44 1983-11-17 1984-08-26 +#> 1 1 7 2014-03-08 2014-03-19 +#> 2 1 24 2016-11-15 2016-11-22 +#> 3 1 24 2016-11-23 2016-11-29 +#> 4 1 24 2016-11-30 2017-01-25 +#> 5 1 32 1991-09-11 2002-11-15 +#> 6 1 33 2017-01-20 2017-03-02 +#> 7 1 33 2017-03-03 2017-06-07 +#> 8 1 37 2003-05-29 2004-12-15 +#> 9 1 37 2004-12-16 2007-07-15 +#> 10 1 38 1990-05-01 1994-07-14 #> # ℹ more rows # } diff --git a/search.json b/search.json index a07053da..91430014 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":"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 age 65 ","code":"cdm$working_age_cohort <- demographicsCohort(cdm = cdm, ageRange = c(18, 65), name = \"working_age_cohort\") settings(cdm$working_age_cohort) #> # A tibble: 1 × 3 #> cohort_definition_id cohort_name age_range #> #> 1 1 demographics 18_65 cohortCount(cdm$working_age_cohort) #> # A tibble: 1 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 2694 2694 attrition(cdm$working_age_cohort) #> # A tibble: 2 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 2694 2694 1 Initial qualify… #> 2 1 2694 2694 2 Age requirement… #> # ℹ 2 more variables: excluded_records , excluded_subjects cdm$working_age_cohort |> addAge(indexDate = \"cohort_start_date\") |> summarise(min_start_age = min(age), median_start_age = median(age), max_start_age = max(age)) #> # Source: SQL [1 x 3] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0//tmp/RtmpKulc3O/file19bb35f0898c.duckdb] #> min_start_age median_start_age max_start_age #> #> 1 17 18 18 cdm$working_age_cohort |> addAge(indexDate = \"cohort_end_date\") |> summarise(min_start_age = min(age), median_start_age = median(age), max_start_age = max(age)) #> # Source: SQL [1 x 3] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0//tmp/RtmpKulc3O/file19bb35f0898c.duckdb] #> min_start_age median_start_age max_start_age #> #> 1 31 57 65"},{"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":"","code":"drug_codes <- getDrugIngredientCodes(cdm, name = c(\"diclofenac\", \"acetaminophen\")) drug_codes #> #> - diclofenac (1 codes) #> - acetaminophen (7 codes) cdm$medications <- conceptCohort(cdm = cdm, conceptSet = drug_codes, name = \"medications\") settings(cdm$medications) #> # A tibble: 2 × 2 #> cohort_definition_id cohort_name #> #> 1 1 diclofenac #> 2 2 acetaminophen cohortCount(cdm$medications) #> # A tibble: 2 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 830 830 #> 2 2 13908 2679"},{"path":[]},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_applying_cohort_restrictions.html","id":"keep-only-the-first-record-per-person","dir":"Articles","previous_headings":"","what":"Keep only the first record per person","title":"Applying cohort restrictions","text":"Individuals can contribute multiple records per cohort. However now ’ll keep earliest cohort entry remaining records using requireIsFirstEntry() CohortConstructor. can see one record per person cohort. Note, applying criteria later applying criteria result different result. ’re requiring individuals meet inclusion criteria time first use diclofenac acetaminophen.","code":"cdm$medications <- cdm$medications %>% requireIsFirstEntry(indexDate = \"cohort_start_date\") cohortCount(cdm$medications) #> # A tibble: 2 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 830 830 #> 2 2 2580 2580"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_applying_cohort_restrictions.html","id":"applying-restrictions-on-patient-demographics","dir":"Articles","previous_headings":"","what":"Applying restrictions on patient demographics","title":"Applying cohort restrictions","text":"Using requireDemographics() ’ll require individuals medications cohort female , relative cohort start date, 18 85 least 30 days prior observation time database. can see many people people excluded based demographic requirements.","code":"cdm$medications <- cdm$medications %>% requireDemographics(indexDate = \"cohort_start_date\", ageRange = list(c(18, 85)), sex = \"Female\", minPriorObservation = 30) cohort_attrition(cdm$medications) %>% dplyr::filter(reason == \"Demographic requirements\") %>% dplyr::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/articles/a02_applying_cohort_restrictions.html","id":"restrictions-on-calendar-dates","dir":"Articles","previous_headings":"","what":"Restrictions on calendar dates","title":"Applying cohort restrictions","text":"Next can use requireInDateRange() keep records cohort entry particular date range. , can track cohort attrition","code":"cdm$medications <- cdm$medications %>% requireInDateRange(indexDate = \"cohort_start_date\", dateRange = as.Date(c(\"2000-01-01\", \"2015-01-01\"))) cohort_attrition(cdm$medications) %>% dplyr::filter(reason == \"cohort_start_date between 2000-01-01 and 2015-01-01\") %>% dplyr::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/articles/a02_applying_cohort_restrictions.html","id":"restrictions-on-cohort-presence","dir":"Articles","previous_headings":"","what":"Restrictions on cohort presence","title":"Applying cohort restrictions","text":"require individuals medication cohorts history GI bleed. can use requireCohortIntersect() function, requiring individuals one intersections GI bleed cohort. Instead requiring individuals history GI bleed, instead require don’t history . case can use requireCohortIntersect() function, time set intersections argument 0 require individuals’ absence cohort rather presence .","code":"cdm$medications_gi_bleed <- cdm$medications %>% requireCohortIntersect(intersections = c(1,Inf), targetCohortTable = \"gi_bleed\", targetCohortId = 1, indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"medications_gi_bleed\") cohort_count(cdm$medications_gi_bleed) #> # A tibble: 2 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 0 0 #> 2 2 7 7 cdm$medications_no_gi_bleed <- cdm$medications %>% requireCohortIntersect(intersections = 0, targetCohortTable = \"gi_bleed\", targetCohortId = 1, indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"medications_no_gi_bleed\") cohort_count(cdm$medications_no_gi_bleed) #> # A tibble: 2 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 179 179 #> 2 2 94 94"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_age_sex_matching.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Generate a matched age and sex 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/a03_age_sex_matching.html","id":"create-mock-data","dir":"Articles","previous_headings":"Introduction","what":"Create mock data","title":"Generate a matched age and sex 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/a03_age_sex_matching.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":"Generate a matched age and sex 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/a03_age_sex_matching.html","id":"matchsex-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"matchSex parameter","title":"Generate a matched age and sex cohort","text":"matchSex boolean parameter (TRUE/FALSE) indicating want match sex (TRUE) want (FALSE).","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_age_sex_matching.html","id":"matchyear-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"matchYear parameter","title":"Generate a matched age and sex 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/a03_age_sex_matching.html","id":"ratio-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"ratio parameter","title":"Generate a matched age and sex 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/a03_age_sex_matching.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":"Generate a matched age and sex 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/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. 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 K (2024). CohortConstructor: Build Manipulate Study Cohorts Using Common Data Model. R package version 0.1.0.900, 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}, year = {2024}, note = {R package version 0.1.0.900}, 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":"package currently experimental. Please use care report issues might come across. goal CohortConstructor support creation manipulation cohorts OMOP Common Data Model.","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":"can install development version CohortConstructor GitHub :","code":"# 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 let’s create CDM reference Eunomia dataset Using CDMConnector package.","code":"library(CDMConnector) library(PatientProfiles) library(dplyr) library(CohortConstructor) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdm_from_con(con, cdm_schema = \"main\", write_schema = c(prefix = \"my_study_\", schema = \"main\")) print(cdm)"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"generating-concept-based-cohorts","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Generating concept based cohorts","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"start making concept based cohort. need provide concept sets get cohort back, cohort end date event date associated records, overlapping records collapsed, records observation kept. can see starting cohorts, add additional restrictions, following associated settings, counts, attrition.","code":"cdm$fractures <- cdm |> conceptCohort(conceptSet = list( \"ankle_fracture\" = 4059173, \"forearm_fracture\" = 4278672, \"hip_fracture\" = 4230399), name = \"fractures\") settings(cdm$fractures) %>% glimpse() #> Rows: 3 #> Columns: 2 #> $ cohort_definition_id 1, 2, 3 #> $ cohort_name \"ankle_fracture\", \"forearm_fracture\", \"hip_fractu… cohort_count(cdm$fractures) %>% glimpse() #> Rows: 3 #> Columns: 3 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 464, 569, 138 #> $ number_subjects 427, 510, 132 attrition(cdm$fractures) %>% glimpse() #> Rows: 3 #> Columns: 7 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 464, 569, 138 #> $ number_subjects 427, 510, 132 #> $ reason_id 1, 1, 1 #> $ reason \"Initial qualifying events\", \"Initial qualifying … #> $ excluded_records 0, 0, 0 #> $ excluded_subjects 0, 0, 0"},{"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 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 108, 152, 62 #> $ number_subjects 104, 143, 60 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 43, 64, 22 #> $ number_subjects 43, 62, 22 #> $ reason_id 4, 4, 4 #> $ reason \"Age requirement: 40 to 65\", \"Age requirement: 40… #> $ excluded_records 65, 88, 40 #> $ excluded_subjects 61, 81, 38 attrition(cdm$fractures) %>% filter(reason == \"Sex requirement: Female\") %>% glimpse() #> Rows: 3 #> Columns: 7 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 19, 37, 12 #> $ number_subjects 19, 36, 12 #> $ reason_id 5, 5, 5 #> $ reason \"Sex requirement: Female\", \"Sex requirement: Fema… #> $ excluded_records 24, 27, 10 #> $ excluded_subjects 24, 26, 10"},{"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\" = 192671), name = \"gibleed\") cdm$fractures <- cdm$fractures %>% requireCohortIntersect(targetCohortTable = \"gibleed\", window = c(-Inf, 0)) attrition(cdm$fractures) %>% filter(reason == \"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 5, 7, 2 #> $ number_subjects 5, 6, 2 #> $ reason_id 8, 8, 8 #> $ reason \"In cohort gibleed between -Inf & 0 days relative… #> $ excluded_records 14, 30, 10 #> $ excluded_subjects 14, 30, 10"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"combining-cohorts","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Combining cohorts","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"Currently separate fracture cohorts. Let’s say want create cohort people fractures. create cohort like :","code":"cdm$fractures <- cdm$fractures |> CohortConstructor::unionCohorts() settings(cdm$fractures) #> # A tibble: 1 × 3 #> cohort_definition_id cohort_name gap #> #> 1 1 ankle_fracture_forearm_fracture_hip_fracture 0 cohortCount(cdm$fractures) #> # A tibble: 1 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 14 13 cdmDisconnect(cdm)"},{"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 kim.lopez@spc.ox.ac.uk (ORCID)","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 cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. gap Number days use merging cohort entries. name Name cohort table.","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/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)"},{"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 cohort cdm object.","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) cohort <- conceptCohort(cdm = cdm, conceptSet = list(a = 1), name = \"cohort\") #> ℹ Subsetting table condition_occurrence using 1 concept with domain: condition. #> ℹ Combining tables. #> ℹ Collapsing records. #> ℹ Creating cohort attributes. #> ✔ Cohort cohort created. cohort |> attrition() #> # A tibble: 1 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 7 7 1 Initial qualify… #> # ℹ 2 more variables: excluded_records , excluded_subjects # }"},{"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, minFutureObservation = 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 ageRange list vectors specifying minimum maximum age. sex Can \"\", \"Male\" \"Female\". minPriorObservation minimum number prior observation days database. minFutureObservation minimum number future 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\") #> ℹ 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 5 5 2 Sex requirement… #> 3 1 4 4 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 Date columns cohort table consider. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column stating column dateColumns used new cohort end date. name Name new cohort restriction.","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\")) ) )) cdm$cohort |> entryAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date entry_reason #> #> 1 1 1 2001-08-01 2001-09-01 date_2; dat… #> 2 1 2 2001-01-01 2001-01-12 date_1 #> 3 1 4 2002-12-09 2002-12-09 date_2; dat… #> 4 1 3 2015-02-14 2015-02-15 date_2 # }"},{"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":"Set cohort start date last set column dates","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 description cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column stating column dateColumns used new cohort end date. description name Name new cohort restriction.","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\")) ) )) cdm$cohort |> entryAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date entry_reason #> #> 1 1 3 2015-02-14 2015-02-15 date_2 #> 2 1 4 2002-12-09 2002-12-09 date_2; dat… #> 3 1 2 2001-01-01 2001-01-12 date_1 #> 4 1 1 2001-08-01 2001-09-01 date_2; dat… # }"},{"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 IDs cohorts modify. 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 restriction.","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 v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 2 1 1951-11-28 2019-01-16 #> 2 1 6 2006-12-25 2022-11-01 #> 3 2 2 1998-11-05 2008-01-27 #> 4 2 8 1954-07-05 1955-07-17 #> 5 2 5 2113-08-18 2144-11-05 #> 6 3 7 2029-01-30 2050-08-27 #> 7 2 3 1993-12-06 1997-05-26 #> 8 1 4 2017-04-18 2077-11-07 #> 9 2 9 2109-11-07 2115-08-03 #> 10 3 10 2003-01-05 2060-02-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 Date columns cohort table consider. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column stating column dateColumns used new cohort end date. name Name new cohort restriction.","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\")) ) )) cdm$cohort |> exitAtFirstDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date exit_reason #> #> 1 1 2 2000-01-01 2001-01-01 date_1 #> 2 1 1 2000-06-03 2001-08-01 date_1; dat… #> 3 1 4 2000-12-09 2002-12-09 date_1; dat… #> 4 1 3 2015-01-15 2015-01-15 date_1 # }"},{"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 description cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column stating column dateColumns used new cohort end date. description name Name new cohort restriction.","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\")) ) )) cdm$cohort |> exitAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date exit_reason #> #> 1 1 2 2000-01-01 2001-01-01 date_1 #> 2 1 4 2000-12-09 2002-12-09 date_2; dat… #> 3 1 3 2015-01-15 2015-04-15 date_2 #> 4 1 1 2000-06-03 2001-08-01 date_2; dat… # }"},{"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, 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 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/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 v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 4 1996-06-30 2013-12-31 #> 2 1 2 2000-05-04 2003-06-15 #> 3 1 1 2001-05-30 2013-06-29 #> 4 1 3 2015-01-27 2015-10-11 #> 5 1 5 2012-03-20 2013-02-10 #> 6 1 7 2014-03-07 2014-04-09 # }"},{"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, mutuallyExclusive = FALSE, returnOnlyComb = 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 IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. gap Number days two subsequent cohort entries merged single cohort record. mutuallyExclusive Whether generated cohorts mutually exclusive . returnOnlyComb Whether get combination cohort back name Name new cohort demographic requirements.","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: 3 × 6 #> cohort_definition_id cohort_name cohort_1 cohort_2 mutually_exclusive gap #> #> 1 1 cohort_1 1 0 FALSE 0 #> 2 2 cohort_2 0 1 FALSE 0 #> 3 3 cohort_1_coho… 1 1 FALSE 0 # }"},{"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, 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 IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. matchSex Whether match sex. matchYearOfBirth Whether match year birth. ratio Number allowed matches per individual target cohort. name Name new generated cohort set.","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 both cohorts #> ✔ Done cdm$new_matched_cohort #> # Source: table [?? x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date cluster_id #> #> 1 1 19 2003-06-22 2005-07-21 36 #> 2 1 84 1995-08-28 1999-04-05 42 #> 3 1 121 2010-01-06 2012-12-04 47 #> 4 1 24 2016-12-17 2016-12-29 59 #> 5 1 119 1978-01-10 1982-09-07 66 #> 6 1 120 2009-02-07 2009-12-14 80 #> 7 1 62 2017-01-18 2017-04-26 73 #> 8 1 118 1975-11-28 1981-05-30 6 #> 9 1 56 2007-09-28 2008-07-15 18 #> 10 1 63 2008-05-20 2008-08-22 19 #> # ℹ 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 cohort 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)) ) #> ℹ Getting records in observation. #> ℹ Applying measurement requirements. #> ℹ Creating cohort attributes. #> ✔ Cohort cohort created. cdm$cohort #> # Source: table [2 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 2015-02-19 2015-02-19 #> 2 1 1 2000-07-01 2000-07-01 # }"},{"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/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 minimum maximum age. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort age requirement.","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: SQL [7 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 2000-05-04 2000-05-17 #> 2 1 2 2000-05-18 2001-01-23 #> 3 1 3 2015-01-27 2015-06-28 #> 4 1 5 2012-03-20 2012-04-30 #> 5 1 5 2012-05-01 2012-07-24 #> 6 1 7 2014-03-07 2014-03-07 #> 7 1 7 2014-03-08 2014-03-20 # }"},{"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 Window consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. targetCohortId Vector cohort definition ids include. indexDate Variable x contains date compute intersection. targetStartDate Date reference cohort table, either start (overlap) (incidence). targetEndDate Date reference cohort table, either end (overlap) NULL (incidence). censorDate Whether censor overlap events specific date column date x. name Name new cohort future observation restriction.","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 7] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date lower_limit #> #> 1 1 1 2001-05-30 2003-05-01 1 #> 2 1 1 2003-05-02 2006-06-10 1 #> 3 1 2 2000-05-04 2000-05-17 1 #> 4 1 2 2000-05-18 2001-01-23 1 #> 5 1 3 2015-01-27 2015-06-28 1 #> 6 1 4 1996-06-30 1998-11-20 1 #> 7 1 5 2012-03-20 2012-04-30 1 #> 8 1 5 2012-05-01 2012-07-24 1 #> 9 1 7 2014-03-07 2014-03-07 1 #> 10 1 7 2014-03-08 2014-03-20 1 #> # ℹ 2 more variables: upper_limit , 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 Concept set list. window Window consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged.. indexDate Variable x contains date compute intersection. targetStartDate Date reference cohort table, either start (overlap) (incidence). targetEndDate Date reference cohort table, either end (overlap) NULL (incidence). censorDate Whether censor overlap events specific date column date x. name Name new cohort future observation restriction.","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 = 1), window = c(-Inf, 0), name = \"cohort2\") # }"},{"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 Window consider events . cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable x contains date compute intersection. censorDate Whether censor overlap events specific date column date x. negate set TRUE, criteria applied exclusion rather inclusion (.e. require absence another cohort). name Name new cohort future observation restriction.","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 IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . ageRange list minimum maximum age. sex Can \"\", \"Male\" \"Female\". one latter, sex included. minPriorObservation minimum number prior observation days database. minFutureObservation minimum number 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 demographic requirements.","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: SQL [3 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 32 1991-09-11 2002-11-15 #> 2 1 38 1990-05-01 1994-07-14 #> 3 1 85 2000-05-09 2001-11-16 # }"},{"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 future observation days database. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort future observation restriction.","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: SQL [10 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 1 2001-05-30 2003-05-01 #> 2 1 1 2003-05-02 2006-06-10 #> 3 1 2 2000-05-04 2000-05-17 #> 4 1 2 2000-05-18 2001-01-23 #> 5 1 3 2015-01-27 2015-06-28 #> 6 1 4 1996-06-30 1998-11-20 #> 7 1 5 2012-03-20 2012-04-30 #> 8 1 5 2012-05-01 2012-07-24 #> 9 1 7 2014-03-07 2014-03-07 #> 10 1 7 2014-03-08 2014-03-20 # }"},{"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 window time index date must observed. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains index date interest name Name new cohort restriction.","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 v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 6 2011-03-07 2014-01-24 #> 2 1 7 2014-03-08 2014-03-19 #> 3 1 13 2014-06-24 2014-06-29 #> 4 1 13 2014-06-30 2014-08-07 #> 5 1 17 2017-03-28 2017-04-05 #> 6 1 18 2012-01-30 2012-05-21 #> 7 1 24 2016-11-15 2016-11-22 #> 8 1 24 2016-11-23 2016-11-29 #> 9 1 24 2016-11-30 2017-01-25 #> 10 1 31 2013-03-29 2014-02-09 #> # ℹ more rows # }"},{"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, indexDate = \"cohort_start_date\", 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 IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Column name cohort contains date restrict . 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, indexDate = \"cohort_start_date\", 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. indexDate Column name cohort contains date restrict . 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/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 prior observation days database. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort prior observation restriction.","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: SQL [4 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 1 2003-05-02 2006-06-10 #> 2 1 2 2000-05-04 2000-05-17 #> 3 1 2 2000-05-18 2001-01-23 #> 4 1 4 1996-06-30 1998-11-20 # }"},{"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\". one latter, sex included. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort sex requirements.","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: SQL [5 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 2000-05-04 2000-05-17 #> 2 1 2 2000-05-18 2001-01-23 #> 3 1 3 2015-01-27 2015-06-28 #> 4 1 5 2012-03-20 2012-04-30 #> 5 1 5 2012-05-01 2012-07-24 # }"},{"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 Window consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable x contains date compute intersection. targetStartDate Date reference cohort table, either start (overlap) (incidence). targetEndDate Date reference cohort table, either end (overlap) NULL (incidence). censorDate Whether censor overlap events specific date column date x. name Name new cohort future observation restriction.","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 [7 x 7] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date lower_limit #> #> 1 1 1 2003-05-02 2006-06-10 1 #> 2 1 2 2000-05-04 2000-05-17 1 #> 3 1 2 2000-05-18 2001-01-23 1 #> 4 1 3 2015-01-27 2015-06-28 1 #> 5 1 4 1996-06-30 1998-11-20 1 #> 6 1 5 2012-05-01 2012-07-24 1 #> 7 1 7 2014-03-08 2014-03-20 1 #> # ℹ 2 more variables: upper_limit , intersect_table # }"},{"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, cohortId = NULL, n, 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. cohortId IDs cohorts include. NULL cohorts considered. Cohorts included sampled. n Number people sampled included cohort. name Name new sampled cohort.","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 v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 23 2001-02-04 2004-06-17 #> 2 1 26 2007-02-24 2010-05-06 #> 3 1 31 2013-03-29 2014-02-09 #> 4 1 33 2017-01-20 2017-03-02 #> 5 1 33 2017-03-03 2017-06-07 #> 6 1 35 2018-01-07 2018-02-19 #> 7 1 35 2018-02-20 2018-03-22 #> 8 1 44 1983-03-22 1983-07-04 #> 9 1 44 1983-07-05 1983-11-16 #> 10 1 44 1983-11-17 1984-08-26 #> # ℹ 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 IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. removeStrata Whether remove strata columns final cohort table. name Name new cohort.","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() |> stratifyCohorts( strata = list(\"sex\", c(\"sex\", \"age_group\")), name = \"my_cohort\" ) cdm$my_cohort #> # Source: SQL [?? x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date age #> #> 1 2 1 2001-05-30 2003-05-01 3 #> 2 2 1 2003-05-02 2006-06-10 5 #> 3 1 2 2000-05-04 2000-05-17 37 #> 4 1 2 2000-05-18 2001-01-23 37 #> 5 1 3 2015-01-27 2015-06-28 28 #> 6 2 4 1996-06-30 1998-11-20 17 #> 7 1 5 2012-03-20 2012-04-30 39 #> 8 1 5 2012-05-01 2012-07-24 39 #> 9 2 7 2014-03-07 2014-03-07 27 #> 10 2 7 2014-03-08 2014-03-20 27 #> # ℹ 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 5 3 2 filter strata:… #> 3 2 10 6 1 Initial qualif… #> 4 2 5 3 2 filter strata:… #> 5 3 10 6 1 Initial qualif… #> 6 3 5 3 2 filter strata:… #> 7 3 5 3 3 filter strata:… #> 8 4 10 6 1 Initial qualif… #> 9 4 5 3 2 filter strata:… #> 10 4 0 0 3 filter strata:… #> 11 5 10 6 1 Initial qualif… #> 12 5 5 3 2 filter strata:… #> 13 5 2 1 3 filter strata:… #> 14 6 10 6 1 Initial qualif… #> 15 6 5 3 2 filter strata:… #> 16 6 3 2 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 using a subset of cohorts from another table. — subsetCohorts","title":"Generate a cohort table using a subset of cohorts from another table. — 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 using a subset of cohorts from another table. — subsetCohorts","text":"","code":"subsetCohorts(cohort, cohortId, minCohortCount = 0, 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 using a subset of cohorts from another table. — subsetCohorts","text":"cohort cohort table cdm reference. cohortId IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. minCohortCount minimum count cohort included. Default 0, meaning non-empty cohorts included. Cohorts included removed cohort set. name Name new cohort demographic requirements.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate a cohort table using a subset of cohorts from another table. — 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 using a subset of cohorts from another table. — subsetCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> subsetCohorts(cohortId = 1) #> # Source: table [?? x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 1 2001-02-15 2001-10-28 #> 2 1 1 2001-10-29 2003-03-15 #> 3 1 1 2003-03-16 2005-02-08 #> 4 1 2 1999-11-11 2002-04-09 #> 5 1 6 2011-03-07 2014-01-24 #> 6 1 7 2014-03-08 2014-03-19 #> 7 1 10 2019-12-04 2019-12-14 #> 8 1 13 2014-06-24 2014-06-29 #> 9 1 13 2014-06-30 2014-08-07 #> 10 1 14 1986-11-29 1987-12-14 #> # ℹ 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 IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. ageRange list minimum maximum age. sex Can \"\", \"Male\" \"Female\". one latter, sex included. minPriorObservation minimum number prior observation days database. minFutureObservation minimum number future observation days database. name Name new cohort demographic requirements.","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: SQL [?? x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 43 2014-10-05 2015-09-27 #> 2 1 48 1970-07-29 1974-01-28 #> 3 1 64 1993-05-18 2001-05-18 #> 4 1 75 1974-01-17 1974-10-19 #> 5 1 43 2014-07-21 2014-10-04 #> 6 1 29 2006-11-24 2008-03-21 #> 7 1 43 2014-07-06 2014-07-20 #> 8 1 29 2006-10-02 2006-11-23 #> 9 1 29 2006-07-07 2006-10-01 #> 10 1 10 2019-12-04 2019-12-14 #> # ℹ 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 [1 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 2015-01-27 2015-06-28 # }"},{"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, 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 IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. gap Number days two subsequent cohort entries subject merged single cohort entry cohortName Name returned cohort. NULL, cohort name created collapsing individual cohort names, separated \"_\". name Name new cohort table.","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/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 IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. name Name new cohort table.","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":"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 age 65 ","code":"cdm$working_age_cohort <- demographicsCohort(cdm = cdm, ageRange = c(18, 65), name = \"working_age_cohort\") settings(cdm$working_age_cohort) #> # A tibble: 1 × 3 #> cohort_definition_id cohort_name age_range #> #> 1 1 demographics 18_65 cohortCount(cdm$working_age_cohort) #> # A tibble: 1 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 2694 2694 attrition(cdm$working_age_cohort) #> # A tibble: 2 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 2694 2694 1 Initial qualify… #> 2 1 2694 2694 2 Age requirement… #> # ℹ 2 more variables: excluded_records , excluded_subjects cdm$working_age_cohort |> addAge(indexDate = \"cohort_start_date\") |> summarise(min_start_age = min(age), median_start_age = median(age), max_start_age = max(age)) #> # Source: SQL [1 x 3] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0//tmp/RtmptkC7Ks/file19c02fb323c4.duckdb] #> min_start_age median_start_age max_start_age #> #> 1 17 18 18 cdm$working_age_cohort |> addAge(indexDate = \"cohort_end_date\") |> summarise(min_start_age = min(age), median_start_age = median(age), max_start_age = max(age)) #> # Source: SQL [1 x 3] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0//tmp/RtmptkC7Ks/file19c02fb323c4.duckdb] #> min_start_age median_start_age max_start_age #> #> 1 31 57 65"},{"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":"","code":"drug_codes <- getDrugIngredientCodes(cdm, name = c(\"diclofenac\", \"acetaminophen\")) drug_codes #> #> - diclofenac (1 codes) #> - acetaminophen (7 codes) cdm$medications <- conceptCohort(cdm = cdm, conceptSet = drug_codes, name = \"medications\") settings(cdm$medications) #> # A tibble: 2 × 2 #> cohort_definition_id cohort_name #> #> 1 1 diclofenac #> 2 2 acetaminophen cohortCount(cdm$medications) #> # A tibble: 2 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 830 830 #> 2 2 13908 2679"},{"path":[]},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_applying_cohort_restrictions.html","id":"keep-only-the-first-record-per-person","dir":"Articles","previous_headings":"","what":"Keep only the first record per person","title":"Applying cohort restrictions","text":"Individuals can contribute multiple records per cohort. However now ’ll keep earliest cohort entry remaining records using requireIsFirstEntry() CohortConstructor. can see one record per person cohort. Note, applying criteria later applying criteria result different result. ’re requiring individuals meet inclusion criteria time first use diclofenac acetaminophen.","code":"cdm$medications <- cdm$medications %>% requireIsFirstEntry(indexDate = \"cohort_start_date\") cohortCount(cdm$medications) #> # A tibble: 2 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 830 830 #> 2 2 2580 2580"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a02_applying_cohort_restrictions.html","id":"applying-restrictions-on-patient-demographics","dir":"Articles","previous_headings":"","what":"Applying restrictions on patient demographics","title":"Applying cohort restrictions","text":"Using requireDemographics() ’ll require individuals medications cohort female , relative cohort start date, 18 85 least 30 days prior observation time database. can see many people people excluded based demographic requirements.","code":"cdm$medications <- cdm$medications %>% requireDemographics(indexDate = \"cohort_start_date\", ageRange = list(c(18, 85)), sex = \"Female\", minPriorObservation = 30) cohort_attrition(cdm$medications) %>% dplyr::filter(reason == \"Demographic requirements\") %>% dplyr::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/articles/a02_applying_cohort_restrictions.html","id":"restrictions-on-calendar-dates","dir":"Articles","previous_headings":"","what":"Restrictions on calendar dates","title":"Applying cohort restrictions","text":"Next can use requireInDateRange() keep records cohort entry particular date range. , can track cohort attrition","code":"cdm$medications <- cdm$medications %>% requireInDateRange(indexDate = \"cohort_start_date\", dateRange = as.Date(c(\"2000-01-01\", \"2015-01-01\"))) cohort_attrition(cdm$medications) %>% dplyr::filter(reason == \"cohort_start_date between 2000-01-01 and 2015-01-01\") %>% dplyr::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/articles/a02_applying_cohort_restrictions.html","id":"restrictions-on-cohort-presence","dir":"Articles","previous_headings":"","what":"Restrictions on cohort presence","title":"Applying cohort restrictions","text":"require individuals medication cohorts history GI bleed. can use requireCohortIntersect() function, requiring individuals one intersections GI bleed cohort. Instead requiring individuals history GI bleed, instead require don’t history . case can use requireCohortIntersect() function, time set intersections argument 0 require individuals’ absence cohort rather presence .","code":"cdm$medications_gi_bleed <- cdm$medications %>% requireCohortIntersect(intersections = c(1,Inf), targetCohortTable = \"gi_bleed\", targetCohortId = 1, indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"medications_gi_bleed\") cohort_count(cdm$medications_gi_bleed) #> # A tibble: 2 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 0 0 #> 2 2 7 7 cdm$medications_no_gi_bleed <- cdm$medications %>% requireCohortIntersect(intersections = 0, targetCohortTable = \"gi_bleed\", targetCohortId = 1, indexDate = \"cohort_start_date\", window = c(-Inf, 0), name = \"medications_no_gi_bleed\") cohort_count(cdm$medications_no_gi_bleed) #> # A tibble: 2 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 179 179 #> 2 2 94 94"},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_age_sex_matching.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Generate a matched age and sex 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/a03_age_sex_matching.html","id":"create-mock-data","dir":"Articles","previous_headings":"Introduction","what":"Create mock data","title":"Generate a matched age and sex 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/a03_age_sex_matching.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":"Generate a matched age and sex 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/a03_age_sex_matching.html","id":"matchsex-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"matchSex parameter","title":"Generate a matched age and sex cohort","text":"matchSex boolean parameter (TRUE/FALSE) indicating want match sex (TRUE) want (FALSE).","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/articles/a03_age_sex_matching.html","id":"matchyear-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"matchYear parameter","title":"Generate a matched age and sex 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/a03_age_sex_matching.html","id":"ratio-parameter","dir":"Articles","previous_headings":"Use generateMatchedCohortSet() to create an age-sex matched cohort","what":"ratio parameter","title":"Generate a matched age and sex 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/a03_age_sex_matching.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":"Generate a matched age and sex 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/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. 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 K (2024). CohortConstructor: Build Manipulate Study Cohorts Using Common Data Model. R package version 0.1.0.900, 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}, year = {2024}, note = {R package version 0.1.0.900}, 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":"package currently experimental. Please use care report issues might come across. goal CohortConstructor support creation manipulation cohorts OMOP Common Data Model.","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":"can install development version CohortConstructor GitHub :","code":"# 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 let’s create CDM reference Eunomia dataset Using CDMConnector package.","code":"library(CDMConnector) library(PatientProfiles) library(dplyr) library(CohortConstructor) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdm_from_con(con, cdm_schema = \"main\", write_schema = c(prefix = \"my_study_\", schema = \"main\")) print(cdm)"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"generating-concept-based-cohorts","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Generating concept based cohorts","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"start making concept based cohort. need provide concept sets get cohort back, cohort end date event date associated records, overlapping records collapsed, records observation kept. can see starting cohorts, add additional restrictions, following associated settings, counts, attrition.","code":"cdm$fractures <- cdm |> conceptCohort(conceptSet = list( \"ankle_fracture\" = 4059173, \"forearm_fracture\" = 4278672, \"hip_fracture\" = 4230399), name = \"fractures\") settings(cdm$fractures) %>% glimpse() #> Rows: 3 #> Columns: 2 #> $ cohort_definition_id 1, 2, 3 #> $ cohort_name \"ankle_fracture\", \"forearm_fracture\", \"hip_fractu… cohort_count(cdm$fractures) %>% glimpse() #> Rows: 3 #> Columns: 3 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 464, 569, 138 #> $ number_subjects 427, 510, 132 attrition(cdm$fractures) %>% glimpse() #> Rows: 3 #> Columns: 7 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 464, 569, 138 #> $ number_subjects 427, 510, 132 #> $ reason_id 1, 1, 1 #> $ reason \"Initial qualifying events\", \"Initial qualifying … #> $ excluded_records 0, 0, 0 #> $ excluded_subjects 0, 0, 0"},{"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 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 108, 152, 62 #> $ number_subjects 104, 143, 60 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 43, 64, 22 #> $ number_subjects 43, 62, 22 #> $ reason_id 4, 4, 4 #> $ reason \"Age requirement: 40 to 65\", \"Age requirement: 40… #> $ excluded_records 65, 88, 40 #> $ excluded_subjects 61, 81, 38 attrition(cdm$fractures) %>% filter(reason == \"Sex requirement: Female\") %>% glimpse() #> Rows: 3 #> Columns: 7 #> $ cohort_definition_id 1, 2, 3 #> $ number_records 19, 37, 12 #> $ number_subjects 19, 36, 12 #> $ reason_id 5, 5, 5 #> $ reason \"Sex requirement: Female\", \"Sex requirement: Fema… #> $ excluded_records 24, 27, 10 #> $ excluded_subjects 24, 26, 10"},{"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\" = 192671), name = \"gibleed\") cdm$fractures <- cdm$fractures %>% requireCohortIntersect(targetCohortTable = \"gibleed\", window = c(-Inf, 0)) attrition(cdm$fractures) %>% filter(reason == \"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 5, 7, 2 #> $ number_subjects 5, 6, 2 #> $ reason_id 8, 8, 8 #> $ reason \"In cohort gibleed between -Inf & 0 days relative… #> $ excluded_records 14, 30, 10 #> $ excluded_subjects 14, 30, 10"},{"path":"https://ohdsi.github.io/CohortConstructor/index.html","id":"combining-cohorts","dir":"","previous_headings":"Creating and manipulating cohorts","what":"Combining cohorts","title":"Build and Manipulate Study Cohorts Using a Common Data Model","text":"Currently separate fracture cohorts. Let’s say want create cohort people fractures. create cohort like :","code":"cdm$fractures <- cdm$fractures |> CohortConstructor::unionCohorts() settings(cdm$fractures) #> # A tibble: 1 × 3 #> cohort_definition_id cohort_name gap #> #> 1 1 ankle_fracture_forearm_fracture_hip_fracture 0 cohortCount(cdm$fractures) #> # A tibble: 1 × 3 #> cohort_definition_id number_records number_subjects #> #> 1 1 14 13 cdmDisconnect(cdm)"},{"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 kim.lopez@spc.ox.ac.uk (ORCID)","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 cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. gap Number days use merging cohort entries. name Name cohort table.","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/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)"},{"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 cohort cdm object.","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) cohort <- conceptCohort(cdm = cdm, conceptSet = list(a = 1), name = \"cohort\") #> ℹ Subsetting table condition_occurrence using 1 concept with domain: condition. #> ℹ Combining tables. #> ℹ Collapsing records. #> ℹ Creating cohort attributes. #> ✔ Cohort cohort created. cohort |> attrition() #> # A tibble: 1 × 7 #> cohort_definition_id number_records number_subjects reason_id reason #> #> 1 1 7 7 1 Initial qualify… #> # ℹ 2 more variables: excluded_records , excluded_subjects # }"},{"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, minFutureObservation = 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 ageRange list vectors specifying minimum maximum age. sex Can \"\", \"Male\" \"Female\". minPriorObservation minimum number prior observation days database. minFutureObservation minimum number future 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\") #> ℹ 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 5 5 2 Sex requirement… #> 3 1 4 4 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 Date columns cohort table consider. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column stating column dateColumns used new cohort end date. name Name new cohort restriction.","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\")) ) )) cdm$cohort |> entryAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date entry_reason #> #> 1 1 1 2001-08-01 2001-09-01 date_1; dat… #> 2 1 2 2001-01-01 2001-01-12 date_1 #> 3 1 3 2015-02-14 2015-02-15 date_2 #> 4 1 4 2002-12-09 2002-12-09 date_1; dat… # }"},{"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":"Set cohort start date last set column dates","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 description cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column stating column dateColumns used new cohort end date. description name Name new cohort restriction.","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\")) ) )) cdm$cohort |> entryAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date entry_reason #> #> 1 1 3 2015-02-14 2015-02-15 date_2 #> 2 1 2 2001-01-01 2001-01-12 date_1 #> 3 1 4 2002-12-09 2002-12-09 date_1; dat… #> 4 1 1 2001-08-01 2001-09-01 date_1; dat… # }"},{"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 IDs cohorts modify. 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 restriction.","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 v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 2 2 1998-11-05 2008-01-27 #> 2 2 1 1951-11-28 2019-01-16 #> 3 1 6 2006-12-25 2022-11-01 #> 4 2 8 1954-07-05 1955-07-17 #> 5 2 5 2113-08-18 2144-11-05 #> 6 3 7 2029-01-30 2050-08-27 #> 7 3 10 2003-01-05 2060-02-27 #> 8 2 3 1993-12-06 1997-05-26 #> 9 1 4 2017-04-18 2077-11-07 #> 10 2 9 2109-11-07 2115-08-03 # }"},{"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 Date columns cohort table consider. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column stating column dateColumns used new cohort end date. name Name new cohort restriction.","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\")) ) )) cdm$cohort |> exitAtFirstDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date exit_reason #> #> 1 1 4 2000-12-09 2002-12-09 date_2; dat… #> 2 1 2 2000-01-01 2001-01-01 date_1 #> 3 1 1 2000-06-03 2001-08-01 date_2; dat… #> 4 1 3 2015-01-15 2015-01-15 date_1 # }"},{"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 description cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. returnReason TRUE return column stating column dateColumns used new cohort end date. description name Name new cohort restriction.","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\")) ) )) cdm$cohort |> exitAtLastDate(dateColumns = c(\"date_1\", \"date_2\")) #> # Source: table [4 x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date exit_reason #> #> 1 1 2 2000-01-01 2001-01-01 date_1 #> 2 1 4 2000-12-09 2002-12-09 date_2; dat… #> 3 1 3 2015-01-15 2015-04-15 date_2 #> 4 1 1 2000-06-03 2001-08-01 date_2; dat… # }"},{"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, 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 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/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 v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 2000-05-04 2003-06-15 #> 2 1 7 2014-03-07 2014-04-09 #> 3 1 1 2001-05-30 2013-06-29 #> 4 1 5 2012-03-20 2013-02-10 #> 5 1 3 2015-01-27 2015-10-11 #> 6 1 4 1996-06-30 2013-12-31 # }"},{"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, mutuallyExclusive = FALSE, returnOnlyComb = 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 IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. gap Number days two subsequent cohort entries merged single cohort record. mutuallyExclusive Whether generated cohorts mutually exclusive . returnOnlyComb Whether get combination cohort back name Name new cohort demographic requirements.","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: 3 × 6 #> cohort_definition_id cohort_name cohort_1 cohort_2 mutually_exclusive gap #> #> 1 1 cohort_1 1 0 FALSE 0 #> 2 2 cohort_2 0 1 FALSE 0 #> 3 3 cohort_1_coho… 1 1 FALSE 0 # }"},{"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, 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 IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. matchSex Whether match sex. matchYearOfBirth Whether match year birth. ratio Number allowed matches per individual target cohort. name Name new generated cohort set.","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 both cohorts #> ✔ Done cdm$new_matched_cohort #> # Source: table [?? x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date cluster_id #> #> 1 1 118 1975-11-28 1981-05-30 6 #> 2 1 56 2007-09-28 2008-07-15 18 #> 3 1 63 2008-05-20 2008-08-22 19 #> 4 1 20 1990-06-07 1993-11-05 26 #> 5 1 19 2003-06-22 2005-07-21 35 #> 6 1 84 1999-04-06 2000-04-12 42 #> 7 1 121 2007-10-25 2010-01-05 46 #> 8 1 94 2017-11-01 2018-07-05 59 #> 9 1 5 2012-07-03 2012-09-24 77 #> 10 1 120 2009-02-07 2009-12-14 79 #> # ℹ 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 cohort 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)) ) #> ℹ Getting records in observation. #> ℹ Applying measurement requirements. #> ℹ Creating cohort attributes. #> ✔ Cohort cohort created. cdm$cohort #> # Source: table [2 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 2015-02-19 2015-02-19 #> 2 1 1 2000-07-01 2000-07-01 # }"},{"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/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 minimum maximum age. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort age requirement.","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: SQL [7 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 2000-05-04 2000-05-17 #> 2 1 2 2000-05-18 2001-01-23 #> 3 1 3 2015-01-27 2015-06-28 #> 4 1 5 2012-03-20 2012-04-30 #> 5 1 5 2012-05-01 2012-07-24 #> 6 1 7 2014-03-07 2014-03-07 #> 7 1 7 2014-03-08 2014-03-20 # }"},{"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 Window consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. targetCohortId Vector cohort definition ids include. indexDate Variable x contains date compute intersection. targetStartDate Date reference cohort table, either start (overlap) (incidence). targetEndDate Date reference cohort table, either end (overlap) NULL (incidence). censorDate Whether censor overlap events specific date column date x. name Name new cohort future observation restriction.","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 7] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date lower_limit #> #> 1 1 1 2001-05-30 2003-05-01 1 #> 2 1 1 2003-05-02 2006-06-10 1 #> 3 1 2 2000-05-04 2000-05-17 1 #> 4 1 2 2000-05-18 2001-01-23 1 #> 5 1 3 2015-01-27 2015-06-28 1 #> 6 1 4 1996-06-30 1998-11-20 1 #> 7 1 5 2012-03-20 2012-04-30 1 #> 8 1 5 2012-05-01 2012-07-24 1 #> 9 1 7 2014-03-07 2014-03-07 1 #> 10 1 7 2014-03-08 2014-03-20 1 #> # ℹ 2 more variables: upper_limit , 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 Concept set list. window Window consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged.. indexDate Variable x contains date compute intersection. targetStartDate Date reference cohort table, either start (overlap) (incidence). targetEndDate Date reference cohort table, either end (overlap) NULL (incidence). censorDate Whether censor overlap events specific date column date x. name Name new cohort future observation restriction.","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 = 1), window = c(-Inf, 0), name = \"cohort2\") # }"},{"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 Window consider events . cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable x contains date compute intersection. censorDate Whether censor overlap events specific date column date x. negate set TRUE, criteria applied exclusion rather inclusion (.e. require absence another cohort). name Name new cohort future observation restriction.","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 IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . ageRange list minimum maximum age. sex Can \"\", \"Male\" \"Female\". one latter, sex included. minPriorObservation minimum number prior observation days database. minFutureObservation minimum number 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 demographic requirements.","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: SQL [3 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 32 1991-09-11 2002-11-15 #> 2 1 38 1990-05-01 1994-07-14 #> 3 1 85 2000-05-09 2001-11-16 # }"},{"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 future observation days database. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort future observation restriction.","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: SQL [10 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 1 2001-05-30 2003-05-01 #> 2 1 1 2003-05-02 2006-06-10 #> 3 1 2 2000-05-04 2000-05-17 #> 4 1 2 2000-05-18 2001-01-23 #> 5 1 3 2015-01-27 2015-06-28 #> 6 1 4 1996-06-30 1998-11-20 #> 7 1 5 2012-03-20 2012-04-30 #> 8 1 5 2012-05-01 2012-07-24 #> 9 1 7 2014-03-07 2014-03-07 #> 10 1 7 2014-03-08 2014-03-20 # }"},{"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 window time index date must observed. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains index date interest name Name new cohort restriction.","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 v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 6 2011-03-07 2014-01-24 #> 2 1 7 2014-03-08 2014-03-19 #> 3 1 13 2014-06-24 2014-06-29 #> 4 1 13 2014-06-30 2014-08-07 #> 5 1 17 2017-03-28 2017-04-05 #> 6 1 18 2012-01-30 2012-05-21 #> 7 1 24 2016-11-15 2016-11-22 #> 8 1 24 2016-11-23 2016-11-29 #> 9 1 24 2016-11-30 2017-01-25 #> 10 1 31 2013-03-29 2014-02-09 #> # ℹ more rows # }"},{"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, indexDate = \"cohort_start_date\", 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 IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Column name cohort contains date restrict . 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, indexDate = \"cohort_start_date\", 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. indexDate Column name cohort contains date restrict . 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/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 prior observation days database. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable cohort contains date compute demographics characteristics restrict . name Name new cohort prior observation restriction.","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: SQL [4 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 1 2003-05-02 2006-06-10 #> 2 1 2 2000-05-04 2000-05-17 #> 3 1 2 2000-05-18 2001-01-23 #> 4 1 4 1996-06-30 1998-11-20 # }"},{"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\". one latter, sex included. cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. name Name new cohort sex requirements.","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: SQL [5 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 2 2000-05-04 2000-05-17 #> 2 1 2 2000-05-18 2001-01-23 #> 3 1 3 2015-01-27 2015-06-28 #> 4 1 5 2012-03-20 2012-04-30 #> 5 1 5 2012-05-01 2012-07-24 # }"},{"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 Window consider events . intersections range indicating number intersections criteria fulfilled. single number passed, number intersections must match . cohortId IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. indexDate Variable x contains date compute intersection. targetStartDate Date reference cohort table, either start (overlap) (incidence). targetEndDate Date reference cohort table, either end (overlap) NULL (incidence). censorDate Whether censor overlap events specific date column date x. name Name new cohort future observation restriction.","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 [7 x 7] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date lower_limit #> #> 1 1 1 2003-05-02 2006-06-10 1 #> 2 1 2 2000-05-04 2000-05-17 1 #> 3 1 2 2000-05-18 2001-01-23 1 #> 4 1 3 2015-01-27 2015-06-28 1 #> 5 1 4 1996-06-30 1998-11-20 1 #> 6 1 5 2012-05-01 2012-07-24 1 #> 7 1 7 2014-03-08 2014-03-20 1 #> # ℹ 2 more variables: upper_limit , intersect_table # }"},{"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, cohortId = NULL, n, 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. cohortId IDs cohorts include. NULL cohorts considered. Cohorts included sampled. n Number people sampled included cohort. name Name new sampled cohort.","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 v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 7 2014-03-08 2014-03-19 #> 2 1 24 2016-11-15 2016-11-22 #> 3 1 24 2016-11-23 2016-11-29 #> 4 1 24 2016-11-30 2017-01-25 #> 5 1 32 1991-09-11 2002-11-15 #> 6 1 33 2017-01-20 2017-03-02 #> 7 1 33 2017-03-03 2017-06-07 #> 8 1 37 2003-05-29 2004-12-15 #> 9 1 37 2004-12-16 2007-07-15 #> 10 1 38 1990-05-01 1994-07-14 #> # ℹ 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 IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. removeStrata Whether remove strata columns final cohort table. name Name new cohort.","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() |> stratifyCohorts( strata = list(\"sex\", c(\"sex\", \"age_group\")), name = \"my_cohort\" ) cdm$my_cohort #> # Source: SQL [?? x 5] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date age #> #> 1 2 1 2001-05-30 2003-05-01 3 #> 2 2 1 2003-05-02 2006-06-10 5 #> 3 1 2 2000-05-04 2000-05-17 37 #> 4 1 2 2000-05-18 2001-01-23 37 #> 5 1 3 2015-01-27 2015-06-28 28 #> 6 2 4 1996-06-30 1998-11-20 17 #> 7 1 5 2012-03-20 2012-04-30 39 #> 8 1 5 2012-05-01 2012-07-24 39 #> 9 2 7 2014-03-07 2014-03-07 27 #> 10 2 7 2014-03-08 2014-03-20 27 #> # ℹ 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 5 3 2 filter strata:… #> 3 2 10 6 1 Initial qualif… #> 4 2 5 3 2 filter strata:… #> 5 3 10 6 1 Initial qualif… #> 6 3 5 3 2 filter strata:… #> 7 3 5 3 3 filter strata:… #> 8 4 10 6 1 Initial qualif… #> 9 4 5 3 2 filter strata:… #> 10 4 0 0 3 filter strata:… #> 11 5 10 6 1 Initial qualif… #> 12 5 5 3 2 filter strata:… #> 13 5 2 1 3 filter strata:… #> 14 6 10 6 1 Initial qualif… #> 15 6 5 3 2 filter strata:… #> 16 6 3 2 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 using a subset of cohorts from another table. — subsetCohorts","title":"Generate a cohort table using a subset of cohorts from another table. — 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 using a subset of cohorts from another table. — subsetCohorts","text":"","code":"subsetCohorts(cohort, cohortId, minCohortCount = 0, 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 using a subset of cohorts from another table. — subsetCohorts","text":"cohort cohort table cdm reference. cohortId IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. minCohortCount minimum count cohort included. Default 0, meaning non-empty cohorts included. Cohorts included removed cohort set. name Name new cohort demographic requirements.","code":""},{"path":"https://ohdsi.github.io/CohortConstructor/reference/subsetCohorts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate a cohort table using a subset of cohorts from another table. — 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 using a subset of cohorts from another table. — subsetCohorts","text":"","code":"# \\donttest{ library(CohortConstructor) cdm <- mockCohortConstructor(nPerson = 100) cdm$cohort1 |> subsetCohorts(cohortId = 1) #> # Source: table [?? x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 1 2001-02-15 2001-10-28 #> 2 1 1 2001-10-29 2003-03-15 #> 3 1 1 2003-03-16 2005-02-08 #> 4 1 2 1999-11-11 2002-04-09 #> 5 1 6 2011-03-07 2014-01-24 #> 6 1 7 2014-03-08 2014-03-19 #> 7 1 10 2019-12-04 2019-12-14 #> 8 1 13 2014-06-24 2014-06-29 #> 9 1 13 2014-06-30 2014-08-07 #> 10 1 14 1986-11-29 1987-12-14 #> # ℹ 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 IDs cohorts modify. NULL, cohorts used; otherwise, specified cohorts modified, rest remain unchanged. ageRange list minimum maximum age. sex Can \"\", \"Male\" \"Female\". one latter, sex included. minPriorObservation minimum number prior observation days database. minFutureObservation minimum number future observation days database. name Name new cohort demographic requirements.","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: SQL [?? x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 43 2014-10-05 2015-09-27 #> 2 1 48 1970-07-29 1974-01-28 #> 3 1 64 1993-05-18 2001-05-18 #> 4 1 75 1974-01-17 1974-10-19 #> 5 1 43 2014-07-21 2014-10-04 #> 6 1 29 2006-11-24 2008-03-21 #> 7 1 43 2014-07-06 2014-07-20 #> 8 1 29 2006-10-02 2006-11-23 #> 9 1 29 2006-07-07 2006-10-01 #> 10 1 10 2019-12-04 2019-12-14 #> # ℹ 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 [1 x 4] #> # Database: DuckDB v0.10.2 [unknown@Linux 6.5.0-1021-azure:R 4.4.0/:memory:] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> #> 1 1 3 2015-01-27 2015-06-28 # }"},{"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, 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 IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. gap Number days two subsequent cohort entries subject merged single cohort entry cohortName Name returned cohort. NULL, cohort name created collapsing individual cohort names, separated \"_\". name Name new cohort table.","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/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 IDs cohorts include. NULL cohorts considered. Cohorts included removed cohort set. name Name new cohort table.","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 # }"}]