Compute time at risk exposed and time at risk unexposed for risk window parameters. See `getSccRiskWindowStats` for example usage.

runSccRiskWindows(
  connection,
  cdmDatabaseSchema,
  tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"),
  exposureIds = NULL,
  exposureDatabaseSchema = cdmDatabaseSchema,
  exposureTable = "drug_era",
  firstExposureOnly = TRUE,
  minAge = "",
  maxAge = "",
  studyStartDate = "",
  studyEndDate = "",
  addLengthOfExposureExposed = TRUE,
  riskWindowStartExposed = 1,
  riskWindowEndExposed = 30,
  addLengthOfExposureUnexposed = TRUE,
  riskWindowEndUnexposed = -1,
  riskWindowStartUnexposed = -30,
  hasFullTimeAtRisk = FALSE,
  washoutPeriod = 0,
  followupPeriod = 0,
  riskWindowsTable = "#risk_windows",
  keepResultsTables = TRUE,
  analysisId = 1,
  resultsDatabaseSchema = NULL
)

Arguments

connection

DatabaseConnector connection instance

cdmDatabaseSchema

Name of database schema that contains the OMOP CDM and vocabulary.

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.

exposureIds

A vector containing the drug_concept_ids or cohort_definition_ids of the exposures of interest. If empty, all exposures in the exposure table will be included.

exposureDatabaseSchema

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

exposureTable

The tablename that contains the exposure cohorts. If exposureTable <> DRUG_ERA, then expectation is exposureTable has format of COHORT table: cohort_concept_id, SUBJECT_ID, COHORT_START_DATE, COHORT_END_DATE.

firstExposureOnly

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

minAge

Integer for minimum allowable age.

maxAge

Integer for maximum allowable age.

studyStartDate

Date for minimum allowable data for index exposure. Date format is 'yyyymmdd'.

studyEndDate

Date for maximum allowable data for index exposure. Date format is 'yyyymmdd'.

addLengthOfExposureExposed

If TRUE, use the duration from drugEraStart -> drugEraEnd as part of timeAtRisk.

riskWindowStartExposed

Integer of days to add to drugEraStart for start of timeAtRisk (0 to include index date, 1 to start the day after).

riskWindowEndExposed

Additional window to add to end of exposure period (if addLengthOfExposureExposed = TRUE, then add to exposure end date, else add to exposure start date).

addLengthOfExposureUnexposed

If TRUE, use the duration from exposure start -> exposure end as part of timeAtRisk looking back before exposure start.

riskWindowEndUnexposed

Integer of days to add to exposure start for end of timeAtRisk (0 to include index date, -1 to end the day before).

riskWindowStartUnexposed

Additional window to add to start of exposure period (if addLengthOfExposureUnexposed = TRUE, then add to exposure end date, else add to exposure start date).

hasFullTimeAtRisk

If TRUE, restrict to people who have full time-at-risk exposed and unexposed.

washoutPeriod

Integer to define required time observed before exposure start.

followupPeriod

Integer to define required time observed after exposure start.

riskWindowsTable

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

keepResultsTables

Keep the results tables in place if they exist. This allows the data set to be added to with aditional targets and outcomes. (ignored if temporary tables are used, default)

analysisId

An integer unique to this analysis

resultsDatabaseSchema

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

Value

Invisibly returns NULL. Creates the risk windows table in the database as a side effect.

Examples

if (FALSE) { # \dontrun{
connection <- DatabaseConnector::connect(connectionDetails)

runSccRiskWindows(
  connection = connection,
  cdmDatabaseSchema = "main",
  exposureIds = c(1124300),
  riskWindowStartExposed = 1,
  riskWindowEndExposed = 30,
  riskWindowsTable = "#risk_windows"
)

DatabaseConnector::disconnect(connection)
} # }