executeTreatmentPatterns {TreatmentPatterns} | R Documentation |
executeTreatmentPatterns
Description
Compute treatment patterns according to the specified parameters within specified cohorts. For more customization, or investigation of patient level outcomes, you can run computePathways and export separately.
Usage
executeTreatmentPatterns(
cohorts,
cohortTableName,
outputPath,
cdm = NULL,
connectionDetails = NULL,
cdmSchema = NULL,
resultSchema = NULL,
tempEmulationSchema = NULL,
minEraDuration = 0,
eraCollapseSize = 30,
combinationWindow = 30,
minCellCount = 5
)
Arguments
cohorts |
(
|
cohortTableName |
( |
outputPath |
( |
cdm |
( |
connectionDetails |
( |
cdmSchema |
( |
resultSchema |
( |
tempEmulationSchema |
( |
minEraDuration |
( |
eraCollapseSize |
( |
combinationWindow |
( |
minCellCount |
( |
Value
(invisible(NULL)
)
Examples
library(TreatmentPatterns)
library(CDMConnector)
library(dplyr)
if (require("CirceR", character.only = TRUE, quietly = TRUE)) {
withr::local_envvar(
R_USER_CACHE_DIR = tempfile(),
EUNOMIA_DATA_FOLDER = Sys.getenv("EUNOMIA_DATA_FOLDER", unset = tempfile())
)
tryCatch({
if (Sys.getenv("skip_eunomia_download_test") != "TRUE") {
CDMConnector::downloadEunomiaData(overwrite = TRUE)
}
},
error = function(e) NA)
con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir())
cdm <- cdmFromCon(con, cdmSchema = "main", writeSchema = "main")
cohortSet <- readCohortSet(
path = system.file(package = "TreatmentPatterns", "exampleCohorts")
)
cdm <- generateCohortSet(
cdm = cdm,
cohortSet = cohortSet,
name = "cohort_table"
)
cohorts <- cohortSet %>%
# Remove 'cohort' and 'json' columns
select(-"cohort", -"json") %>%
mutate(type = c("event", "event", "event", "event", "exit", "event", "event", "target")) %>%
rename(
cohortId = "cohort_definition_id",
cohortName = "cohort_name",
) %>%
select("cohortId", "cohortName", "type")
executeTreatmentPatterns(
cohorts = cohorts,
cohortTableName = "cohort_table",
cdm = cdm,
outputPath = tempdir()
)
DBI::dbDisconnect(con, shutdown = TRUE)
}