dbImportOneStudy: Import SEND study data in SAS xport format into a SEND...

View source: R/populateDBFunctions.R

dbImportOneStudyR Documentation

Import SEND study data in SAS xport format into a SEND database from a single study folder

Description

Check each of the SAS xpt file located in the specified folder - import content from file and load it into the corresponding SEND domain table in the open database.

Usage

dbImportOneStudy(dbToken, xptPath, overWrite = FALSE, checkRequiredVars = TRUE)

Arguments

dbToken

Mandatory
Token for the open database connection (see initEnvironment).

xptPath

Mandatory, character
Location of the SAS xport files

overWrite

Mandatory, boolean
Whether an already existing study in the database may be overwritten by newly imported data.

checkRequiredVars

Mandatory, boolean
Whether not-required domains are checked for existence and content of required variables

Details

These requirements to the content of the folder must be fulfilled:

  1. The folder must contain some SAS xport files named [send domain].xpt - the case of the file names doesn't care

  2. A minimum set of required domain files must be included: ts.xpt, tx.xpt, dm.xpt.

  3. Each xpt file must contain one data table with same name as the file name - i.e. a send domain name.

  4. Each xpt file must contain a non-empty STUDYID value in each row equal to the value of TS.STUDYID.

  5. Each xpt file must contain a set of required column(s).
    In general it's (where relevant for the different kinds of domains):
    STUDYID, DOMAIN, --SEQ, USUBJID, --TESTCD, --TEST,--ORRES, --ORRESU, --STRESC, --STRESN, --STRESU

  6. The DOMAIN variable must contain the name of the actual domain in all rows

The last two requirements are checked for the required domains in all cases. For other domains, these two requirements are only checked if parameter checkRequiredVars = TRUE.

If an error is detected, the import and load of data is canceled, and further execution is aborted (i.e. error message is written to the console).
These error situations are checked and reported:

  • Any of the requirements 1 to 3 are not fulfilled or any of the following requirements are not fulfilled for one of the required domains

  • A study with the same value if STUDYID exists in the database and parameter overWrite = FALSE.

If one of the requirements 4 to 6 are not fulfilled for a not-required domain, this domain is excluded from the import. These kinds of issues are reported as one warning message to the console when data has been loaded.

Some non-critical issues, which doesn't prohibit data to be loaded to the database may be detected. These are reported as one warning message to the console when data has been loaded (together with eventual warning messages for skipped domains).
These non-critical issues are checked and reported:

  • The study folder contains one or more xpt file(s) with names(s) not matching SEND domain name(s).
    Such files are ignored by the import/load process.

  • An imported data tables contains one or more column(s) which do(es)n't exist(s) in the corresponding domain.

The database must be an SQLite database - no other types of databases are supported by this function.

Value

No return value, called for side effects

Examples

## Not run: 
# Do not overwrite if study already exists in the database
dbImportOneStudy(myDbToken,'/mydatapath/studies/1213443')
# Allow to overwrite data if study already exists in the database
dbImportOneStudy(myDbToken,'/mydatapath/studies/786756', overwrite = TRUE)

## End(Not run)

sendigR documentation built on Aug. 18, 2022, 9:07 a.m.