The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
CohortGenerator is part of HADES.
This R package contains functions for generating cohorts using data in the CDM.
# First construct a cohort definition set: an empty
# data frame with the cohorts to generate
<- CohortGenerator::createEmptyCohortDefinitionSet()
cohortsToCreate
# Fill the cohort set using cohorts included in this
# package as an example
<- list.files(path = system.file("testdata/name/cohorts", package = "CohortGenerator"), full.names = TRUE)
cohortJsonFiles for (i in 1:length(cohortJsonFiles)) {
<- cohortJsonFiles[i]
cohortJsonFileName <- tools::file_path_sans_ext(basename(cohortJsonFileName))
cohortName # Here we read in the JSON in order to create the SQL
# using [CirceR](https://ohdsi.github.io/CirceR/)
# If you have your JSON and SQL stored differenly, you can
# modify this to read your JSON/SQL files however you require
<- readChar(cohortJsonFileName, file.info(cohortJsonFileName)$size)
cohortJson <- CirceR::cohortExpressionFromJson(cohortJson)
cohortExpression <- CirceR::buildCohortQuery(cohortExpression, options = CirceR::createGenerateOptions(generateStats = FALSE))
cohortSql <- rbind(cohortsToCreate, data.frame(cohortId = i,
cohortsToCreate cohortName = cohortName,
sql = cohortSql,
stringsAsFactors = FALSE))
}
# Generate the cohort set against Eunomia.
# cohortsGenerated contains a list of the cohortIds
# successfully generated against the CDM
<- Eunomia::getEunomiaConnectionDetails()
connectionDetails
# Create the cohort tables to hold the cohort generation results
<- CohortGenerator::getCohortTableNames(cohortTable = "my_cohort_table")
cohortTableNames ::createCohortTables(connectionDetails = connectionDetails,
CohortGeneratorcohortDatabaseSchema = "main",
cohortTableNames = cohortTableNames)
# Generate the cohorts
<- CohortGenerator::generateCohortSet(connectionDetails = connectionDetails,
cohortsGenerated cdmDatabaseSchema = "main",
cohortDatabaseSchema = "main",
cohortTableNames = cohortTableNames,
cohortDefinitionSet = cohortsToCreate)
# Get the cohort counts
<- CohortGenerator::getCohortCounts(connectionDetails = connectionDetails,
cohortCounts cohortDatabaseSchema = "main",
cohortTable = cohortTableNames$cohortTable)
print(cohortCounts)
CohortGenerator is an R package.
Requires R (version 3.6.0 or higher).
Make sure your R environment is properly configured. This means that Java must be installed. See these instructions for how to configure your R environment.
In R, use the following commands to download and install CohortGenerator:
::install_github("OHDSI/CohortGenerator") remotes
Documentation can be found on the package website.
PDF versions of the documentation are also available:
Read here how you can contribute to this package.
CohortGenerator is licensed under Apache License 2.0
This package is being developed in RStudio.
Beta
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.