CohortGenerator is part of HADES.
IntroductionThis R package contains functions for generating cohorts using data in the CDM.
Features# First construct a cohort definition set: an empty
# data frame with the cohorts to generate
cohortsToCreate <- CohortGenerator::createEmptyCohortDefinitionSet()
# Fill the cohort set using cohorts included in this
# package as an example
cohortJsonFiles <- list.files(path = system.file("testdata/name/cohorts", package = "CohortGenerator"), full.names = TRUE)
for (i in 1:length(cohortJsonFiles)) {
cohortJsonFileName <- cohortJsonFiles[i]
cohortName <- tools::file_path_sans_ext(basename(cohortJsonFileName))
# 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
cohortJson <- readChar(cohortJsonFileName, file.info(cohortJsonFileName)$size)
cohortExpression <- CirceR::cohortExpressionFromJson(cohortJson)
cohortSql <- CirceR::buildCohortQuery(cohortExpression, options = CirceR::createGenerateOptions(generateStats = FALSE))
cohortsToCreate <- rbind(cohortsToCreate, data.frame(cohortId = i,
cohortName = cohortName,
sql = cohortSql,
stringsAsFactors = FALSE))
}
# Generate the cohort set against Eunomia.
# cohortsGenerated contains a list of the cohortIds
# successfully generated against the CDM
connectionDetails <- Eunomia::getEunomiaConnectionDetails()
# Create the cohort tables to hold the cohort generation results
cohortTableNames <- CohortGenerator::getCohortTableNames(cohortTable = "my_cohort_table")
CohortGenerator::createCohortTables(connectionDetails = connectionDetails,
cohortDatabaseSchema = "main",
cohortTableNames = cohortTableNames)
# Generate the cohorts
cohortsGenerated <- CohortGenerator::generateCohortSet(connectionDetails = connectionDetails,
cdmDatabaseSchema = "main",
cohortDatabaseSchema = "main",
cohortTableNames = cohortTableNames,
cohortDefinitionSet = cohortsToCreate)
# Get the cohort counts
cohortCounts <- CohortGenerator::getCohortCounts(connectionDetails = connectionDetails,
cohortDatabaseSchema = "main",
cohortTable = cohortTableNames$cohortTable)
print(cohortCounts)
Technology
CohortGenerator is an R package.
System requirementsRequires R (version 3.6.0 or higher).
Getting StartedMake 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:
remotes::install_github("OHDSI/CohortGenerator")
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.
LicenseCohortGenerator is licensed under Apache License 2.0
DevelopmentThis package is being developed in RStudio.
Development statusBeta
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4