Skip to content

Commit

Permalink
Add overview of RTT waits
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgthomas committed Jul 19, 2024
1 parent 5263e8a commit 1b61b9c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
53 changes: 53 additions & 0 deletions data-raw/england_rtt_overview.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# ---- Load libs ----
library(tidyverse)
library(readxl)
library(devtools)
library(httr2)
library(lubridate)
library(janitor)

# ---- Load internal sysdata.rda file with URL's ----
load_all(".")

# get url from query_urls table
query_url <-
query_urls |>
filter(id == "rtt_overview") |>
pull(query)

# download xls to as a temp file
download <- tempfile(fileext = ".xlsx")

request(query_url) |>
req_perform(download)

# read the xls file
raw <- read_excel(download, skip = 11)

england_rtt_overview <-
raw |>
select(
month = `...2`,
# `Median wait (weeks)` = `Median wait (weeks)...3`,
`No. within 18 weeks` = `No. within 18 weeks...5`,
`No. > 18 weeks`,
`No. > 52 weeks` = `No. > 52 weeks...11`,
`Total waiting` = `Total waiting (mil)`
) |>

# Fix dates
filter(!is.na(month)) |>
mutate(
month = if_else(
str_detect(month, "Feb"),
ym("2024-02"),
janitor::convert_to_date(month, string_conversion_failure = "warning")
)
) |>

pivot_longer(cols = -month, names_to = "type_of_wait", values_to = "count") |>
mutate(count = as.integer(count)) |>
drop_na()

# Save output to data/ folder
usethis::use_data(england_rtt_overview, overwrite = TRUE)
1 change: 1 addition & 0 deletions data-raw/query-urls.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ query_urls <-
"A&E Attendances and Emergency Admissions", "nhs_accident_emergency_november_23", "November 2023", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2023/12/November-2023-AE-by-provider-gPRdZ.xls", "https://www.england.nhs.uk/statistics/statistical-work-areas/ae-waiting-times-and-activity/ae-attendances-and-emergency-admissions-2023-24/",
"A&E Attendances and Emergency Admissions", "nhs_accident_emergency_december_23", "December 2023", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2024/01/December-2023-AE-by-provider-a5iwg.xls", "https://www.england.nhs.uk/statistics/statistical-work-areas/ae-waiting-times-and-activity/ae-attendances-and-emergency-admissions-2023-24/",
"A&E Providers to Acute Trusts Lookup", "acute_trust_attribution", "June 2022", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2023/02/June-2022-Acute-Trust-Attribution-File.xls", "https://www.england.nhs.uk/statistics/statistical-work-areas/ae-waiting-times-and-activity/ae-attendances-and-emergency-admissions-2022-23/",
"Consultant-led Referral to Treatment Waiting Times Data 2024-25", "rtt_overview", "May 2024", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2024/07/RTT-Overview-Timeseries-Including-Estimates-for-Missing-Trusts-May24-XLS-113K-89156.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/rtt-waiting-times/rtt-data-2024-25/",
"Crime severity", "england_wales_crime_severity", "", "", "https://www.ons.gov.uk/file?uri=/peoplepopulationandcommunity/crimeandjustice/datasets/crimeseverityscoreexperimentalstatistics/current/datatool.xls", "https://www.ons.gov.uk/peoplepopulationandcommunity/crimeandjustice/datasets/crimeseverityscoreexperimentalstatistics",
"Critical care and General & Acute Beds – Urgent and Emergency Care Daily Situation Reports", "nhs_critical_general_acute_beds_april_22", "April 2022", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2022/05/202204-April-2022-sitrep-data-FINAL.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/bed-availability-and-occupancy/critical-care-and-general-acute-beds-urgent-and-emergency-care-daily-situation-reports/critical-care-and-general-acute-beds-urgent-and-emergency-care-daily-situation-reports-2022-23/",
"Critical care and General & Acute Beds – Urgent and Emergency Care Daily Situation Reports", "nhs_critical_general_acute_beds_may_22", "May 2022", "OGLv3", "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2022/06/202205-May-2022-sitrep-data-FINAL.xlsx", "https://www.england.nhs.uk/statistics/statistical-work-areas/bed-availability-and-occupancy/critical-care-and-general-acute-beds-urgent-and-emergency-care-daily-situation-reports/critical-care-and-general-acute-beds-urgent-and-emergency-care-daily-situation-reports-2022-23/",
Expand Down
Binary file added data/england_rtt_overview.rda
Binary file not shown.

0 comments on commit 1b61b9c

Please sign in to comment.