#' Profile National Health Service provider performance
#'
#' @param data A data frame from vowr_import().
#'
#' @return A summary table with the number of months, mean waiting time,
#' median waiting time, waiting-time volatility, and total backlog for each
#' provider.
#'
#' @export
vowr_profile <- function(data) {
  profile <- dplyr::group_by(data, provider_org_code, provider_org_name)

  profile <- dplyr::summarise(
    profile,
    n_months      = dplyr::n(),
    mean_wait     = base::mean(mean_wait_weeks, na.rm = TRUE),
    median_wait   = stats::median(mean_wait_weeks, na.rm = TRUE),
    volatility    = stats::sd(mean_wait_weeks, na.rm = TRUE),
    total_backlog = base::sum(backlog_total, na.rm = TRUE),
    .groups       = "drop"
  )

  return(profile)
}
