-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathuploadTab.R
769 lines (685 loc) · 25.9 KB
/
uploadTab.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
output$uploadPage <- renderUI({
if (authRequired && !authenticatedUser()){
return(tags$h3(class = "row_text title", notAuthenticatedMessage))
}
fluidPage(
uiOutput("tooBusyMessage"),
uiOutput("uploadIntro"),
uiOutput("dataRequestInfo"),
uiOutput("uploadMissingSummary"),
uiOutput("uploadFileFormatError"),
uiOutput("uploadSummary"),
uiOutput("selectFiles")
)
})
collapseStatus <- reactiveValues(
noActive = FALSE,
active = FALSE,
uploadSummary = FALSE
)
requestedVariables <- reactive({
if (!hubInfo$fromHub) return(NULL)
concept <- userDetails()$uploadconcept_mr
message <- "Your dataset"
if (is.null(uploadList()$MissingTables) &&
(is_empty(tablesAndVariables$missingConceptColumns))){
return(tags$p(message, "contains", span("all variables requested by", concept,
class = "text-green", style = "font-weight: bold")))
}
numVarsMissing <- tablesAndVariables$missingVariableCount
numTables <- length(tablesAndVariables$missingConceptColumns)
connector <- ifelse(numTables == 1, "in", "across")
return(
tagList(
tags$p(message, "is",
tags$a(span("missing", numVarsMissing,
makeItPluralOrNot("variable", numVarsMissing),
class = "text-red", style = "font-weight: bold"),
href = "#missingBox"),
"requested by", concept,
connector, numTables,
paste0(makeItPluralOrNot("table", numTables), ".")
)
#actionLink("showMissing", span("missing", numVarsMissing,
# makeItPluralOrNot("variable", numVarsMissing), "requested by", concept,
# connector, numTables, makeItPluralOrNot("table", numTables), ".",
# class = "text-red", style = "font-weight: bold")))
# tags$ul(tablesAndVariables$missingConceptColumns) # for now don't repeat info in yellow box
)
)
})
unrecognizedVariables <- function(){
numExtraFiles <- length(uploadList()$ExtraFiles)
extraFilesFlag <- numExtraFiles > 0
numExtraVariables <- tablesAndVariables$details$non_des_count
extraVariablesFlag <- numExtraVariables > 0
numDeprecated <- tablesAndVariables$details$deprecated_count
deprecatedFlag <- numDeprecated > 0
numberOfMessages <- sum(extraFilesFlag, extraVariablesFlag, deprecatedFlag)
if (numberOfMessages == 0) return(NULL)
message <- "In addition, your dataset contains"
period1 <- ""
period2 <- ""
if (numberOfMessages == 3){
connector1 <- ","
connector2 <- ", and"
} else if (numberOfMessages == 2){
if (extraFilesFlag){
connector1 <- " and"
connector2 <- ""
if (extraVariablesFlag) period2 <- "."
} else {
connector1 <- ""
connector2 <- " and"
}
} else {
connector1 <- ""
connector2 <- ""
if (extraFilesFlag) period1 <- "."
else if (extraVariablesFlag) period2 <- "."
}
extraFileMsg <- if_else(extraFilesFlag,
paste0(numExtraFiles, " unrecognized ", makeItPluralOrNot("file", numExtraFiles), period1),
"")
extraVariablesMsg <- if_else(extraVariablesFlag,
paste0(numExtraVariables, " unrecognized ", makeItPluralOrNot("variable", numExtraVariables), period2),
"")
deprecatedVariablesMsg <- if_else(deprecatedFlag,
paste0(numDeprecated, " deprecated ", makeItPluralOrNot("variable", numDeprecated), "."),
"")
return(tags$p(message, tags$b(paste0(extraFileMsg, connector1)), tags$b(paste0(extraVariablesMsg, connector2)),
tags$b(paste0(deprecatedVariablesMsg)),
"See summary box above for details."))
}
output$groupByMenuUI <- renderUI({
groupOptions <- groupByInfo()
if (is.null(groupOptions$otherGroupOptions)){
groups <- defGroupVar
message <- tagList(
tags$p("For reporting purposes your dataset will be grouped by the variable",
defGroupVar),
makeBulletedList(groupOptions$programs),
tags$em("If you prefer that your data are grouped differently for reports,",
"please include that variable in",
indexTableName,
"and upload your revised dataset.")
)
return(message)
}
if (is.null(formattedTables())){
groupVar <- currentGroupSelection()
if (is.null(groupVar)) groupVar <- defGroupVar
if (groupVar == defGroupVar){
groupNames <- sort(groupOptions$programs)
} else {
groupNames <- sort(groupOptions$otherGroupOptions[[groupVar]]$levels)
}
message <- tagList(
tags$p("Your data will be grouped by", tags$b(groupVar),"for reporting into the following",
paste0(makeItPluralOrNot("group", length(groupNames)), ":")),
makeBulletedList(groupNames),
tags$br(),
tags$em("To group by a different variable, choose from the list below of alternate grouping variables found in your",
indexTableName,
"file or upload a revised dataset that includes the desired grouping variable in",
indexTableName
),
tags$br(),
selectInput("groupBySelect",
"Grouping variables:",
c(defGroupVar, names(groupOptions$otherGroupOptions)),
selected = groupVar)
)
return(message)
}
else {
groupVar<- finalGroupChoice()
if (groupVar == defGroupVar) groupNames <- groupOptions$programs
else groupNames <- groupOptions$otherGroupOptions[[groupVar]]$levels
tagList(
tags$p("Your data will be grouped for reporting purposes by", tags$b(groupVar)),
makeBulletedList(groupNames),
tags$br(),
tags$em("Data checks are complete and grouped by ", groupVar,
". Upload your dataset again to choose a different grouping variable.",
"Grouping variables must be included in",
indexTableName)
)
}
})
showGroupModal <- function(saveAndGo = FALSE){
if (!is.null(finalGroupChoice()) || is.null(groupByInfo()$otherGroupOptions)){
buttons <- modalButton("Close")
} else {
# other group options exist
if (saveAndGo){
# the user was attempting to continue to data quality checks with one patient group. Now
# once they save, start DQ checks. Otherwise, just save
saveButton <- actionButton("saveGroupAndGo", "Save", class = "btn-success")
cancelButton <- actionButton("cancelAndGo", "Cancel")
} else {
saveButton <- actionButton("saveGroup", "Save", class = "btn-success")
cancelButton <- actionButton("cancelGroup", "Cancel")
}
buttons <- tagList(
cancelButton,
saveButton
)
}
showModal(tags$div(id="dataQualityChecks",
modalDialog(
easyClose = FALSE,
title = "Dataset Grouping Options",
size = 'l',
uiOutput("groupByMenuUI"),
footer = buttons,
fade = FALSE
)
))
}
observeEvent(input$openGroupModal,{
showGroupModal()
})
observeEvent(input$cancelGroup,{
removeModal()
})
observeEvent(input$cancelAndGo,{
removeModal()
startStep2()
})
observeEvent(input$saveGroup,{
groupByChoice(input$groupBySelect)
removeModal()
})
observeEvent(input$saveGroupAndGo,{
groupByChoice(input$groupBySelect)
removeModal()
startStep2()
})
observeEvent(input$groupBySelect,{
currentGroupSelection(input$groupBySelect)
})
output$uploadIntro <- renderUI({
tagList(
tags$h3(class = "row_text title",tags$strong(span("STEP 1 ", class = "text-red")),
" Upload files", backToHubMessage()),
tags$h5(class = "row_text subtitle",
paste0(
"Choose the files containing your ",
networkName,
" tables to check for data quality. After files are uploaded, review the table summarizing uploaded files and variables."
)
)
)
})
observeEvent(uploadList(),{
if (is.null(uploadList())) return(NULL)
collapseStatus$noActive <- TRUE
collapseStatus$active <- TRUE
})
observeEvent(input$noActiveID,{
collapseStatus$noActive <- !collapseStatus$noActive
})
observeEvent(input$activeID,{
collapseStatus$active <- !collapseStatus$active
})
observeEvent(input$uploadSummaryID,{
collapseStatus$uploadSummary <- !collapseStatus$uploadSummary
})
getPreferredDataFormats <- function(concept){
formatPrefs <- names(concept)[str_detect(names(concept), "dataformat_prefer")]
requestedFormats <- c()
for (formatPref in formatPrefs){
formatChosen <- concept[[formatPref]]
if (is.null(formatChosen)) next
if (formatChosen == "1") {
index <- as.numeric(str_after_last(formatPref, "_"))
formatName <- fileFormats[[as.character(index)]] #fileFormats in definitions.R
requestedFormats <- c(requestedFormats, formatName)
}
}
if (is.null(requestedFormats)) requestedFormats <- "None specified"
return(requestedFormats)
}
getContactDisplay <- function(contact, datacontactFlag = FALSE){
# datacontactFlag indicates adding "Data Contact" in italics after the email link
if (is_blank(contact)) return(NULL)
regionCode <- hubInfo$userDetails$regionCode
name <- paste(contact$firstname, contact$lastname, paste0("(", regionCode,")"))
# in case Institution field is blank in REDCap:
if (safeTrimWS(contact$institution) == ""){
institution <- ""
} else {
institution <- paste0(", ", contact$institution)
}
if (datacontactFlag){
displayText <-
tags$li(a(name, href=paste0("mailto:", contact$email), target="_blank"),
em("(Data contact)"), institution)
} else {
displayText <-
tags$li(a(name, href=paste0("mailto:", contact$email), target="_blank"),
institution)
}
return(displayText)
}
# Show user details about the current data request
dataRequestInfo <- reactive({
if (projectDef$hub_y != "1") return(NULL)
if (!hubInfo$fromHub || !hubInfo$dataRequest){
# at this point this is specific to the IeDEA Hub
box(
collapsible = TRUE,
collapsed = collapseStatus$noActive,
width = 10,
title = actionLink("noActiveID", "No Active Data Request"),
tagList(
tags$p(em("There is no active data request currently linked to this data upload. Not all features of the Toolkit are available.")),
tags$ul(tags$li(span(strong("Available: "), style="color:#00a65a"),"data upload, data quality checking, report generation"),tags$li(span(strong("Not available: "), style="color:#dd4b39"),"data upload to cloud")),
tags$p("You may select an active data request on the IeDEA Hub", a(" Submit Data", href="http://iedeahub.org", target="_blank")," page.")
)
)
}
else {
req(userDetails())
req(concept())
concept_url <- paste0(plugin_url, "?token=",
userDetails()$uploadhub_token, "&option=ttl",
"&record=", userDetails()$uploadconcept_id,
"&pid=58325")
request_url <- paste0(plugin_url, "?token=",
userDetails()$uploadhub_token, "&option=sop",
"&record=", userDetails()$datacall_id,
"&pid=58325")
listOfTableLabels <- tagList(
lapply(names(concept()$tablefields), function(x){
tableLabelClass <- paste0("label des-",tableDef[[x]]$table_category)
span(x, class = tableLabelClass)
})
)
requestedFormats <- concept()$requestedFormats
# remind user that CSV is always an accepted alternative
if (!"csv" %in% tolower(requestedFormats)){
if (length(requestedFormats) == 1){
requestedFormats <- paste0(requestedFormats, " (preferred)")
}
requestedFormats <- c(requestedFormats, "CSV (always allowed)")
}
box(
width = 10,
collapsible = TRUE,
collapsed = collapseStatus$active,
title = actionLink("activeID", tags$div(strong(userDetails()$uploadconcept_mr), "Active Data Request")),
tagList(
tags$p(div(strong("Title "),class="col-md-2"), div(userDetails()$uploadconcept_title,class="col-md-10")),
tags$br(),
tags$p(div(strong("Hub Pages"), class="col-md-2"),
div(tags$a(span(paste(userDetails()$uploadconcept_mr,"on Hub"),icon("external-link")),
href = concept_url, target="_blank"),
",",
HTML(' '),HTML(' '),
tags$a(span("Data Specification",icon("external-link")),
href = request_url, target="_blank"),
HTML(' '),HTML(' '),
pdfDownloadButton("sopFinal"),
class = "col-md-10"
)
),
tags$p(
div(strong("Requested Tables "),class="col-md-2"),
tags$div(listOfTableLabels, class="col-md-10"), class = "row toolkit"),
tags$p(
div(strong("Requested Data Format "),class="col-md-2"),
tags$div(paste(requestedFormats, collapse = ", "), class="col-md-10"), class = "row toolkit"
),
tags$p(div(strong("Contacts"), class = "col-md-2"),
div(
tags$ul(
getContactDisplay(concept()$contact1),
getContactDisplay(concept()$contact2),
getContactDisplay(concept()$datacontact, datacontactFlag = TRUE)
),
class = "col-md-10"
),
class = "row toolkit"
),
tags$p(div(strong("Data Downloaders"), class = "col-md-2"),
div(
tags$ul(
lapply(concept()$downloaders, function(x){
getContactDisplay(x)})
), class = "col-md-10"),
class = "row toolkit")
)
)
}
})
output$dataRequestInfo <- renderUI({
if (is.null(hubInfo$fromHub)) return(NULL)
fluidRow(
dataRequestInfo()
)
})
output$sopFinal <- downloadHandler(
filename = "sopfinal.pdf",
content = function(file) {
record_id_Harmonist3 <- hubInfo$userDetails$datacall_id
sopfinal <- downloadREDCapFile(file, tokenForHarmonist3,
record_id_Harmonist3, "sop_finalpdf")
if (inherits(sopfinal, "postFailure")) {
# File failed to download, not sure there's anything to do about it
}
}
)
output$uploadMissingSummary <- renderUI({
if (resetFileInput$reset) return(NULL)
if (!hubInfo$fromHub) return(NULL)
if (is.null(uploadList())) return(NULL)
if (is.null(uploadedTables())) return(NULL)
if (is.null(uploadList()$MissingTables) &&
(is_empty(tablesAndVariables$missingConceptColumns))) return(NULL)
if (!is.null(uploadList()$MissingTables)){
listOfTables <- tagList(
lapply(uploadList()$MissingTables, function(x){
tableLabelClass <- paste0("label des-",tableDef[[x]]$table_category)
span(x, class = tableLabelClass)
})
)
missingTablesMessage <- tags$p(
div(strong("The following",
makeItPluralOrNot("table", length(uploadList()$MissingTables)),
"requested by", userDetails()$uploadconcept_mr, "were not found:"),
listOfTables)
)
} else missingTablesMessage <- NULL
if (!is_empty(tablesAndVariables$missingConceptColumns)){
missingColsMessage <-
tagList(
tags$p(strong("The following",
makeItPluralOrNot("variable", tablesAndVariables$missingVariableCount),
"requested by", userDetails()$uploadconcept_mr, "were not found:")),
tags$ul(tablesAndVariables$missingConceptColumnsFormatted)
)
} else missingColsMessage <- NULL
fluidRow(
tags$a(id = "missingBox"),
box(
width = 10,
solidHeader = TRUE,
status = "warning",
title = "Missing Variables",
# missingTablesMessage, JUDY remove this if final decision
missingColsMessage
)
)
})
output$uploadFileFormatError <- renderUI({
if (resetFileInput$reset) return(NULL)
if (!hubInfo$fromHub) return(NULL)
if (is.null(uploadList())) return(NULL)
if (is.null(uploadedTables())) return(NULL)
if (is_empty(uploadList()$nonmatchingFileFormats)) return(NULL)
nonmatchingFiles <- uploadList()$nonmatchingFileFormats
reqFormats <- concept()$requestedFormats
requestedmsg <- paste(sapply(reqFormats,function(i) as.character(tags$strong(i))),
paste0(".",concept()$requestedExtensions), sep = " (")
requestedmsg <- glue::glue_collapse(
paste0(requestedmsg, ")"),
sep = ", ",
last = " and ")
nonmatchingMessage <-
tagList(
tags$p(tags$strong("The following",
makeItPluralOrNot("file", length(nonmatchingFiles)),
makeItPluralOrNot("does", length(nonmatchingFiles)),
"not match the file format",
"requested by",
paste0(userDetails()$uploadconcept_mr,":")
)),
makeBulletedList(nonmatchingFiles),
tags$p(userDetails()$uploadconcept_mr,
"requests",
HTML(requestedmsg),
"files.",
tags$em("Note that CSV files are always an acceptable option."))
)
fluidRow(
tags$a(id = "fileFormatBox"),
box(
width = 10,
solidHeader = TRUE,
status = "warning",
title = "File Format Error",
nonmatchingMessage
)
)
})
# uploadSummary UI --------------------------------------------------------
output$uploadSummary <- renderUI({
if (resetFileInput$reset) return(NULL)
if (is.null(uploadList())) return(NULL)
if (is.null(uploadedTables())) return(NULL)
uploadInfo <- renderTable({tablesAndVariables$details$variableSummaryToDisplay},
sanitize.text.function = function(x) x) #this allows escape html in renderTable
# if the uploaded dataset included deprecated variables, add explanatory line below table
if (tablesAndVariables$details$deprecated_count > 0){
if (projectDef$datamodel_url_y == "1"){
deprecatedMessage <- div(
tags$em(
tags$span("Note: Deprecated variables are shown in red. See the ",
networkName,
tags$a(tags$u("data model browser"),
href=projectDef$datamodel_url,
target="_blank", style= "color: #dd4b39"),
"for details.", style= "color: #dd4b39")
)
)
} else {
deprecatedMessage <- div(
tags$em(
tags$span("Note: Deprecated variables are shown in red.", style= "color: #dd4b39")
)
)
}
} else deprecatedMessage <- NULL
if (!is_empty(uploadList()$emptyFiles)){
emptyFileMessage <- tagList(
tags$p(" The following uploaded",
makeItPluralOrNot("file", length(uploadList()$emptyFiles)),
"were empty:"),
makeBulletedList(uploadList()$emptyFiles)
)
} else emptyFileMessage <- NULL
if (!is.null(tablesAndVariables$blankTables)){
blankTableMessage <- tagList(
tags$p(" The following file(s) had ",
networkName,
" table names and headers but 0 valid records:"),
makeBulletedList(tablesAndVariables$blankTables)
)
} else blankTableMessage <- NULL
if (length(uploadList()$ExtraFiles) == 0){
extraFileMessage <- NULL
} else {
extraFileMessage <- tagList(
tags$p(" ",
makeItPluralOrNot("File", length(uploadList()$ExtraFiles)),
"in other format or not conforming to the ",
networkName,
"data model (excluded from data quality checks):",
paste(uploadList()$ExtraFiles, collapse = ", "))
# renderTable({
# uploadList()$ExtraFiles
# }, rownames = FALSE, colnames = FALSE)
)
}
if (any(uploadList()$tablesWithNoPatientID %in% pregnancyTables)){
filesNotCheckedMessage <-
tags$p("The following tables that use a key identifier other than PATIENT are excluded from some data quality checks at this time but will be included in the next version of Harmonist:",
paste0(combine_words(uploadList()$tablesWithNoPatientID[uploadList()$tablesWithNoPatientID %in% pregnancyTables]), ".")
)
} else {
filesNotCheckedMessage <- NULL
}
tagList(
fluidRow(
box(
id = "uploadSummary",
width = 10,
title = actionLink("uploadSummaryID",
span("Summary of Uploaded ",
networkName,
" Tables", style = "color: white")),
solidHeader = TRUE,
status = "primary",
collapsible = TRUE,
collapsed = collapseStatus$uploadSummary,
uploadInfo,
deprecatedMessage,
blankTableMessage,
extraFileMessage,
emptyFileMessage,
filesNotCheckedMessage
)
)
)
})
# UI to prompt user to select files to check and submit
output$selectFiles <- renderUI({
if (is.null(hubInfo$fromHub)) return(NULL)
if (projectDef$datamodel_url_y == "1"){
datamodelText <- tags$a(
networkName,
projectDef$datamodel_name,
href=projectDef$datamodel_url, target="_blank"
)
} else {
datamodelText <- paste0(
networkName, " ",
projectDef$datamodel_name
)
}
if (networkName == "IeDEA"){
sampleDataDesc <- tags$p(
"The sample dataset contains 48 intentionally error-filled records representing the following IeDEA DES tables:",
tagList(
lapply(c("tblBAS", "tblLTFU", "tblVIS", "tblART", "tblLAB", "tblLAB_BP"), function(x){
tableLabelClass <- paste0("label des-",tableDef[[x]]$table_category)
span(x, class = tableLabelClass)
})
)
)
} else {
sampleDataDesc <- paste0("The sample dataset contains intentionally error-filled records ",
"for use in demonstrating the Harmonist Data Toolkit")
}
uploadFileUI <-
tagList(
fluidRow(
box(width = 5,
status= "success",
solidHeader = TRUE,
title = "Select Data Files",
tagList(
tags$p("Upload data in the ",
datamodelText,
" format. ",
indexTableName,
" is required."),
tags$p("Allowed file formats include ",
strong("CSV, SAS, Stata, SPSS, RDS, or a ZIP containing multiple files"), " of this type."),
tags$p(tags$em("Select a single ZIP file or multiple files with Ctrl+Click"), align = "center"),
fileInput("loaded",
"Data files",
multiple = TRUE)
)
),
box(width = 5,
title = "Use Sample Dataset",
tags$p("Launch the Toolkit with a sample dataset (fake data) for practice, testing, and demonstrations."),
sampleDataDesc,
tags$br(),
actionButton("runWithSample", "Launch with Sample Data")
)
)
)
if (resetFileInput$reset){
return(uploadFileUI)
}
else if (!is.null(uploadedTables())){
# revisit here Judy - maybe call groupByInfo() here
if (is.null(groupByInfo()$otherGroupOptions)) buttonLabel <- "Details"
else if (!is.null(finalGroupChoice())) buttonLabel <- "Details"
else buttonLabel <- "Change selection"
if (!hubInfo$fromHub){
requiredVariableMessage <-
tags$p("Your dataset contains",
span("all required",
projectDef$datamodel_abbrev,
" variables", class = "text-green", style = "font-weight: bold"))
} else requiredVariableMessage <- NULL # required variables are also requested variables
requestedVariablesMessage <- requestedVariables()
unrecognizedFileAndVariableMessage <- unrecognizedVariables()
reportGroupingMessage <- tags$p("Your dataset will be subdivided for reports by ",
tags$b(groupByChoice()),
xsButton("openGroupModal", label = buttonLabel)
)
return(
tagList(
fluidRow(class = "rowUploadComplete",
box(
width = 5,
title = span("Upload Complete", style = "color: white"),
solidHeader = TRUE,
status = "success",
tagList(
tags$p(tags$b(span(icon("check-square"),"Dataset successfully uploaded"))),
requiredVariableMessage,
requestedVariablesMessage,
unrecognizedFileAndVariableMessage,
reportGroupingMessage,
actionButton("step2","Continue to Step 2", class="btn-success")
)
),
box(
width = 5,
title = span("Restart session"),
tagList(
tags$p("Start over and upload a", tags$b("revised or different dataset.")),
actionButton("uploadNew","Upload new dataset")
)
)))
)
} else if (is.null(uploadList())){
return(
uploadFileUI
)
}
})
observe({
if (tooBusy()) {
shinyjs::hide("selectFiles")
}
else shinyjs::show("selectFiles")
})
observeEvent(input$testContinue,{
hubInfo$fromHub <- FALSE
resetFileInput$newData <- TRUE
resetFileInput$reset <- FALSE
updateTabItems(session,"tabs", "upload")
updateQueryString("?tab=upload", mode = "push")
useSampleData(TRUE)
})
observeEvent(input$testStop,{
useSampleData(FALSE)
removeModal()
})
observeEvent(input$runWithSample,{
if (!hubInfo$dataRequest){
useSampleData(TRUE)
resetFileInput$newData <- TRUE
resetFileInput$reset <- FALSE
} else {
informNoConcept(userDetails()$uploadconcept_mr)
}
})