ebmdatalab / open-nhs-hospital-use-data

For analysis of https://opendata.nhsbsa.net/dataset/secondary-care-medicines-data
0 stars 0 forks source link

missing trust IDs in etr data #17

Open milanwiedemann opened 2 years ago

milanwiedemann commented 2 years ago

here's a list of trust IDs from @HelenCEBM with missing STP (* indicates @AnnaB45 looked up their STP). ideally we find a way to fix this in the data so that we dont need to do this in every notebook.

here's how we currently do this manually in R:

 # some data cleaning as scmd uses some ods codes that are not up to date
  mutate(stp_code = as.character(stp_code),
         stp_code = case_when(
           ods_code == "RQ6" ~ "QYG", # Cheshire + Merseyside
           ods_code %in% c("RNL", "RE9", "RLN") ~ "QHM", # Cumbria
           ods_code %in% c("RM2", "RW3") ~ "QOP", # Mcr
           ods_code == "RGQ" ~ "QJG", # Suffolk and North East Essex
           ods_code == "RJF" ~ "QJ2", # Derbyshire
           ods_code == "RR1" ~ "QHL", # Birmingham
           ods_code == "R1J" ~ "QR1", # Gloucestershire (trust present in data but wrong/old code)
           ods_code == "R1E" ~ "QNC", # Staffs
           ods_code == "TAD" ~ "QWO", # W Yorks
           ods_code == "TAJ" ~ "QUA", # Black country
           ods_code == "TAH" ~ "QF7", # South Yorkshire & Bassetlow
           ods_code == "TAF" ~ "QMJ", # North Central London
           TRUE ~ stp_code
         )
HelenCEBM commented 2 years ago

Just to add, this list was from the COVID notebook and so looking across the full dataset there are probably several more.

We are looking up their details in the ODS etr.csv file, but we cannot seem to find older versions of this file to download to look up all historic codes systematically. There is one archive version available from 2015 (here) but this may be too old as several of the STP codes may have changed.

HelenCEBM commented 2 years ago

Some trusts, e.g RNL, were present in the etr file that Anna was using, but are re-mapped to a different STP. (RNL merged with RNN and therefore became part of STP QHM rather than Q74, but the old RNL code continued to be used for some purposes. RNL now no longer appears in the latest etr file).