Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major update of Care Home script #945

Merged
merged 42 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6efb78b
# major changes to care home script
Apr 29, 2024
487fae7
minor note updates
Apr 29, 2024
2ece590
Style code
SwiftySalmon Apr 29, 2024
faaaa50
Merge branch 'June-24-update' into care_home_update
Jennit07 May 6, 2024
45eee7b
Merge branch 'June-24-update' into care_home_update
Jennit07 May 7, 2024
20ec898
Merge branch 'master' into care_home_update
SwiftySalmon Jun 19, 2024
35918e4
Update documentation
SwiftySalmon Jun 19, 2024
7c7f2d7
couple of note updates
Jun 20, 2024
e7a90f5
Update R/process_sc_all_care_home.R
SwiftySalmon Jun 20, 2024
db5b372
Update R/process_sc_all_care_home.R
SwiftySalmon Jun 20, 2024
be05f47
Style code
SwiftySalmon Jun 20, 2024
c993b5b
Update R/process_sc_all_care_home.R
SwiftySalmon Jun 20, 2024
06dbab6
change to ch name lookup
Jun 20, 2024
471e9f1
Merge branch 'care_home_update' of github.com:Public-Health-Scotland/…
Jun 20, 2024
504c1bd
Update documentation
SwiftySalmon Jun 20, 2024
7721dd9
remove fill ch provider fill line
Jun 20, 2024
70f6343
Merge branch 'care_home_update' of github.com:Public-Health-Scotland/…
Jun 20, 2024
8b3679b
update fill ch names so it works with new ch methodology
Jul 3, 2024
b78abfe
Style code
SwiftySalmon Jul 3, 2024
a5fbbb8
Merge branch 'september-2024' into care_home_update
Jennit07 Jul 5, 2024
49ebb85
Update documentation
Jennit07 Jul 5, 2024
e999820
Merge branch 'september-2024' into care_home_update
Jennit07 Jul 5, 2024
bdc4f86
Merge branch 'september-2024' into care_home_update
Jennit07 Jul 5, 2024
5d1e27c
Merge branch 'september-2024' into care_home_update
SwiftySalmon Jul 16, 2024
48b5b8b
Style code
SwiftySalmon Jul 16, 2024
ee5f663
Update documentation
SwiftySalmon Jul 16, 2024
02e0d66
Remove redundant variable `latest_sc_id`
Jennit07 Jul 16, 2024
1a6c230
use slfhelper::get_chi
Jennit07 Jul 17, 2024
58bc740
new section for sc_ch_id_markers
Jennit07 Jul 17, 2024
0845a7b
Style code
Jennit07 Jul 17, 2024
fc9b6a4
Update documentation
Jennit07 Jul 17, 2024
ba19735
Remove extra text and white space
Jennit07 Jul 17, 2024
3c2e288
Merge branch 'september-2024' into care_home_update
Jennit07 Jul 29, 2024
5312011
Merge branch 'september-2024' into care_home_update
Jennit07 Aug 7, 2024
fcb1eac
add rename to use death_date_chi
Jennit07 Aug 7, 2024
1c71d78
use `read_excel` function
Jennit07 Aug 7, 2024
71d7a6b
Update documentation
Jennit07 Aug 7, 2024
6ad114f
Return the paths only for SPD and ch name
Jennit07 Aug 7, 2024
7ac901f
Update documentation
Jennit07 Aug 7, 2024
a30600c
Remove rename - no longer needed
Jennit07 Aug 7, 2024
3dae4e1
fix typo
Jennit07 Aug 7, 2024
9709bcb
remove variables that dont exist
Jennit07 Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions R/fill_ch_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@
)

# Care Home name lookup from the Care Inspectorate
# Previous contact 'Al Scougal' <Al.Scougal@careinspectorate.gov.scot>
ch_name_lookup <- openxlsx::read.xlsx(ch_name_lookup_path,
# Contact: IntelligenceTeam@careinspectorate.gov.scot
ch_name_lookup <- openxlsx::read.xlsx(ch_name_lookup_path, # (n = 3256)
detectDates = TRUE
) %>%
# Drop any Care Homes that were closed before 2017/18
dplyr::select(
ch_postcode = "AccomPostCodeNo",

Check failure on line 43 in R/fill_ch_names.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`Accom` is not a recognized word. (unrecognized-spelling)
ch_name_validated = "ServiceName",
ch_date_registered = "DateReg",
ch_date_cancelled = "DateCanx"

Check failure on line 46 in R/fill_ch_names.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`Canx` is not a recognized word. (unrecognized-spelling)
) %>%
dplyr::filter(
is.na(.data[["ch_date_cancelled"]]) |
(.data[["ch_date_cancelled"]] >= start_fy("1718"))
(.data[["ch_date_cancelled"]] >= start_fy("1718")) # (n = 1375)
) %>%
# Standardise the postcode and CH name
dplyr::mutate(
Expand All @@ -61,7 +61,7 @@
dplyr::summarise(
# Find the latest date for each CH name / postcode
latest_close_date = dplyr::if_else(
is.na(max(.data[["ch_date_cancelled"]])),
is.na(max(.data[["ch_date_cancelled"]])), # if is na set to todays date as still open
Sys.Date(),
max(.data[["ch_date_cancelled"]])
),
Expand Down Expand Up @@ -131,6 +131,7 @@
"open_interval"
)

# name is not a match. replaces name with better match if possible
no_match_pc_name_bad <- ch_data %>%
dplyr::anti_join(ch_name_lookup,
by = dplyr::join_by("ch_postcode"),
Expand All @@ -155,13 +156,16 @@
)
)

no_match_pc_name_missing <- ch_data %>%
# cases where care home anme and postcode are missing

Check failure on line 159 in R/fill_ch_names.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`anme` is not a recognized word. (unrecognized-spelling)
no_match_pc_name_missing <- ch_data %>% # (n = 135)
dplyr::anti_join(ch_name_lookup,
by = dplyr::join_by("ch_postcode"),
na_matches = "never"
) %>%
dplyr::filter(is.na(.data[["ch_name"]]) & is.na(.data[["ch_postcode"]]))

# cases where care home name is present but postcode is missing.
# assigns new postcode if possible
no_match_pc_missing <- ch_data %>%
dplyr::anti_join(ch_name_lookup,
by = dplyr::join_by("ch_postcode"),
Expand All @@ -186,13 +190,15 @@
)
)

no_match_name_missing <- ch_data %>%
# cases where care home name is missing but postcode is present
no_match_name_missing <- ch_data %>% # (n = 3589)
dplyr::anti_join(ch_name_lookup,
by = dplyr::join_by("ch_postcode"),
na_matches = "never"
) %>%
dplyr::filter(is.na(.data[["ch_name"]]) & !is.na(.data[["ch_postcode"]]))


ch_name_pc_clean <- ch_data %>%
# Remove records with no matching postcode, we'll add them back later
dplyr::semi_join(ch_name_lookup,
Expand Down
4 changes: 2 additions & 2 deletions R/process_lookup_sc_demographics.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ process_lookup_sc_demographics <- function(
dplyr::ungroup()

# check to make sure all cases of chi are still there
dplyr::n_distinct(sc_demog_lookup$chi) # 524810
dplyr::n_distinct(sc_demog_lookup$social_care_id) # 636404
dplyr::n_distinct(sc_demog_lookup$chi) # 525,834
dplyr::n_distinct(sc_demog_lookup$social_care_id) # 637,422


if (write_to_disk) {
Expand Down
Loading
Loading