Compute statistics from risk windows.

getSccRiskWindowStats(
  connection,
  outcomeDatabaseSchema,
  tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"),
  oracleTempSchema = NULL,
  outcomeIds = NULL,
  cdmVersion = 5,
  outcomeTable = "condition_era",
  firstOutcomeOnly = TRUE,
  resultsDatabaseSchema = NULL,
  riskWindowsTable = "#risk_windows"
)

Arguments

connection

DatabaseConnector connection instance

outcomeDatabaseSchema

The name of the database schema that is the location where the data used to define the outcome cohorts is available. If exposureTable = CONDITION_ERA, exposureDatabaseSchema is not used by assumed to be cdmSchema. Requires read permissions to this database.

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.

oracleTempSchema

For Oracle only: the name of the database schema where you want all temporary tables to be managed. Requires create/insert permissions to this database.

outcomeIds

The condition_concept_ids or cohort_definition_ids of the outcomes of interest. If empty, all the outcomes in the outcome table will be included.

cdmVersion

Define the OMOP CDM version used: currently support "4" and "5".

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.

firstOutcomeOnly

If TRUE, only use first occurrence of each condition concept id for each person.

resultsDatabaseSchema

Schema to oputput results to. Ignored if resultsTable and riskWindowsTable are temporary.

riskWindowsTable

String: optionally store the risk windows in a (non-temporary) table.

Value

list containing data frames: treatmentTimeDistribution, timeToOutcomeDistribution, timeToOutcomeDistributionExposed, timeToOutcomeDistributionUnexposed

Details

Requires a risk window table to be created first with `runSccRiskWindows`

Examples

if (FALSE) {
# First, create the risk windows table
connectionDetails <- Eunomia::getEunomiaConnectionDetails()
connection <- DatabaseConnector::connect(connectionDetails)
riskWindowsTable <- "computed_risk_windows"
runSccRiskWindows(connection,
                  cdmDatabaseSchema = "main",
                  exposureIds = c(1102527, 1125315),
                  resultsDatabaseSchema = "main", # This is the schema where the results will be stored
                  riskWindowsTable = riskWindowsTable,
                  exposureTable = "drug_era")
# Get stats based on outcomes of interest
tarStats <- getSccRiskWindowStats(connection,
                                  outcomeDatabaseSchema = "main",
                                  resultsDatabaseSchema = "main",
                                  riskWindowsTable = riskWindowsTable,
                                  outcomeTable = "condition_era",
                                  outcomeIds = 192671)
}