-
-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Labels
Description
vitals app
pkgload::load_all("teal.code")
library(teal.modules.clinical)
library(teal.modules.general)
options(shiny.useragg = FALSE)
## Data reproducible code ----
data <- teal_data()
data <- within(data, {
library(random.cdisc.data)
library(nestcolor)
ADSL <- radsl(seed = 1)
ADMH <- radmh(ADSL, seed = 1)
ADAE <- radae(ADSL, seed = 1)
ADCM <- radcm(ADSL, seed = 1)
ADVS <- radvs(ADSL, seed = 1)
ADLB <- radlb(ADSL, seed = 1)
## Modify ADCM
ADCM$CMINDC <- paste0("Indication_", as.numeric(ADCM$CMDECOD))
ADCM$CMDOSE <- 1
ADCM$CMTRT <- ADCM$CMCAT
ADCM$CMDOSU <- "U"
ADCM$CMROUTE <- "CMROUTE"
ADCM$CMDOSFRQ <- "CMDOSFRQ"
ADCM$CMASTDTM <- ADCM$ASTDTM
ADCM$CMAENDTM <- ADCM$AENDTM
teal.data::col_labels(
ADCM[c("CMINDC", "CMTRT", "ASTDY", "AENDY")]
) <- c(
"Indication",
"Reported Name of Drug, Med, or Therapy",
"Study Day of Start of Medication",
"Study Day of End of Medication"
)
## Modify ADHM
ADMH[["MHDISTAT"]] <- "ONGOING"
teal.data::col_labels(ADMH[c("MHDISTAT")]) <- c("Status of Disease")
})
join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADMH", "ADAE", "ADCM", "ADVS", "ADLB")]
## App configuration ----
ADSL <- data[["ADSL"]]
ADMH <- data[["ADMH"]]
ADAE <- data[["ADAE"]]
ADCM <- data[["ADCM"]]
ADVS <- data[["ADVS"]]
ADLB <- data[["ADLB"]]
## Define variable inputs
aeterm_input <- choices_selected(
choices = variable_choices(ADAE, "AETERM"),
selected = "AETERM"
)
cmtrt_input <- choices_selected(
choices = variable_choices(ADCM, "CMTRT"),
selected = "CMTRT"
)
cmindc_input <- choices_selected(
choices = variable_choices(ADCM, "CMINDC"),
selected = "CMINDC"
)
atirel_input <- choices_selected(
choices = variable_choices(ADCM, "ATIREL"),
selected = "ATIREL"
)
cmdecod_input <- choices_selected(
choices = variable_choices(ADCM, "CMDECOD"),
selected = "CMDECOD"
)
## App header and footer ----
nest_logo <- "https://raw.githubusercontent.com/insightsengineering/hex-stickers/main/PNG/nest.png"
app_source <- "https://github.com/insightsengineering/teal.gallery/tree/main/patient-profile"
gh_issues_page <- "https://github.com/insightsengineering/teal.gallery/issues"
header <- tags$span(
style = "display: flex; align-items: center; justify-content: space-between; margin: 10px 0 10px 0;",
tags$span("My first teal app", style = "font-size: 30px;"),
tags$span(
style = "display: flex; align-items: center;",
tags$img(src = nest_logo, alt = "NEST logo", height = "45px", style = "margin-right:10px;"),
tags$span(style = "font-size: 24px;", "NEST @ Roche")
)
)
footer <- tags$p(
"This teal app is brought to you by the NEST Team at Roche/Genentech.
For more information, please visit:",
tags$a(href = app_source, target = "_blank", "Source Code"), ", ",
tags$a(href = gh_issues_page, target = "_blank", "Report Issues")
)
app <- init(
data = data,
title = build_app_title("Patient Profile Analysis Teal Demo App", nest_logo),
header = header,
footer = footer,
filter = teal_slices(
count_type = "all",
teal_slice(dataname = "ADSL", varname = "SEX"),
teal_slice(dataname = "ADSL", varname = "AGE")
),
modules = modules(
tm_g_pp_vitals(
label = "Vitals",
parentname = "ADSL",
patient_col = "USUBJID",
plot_height = c(600L, 200L, 2000L),
paramcd = choices_selected(
choices = variable_choices(ADVS, "PARAMCD"),
selected = "PARAMCD"
),
xaxis = choices_selected(
choices = variable_choices(ADVS, "ADY"),
selected = "ADY"
),
aval_var = choices_selected(
choices = variable_choices(ADVS, "AVAL"),
selected = "AVAL"
)
)
)
)
shinyApp(app$ui, app$server)Above app fails as split_code wrongly detects end of the call and results in evaluation error:
Look, above call has been splitted into following:
# [15] "base_labels <- stats::setNames(c(\"140mmHg\", \"90mmHg\", \"38° C\", \"20/min\", \"94%\", \"100bpm\"), known_vita)\np"
# [16] "aramcd_labels_e <- base_labels[paramcd_levels_e]\n"