monthly_det <- aki %>%
filter(!is.na(AdmMonth)) %>%
group_by(AdmMonth) %>%
summarise(n = n(),
Det = sum(early_detection),
Rate = Det / n * 100, .groups = "drop") %>%
filter(n >= 2)
p_det_line <- ggplot(monthly_det, aes(x = AdmMonth, y = Rate)) +
geom_ribbon(aes(ymin = pmax(0, Rate - 15),
ymax = pmin(100, Rate + 15)),
fill = "#aed6f1", alpha = 0.35) +
geom_line(colour = "#1a3a5c", linewidth = 1.2) +
geom_point(aes(size = n, colour = Rate), alpha = 0.85) +
geom_hline(yintercept = 90, linetype = "dashed", colour = "#27ae60", linewidth = 1) +
geom_hline(yintercept = 50, linetype = "dashed", colour = "#f39c12", linewidth = 1) +
geom_hline(yintercept = 5, linetype = "dotted", colour = "#e74c3c", linewidth = 0.8) +
annotate("text", x = as.POSIXct("2024-03-01"), y = 93,
label = "Jun 2026 Target: 90%", colour = "#27ae60",
size = 3.3, fontface = "bold") +
annotate("text", x = as.POSIXct("2024-03-01"), y = 53,
label = "Dec 2024 Target: 50%", colour = "#f39c12",
size = 3.3, fontface = "bold") +
annotate("text", x = as.POSIXct("2023-07-01"), y = 7,
label = "Baseline: 5%", colour = "#e74c3c", size = 3.1) +
scale_colour_gradient(low = "#e74c3c", high = "#27ae60",
limits = c(0, 100), name = "Rate (%)") +
scale_size_continuous(range = c(3, 8), name = "N") +
scale_x_datetime(date_labels = "%b %Y", date_breaks = "2 months") +
scale_y_continuous(limits = c(0, 110),
labels = function(x) paste0(x, "%")) +
labs(title = "A - Monthly Early Detection Rate",
x = NULL, y = "Detection Rate (%)") +
theme_minimal(base_size = 12) +
theme(plot.title = element_text(face = "bold", colour = "#1a3a5c"),
axis.text.x = element_text(angle = 45, hjust = 1))
qtr_det <- aki %>%
filter(!is.na(AdmQuarter)) %>%
group_by(AdmQuarter) %>%
summarise(n = n(),
Det = sum(early_detection),
Rate = Det / n * 100, .groups = "drop")
p_det_bar <- qtr_det %>%
mutate(Band = case_when(Rate >= 90 ~ ">=90% (Target)",
Rate >= 50 ~ "50-89%",
TRUE ~ "<50%")) %>%
ggplot(aes(x = AdmQuarter, y = Rate, fill = Band)) +
geom_col(colour = "white") +
geom_text(aes(label = paste0(round(Rate, 0), "%\n(n=", n, ")")),
vjust = -0.25, size = 3.3, fontface = "bold") +
geom_hline(yintercept = 90, linetype = "dashed",
colour = "#27ae60", linewidth = 1) +
geom_hline(yintercept = 50, linetype = "dashed",
colour = "#f39c12", linewidth = 1) +
scale_fill_manual(values = c(">=90% (Target)" = "#27ae60",
"50-89%" = "#2980b9",
"<50%" = "#e74c3c")) +
scale_y_continuous(limits = c(0, 120),
labels = function(x) paste0(x, "%")) +
labs(title = "B - Quarterly Early Detection Rate",
x = "Quarter", y = "Rate (%)", fill = "Band") +
theme_minimal(base_size = 12) +
theme(plot.title = element_text(face = "bold", colour = "#1a3a5c"),
axis.text.x = element_text(angle = 45, hjust = 1),
legend.position = "bottom")
p_det_line / p_det_bar +
plot_annotation(
title = "Figure 4. Early AKI Detection Trends",
caption = "Months with < 2 admissions excluded. Dashed lines = project targets.",
theme = theme(plot.title = element_text(face = "bold", size = 14, colour = "#1a3a5c"),
plot.caption = element_text(colour = "grey50"))
)