Class for automating the creation of bulk cohorts
Source:R/TemplateCohorts.R
CohortTemplateDefinition.RdClass for automating the creation of bulk cohorts
Class for automating the creation of bulk cohorts
Details
This class provides a framework for automating the creation of bulk cohorts by defining template SQL queries and associated callbacks to execute them. This is useful when defining lots of exposure or outcomes for cohorts that are very general in nature. For example, all RxNorm ingredient cohorts, all ATC ingredient cohorts or all SNOMED condition occurrences with > x diagnosis codes.
These cohorts can then be subsetted with common cohort subset operations such as limiting to specific age, gender, or observation criteria, should this be excluded from the cohort definition. However, when applying operations in bulk it may be more efficient to include such definitions within the template sql itself.
This approach is also useful for cohorts that can not based on ATLAS/CirceDefinitions alone.
CURRENTLY NOT SUPPORTED: * Saving definitions that use runtime arguments on a per cdm basis. This creates a challenge for running the same cohort across different databases. Furthermore, saving information within the CDM schema in a shared OHDSI study is not desirable.
Active bindings
namename for this template definition that describes the cohorts it creation
sqlArgsoptional arguments for sql
templateSqlsql template
translateSqltranslate the sql for different platforms
referencesdata.frame of name/id references for cohort template that aligns with cohort set
Methods
Method new()
Usage
CohortTemplateDefinition$new(settings)Arguments
settingsSettings of object to load seealso createCohortTemplateDefinition To alter the execution, override this function in a subclass. This translates and executes the sql of the cohort definition Note that calling this function will generate the cohorts but will not do so in an incremental manner. Checksums and timestamps will, however, be added to the generation table ever want to call this function outside of a testing environment. It is best practice to always use the standard runCohortGeneration/generateCohortSet pipeline to ensure validity of execution steps.
Method executeTemplateSql()
Usage
CohortTemplateDefinition$executeTemplateSql(
connection,
cohortDatabaseSchema,
cdmDatabaseSchema,
cohortTableNames,
vocabularyDatabaseSchema = cdmDatabaseSchema,
tempEmulationSchema = getOption("sqlRenderTempEmulationSchema")
)Arguments
connectionAn object of type
connectionas created using theconnectfunction in the DatabaseConnector package. Can be left NULL ifconnectionDetailsis provided, in which case a new connection will be opened at the start of the function, and closed when the function finishes.cohortDatabaseSchemaSchema name where your cohort tables reside. Note that for SQL Server, this should include both the database and schema name, for example 'scratch.dbo'.
cohortDatabaseSchemaSchema name where your cohort tables reside. Note that for SQL Server, this should include both the database and schema name, for example 'scratch.dbo'.
cdmDatabaseSchemaSchema name where your patient-level data in OMOP CDM format resides. Note that for SQL Server, this should include both the database and schema name, for example 'cdm_data.dbo'.
cohortTableNamesThe names of the cohort tables. See
getCohortTableNamesfor more details.vocabularyDatabaseSchemavocabulary database schema
tempEmulationSchemacdm temp emulation schema get template references data.frame
Method getId()
this is not the cohort ids and is based off of the checksum of the template definition get checksum