inst/shiny-dashboards/dashboard_cohort/ui.R

# UI for cohort dashboard

# load packages
library(shinydashboard)
library(DT)


## Define dashboard header

header <- dashboardHeader(
        title = "Cohort dashboard"
)


## Define dashboard left sidebar

sidebar <- dashboardSidebar(
        sidebarMenu(
                menuItem("Upload data", tabName = "upload", icon = icon("database")),
                menuItem("Summary", tabName = "summary", icon = icon("chart-line")),
                menuItem("Characteristics", tabName = "characteristics", icon = icon("users")),
                menuItem("DST", tabName = "dst", icon = icon("vial")),
                menuItem("Treatment", tabName = "treatment", icon = icon("pills")),
                menuItem("Outcomes", tabName = "outcomes", icon = icon("poll-h")),
                hr(),
                tags$b("Last inclusion:"), 
                textOutput("recent_patient"),
                hr(),
                tags$b("   Global selectors:"),
                uiOutput("year_filter"),
                selectInput("filter_month",
                            label = "Choose month:",
                            choices = c("All", month.abb),
                            selected = month.abb[lubridate::month(Sys.Date() - 1)],
                            multiple = TRUE),
                hr()
        )
)


## Define dashboard body

body <- dashboardBody(
        tabItems(
                tabItem(
                        tabName = "upload",
                        fluidRow(box(
                                width = 4,
                                title = "Admission file upload",
                                status = "primary",
                                solidHeader = TRUE,
                                fileInput(
                                        inputId = "file",
                                        label = "Must be .csv file",
                                        multiple = FALSE,
                                        accept = "text/csv"
                                )
                        ))
                ),
                tabItem(
                        tabName = "summary",
                        fluidRow(
                                valueBox(
                                        width = 3,
                                        value = textOutput("patient_cohort"),
                                        subtitle = "Patients entering cohort",
                                        icon = icon("user-check"),
                                        color = "blue"
                                ), 
                                valueBox(
                                        width = 3,
                                        value = textOutput("drtb_tx"),
                                        subtitle = "DR-TB treatment started",
                                        icon = icon("prescription"),
                                        color = "blue"
                                ),
                                valueBox(
                                        width = 3,
                                        value = textOutput("dstb_tx"),
                                        subtitle = "DS-TB treatment started",
                                        icon = icon("prescription"),
                                        color = "blue"
                                ),
                                valueBox(
                                        width = 3,
                                        value = textOutput("exit_cohort"),
                                        subtitle = "Patients exiting cohort",
                                        icon = icon("flag-checkered"),
                                        color = "blue"
                                )
                        ),
                        fluidRow(
                                box(
                                        width = 5,
                                        title = "Monthly cohort inclusion",
                                        status = "primary",
                                        solidHeader = TRUE,
                                        plotOutput("annual_inclusion_plot")
                                ), 
                                box(
                                        width = 7,
                                        title = "Monthly cohort inclusion by DST",
                                        status = "primary",
                                        solidHeader = TRUE,
                                        plotOutput("annual_inclusion_plot_dst")
                                )
                        ),
                        fluidRow(
                                box(
                                        width = 5,
                                        title = "Blank",
                                        status = "primary",
                                        solidHeader = TRUE
                                ),
                                        uiOutput("district_inclusion")
                        )
                ),
                tabItem(
                        tabName = "characteristics",
                        h2("Baseline patient characteristics"),
                        fluidRow(
                                box(
                                        width = 4,
                                        title = "Age by month",
                                        status = "primary",
                                        solidHeader = TRUE,
                                        plotOutput("age_month")
                                ),
                                box(
                                        width = 4,
                                        title = "Key ratios by month",
                                        status = "primary",
                                        solidHeader = TRUE,
                                        plotOutput("ratio_month")
                                ),
                                box(
                                        width = 4,
                                        title = "Weight by age",
                                        status = "primary",
                                        solidHeader = TRUE,
                                        plotOutput("weight_month")
                                )
                        ),
                        fluidRow(
                                box(
                                        width = 1,
                                        title = "DST filter",
                                        status = "primary",
                                        solidHeader = TRUE,
                                        uiOutput("dst_filter")
                                ),
                                box(
                                        width = 3,
                                        title = "Definition",
                                        status = "primary",
                                        solidHeader = TRUE,
                                        HTML("<strong>DS-TB:</strong> Includes HR sensitive and Unknown DST"),
                                        br(),
                                        HTML(
                                                "<strong>DR-TB:</strong> Includes H/R mono-resistant, PDR, MDR, and XDR-TB"
                                        )
                                )
                        ),
                        fluidRow(
                                box(
                                        width = 4,
                                        title = "Categorised age distribution",
                                        status = "primary",
                                        solidHeader = TRUE,
                                        DTOutput("age_cat_year"), 
                                        br(), br(),
                                        DTOutput("age_paeds_year")
                                ),
                                box(
                                        width = 4,
                                        title = "Blank",
                                        status = "primary",
                                        solidHeader = TRUE
                                ),
                                box(
                                        width = 4,
                                        title = "Categorised weight distribution",
                                        status = "primary",
                                        solidHeader = TRUE
                                )
                        )
                ),
                tabItem(
                        tabName = "dst",
                        h2("DST summary")
                ),
                tabItem(
                        tabName = "treatment",
                        h2("Treatment aggregates")
                ),
                tabItem(
                        tabName = "outcomes",
                        h2("Cohort outcomes")
                )
        )
)


# Compile ui object

ui <- dashboardPage(
        skin = "red",
        header = header,
        sidebar = sidebar,
        body = body
)
JayAchar/tbreportr documentation built on May 27, 2019, 12:01 a.m.