#' Visualize provider risk distribution
#'
#' @param flagged_data A data frame produced by vowr_flag()
#' @return A ggplot object
#' @importFrom ggplot2 ggplot aes geom_point scale_color_manual theme_minimal labs geom_vline geom_hline
#' @export

vowr_plot <- function(flagged_data) {
  p <- ggplot2::ggplot(flagged_data, ggplot2::aes(x = mean_wait, y = volatility, color = risk_flag)) +
    ggplot2::geom_point(alpha = 0.6, size = 2) +
    ggplot2::scale_color_manual(values = c(
      "Critical (Breach & Unstable)" = "red",
      "High (Breach)" = "orange",
      "Warning (Unstable)" = "blue",
      "Stable" = "darkgreen"
    )) +
    ggplot2::geom_vline(xintercept = 18, linetype = "dashed", color = "gray50") +
    ggplot2::theme_minimal() +
    ggplot2::labs(
      title = "NHS Provider Risk Classification",
      x = "Mean Waiting Time (Weeks)",
      y = "Performance Volatility (SD)",
      color = "Risk Category"
    )

  return(p)
}
