@@ -41,7 +41,8 @@ mod_dataUpload_ui <- function(id){
4141 div(style = " display: inline-block; " ,h3(" Data upload" )),
4242 div(style = " display: inline-block; float:right;" ,mod_dataComplyRules_ui(" dataComplyRules_ui_1" )),
4343 HTML(" <br>ADSL file is mandatory & BDS/ OCCDS files are optional" ),
44- fileInput(ns(" file" ), " Upload sas7bdat files" ,accept = c(" .sas7bdat" ), multiple = TRUE ),
44+ # fileInput(ns("file"), "Upload sas7bdat files",accept = c(".sas7bdat"), multiple = TRUE),
45+ fileInput(ns(" file" ), " Upload datasets" , accept = c(" .txt" , " .csv" , " .xls" , " .xlsx" , " .sas7bdat" ), multiple = TRUE ),
4546 uiOutput(ns(" radio_test" ))
4647 )
4748 ),
@@ -91,18 +92,25 @@ mod_dataUpload_server <- function(input, output, session){
9192 data_list <- list ()
9293
9394 # # data list
94- for (i in 1 : nrow(input $ file )){
95- if (length(grep(" .sas7bdat" , input $ file $ name [i ], ignore.case = TRUE )) > 0 ){
96- data_list [[i ]] <- haven :: zap_formats(haven :: read_sas(input $ file $ datapath [i ])) %> %
97- dplyr :: mutate(dplyr :: across(.cols = where(is.character ),
98- .fns = na_if , y = " " ))
99- }else {
100- data_list [[i ]] <- NULL
101- }
102- }
95+ # for (i in 1:nrow(input$file)){
96+ # if(length(grep(".sas7bdat", input$file$name[i], ignore.case = TRUE)) > 0){
97+ # data_list[[i]] <- haven::zap_formats(haven::read_sas(input$file$datapath[i])) %>%
98+ # dplyr::mutate(dplyr::across(.cols = where(is.character),
99+ # .fns = na_if, y = ""))
100+ # }else{
101+ # data_list[[i]] <- NULL
102+ # }
103+ # }
104+
105+ data_list <- input $ file $ datapath | >
106+ purrr :: map(\(x ) {
107+ read_data(x )
108+ }) | >
109+ purrr :: set_names(toupper(tools :: file_path_sans_ext(input $ file $ name )))
110+
103111
104112 # names
105- names(data_list ) <- toupper(stringr :: str_remove(input $ file $ name , " .sas7bdat" ))
113+ # names(data_list) <- toupper(stringr::str_remove(input$file$name, ".sas7bdat"))
106114
107115
108116
@@ -111,11 +119,19 @@ mod_dataUpload_server <- function(input, output, session){
111119 id = NULL , # "dataComply_ui_1",
112120 datalist = reactive(data_list ))
113121
122+ # if(length(names(dl_comply)) > 0){
123+ # # append to existing reactiveValues list
124+ # dd$data <- c(dd$data, dl_comply) # dl_comply #
125+
126+ # }
114127 if (length(names(dl_comply )) > 0 ){
115- # append to existing reactiveValues list
116- dd $ data <- c( dd $ data , dl_comply ) # dl_comply #
128+ # Normalize ADaM dataset names based on domain validation
129+ dl_normalized <- normalize_adam_datasets( dl_comply )
117130
131+ # append to existing reactiveValues list
132+ dd $ data <- c(dd $ data , dl_normalized )
118133 }
134+
119135
120136 # set dd$current to FALSE for previous & TRUE for current uploads
121137 dd $ current <- c(rep(FALSE , length(dd $ current )), rep(TRUE , length(data_list )))
0 commit comments