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

Clean up code #1007

Merged
merged 5 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# September 2024 Update - Unreleased
# September 2024 Update - released 13-Sep-24
* New 24/25 files created
* New NSU cohort for 23/24 available
* New SPARRA scores calculated from April 24/25
Expand Down Expand Up @@ -75,7 +75,7 @@
* Homelessness Flags.
* Bug fixes:
* Blank `datazone` in A&E. This has been fixed and was due to PC8 postcode format matching onto SLF pc lookup.
* Large increase in preventable beddays. This was caused due to an SPSS vs R logic difference. Uses SPSS logic which

Check failure on line 78 in NEWS.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`SPSS` is not a recognized word. (unrecognized-spelling)

Check failure on line 78 in NEWS.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`SPSS` is not a recognized word. (unrecognized-spelling)
brings the difference down to `3.3%`.
* Issue with `locality` which showed `locality` in each row instead of its true `locality`. This has now been fixed.
* Duplicated CHI in the individual file. The issue was identified when trying to include HRIs. This has now been corrected.
Expand All @@ -94,7 +94,7 @@
* Removal of `keydate1_dateformat` and `keydate2_dateformat`.
* `dd_responsible_lca` – This variable now uses CA2019 codes instead of the 2-digit ‘old’ LCA code.
* Preventable beddays - not able to calculate these correctly. * Death fixes not included.
* Variables not ordered in R like they used to be in SPSS.

Check failure on line 97 in NEWS.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`SPSS` is not a recognized word. (unrecognized-spelling)
* End of HHG.
* New variable `ch_postcode`.
* rename of variables `cost_total_net_incdnas`, `ooh_outcome.1`, `ooh_outcome.2`, `ooh_outcome.3`, `ooh_outcome.4`, `totalnodncontacts`.
Expand Down Expand Up @@ -155,7 +155,7 @@
* Fixed a bug where CH costs was not referring to end of year.
* e.g. 2018 costs relates to 2017/18
* The changes to Homelessness described in the March update have been properly implemented.
* We now use [`{haven}`](https://haven.tidyverse.org/news/index.html) to compress the SPSS files which compresses them better than SPSS does 🤷

Check failure on line 158 in NEWS.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`SPSS` is not a recognized word. (unrecognized-spelling)

Check failure on line 158 in NEWS.md

View workflow job for this annotation

GitHub Actions / Check Spelling

`SPSS` is not a recognized word. (unrecognized-spelling)
♂️
* `cij_marker` is now a numeric instead of a string which changes empty strings to missing instead of blank using sysmis.
* Check code of the form `cij_marker = "x"`. `x` now needs to be a numeric.
Expand Down
1 change: 0 additions & 1 deletion R/fill_geographies.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ fill_gpprac_geographies <- function(
#'
#' @return data with matched HSCP and LCA codes
cascade_geographies <- function(data) {
# TODO rework this function into a series of smaller functions which operate on vectors
# e.g. cascade_hscp_lca <- function(hscp, lca) {...}
# Would take HSCP and populate any missing LCA using it
data <- data %>%
Expand Down
1 change: 0 additions & 1 deletion R/process_extract_alarms_telecare.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ process_extract_alarms_telecare <- function(
"smrtype",
"chi",
"dob",
# "person_id",
"gender",
"postcode",
"sc_send_lca",
Expand Down
1 change: 0 additions & 1 deletion R/process_extract_care_home.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ process_extract_care_home <- function(
"recid",
"smrtype",
"chi",
# "person_id",
"dob",
"gender",
"postcode",
Expand Down
1 change: 0 additions & 1 deletion R/process_extract_gp_ooh.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ process_extract_gp_ooh <- function(year,
)

# Keep the location descriptions as a lookup.
# TODO write the GP OoH lookup out using some functions
location_lookup <- ooh_clean %>%
dplyr::group_by(.data$location) %>%
dplyr::summarise(
Expand Down
3 changes: 1 addition & 2 deletions R/process_extract_home_care.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ process_extract_home_care <- function(
tidyselect::starts_with("hc_cost_"),
"cost_total_net",
"hc_provider",
"hc_reablement",
# "person_id"
"hc_reablement"
) %>%
slfhelper::get_anon_chi()

Expand Down
1 change: 0 additions & 1 deletion R/process_extract_homelessness.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ process_extract_homelessness <- function(
dplyr::rename(hl1_completeness = "pct_complete_all") %>%
dplyr::mutate(hl1_completeness = round(.data$hl1_completeness, 1))

# TODO - Include person_id (from client_id)
final_data <- hl1_data %>%
dplyr::select(
"year",
Expand Down
1 change: 0 additions & 1 deletion R/process_extract_sds.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ process_extract_sds <- function(
"smrtype",
"chi",
"dob",
# "person_id",
"gender",
"postcode",
"sc_send_lca",
Expand Down
6 changes: 0 additions & 6 deletions R/process_sc_all_alarms_telecare.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ process_sc_all_alarms_telecare <- function(
# Replace social_care_id with latest if needed (assuming replace_sc_id_with_latest is a custom function)
data <- replace_sc_id_with_latest(data)

# data$person_id <- paste0(
# data$sending_location,
# "-",
# data$social_care_id
# )

# Deal with episodes that have a package across quarters
data[, pkg_count := seq_len(.N), by = list(
Expand Down Expand Up @@ -125,7 +120,6 @@ process_sc_all_alarms_telecare <- function(
dob = data.table::last(dob),
postcode = data.table::last(postcode),
recid = data.table::last(recid),
# person_id = data.table::last(person_id),
sc_send_lca = data.table::last(sc_send_lca)
), by = list(
sending_location,
Expand Down
1 change: 0 additions & 1 deletion R/process_sc_all_care_home.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
by = c("sending_location", "social_care_id")
) %>%
replace_sc_id_with_latest() %>%
dplyr::select(-latest_flag, -latest_sc_id)

Check notice on line 50 in R/process_sc_all_care_home.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`Line` matches candidate pattern `(?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})` (candidate-pattern)


# cleaning and matching care home names
Expand Down Expand Up @@ -385,7 +385,6 @@
)) %>%
dplyr::select(
"chi",
# "person_id",
"gender",
"dob",
"postcode",
Expand Down
6 changes: 0 additions & 6 deletions R/process_sc_all_sds.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ process_sc_all_sds <- function(
"SDS",
convert_sc_sending_location_to_lca(sending_location)
)]
# sds_full_clean_long$person_id <- paste0(
# sds_full_clean_long$sending_location,
# "-",
# sds_full_clean_long$social_care_id
# )

# Group, arrange and create flags for episodes
sds_full_clean_long[,
Expand Down Expand Up @@ -176,7 +171,6 @@ process_sc_all_sds <- function(
dob = data.table::last(dob),
postcode = data.table::last(postcode),
recid = data.table::last(recid),
# person_id = data.table::last(person_id),
sc_send_lca = data.table::last(sc_send_lca)
), by = list(sending_location, social_care_id, smrtype, episode_counter)]
rm(sds_full_clean_long)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ phs_db_connection <- function(dsn, username = Sys.getenv("USER")) {
}


# TODO- check R conversion for SC demog lookup. This may differ
#' Social Care Demographic Lookup File Path
#'
#' @description Get the file path for the Social Care Demographic lookup file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ source("All_years/04-Social_Care/00-Social_Care_functions.R")
sc_con <- phs_db_connection(dsn = "DVPROD")

# Read demographic file
# TODO replace the demographic file with R code
demog_file <- read_demog_file(
social_care_dir = social_care_dir,
latest_update = latest_update()
Expand Down
Loading