nhs-r-community / demos-and-how-tos

A repo for community contributed demos and how-tos to get common stuff done in the R language
https://nhs-r-community.github.io/demos-and-how-tos/
MIT License
29 stars 13 forks source link

ccg mergers - ICB update needed #34

Closed GirlThatGraphs closed 2 years ago

GirlThatGraphs commented 2 years ago

when running the first code section it now only returns 142 records. Removing the requirement of CCG returns 248 records as per demo, however these still appear different than the original list.

NHSRtools::ods_get_ccgs() |> select(name, org_id, last_change_date, status) |> filter(str_detect(name, "^NHS"))

tomjemmett commented 2 years ago

having had a very quick look at the underlying data, it seems like it still works, first example ICB I found gives:

successors |>
  filter(new_code == "M1J4Y") |>
  select(old_code, new_code) |>
  inner_join(ccgs |> select(old_code=org_id, old_name=name), by=c("old_code")) |>
  inner_join(ccgs |> select(new_code=org_id, new_name=name), by=c("new_code"))

with results:


# A tibble: 3 × 4
  old_code new_code old_name              new_name                                             
  <chr>    <chr>    <chr>                 <chr>                                                
1 04F      M1J4Y    NHS MILTON KEYNES CCG NHS BEDFORDSHIRE, LUTON AND MILTON KEYNES ICB - M1J4Y
2 06F      M1J4Y    NHS BEDFORDSHIRE CCG  NHS BEDFORDSHIRE, LUTON AND MILTON KEYNES ICB - M1J4Y
3 06P      M1J4Y    NHS LUTON CCG         NHS BEDFORDSHIRE, LUTON AND MILTON KEYNES ICB - M1J4Y

I'll try to re-run the full code and update the repo later :-). I'll have a quick check to see whether we should create an updated document and keep the current file as is.

ChrisBeeley commented 2 years ago

Base pipe FTW :grin:

tomjemmett commented 2 years ago

thanks for this @GirlThatGraphs - the issue seems to be that the CCG's that remained at the point of ICB's taking over have been renamed to match the ICB or sub-ICB that superseded them. I've resolved this by loading the 2021 CCG reference file and using that to replace the names of the CCG's that have been renamed.

It doesn't appear that there is a proper way to find which ICB succeeded a CCG from the ODS data, but I did find CCG to ICB list