-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathimportStudies.R
45 lines (36 loc) · 1.49 KB
/
importStudies.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
###################################################################################
library(sendigR)
studyRoot <- "path/to/files"
dbRoot <- "path/to/db"
# CT files folder
pathBase <-"path/to/ct"
# Output to temp folder
tempDir <- tempdir()
# Call the gen_vocab function with the CDISC CT file, extensible CT file and the target json file
infile2 <- paste0(pathBase, "/SEND_Terminology_EXTENSIBLE.txt")
infile1 <- paste0(pathBase, "/SEND Terminology_2021_12_17.txt")
jsonfile <- paste0(tempDir, "/SEND3.1_test.json")
sendigR::gen_vocab(list(infile1, infile2),jsonfile)
# Call the standardize_file function to harmonize the xpt file.
rawXptFolder <- "path/to/study"
cleanXptFolder <- paste0(tempDir, "/Studies/studydir/")
sendigR::standardize_file(rawXptFolder, cleanXptFolder, jsonfile )
# xpt clean was done, start to import studies in cleaXptFolder to the sqllite database
# Initialization
dbToken <- sendigR::initEnvironment(dbType='sqlite',
dbPath=paste(dbRoot,'study_sub.db',sep='/'),
dbCreate=TRUE)
# Create database schema
dbCreateSchema(dbToken)
# import studies
cleanXptFolder <- paste0(tempDir, "/Studies")
xptfolders <- list.dirs(cleanXptFolder, recursive=FALSE)
for (oneStudy in xptfolders){
sendigR::dbImportOneStudy(dbToken, oneStudy, overWrite=TRUE)
}
# Create Indexes if needed
sendigR::dbCreateIndexes(dbToken, replaceExisting=TRUE)
# Start Dashboard
sendigR::execSendDashboard(dbToken)
# Disconnect from database
sendigR::disconnectDB(dbToken)