-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathui.R
462 lines (457 loc) · 16.4 KB
/
ui.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
# UI for stanpumpR
# UI ------------------------------------------------------
ui <- function(request) {
dashboardPage(
dashboardHeader(
title = config$title,
tags$li(
class = "dropdown",
tags$a(
href = config$help_link,
id = "help_link",
"Examples and Help",
target = "_blank"
)
)
),
dashboardSidebar(
collapsed = TRUE,
disable = TRUE,
width = "200px",
sidebarMenu(
id = "simType",
menuItem("stanpumpR", tabName = "SimulationMode", selected = TRUE)
)
),
dashboardBody(
useShinyjs(),
useWaiter(),
tags$script(src = "app.js"),
tags$head(tags$link(href = "app.css", rel = "stylesheet")),
style = "max-height: 95vh; overflow-y: auto;" ,
fluidRow(
column(
width=4,
fluidRow( # start of fluid row within this column
h4("Patient Covariates"),
style = "border-style: solid; border-color: white; border-radius: 5px;",
column(
width = 4,
div(
class = "form-first-row",
div( # Age ************************************
class = "cancel-margin",
numericInput(
inputId = "age",
label = "Age",
value = defaultAge,
min = MIN_AGE,
max = MAX_AGE
),
bsTooltip(
id = "age",
title = "Enter age and select years or months",
placement = "top",
options = list(container = "body")
)
), # end of cancel-margin div
div( #style = "font-size: 10px;",
radioButtons(
inputId = "ageUnit",
label = NULL,
choiceNames = c("years","months"),
choiceValues = c(UNIT_YEAR, UNIT_MONTH),
inline = TRUE,
selected = defaultAgeUnit
)
)
), # end of form-first-row div
div( # weight *****************************************
class = "cancel-margin",
numericInput(
inputId = "weight",
label = "Weight",
value = defaultWeight,
min = MIN_WEIGHT,
max = MAX_WEIGHT
),
bsTooltip(
id = "weight",
title = "Enter weight and select kilograms or pounds",
placement = "top",
options = list(container = "body")
)
), # End of class cancel-margin div
radioButtons(
inputId = "weightUnit",
label = NULL,
choiceNames = c("kg", "lb"),
choiceValues = c(UNIT_KG, UNIT_LB),
inline = TRUE,
selected = defaultWeightUnit
),
div( # Height ********************************************
class = "cancel-margin",
numericInput(
inputId = "height",
label = "Height",
value = defaultHeight,
min = MIN_HEIGHT,
max = MAX_HEIGHT
),
bsTooltip(
id = "height",
title = "Enter height and select centimeters or inches",
placement = "right",
options = list(container = "body")
)
), # end of cancel-margin div
radioButtons(
inputId = "heightUnit",
label = NULL,
choiceNames = c("cms","inches"),
choiceValues = c(UNIT_CM, UNIT_INCH),
inline = TRUE,
selected = defaultHeightUnit
)
), # end of column
column(
width = 6,
# div(
# class = "form-first-row",
radioButtons(
inputId = "sex",
label = "Sex",
choiceNames = c("Male","Female"),
choiceValues = c("male","female"),
inline = TRUE,
selected = defaultSex
),
# ), # end of class: form-first-row div
disabled(conditionalPanel(
condition = "input.age && input.ageUnit && input.ageUnit == 1 && input.age > 11 & input.age < 60 && input.sex == 'female'",
radioButtons(
inputId = "pregnant",
label = "Pregnant",
choiceNames = c("Yes","No"),
choiceValues = c(TRUE, FALSE),
inline = TRUE,
selected = FALSE
),
bsTooltip(
id = "pregnant",
title = "Not implemented yet",
placement = "right",
options = list(container = "body")
)
)),
disabled(radioButtons(
inputId = "cyp2d6",
label = "CYP 2D6",
choiceNames = c("Rapid","Typical", "Slow"),
choiceValues = c("rapid","typical", "slow"),
inline = FALSE,
selected = "typical"
),
bsTooltip(
id = "cyp2d6",
title = "Not implemented yet",
placement = "right",
options = list(container = "body")
)),
disabled(radioButtons(
inputId = "renal",
label = "Renal Function",
choiceNames = c("Normal","Impaired", "ESRD"),
choiceValues = c("normal","impaired", "ESRD"),
inline = FALSE,
selected = "normal"
),
bsTooltip(
id = "renal",
title = "Not implemented yet",
placement = "right",
options = list(container = "body")
))
)
), # fluidrow within column
fluidRow(
h4("Dose Table"),
style = "border-style: solid; border-color: white; border-radius: 5px; height: 450px; ",
column(
width=12,
fluidRow(
column(
width = 4,
textInput("referenceTime", "Reference Time", placeholder = "HH:MM"),
bsTooltip(
id = "referenceTime",
title = 'Time is selected based on your local time. Select "none" for absolute time.',
placement = "right",
options = list(container = "body")
)
)
), # end of fluid row
# Note to Dean: Here is where the handsontable is output. My guess is that this is where
# you would replace the existing "rHandsontableOutput()" function with JavaScript code that
# will process and validate the table.
tags$script(HTML(js_drug_defaults)),
tags$script(src = "hot_funs.js"),
rHandsontableOutput(outputId = "doseTableHTML"),
bsTooltip(
id = "doseTableHTML",
title = "Enter the drug and the units by typing or by using the pull down menu. Clock times are entered as HH:MM.",
placement = "right",
options = list(container = "body")
)
) # End of column
) # end of second fluid row in width 5 column
), # end of width 5 column
column(
width=8,
fillPage(
div(
style = "position:relative",
# Start of plot Output
plotOutput(
outputId = "PlotSimulation",
width="100%",
height="500px",
click = clickOpts(
id = "plot_click",
clip = FALSE
),
dblclick = dblclickOpts(
id = "plot_dblclick",
clip=FALSE
),
hover = hoverOpts(
id = "plot_hover",
delay = 500,
delayType = "debounce",
clip = FALSE,
nullOutside = FALSE
)
), # End of plotOutput
uiOutput("hover_info")
) # End of div
), # End of fillPage
############################################################################
fluidRow(
style = "border-style: solid; border-color: white; border-radius: 5px; height: 300px",
h4("Graph Options"),
column( # Column 1, Simulation Mode
width = 2,
textInput(
inputId = "title",
label = "Title",
value = paste("Simulation on",format(Sys.time()))
),
bsTooltip(
id = "title",
title = "Enter a title for your simulation",
placement = "top",
options = list(container = "body")
),
textInput(
inputId = "caption",
label = "Caption",
value = "",
placeholder = "Enter figure caption"
),
bsTooltip(
id = "caption",
title = "Text to appear below your simulation",
placement = "bottom",
options = list(container = "body")
),
div(
style = "padding-bottom: 10px;",
actionButton(
inputId = "setTarget",
label = "Suggest",
icon=icon("fas fa-syringe"),
width = NULL
)
),
actionButton(
inputId = "editDrugs",
label = "Edit Drugs",
icon=icon("fas fa-syringe"),
width = NULL
)
), # End of column
# Column 2, Simulation Mode
column(
width = 2,
radioButtons(
inputId = "typical",
label = "Show typical:",
choices = c("none","Mid", "Range"),
selected = "Range",
inline = FALSE
),
bsTooltip(
id = "typical",
title = "Show typical clinical values",
placement = "top",
options = list(container = "body")
),
radioButtons(
inputId = "normalization",
label = "Normalize to:",
choices = c("none","Peak plasma", "Peak effect site"),
selected = "none",
inline = FALSE
),
bsTooltip(
id = "normalization",
title = "Normalization can help show relationships",
placement = "top",
options = list(container = "body")
)
),
# Select MEAC, Select Interaction, events, and time to emergence
column(
width = 2,
checkboxGroupInput(
inputId = "addedPlots",
label = "Additional Plots",
choiceNames = c("MEAC", "Interaction", "Events", "Time until ___"),
choiceValues = c("MEAC", "Interaction", "Events", "Time Until")
),
bsTooltip(
id = "addedPlots",
title = "MEAC normalizes each opioid to the minimum effective analgesic concentration, a measure of opioid potency. Interaction shows the opioid hypnotic interaction. It is very preliminary.",
placement = "top",
options = list(container = "body")
),
conditionalPanel(
condition = "!(input.addedPlots.includes('Time Until') || input.addedPlots.includes('Events') || input.addedPlots.includes('Interaction'))",
checkboxInput(
inputId = "logY",
label = "Log Y axis",
value = FALSE
),
bsTooltip(
id = "logY",
title = "Plot Y axis on a log scale",
placement = "top",
options = list(container = "body")
)
)
),
# Column 5, Simulation Mode
column(
width = 2,
selectInput(
inputId = "maximum",
label = "Max Time",
choices = maxtimes$times,
selected = 60
),
bsTooltip(
id = "maximum",
title = "Maximum time. Axis will automatically expand as you enter more doses, unless maximum is set to 10 minutes",
placement = "top",
options = list(container = "body")
),
selectInput(
inputId = "plasmaLinetype",
label = "Plasma",
selected = "blank",
choices = c("solid",
"dashed",
"longdash",
"dotted",
"dotdash",
"twodash",
"blank")
),
bsTooltip(
id = "plasmaLinetype",
title = "Line type for plasma concentrations",
placement = "top",
options = list(container = "body")
),
selectInput(
inputId = "effectsiteLinetype",
label = "Effect site",
selected = "solid",
choices = c("solid",
"dashed",
"longdash",
"dotted",
"dotdash",
"twodash",
"blank")
),
bsTooltip(
id = "effectsiteLinetype",
title = "Line type for effect site concentrations",
placement = "bottom",
options = list(container = "body")
)
),
column(
offset = 0,
width = 4,
fluidRow(
column(
width = 9,
textInput(
inputId = "recipient",
label = "Email slide to:"
),
bsTooltip(
id = "recipient",
title = "Enter a valid e-mail address",
placement = "top",
options = list(container = "body")
)
),
column(
width = 3,
div(
id = "sendSlideButton",
style = "padding-top: 25px;",
actionButton(
inputId = "sendSlide",
label = "GO!",
icon = icon("far fa-envelope")
),
bsTooltip(
id = "sendSlide",
title = "Click ONCE to send slide",
placement = "top",
options = list(container = "body")
)
),
div(
id = "sendSlideError",
style = "padding-top: 25px;",
"Check address"
)
)
), # End of fluid row
imageOutput(
outputId = "sentPlot",
height = "100px",
width = "166px"
)
) # end columnn
) # end fluidRow
) # End of right hand colunn
), # end of first fluid row
fluidRow(
column(
12,
wellPanel(
id = "logSection",
uiOutput("logContent")
)
)
)
) # end dashboardBody
) # end dashboardPage
}