Last active
May 26, 2021 15:36
-
-
Save tomjemmett/17aa43687d5d159c7a7ba8c4207ee2e5 to your computer and use it in GitHub Desktop.
script and csv to get a list of ccg codes and what they are mapped to in 2021/22. all ccg's are present in the file, in the case of a ccg that has not changed since it's introduction old_code == new_code, allowing you to perform a join to another dataset without losing rows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| old_code | new_code | |
|---|---|---|
| 02N | 36J | |
| 09C | 91Q | |
| 10Y | 14Y | |
| 07L | A3A8R | |
| 07M | 93C | |
| 02P | 02P | |
| 99E | 99E | |
| 02Q | 02Q | |
| 11E | 92G | |
| 92G | 92G | |
| 06F | M1J4Y | |
| M1J4Y | M1J4Y | |
| 15A | 15A | |
| 07N | 72Q | |
| 15E | 15E | |
| 13P | 15E | |
| 04X | 15E | |
| 00Q | 00Q | |
| D2P2L | D2P2L | |
| 00R | 00R | |
| 00T | 00T | |
| 10G | D4U1Y | |
| 02W | 36J | |
| 36J | 36J | |
| 02R | 36J | |
| 07P | W2U3Z | |
| 09D | 09D | |
| 11H | 15C | |
| 15C | 15C | |
| 07Q | 72Q | |
| 14Y | 14Y | |
| 00V | 00V | |
| 02T | 02T | |
| 06H | 06H | |
| 07R | 93C | |
| 04Y | 04Y | |
| 09E | 91Q | |
| 99F | 99F | |
| 09A | W2U3Z | |
| 00W | 14L | |
| 27D | 27D | |
| 10H | 14Y | |
| 00X | 00X | |
| 07T | A3A8R | |
| 09G | 70F | |
| 03V | 78H | |
| 84H | 84H | |
| 05A | B2M3M | |
| B2M3M | B2M3M | |
| 09H | 70F | |
| 07V | 36L | |
| 00C | 16C | |
| 09J | 91Q | |
| 15M | 15M | |
| 15N | 15N | |
| 02X | 02X | |
| 11J | 11J | |
| 05C | D2P2L | |
| 00D | 84H | |
| 07W | W2U3Z | |
| 06K | 06K | |
| 15D | D4U1Y | |
| 09F | 97R | |
| 01C | 27D | |
| 01A | 01A | |
| 03W | 03W | |
| 02Y | 02Y | |
| 05D | 05D | |
| 09L | 92A | |
| 97R | 97R | |
| 07X | 93C | |
| 03X | 15M | |
| 10K | D9Y0V | |
| D4U1Y | D4U1Y | |
| 02M | 02M | |
| 00F | 13T | |
| 11M | 11M | |
| 03A | X2C4Y | |
| 01E | 01E | |
| 06M | 26A | |
| 08A | 72Q | |
| 09N | 92A | |
| 01F | 01F | |
| 03D | 42D | |
| 08C | W2U3Z | |
| D9Y0V | D9Y0V | |
| 03Y | 15M | |
| 08D | 93C | |
| 03E | 42D | |
| 08E | W2U3Z | |
| 00K | 16C | |
| 09P | 97R | |
| 08F | A3A8R | |
| 18C | 18C | |
| 05F | 18C | |
| 06N | 06N | |
| 01D | 01D | |
| 99K | 97R | |
| 08G | W2U3Z | |
| 09X | 70F | |
| 07Y | W2U3Z | |
| 03F | 03F | |
| 06L | 06L | |
| 10L | D9Y0V | |
| 08H | 93C | |
| 91Q | 91Q | |
| 11N | 11N | |
| 08J | 36L | |
| X2C4Y | X2C4Y | |
| 01J | 01J | |
| 08K | 72Q | |
| 15F | 15F | |
| 02V | 15F | |
| 03G | 15F | |
| 03C | 15F | |
| 04C | 04C | |
| 08L | 72Q | |
| 71E | 71E | |
| 03T | 71E | |
| 04D | 71E | |
| 99A | 99A | |
| 06P | M1J4Y | |
| 14L | 14L | |
| 04E | 52R | |
| 09W | 91Q | |
| 08R | 36L | |
| 06Q | 06Q | |
| 04F | M1J4Y | |
| 01K | 01K | |
| 04G | 78H | |
| 04H | 52R | |
| 10M | 15A | |
| 13T | 13T | |
| 00G | 13T | |
| 00H | 13T | |
| 08M | A3A8R | |
| 26A | 26A | |
| 78H | 78H | |
| 10N | 15A | |
| 93C | 93C | |
| 01H | 01H | |
| 04J | 15M | |
| 00J | 84H | |
| 06T | 06T | |
| 99M | D4U1Y | |
| 03H | 03H | |
| A3A8R | A3A8R | |
| 99P | 15N | |
| 10J | D9Y0V | |
| 03J | X2C4Y | |
| 03K | 03K | |
| 01M | 14L | |
| 06V | 26A | |
| 11T | 15C | |
| 05G | 05G | |
| 99C | 99C | |
| 00L | 00L | |
| W2U3Z | W2U3Z | |
| 09Y | 92A | |
| 42D | 42D | |
| 06W | 26A | |
| 52R | 52R | |
| 04K | 52R | |
| 04L | 52R | |
| 04M | 52R | |
| 00Y | 00Y | |
| 10Q | 10Q | |
| 10R | 10R | |
| 08N | A3A8R | |
| 05J | 18C | |
| 08P | 36L | |
| 03L | 03L | |
| 04N | 52R | |
| 01G | 01G | |
| 05L | D2P2L | |
| 03M | 42D | |
| 03N | 03N | |
| 05N | M2L0M | |
| M2L0M | M2L0M | |
| 10T | D4U1Y | |
| 05P | 15E | |
| 11X | 11X | |
| 10X | D9Y0V | |
| 01R | 27D | |
| 99Q | 15N | |
| 10V | D9Y0V | |
| 72Q | 72Q | |
| 05Q | 05Q | |
| 99G | 99G | |
| 04R | 15M | |
| 12A | 15C | |
| 10A | 91Q | |
| 99D | 71E | |
| 01N | 14L | |
| 06Y | 26A | |
| 01V | 01V | |
| 10W | 15A | |
| 01T | 01T | |
| 00M | 16C | |
| 00N | 00N | |
| 08Q | 72Q | |
| 05R | B2M3M | |
| 04Q | 71E | |
| 36L | 36L | |
| 05T | 18C | |
| 05V | 05V | |
| 01X | 01X | |
| 01W | 01W | |
| 05W | 05W | |
| 00P | 00P | |
| 99H | 92A | |
| 92A | 92A | |
| 10C | D4U1Y | |
| 08T | 36L | |
| 10D | 91Q | |
| 12D | 92G | |
| 01Y | 01Y | |
| 16C | 16C | |
| 05X | M2L0M | |
| 10E | 91Q | |
| 07G | 07G | |
| 08V | A3A8R | |
| 02A | 02A | |
| 03Q | 03Q | |
| 02D | 27D | |
| 03R | 03R | |
| 05Y | D2P2L | |
| 08W | A3A8R | |
| 08X | 36L | |
| 02E | 02E | |
| 05H | B2M3M | |
| 02F | 27D | |
| 07H | 07H | |
| 11A | D9Y0V | |
| 99J | 91Q | |
| 02G | 02G | |
| 04V | 04V | |
| 08Y | W2U3Z | |
| 07J | 26A | |
| 07K | 07K | |
| 70F | 70F | |
| 02H | 02H | |
| 99N | 92G | |
| 11C | D4U1Y | |
| 12F | 12F | |
| 11D | 15A | |
| 06A | D2P2L | |
| 06D | 18C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| ccgs <- NHSRtools::ods_get_ccgs() |> | |
| select(name, org_id, last_change_date, status) |> | |
| filter(str_detect(name, "^NHS .* CCG$")) | |
| ccg_successors <- NHSRtools::ods_get_successors() |> | |
| semi_join(ccgs, by = c("old_code" = "org_id")) |> | |
| select(old_code, new_code) | |
| # successors file is not yet up to date - manually handling the 2021 mergers | |
| ccg_successors_21 <- tribble( | |
| ~old_code, ~new_code, | |
| "06F", "M1J4Y", | |
| "06P", "M1J4Y", | |
| "04F", "M1J4Y", | |
| "10K", "D9Y0V", | |
| "10L", "D9Y0V", | |
| "10J", "D9Y0V", | |
| "10V", "D9Y0V", | |
| "10X", "D9Y0V", | |
| "11A", "D9Y0V", | |
| "15D", "D4U1Y", | |
| "99M", "D4U1Y", | |
| "10C", "D4U1Y", | |
| "07L", "A3A8R", | |
| "07T", "A3A8R", | |
| "08F", "A3A8R", | |
| "08M", "A3A8R", | |
| "08N", "A3A8R", | |
| "08V", "A3A8R", | |
| "08W", "A3A8R", | |
| "07P", "W2U3Z", | |
| "09A", "W2U3Z", | |
| "07W", "W2U3Z", | |
| "08C", "W2U3Z", | |
| "08E", "W2U3Z", | |
| "08G", "W2U3Z", | |
| "07Y", "W2U3Z", | |
| "08Y", "W2U3Z", | |
| "05N", "M2L0M", | |
| "05X", "M2L0M", | |
| "05C", "D2P2L", | |
| "05L", "D2P2L", | |
| "05Y", "D2P2L", | |
| "06A", "D2P2L", | |
| "05A", "B2M3M", | |
| "05R", "B2M3M", | |
| "05H", "B2M3M", | |
| "03A", "X2C4Y", | |
| "03J", "X2C4Y" | |
| ) | |
| ccg_successors_fixed <- bind_rows( | |
| ccg_successors |> | |
| anti_join(ccg_successors_21, by = c("new_code" = "old_code")), | |
| ccg_successors |> | |
| inner_join(ccg_successors_21, by = c("new_code" = "old_code")) |> | |
| transmute(old_code, new_code = new_code.y), | |
| ccg_successors_21 | |
| ) | |
| ccg_to_202122 <- ccgs |> | |
| transmute(old_code = org_id, new_code = old_code) |> | |
| rows_update(ccg_successors_fixed, by = "old_code") | |
| ccg_to_202122 |> write_csv("ccg_to_202122.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment