Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5926532
Fix depreciation warnings in process_extract_acute
LucyEmma22 Mar 10, 2026
b3ded39
Fix depreciation warnings in process_extract_delayed_discharges
LucyEmma22 Mar 10, 2026
4489c68
Fix depreciation warnings in process_extract_district_nursing
LucyEmma22 Mar 11, 2026
80ded93
Fix depreciation warnings in process_extract_homelessness
LucyEmma22 Mar 11, 2026
66018b2
Fix depreciation warnings in process_extract_mental_health
LucyEmma22 Mar 11, 2026
e9e4a17
Fix depreciation warnings in process_extract_ooh_diagnosis
LucyEmma22 Mar 11, 2026
482231d
Fix depreciation warnings in process_it_chi_deaths_extract
LucyEmma22 Mar 11, 2026
e81a9a5
Fix depreciation warning for create_homelessness_lookup in process_lo…
LucyEmma22 Mar 11, 2026
2d83bc9
Fix depreciation warnings in process_lookup_sc_client
LucyEmma22 Mar 12, 2026
047a88d
Fix depreciation warnings in fill_ch_names
LucyEmma22 Mar 16, 2026
e1f3ae5
Fix deprecation warnings in add_smrtype
LucyEmma22 Apr 1, 2026
cf0174b
Fix deprecation warnings in convert_ca_to_lca
LucyEmma22 Apr 1, 2026
386ffce
Fix deprecation warnings in convert_monthly_rows_to_vars
LucyEmma22 Apr 1, 2026
f5fbf6f
Fix deprecation warnings in convert_sc_sending_location_to_lca
LucyEmma22 Apr 1, 2026
fd1674e
Fix deprecation warnings in get_la_code_opendata_lookup
LucyEmma22 Apr 1, 2026
53cf925
Fix deprecation warnings in get_source_extract_path
LucyEmma22 Apr 1, 2026
e3766a9
Fix deprecation warnings in process_extract_maternity
LucyEmma22 Apr 2, 2026
bb3ea7a
Fix deprecation changes in process_extract_ooh_consultations
LucyEmma22 Apr 2, 2026
6125f38
Fix deprecation warnings in process_extract_ooh_outcomes
LucyEmma22 Apr 2, 2026
17ea29d
Fix deprecation warnings in process_lookup_gpprac
LucyEmma22 Apr 2, 2026
11de0d7
Merge branch 'development' into change-depreciation-process-scripts
LucyEmma22 Apr 2, 2026
e6584c5
Fix "no visible binding" note
LucyEmma22 Apr 9, 2026
75cc3fe
Fix no visible binding for convert_monthly_rows_to_vars
LucyEmma22 Apr 10, 2026
2dbe1db
Style code
LucyEmma22 Apr 10, 2026
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
6 changes: 3 additions & 3 deletions R/add_smrtype.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ add_smrtype <- function(recid,
recid == "HL1" & main_applicant_flag == "N" ~ "HL1-Other"
)
} else if (all(recid == "OoH")) {
smrtype <- dplyr::case_match(
smrtype <- dplyr::recode_values(
consultation_type,
"DISTRICT NURSE" ~ "OOH-DN",
"DOCTOR ADVICE/NURSE ADVICE" ~ "OOH-Advice",
Expand All @@ -167,11 +167,11 @@ add_smrtype <- function(recid,
"COVID19 ASSESSMENT" ~ "OOH-C19Ass",
"COVID19 ADVICE" ~ "OOH-C19Adv",
"COVID19 OTHER" ~ "OOH-C19Oth",
.default = "OOH-Other"
default = "OOH-Other"
)
} else {
# Recids that can be recoded with no identifier
smrtype <- dplyr::case_match(
smrtype <- dplyr::recode_values(
recid,
"00B" ~ "Outpatient",
"04B" ~ "Psych-IP",
Expand Down
2 changes: 1 addition & 1 deletion R/convert_ca_to_lca.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' @family code functions
#' @seealso convert_sc_sending_location_to_lca
convert_ca_to_lca <- function(ca_var) {
lca <- dplyr::case_match(
lca <- dplyr::recode_values(
ca_var,
c("S12000033", "Aberdeen City") ~ "01",
c("S12000034", "Aberdeenshire") ~ "02",
Expand Down
12 changes: 6 additions & 6 deletions R/convert_monthly_rows_to_vars.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ convert_monthly_rows_to_vars <- function(data,
month_order <- tolower(month.abb[c(4L:12L, 1L:3L)])

data %>%
dplyr::mutate(month_name = month_order[{{ month_num_var }}]) %>%
dplyr::select(-{{ month_num_var }}) %>%
dplyr::mutate(month_name = month_order[.data[[month_num_var]]]) %>%
dplyr::select(-all_of(month_num_var)) %>%
dplyr::rename(
cost = {{ cost_var }},
beddays = {{ beddays_var }}
cost = all_of(cost_var),
beddays = all_of(beddays_var)
) %>%
tidyr::pivot_wider(
names_from = .data$month_name,
names_from = "month_name",
names_glue = "{month_name}_{.value}",
values_from = c(.data$cost, .data$beddays),
values_from = c("cost", "beddays"),
values_fill = 0.00
) %>%
dplyr::select(
Expand Down
4 changes: 2 additions & 2 deletions R/convert_sc_sending_location_to_lca.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#'
#' @seealso convert_ca_to_lca
convert_sc_sending_location_to_lca <- function(sending_location) {
lca <- dplyr::case_match(
lca <- dplyr::recode_values(
sending_location,
100L ~ "01", # Aberdeen City
110L ~ "02", # Aberdeenshire
Expand Down Expand Up @@ -50,7 +50,7 @@ convert_sc_sending_location_to_lca <- function(sending_location) {
390L ~ "30", # Stirling
400L ~ "31", # West Lothian
235L ~ "32", # Na_h_Eileanan_Siar
.default = NA_character_
default = NA_character_
)

return(lca)
Expand Down
4 changes: 2 additions & 2 deletions R/fill_ch_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fill_ch_names <- function(ch_data,
ch_name_validated = clean_up_free_text(.data[["ch_name_validated"]]),
ch_date_registered = lubridate::as_date(.data[["ch_date_registered"]]),
ch_date_cancelled = lubridate::as_date(.data[["ch_date_cancelled"]]),
ch_active = dplyr::case_match(
ch_active = dplyr::recode_values(
.data[["ch_active"]],
"Active" ~ TRUE,
c("Cancelled", "Inactive") ~ FALSE
Expand All @@ -106,7 +106,7 @@ fill_ch_names <- function(ch_data,
ch_active = any(.data[["ch_active"]])
) %>%
dplyr::ungroup() %>%
dplyr::rename(ch_postcode_lookup = .data[["ch_postcode"]]) %>%
dplyr::rename(ch_postcode_lookup = all_of("ch_postcode")) %>%
dplyr::mutate(
ch_pc_partial = stringr::str_sub(.data[["ch_postcode_lookup"]], 1, -2),
ch_pc_partial2 = stringr::str_sub(.data[["ch_postcode_lookup"]], 1, -3),
Expand Down
4 changes: 2 additions & 2 deletions R/get_la_code_opendata_lookup.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ get_la_code_opendata_lookup <- function() {
) %>%
dplyr::distinct() %>%
dplyr::mutate(
sending_local_authority_name = dplyr::case_match(
sending_local_authority_name = dplyr::recode_values(
.data$CAName,
"City of Edinburgh" ~ "Edinburgh",
"Na h-Eileanan Siar" ~ "Eilean Siar",
.default = .data$CAName
default = .data$CAName
) %>%
stringr::str_replace("\\sand\\s", " \\& ")
)
Expand Down
2 changes: 1 addition & 1 deletion R/get_source_extract_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ get_source_extract_path <- function(year,
return(get_dummy_boxi_extract_path(BYOC_MODE = BYOC_MODE))
}

file_name <- dplyr::case_match(
file_name <- dplyr::recode_values(
type,
"acute" ~ "anon-acute_for_source",
"ae" ~ "anon-a_and_e_for_source",
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_acute.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ process_extract_acute <- function(data,
# Apply new costs for C3 specialty, these are taken from the 2017/18 file
fix_c3_costs(year) %>%
# initialise monthly cost/beddays variables in a separate data frame for matching
convert_monthly_rows_to_vars(.data$costmonthnum, .data$cost_total_net, .data$yearstay) %>%
convert_monthly_rows_to_vars("costmonthnum", "cost_total_net", "yearstay") %>%
# add yearstay and cost_total_net variables
dplyr::mutate(
yearstay = rowSums(dplyr::pick(tidyselect::ends_with("_beddays"))),
Expand Down
6 changes: 3 additions & 3 deletions R/process_extract_delayed_discharges.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ process_extract_delayed_discharges <- function(

dd_clean <- data %>%
dplyr::rename(
record_keydate1 = .data[["rdd"]],
record_keydate2 = .data[["delay_end_date"]]
record_keydate1 = all_of("rdd"),
record_keydate2 = all_of("delay_end_date")
) %>%
# Use end of the month date for records with no end date
# (but we think have ended)
Expand All @@ -74,7 +74,7 @@ process_extract_delayed_discharges <- function(
) %>%
# recode blanks to NA
dplyr::mutate(
dplyr::across(tidyselect::ends_with("_delay_reason"), dplyr::na_if, "")
dplyr::across(tidyselect::ends_with("_delay_reason"), \(x) dplyr::na_if(x, ""))
) %>%
# create flags for no_end_date and correct_dates
dplyr::mutate(
Expand Down
8 changes: 4 additions & 4 deletions R/process_extract_district_nursing.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ process_extract_district_nursing <- function(
dn_costs <- dn_clean %>%
# Recode HB codes to HB2019 so they match the cost lookup
dplyr::mutate(
hbtreatcode = dplyr::case_match(
hbtreatcode = dplyr::recode_values(
.data$hbtreatcode,
"S08000018" ~ "S08000029", # Fife 2014
"S08000027" ~ "S08000030", # Tayside 2014
"S08000021" ~ "S08000031", # Glasgow 2018
"S08000023" ~ "S08000032", # Lanarkshire 2018
.default = .data$hbtreatcode
default = .data$hbtreatcode
)
) %>%
# match files with DN Cost Lookup
Expand All @@ -76,11 +76,11 @@ process_extract_district_nursing <- function(
create_day_episode_costs(.data$record_keydate1, .data$cost_total_net) %>%
# Return HB values to HB2018
dplyr::mutate(
hbtreatcode = dplyr::case_match(
hbtreatcode = dplyr::recode_values(
.data$hbtreatcode,
"S08000031" ~ "S08000021", # Glasgow
"S08000032" ~ "S08000023", # Lanarkshire
.default = .data$hbtreatcode
default = .data$hbtreatcode
)
)

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_homelessness.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ process_extract_homelessness <- function(
hl1_data <- data %>%
dplyr::left_join(
completeness_data %>%
dplyr::select(.data$sending_local_authority_name, .data$pct_complete_all),
dplyr::select("sending_local_authority_name", "pct_complete_all"),
by = dplyr::join_by("sending_local_authority_name")
) %>%
dplyr::rename(hl1_completeness = "pct_complete_all") %>%
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_maternity.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ process_extract_maternity <- function(data,
levels = c(1L:5L, 8L)
),
smrtype = add_smrtype(.data$recid, .data$mpat),
ipdc = dplyr::case_match(
ipdc = dplyr::recode_values(
.data$smrtype,
"Matern-IP" ~ "I",
"Matern-DC" ~ "D"
Expand Down
8 changes: 4 additions & 4 deletions R/process_extract_mental_health.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ process_extract_mental_health <- function(data, year, write_to_disk = TRUE) {
"NA"
)
) %>%
dplyr::select(-.data$cij_inpatient) %>%
dplyr::select(-"cij_inpatient") %>%
# cij_admtype recode unknown to 99
dplyr::mutate(
cij_admtype = dplyr::if_else(
Expand All @@ -50,9 +50,9 @@ process_extract_mental_health <- function(data, year, write_to_disk = TRUE) {
) %>%
# monthly beddays and costs
convert_monthly_rows_to_vars(
.data$costmonthnum,
.data$cost_total_net,
.data$yearstay
"costmonthnum",
"cost_total_net",
"yearstay"
) %>%
dplyr::mutate(
# yearstay
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_ooh_consultations.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ process_extract_ooh_consultations <- function(data, year) {
# change back to anon_chi
slfhelper::get_anon_chi() %>%
dplyr::mutate(
attendance_status = dplyr::case_match(
attendance_status = dplyr::recode_values(
.data$attendance_status,
"Y" ~ 1L,
"N" ~ 8L
Expand Down
4 changes: 2 additions & 2 deletions R/process_extract_ooh_diagnosis.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ process_extract_ooh_diagnosis <- function(data, year) {
dplyr::rename(diag = "readcode") %>%
# restructure data
tidyr::pivot_wider(
names_from = .data$diag_n,
values_from = c(.data$diag, .data$description),
names_from = "diag_n",
values_from = c("diag", "description"),
names_glue = "{.value}{diag_n}"
) %>%
dplyr::select(
Expand Down
8 changes: 4 additions & 4 deletions R/process_extract_ooh_outcomes.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ process_extract_ooh_outcomes <- function(data, year) {
data.table::as.data.table() %>%
# Recode outcome
dplyr::mutate(
outcome = dplyr::case_match(
outcome = dplyr::recode_values(
.data$outcome,
"DEATH" ~ "00",
"999/AMBULANCE" ~ "01",
Expand All @@ -38,7 +38,7 @@ process_extract_ooh_outcomes <- function(data, year) {
"REFERRED TO SOCIAL SERVICES" ~ "24",
"OTHER HC REFERRAL/ADVISED TO CONTACT OTHER HCP (NON-EMERGENCY)" ~ "29",
"OTHER" ~ "99",
.default = .data$outcome
default = .data$outcome
)
) %>%
# Sort so we prefer 'lower' outcomes e.g. Death, over things like 'Other'
Expand All @@ -48,9 +48,9 @@ process_extract_ooh_outcomes <- function(data, year) {
dplyr::ungroup() %>%
# use row order to pivot outcomes
tidyr::pivot_wider(
names_from = .data$outcome_n,
names_from = "outcome_n",
names_prefix = "ooh_outcome",
values_from = .data$outcome
values_from = "outcome"
) %>%
dplyr::select(
"ooh_case_id",
Expand Down
2 changes: 1 addition & 1 deletion R/process_it_chi_deaths.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ process_it_chi_deaths <- function(data, write_to_disk = TRUE) {
dplyr::distinct(.data$anon_chi, .keep_all = TRUE) %>%
# remove death_date_nrs as this is the nrs weekly unvalidated data and we should not use this.
# the boxi nrs death date is more reliable as this is provided monthly and is validated.
dplyr::select(.data$anon_chi, .data$death_date_chi) %>%
dplyr::select("anon_chi", "death_date_chi") %>%
dplyr::mutate(
death_date_chi = lubridate::ymd(.data$death_date_chi)
)
Expand Down
4 changes: 2 additions & 2 deletions R/process_lookup_gpprac.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ process_lookup_gpprac <- function(
) %>%
dplyr::mutate(
lca = convert_ca_to_lca(.data$ca2018),
hbpraccode = dplyr::case_match(
hbpraccode = dplyr::recode_values(
.data$gpprac,
c(99942L, 99957L, 99961L, 99981L, 99999L) ~ "S08200003",
99995L ~ "S08200001",
.default = .data$hbpraccode
default = .data$hbpraccode
)
)

Expand Down
2 changes: 1 addition & 1 deletion R/process_lookup_homelessness.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ create_homelessness_lookup <- function(
}
homelessness_lookup <- homelessness_data %>%
dplyr::distinct(.data$anon_chi, .data$record_keydate1, .data$record_keydate2) %>%
tidyr::drop_na(.data$anon_chi) %>%
tidyr::drop_na("anon_chi") %>%
dplyr::mutate(hl1_in_fy = 1L)

log_slf_event(stage = "process", status = "complete", type = "homelessness_lookup", year = year)
Expand Down
14 changes: 8 additions & 6 deletions R/process_lookup_sc_client.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ process_lookup_sc_client <-
replace_sc_id_with_latest() %>%
# remove cases with no data in client
dplyr::filter(!(is.na(.data$financial_year))) %>%
dplyr::select(-.data$latest_sc_id, -.data$period)
dplyr::select(-"latest_sc_id", -"period")

client_clean <- sc_client_demographics %>%
dplyr::group_by(.data$sending_location, .data$social_care_id, .data$anon_chi) %>%
Expand Down Expand Up @@ -92,7 +92,7 @@ process_lookup_sc_client <-
"other_vulnerable_groups",
"type_of_housing"
),
tidyr::replace_na, 9L
\(x) tidyr::replace_na(x, 9L)
)
) %>%
# factor labels
Expand All @@ -117,9 +117,11 @@ process_lookup_sc_client <-
"autism",
"other_vulnerable_groups"
),
factor,
levels = c(0L, 1L, 9L),
labels = c("No", "Yes", "Not Known")
\(x) factor(
x,
levels = c(0L, 1L, 9L),
labels = c("No", "Yes", "Not Known")
)
),
type_of_housing = factor(.data$type_of_housing,
levels = 1L:9L,
Expand Down Expand Up @@ -202,7 +204,7 @@ process_lookup_sc_client <-
) %>%
dplyr::arrange(.data$anon_chi, .data$count_not_known) %>%
dplyr::distinct(.data$anon_chi, .keep_all = TRUE) %>%
dplyr::select(-.data$sending_location, -.data$count_not_known)
dplyr::select(-"sending_location", -"count_not_known")

if (write_to_disk) {
write_file(
Expand Down