forked from darwin-eu-dev/TreatmentPatterns
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Upload the patient-level results as cohorts per (combination) treatment and / or per pathway.
We can create a function that takes in several arguments:
andromeda: The Andromeda object created bycomputePathways().cohortTableName: Name of the cohort table to write to.cdm: Optionally aCDM-ReferencefromCDMConnector.connectionDetails: OptionallyConnectionDetailsfromDatabaseConnector.resultSchema: Optionally a schema where to write to.
#' @title uploadCohorts
#'
#' Uploads patient level groups per (combination) event as seperate cohorts.
#'
#' @param andromeda
#' @param cohortTableName
#' @param cdm
#' @param connectionDetails
#' @param resultSchema
#'
#' @return `NULL`
#'
#' @export
#'
#' @examples
#' # <Example code>
uploadCohorts <- function(andromeda, cohortTableName, cdm = NULL, connectionDetails = NULL, resultSchema = NULL) {
# 1. Check inputs
# 2. Check if records to be uploaded are valid:
# a. One person may belong to multiple cohorts
# b. One person may belong to the same cohort for multiple different time periods
# c. One person may not belong to the same cohort multiple times during the same period of time
# d. A cohort may have zero or more members
# 3. Upload to database
# if cdm != NULL:
# > upload with CDMConnector
# else if connectionDetails != NULL:
# > upload with DatabaseConnector, to resultSchema
}TreatmentPatterns example result to work with
library(TreatmentPatterns)
library(CDMConnector)
library(dplyr)
con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomiaDir())
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 %>%
select(
cohortId = "cohort_definition_id",
cohortName = "cohort_name"
) %>%
mutate(type = c("event", "event", "event", "event", "exit", "event", "event", "target"))
outputEnv <- computePathways(
cohorts = cohorts,
cohortTableName = "cohort_table",
cdm = cdm
)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers