output$tab_1_purpose_IPD <- renderHighchart({
req(patients_filter())
req(patients_filter() %>% filter(ipdopd == "Inpatient") %>% nrow() > 1)
dta <- patients_filter() %>%
group_by(ipdopd, typeind_cat) %>%
count() %>%
ungroup() %>%
filter(ipdopd == "Inpatient") %>%
mutate(colors = case_when(
typeind_cat == "Prophylaxis" ~ colors_ipd[1],
typeind_cat == "Treatment" ~ colors_ipd[2],
typeind_cat == "Unknown" ~ "#e3e3e7"))
highchart() %>%
hc_add_series(dta, "pie", hcaes(name = typeind_cat, y = n, color = colors),
dataLabels = list(enabled = TRUE, style = list(fontSize = "13px"),
format = '{point.name} <br>{point.percentage:.0f} %')) %>%
hc_title(text = "Inpatient") %>%
hc_tooltip(headerFormat = "", pointFormat = "{point.n} Prescriptions")
})
output$tab_1_purpose_OPD <- renderHighchart({
req(patients_filter())
req(patients_filter() %>% filter(ipdopd == "Outpatient") %>% nrow() > 1)
dta <- patients_filter() %>%
group_by(ipdopd, typeind_cat) %>%
count() %>%
ungroup() %>%
filter(ipdopd == "Outpatient") %>%
mutate(colors = case_when(
typeind_cat == "Prophylaxis" ~ colors_opd[1],
typeind_cat == "Treatment" ~ colors_opd[2],
typeind_cat == "Unknown" ~ "#e3e3e7"))
highchart() %>%
hc_add_series(dta, "pie", hcaes(name = typeind_cat, y = n, color = colors),
dataLabels = list(enabled = TRUE, style = list(fontSize = "13px"),
format = '{point.name} <br>{point.percentage:.0f} %')) %>%
hc_title(text = "Outpatient") %>%
hc_tooltip(headerFormat = "", pointFormat = "{point.n} Prescriptions%")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.