% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DataLoadingSaving.R
\name{getDbCohortMethodData}
\alias{getDbCohortMethodData}
\title{Get the cohort data from the server}
\usage{
getDbCohortMethodData(
  connectionDetails,
  cdmDatabaseSchema,
  tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"),
  targetId,
  comparatorId,
  outcomeIds,
  exposureDatabaseSchema = cdmDatabaseSchema,
  exposureTable = "drug_era",
  outcomeDatabaseSchema = cdmDatabaseSchema,
  outcomeTable = "condition_occurrence",
  nestingCohortDatabaseSchema = cdmDatabaseSchema,
  nestingCohortTable = "cohort",
  getDbCohortMethodDataArgs = createGetDbCohortMethodDataArgs()
)
}
\arguments{
\item{connectionDetails}{An R object of type \code{connectionDetails} created using the
\code{\link[DatabaseConnector:createConnectionDetails]{DatabaseConnector::createConnectionDetails()}} function.}

\item{cdmDatabaseSchema}{The name of the database schema that contains the OMOP CDM
instance. Requires read permissions to this database. On SQL
Server, this should specify both the database and the schema,
so for example 'cdm_instance.dbo'.}

\item{tempEmulationSchema}{Some database platforms like Oracle and Impala do not truly
support temp tables. To emulate temp tables, provide a schema
with write privileges where temp tables can be created.}

\item{targetId}{A unique identifier to define the target cohort.  If
exposureTable = DRUG_ERA, targetId is a concept ID and all
descendant concepts within that concept ID will be used to
define the cohort.  If exposureTable <> DRUG_ERA, targetId is
used to select the COHORT_DEFINITION_ID in the cohort-like table.}

\item{comparatorId}{A unique identifier to define the comparator cohort.  If
exposureTable = DRUG_ERA, comparatorId is a concept ID and all
descendant concepts within that concept ID will be used to
define the cohort.  If exposureTable <> DRUG_ERA, comparatorId
is used to select the COHORT_DEFINITION_ID in the cohort-like
table.}

\item{outcomeIds}{A list of cohort IDs used to define outcomes.}

\item{exposureDatabaseSchema}{The name of the database schema that is the location where the
exposure data used to define the exposure cohorts is available.}

\item{exposureTable}{The tablename that contains the exposure cohorts. If
exposureTable <> DRUG_ERA, then expectation is \code{exposureTable}
has format of COHORT table: COHORT_DEFINITION_ID, SUBJECT_ID,
COHORT_START_DATE, COHORT_END_DATE.}

\item{outcomeDatabaseSchema}{The name of the database schema that is the location where the
data used to define the outcome cohorts is available.}

\item{outcomeTable}{The tablename that contains the outcome cohorts.  If
outcomeTable <> CONDITION_OCCURRENCE, then expectation is
outcomeTable has format of COHORT table: COHORT_DEFINITION_ID,
SUBJECT_ID, COHORT_START_DATE, COHORT_END_DATE.}

\item{nestingCohortDatabaseSchema}{The name of the database schema that is the location where the
data used to define the nesting cohorts is available.}

\item{nestingCohortTable}{The tablename that contains the nesting cohorts. Must have
the format of COHORT table: COHORT_DEFINITION_ID, SUBJECT_ID,
COHORT_START_DATE, COHORT_END_DATE.}

\item{getDbCohortMethodDataArgs}{An object of type \code{GetDbCohortMethodDataArgs} as created by
the \code{\link[=createGetDbCohortMethodDataArgs]{createGetDbCohortMethodDataArgs()}} function.}
}
\value{
A \link{CohortMethodData} object.
}
\description{
This function executes a large set of SQL statements against the database in OMOP CDM format to
extract the data needed to perform the analysis.
}
\details{
Based on the arguments, the treatment and comparator cohorts are retrieved, as well as outcomes
occurring in exposed subjects. The treatment and comparator cohorts can be identified using the
DRUG_ERA table, or through user-defined cohorts in a cohort table either inside the CDM schema or
in a separate schema. Similarly, outcomes are identified using the CONDITION_ERA table or through
user-defined cohorts in a cohort table either inside the CDM schema or in a separate schema.
Optionally, the target and comparator cohorts can be restricted to be within a nesting cohort,
which can reside in a  different database schema and table.
}
