Skip to contents

Function for creating dataset which can be used as input for Cohort2Trajectory package

Usage

createC2TInput(
  data,
  cdm,
  targetCohortId = "target",
  complementaryMappingTable = NULL
)

Arguments

data

Data list object

cdm

Connection to database (CDMConnector)

targetCohortId

Target cohort id

complementaryMappingTable

Mapping table for mapping concept_ids if present

Examples

if (FALSE) { # \dontrun{
  data <- readRDS("./snapshots/CohortContrastDataSnapshot.rds")
  user <- Sys.getenv("DB_USERNAME")
  pw <- Sys.getenv("DB_PASSWORD")
  server <- stringr::str_c(Sys.getenv("DB_HOST"), "/", Sys.getenv("DB_NAME"))
  port <- Sys.getenv("DB_PORT")

  cdmSchema <-
    Sys.getenv("OHDSI_CDM")
  cdmVocabSchema <-
    Sys.getenv("OHDSI_VOCAB")
  cdmResultsSchema <-
    Sys.getenv("OHDSI_RESULTS")
  writeSchema <-
    Sys.getenv("OHDSI_WRITE")
  writePrefix <- "cc_"

  db = DBI::dbConnect(
    RPostgres::Postgres(),
    dbname = Sys.getenv("DB_NAME"),
    host = Sys.getenv("DB_HOST"),
    user = Sys.getenv("DB_USERNAME"),
    password = Sys.getenv("DB_PASSWORD"),
    port = port
  )

  cdm <- CDMConnector::cdmFromCon(
    con = db,
    cdmSchema = cdmSchema,
    achillesSchema = cdmResultsSchema,
    writeSchema = list(schema = writeSchema, prefix = writePrefix)
  )

  data = createC2TInput(data, cdm)
} # }