| Title: | Integration Unit Tests for Pharmacoepidemiological Studies |
|---|---|
| Description: | An R interface to load testing data in the 'OMOP' Common Data Model ('CDM'). An input file, csv or xlsx, can be converted to a 'CDMConnector' object. This object can be used to execute and test studies that use the 'CDM' <https://www.ohdsi.org/data-standardization/>. |
| Authors: | Cesar Barboza [aut, cre] (ORCID: <https://orcid.org/0009-0002-4453-3071>), Ioanna Nika [aut], Ger Inberg [aut] (ORCID: <https://orcid.org/0000-0001-8993-8748>), Adam Black [aut] (ORCID: <https://orcid.org/0000-0001-5576-8701>) |
| Maintainer: | Cesar Barboza <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 0.8.0 |
| Built: | 2026-05-18 11:09:25 UTC |
| Source: | https://github.com/darwin-eu/testgenerator |
Check if a given remote file is available for download
checkRemoteFileAvailable(remoteFile)checkRemoteFileAvailable(remoteFile)
remoteFile |
a remote resource |
NULL if the remote resource is not available, other "success"
Check if the given tables and columns are valid and return the loaded data.
checkTablesColumns(cdmVersion, filePath, extraTable = FALSE)checkTablesColumns(cdmVersion, filePath, extraTable = FALSE)
cdmVersion |
cdm version |
filePath |
Path to the test patient data in xlsx format |
extraTable |
if extra tables are provided or not, default FALSE |
a named list containing the loaded data
Drops the schema containing the test CDM and disconnects from the database.
cleanupTestCdm(cdm)cleanupTestCdm(cdm)
cdm |
A CDM reference object created by |
Invisibly returns NULL.
Download Test Data Files
downloadTestData( datasetName = "mimicIV", cdmVersion = "5.3", pathToData = Sys.getenv("STUDY_DATASETS"), overwrite = FALSE )downloadTestData( datasetName = "mimicIV", cdmVersion = "5.3", pathToData = Sys.getenv("STUDY_DATASETS"), overwrite = FALSE )
datasetName |
The data set name as found on https://github.com/darwin-eu/EunomiaDatasets. The data set name corresponds to the folder with the data set ZIP files |
cdmVersion |
The OMOP CDM version. This version will appear in the suffix of the data file, for example: synpuf_5.3.zip. Default: '5.3' |
pathToData |
The path where the Eunomia data is stored on the file system., By default the value of the environment variable "EUNOMIA_DATA_FOLDER" is used. |
overwrite |
Control whether the existing archive file will be overwritten should it already exist. |
Invisibly returns the destination if the download was successful.
downloadTestData(pathToData = tempdir())downloadTestData(pathToData = tempdir())
Generates an Excel file with sheets that correspond to an OMOP-CDM tables.
generateTestTables( tableNames = c("person", "observation_period", "visit_occurrence", "visit_detail", "condition_occurrence", "drug_exposure", "procedure_occurrence", "measurement", "observation", "death", "drug_era", "condition_era", "dose_era", "location", "care_site", "provider"), cdmVersion, outputFolder, filename = paste0("test_cdm_", cdmVersion) )generateTestTables( tableNames = c("person", "observation_period", "visit_occurrence", "visit_detail", "condition_occurrence", "drug_exposure", "procedure_occurrence", "measurement", "observation", "death", "drug_era", "condition_era", "dose_era", "location", "care_site", "provider"), cdmVersion, outputFolder, filename = paste0("test_cdm_", cdmVersion) )
tableNames |
A list specifying the table names to include in the Excel file. |
cdmVersion |
The CDM version to use for creating the requested tables (either 5.3 or 5.4). |
outputFolder |
The folder where the Excel file will be saved. |
filename |
The name of the Excel file. It does not include the extension .xlsx. |
An Excel file with the tables requested.
graphCohort() is deprecated and will be removed in a future release.
graphCohort(subject_id, cohorts = list())graphCohort(subject_id, cohorts = list())
subject_id |
Deprecated. |
cohorts |
Deprecated. |
Invisibly returns NULL.
Pushes test population into a blank CDM.
patientsCDM( pathJson = NULL, testName = NULL, cdmVersion = "5.4", cdmName = NULL, dbms = "duckdb", writeSchema = NULL )patientsCDM( pathJson = NULL, testName = NULL, cdmVersion = "5.4", cdmName = NULL, dbms = "duckdb", writeSchema = NULL )
pathJson |
Directory where the sample populations in json are located. If NULL, gets the default inst/testCases directory. |
testName |
Name of the sample population JSON file. If NULL it will push the first sample population in the testCases directory. |
cdmVersion |
cdm version, default "5.4". |
cdmName |
Name of the cdm, default NULL. |
dbms |
Database management system to use. One of "duckdb", "databricks",
"sqlserver" or "postgresql". Default is "duckdb" which creates a local
DuckDB CDM. For remote databases the function creates the CDM locally,
trims the vocabulary, uploads to a new schema on the remote database,
and returns the remote CDM reference. Remote databases require
environment variables to be set. Call |
writeSchema |
Optional schema name to use on the remote database.
If NULL (default), a unique schema is created automatically. Only used
when |
A CDM reference object with a sample population.
filePath <- system.file("extdata", "testPatientsRSV.xlsx", package = "TestGenerator") TestGenerator::readPatients(filePath = filePath, outputPath = tempdir()) cdm <- TestGenerator::patientsCDM(pathJson = tempdir(), testName = "test") duckdb::duckdb_shutdown(duckdb::duckdb())filePath <- system.file("extdata", "testPatientsRSV.xlsx", package = "TestGenerator") TestGenerator::readPatients(filePath = filePath, outputPath = tempdir()) cdm <- TestGenerator::patientsCDM(pathJson = tempdir(), testName = "test") duckdb::duckdb_shutdown(duckdb::duckdb())
Converts a sample of patients into Unit Testing Definition JSON file.
readPatients( filePath = NULL, testName = "test", outputPath = NULL, cdmVersion = "5.4", extraTable = FALSE )readPatients( filePath = NULL, testName = "test", outputPath = NULL, cdmVersion = "5.4", extraTable = FALSE )
filePath |
Path to the test patient data in Excel format. The Excel has sheets that represent tables from the OMOP-CDM, e.g. person, drug_exposure, condition_ocurrence, etc. |
testName |
A name of the test population in character. |
outputPath |
Path of the output file, if NULL, a folder will be created in the project folder inst/testCases. |
cdmVersion |
cdm version, default "5.4". |
extraTable |
Name of non-standard tables to be included in the test CDM. |
A JSON file with sample patients inside the project directory.
filePath <- system.file("extdata", "testPatientsRSV.xlsx", package = "TestGenerator") readPatients(filePath = filePath, outputPath = tempdir())filePath <- system.file("extdata", "testPatientsRSV.xlsx", package = "TestGenerator") readPatients(filePath = filePath, outputPath = tempdir())
Converts a sample of patients in CSV format into a Unit Testing Definition JSON file.
readPatients.csv( filePath = NULL, testName = "test", outputPath = NULL, cdmVersion = "5.4", reduceLargeIds = FALSE )readPatients.csv( filePath = NULL, testName = "test", outputPath = NULL, cdmVersion = "5.4", reduceLargeIds = FALSE )
filePath |
Path to the test patient data in CSV format. Multiple CSV files representing tables tables from the OMOP-CDM must be provided, e.g. person.csv, drug_exposure.csv, condition_ocurrence.csv, etc. |
testName |
Name for the test population file in character. |
outputPath |
Path of the output file, if NULL, a folder will be created in the project folder inst/testCases. |
cdmVersion |
cdm version, default "5.4". |
reduceLargeIds |
Reduces the length of very long ids generally in int64 format, such as those found in the MIMIC-IV database. |
A JSON file with sample patients inside the project directory.
filePath <- system.file("extdata", "mimic_sample", package = "TestGenerator") readPatients.csv( filePath = filePath, outputPath = tempdir(), cdmVersion = "5.3" )filePath <- system.file("extdata", "mimic_sample", package = "TestGenerator") readPatients.csv( filePath = filePath, outputPath = tempdir(), cdmVersion = "5.3" )
Converts a sample of patients in XLSX format into Unit Testing Definition JSON file.
readPatients.xl( filePath = NULL, testName = "test", outputPath = NULL, cdmVersion = "5.4", extraTable = FALSE )readPatients.xl( filePath = NULL, testName = "test", outputPath = NULL, cdmVersion = "5.4", extraTable = FALSE )
filePath |
Path to the test patient data in Excel format. The Excel has sheets that represent tables from the OMOP-CDM, e.g. person, drug_exposure, condition_ocurrence, etc. |
testName |
A name of the test population in character. |
outputPath |
Path to write the test JSON files. If NULL, the files will be written at the project's testthat folder, i.e. tests/testthat/testCases. |
cdmVersion |
cdm version, default "5.4". |
extraTable |
TRUE or FALSE. If TRUE, non-standard tables will be included in the test CDM. |
A directory with the test JSON files with sample patients inside the project directory.
filePath <- system.file("extdata", "testPatientsRSV.xlsx", package = "TestGenerator") readPatients.xl(filePath = filePath, outputPath = tempdir())filePath <- system.file("extdata", "testPatientsRSV.xlsx", package = "TestGenerator") readPatients.xl(filePath = filePath, outputPath = tempdir())
Copies GitHub Action workflow templates from the package's
inst/workflows directory to the .github/workflows directory of
the current project. The copied workflows can be used to run backend-specific
tests for PostgreSQL, SQL Server, and Databricks.
useGithubAction( dbms_type = c("postgresql", "sqlserver", "databricks"), overwrite = FALSE )useGithubAction( dbms_type = c("postgresql", "sqlserver", "databricks"), overwrite = FALSE )
dbms_type |
A character vector of supported DBMS types to process.
Supported values are |
overwrite |
A logical value indicating whether to overwrite existing
workflow files in the |
Invisibly returns TRUE when the selected workflow files are
copied successfully.
## Not run: useGithubAction(dbms_type = "postgresql") useGithubAction( dbms_type = c("postgresql", "sqlserver", "databricks"), overwrite = TRUE ) ## End(Not run)## Not run: useGithubAction(dbms_type = "postgresql") useGithubAction( dbms_type = c("postgresql", "sqlserver", "databricks"), overwrite = TRUE ) ## End(Not run)