Title: | Integration Unit Tests for Pharmacoepidemiological Studies |
---|---|
Description: | Push a sample population for unit testing on data mapped to the Observational Medical Outcomes Partnership (OMOP) Common Data Model. |
Authors: | Cesar Barboza [cre, aut] , Ioanna Nika [aut], Ger Inberg [aut] , Adam Black [aut] |
Maintainer: | Cesar Barboza <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.3.3 |
Built: | 2024-11-08 16:16:52 UTC |
Source: | https://github.com/darwin-eu/testgenerator |
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.
## Not run: downloadTestData() ## End(Not run)
## Not run: downloadTestData() ## End(Not run)
Generates an Excel file with sheets that correspond to an OMOP-CDM tables.
generateTestTables( tableNames, cdmVersion, outputFolder, filename = paste0("test_cdm_", cdmVersion) )
generateTestTables( tableNames, 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()' aids in the visualisation of cohorts timelines, useful to get a grip on intersections.
graphCohort(subject_id, cohorts = list())
graphCohort(subject_id, cohorts = list())
subject_id |
Only one subject id per visualisation |
cohorts |
List of cohorts |
A ggplot graph
hosptalised <- tibble::tibble(cohort_definition_id = 2, subject_id = 1, cohort_start_date = "2018-01-01", cohort_end_date = "2018-01-10") icu_patients <- tibble::tibble(cohort_definition_id = 5, subject_id = 1, cohort_start_date = "2018-01-02", cohort_end_date = "2018-01-04") drugs_treatment <- tibble::tibble(cohort_definition_id = 5, subject_id = 1, cohort_start_date = "2018-01-07", cohort_end_date = "2018-01-09") TestGenerator::graphCohort(subject_id = 1, cohorts = list("hosptalised" = hosptalised, "icu_patients" = icu_patients, "drugs_treatment" = drugs_treatment))
hosptalised <- tibble::tibble(cohort_definition_id = 2, subject_id = 1, cohort_start_date = "2018-01-01", cohort_end_date = "2018-01-10") icu_patients <- tibble::tibble(cohort_definition_id = 5, subject_id = 1, cohort_start_date = "2018-01-02", cohort_end_date = "2018-01-04") drugs_treatment <- tibble::tibble(cohort_definition_id = 5, subject_id = 1, cohort_start_date = "2018-01-07", cohort_end_date = "2018-01-09") TestGenerator::graphCohort(subject_id = 1, cohorts = list("hosptalised" = hosptalised, "icu_patients" = icu_patients, "drugs_treatment" = drugs_treatment))
Pushes test population into a blank CDM.
patientsCDM( pathJson = NULL, testName = NULL, cdmVersion = "5.3", cdmName = NULL )
patientsCDM( pathJson = NULL, testName = NULL, cdmVersion = "5.3", cdmName = 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.3". |
cdmName |
Name of the cdm, default NULL. |
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.3" )
readPatients( filePath = NULL, testName = "test", outputPath = NULL, cdmVersion = "5.3" )
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.3". |
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.3", reduceLargeIds = FALSE )
readPatients.csv( filePath = NULL, testName = "test", outputPath = NULL, cdmVersion = "5.3", 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.3". |
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())
filePath <- system.file("extdata", "mimic_sample", package = "TestGenerator") readPatients.csv(filePath = filePath, outputPath = tempdir())
Converts a sample of patients in XLSX format into Unit Testing Definition JSON file.
readPatients.xl( filePath = NULL, testName = "test", outputPath = NULL, cdmVersion = "5.3" )
readPatients.xl( filePath = NULL, testName = "test", outputPath = NULL, cdmVersion = "5.3" )
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.3". |
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())