output$tab_1_prescriptions_var_OPD <- renderHighchart({
req(patients_filter())
req(patients_filter() %>% filter(ipdopd == "Outpatient") %>% nrow() > 1)
var <- input$var_pivot
x <- sym(var)
dta <- patients_filter() %>%
filter(ipdopd == "Outpatient") %>%
group_by(!! x) %>%
count() %>%
ungroup() %>%
mutate(total_prescriptions = sum(n)) %>%
mutate(pct = round(100*n / total_prescriptions, 1))
hchart(dta, type = "column", hcaes(x = !! x, y = pct, color = colors_ipd_opd[["OPD"]])) %>%
hc_tooltip(headerFormat = "", pointFormat = "{point.pct}% <br>({point.n} of {point.total_prescriptions} outpatient prescriptions)") %>%
hc_title(text = "Outpatient") %>%
hc_yAxis(title = list(text = "% of Outpatient Prescriptions")) %>%
hc_xAxis(title = "")
})
output$tab_1_prescriptions_var_IPD <- renderHighchart({
req(patients_filter())
req(patients_filter() %>% filter(ipdopd == "Inpatient") %>% nrow() > 1)
var <- input$var_pivot
x <- sym(var)
dta <- patients_filter() %>%
filter(ipdopd == "Inpatient") %>%
group_by(!! x) %>%
count() %>%
ungroup() %>%
mutate(total_prescriptions = sum(n)) %>%
mutate(pct = round(100*n / total_prescriptions, 1))
hchart(dta, type = "column", hcaes(x = !! x, y = pct, color = colors_ipd_opd[["IPD"]])) %>%
hc_tooltip(headerFormat = "", pointFormat = "{point.pct}% <br>({point.n} of {point.total_prescriptions} inpatient prescriptions)") %>%
hc_title(text = "Inpatient") %>%
hc_yAxis(title = list(text = "% of Inpatient Prescriptions")) %>%
hc_xAxis(title = "")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.