Skip to content

Commit db9b044

Browse files
authored
Merge branch 'development' into refactor-ae
2 parents 82ba09e + e04a401 commit db9b044

45 files changed

Lines changed: 149 additions & 162 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

R/add_hri_variables.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ add_hri_variables <- function(
7878
hri_lookup <- data %>%
7979
dplyr::select(
8080
"year",
81-
chi_variable,
81+
dplyr::all_of(chi_variable),
8282
"postcode",
8383
"gpprac",
8484
"lca",
@@ -134,7 +134,7 @@ add_hri_variables <- function(
134134
) %>%
135135
# Select only required variables for the lookup
136136
dplyr::select(
137-
chi_variable,
137+
dplyr::all_of(chi_variable),
138138
"hri_scot",
139139
"hri_scotp",
140140
"hri_hb",

R/add_keep_population_flag.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ add_keep_population_flag <- function(individual_file, year) {
1717
pop_estimates <-
1818
readr::read_rds(get_pop_path(type = "datazone")) %>%
1919
dplyr::select(
20-
.data$year,
21-
.data$datazone2011,
22-
.data$sex,
23-
.data$age0:.data$age90plus
20+
"year",
21+
"datazone2011",
22+
"sex",
23+
"age0":"age90plus"
2424
)
2525

2626
# Step 1: Obtain the population estimates for Locality, AgeGroup, and Gender
@@ -56,7 +56,7 @@ add_keep_population_flag <- function(individual_file, year) {
5656
add_age_group(.data$age) %>%
5757
dplyr::left_join(
5858
readr::read_rds(get_locality_path()) %>%
59-
dplyr::select("locality" = "hscp_locality", .data$datazone2011),
59+
dplyr::select("locality" = "hscp_locality", "datazone2011"),
6060
by = "datazone2011"
6161
) %>%
6262
dplyr::group_by(.data$locality, .data$age_group, .data$gender) %>%
@@ -110,7 +110,7 @@ add_keep_population_flag <- function(individual_file, year) {
110110
) %>%
111111
dplyr::filter(.data$keep_nsu == 1L) %>%
112112
dplyr::ungroup() %>%
113-
dplyr::select(-.data$flag_to_remove)
113+
dplyr::select(-"flag_to_remove")
114114

115115
# step 3: match the flag back onto the slf
116116
individual_file <- individual_file %>%

R/add_smrtype.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ add_smrtype <- function(recid,
157157
recid == "HL1" & main_applicant_flag == "N" ~ "HL1-Other"
158158
)
159159
} else if (all(recid == "OoH")) {
160-
smrtype <- dplyr::case_match(
160+
smrtype <- dplyr::recode_values(
161161
consultation_type,
162162
"DISTRICT NURSE" ~ "OOH-DN",
163163
"DOCTOR ADVICE/NURSE ADVICE" ~ "OOH-Advice",
@@ -167,11 +167,11 @@ add_smrtype <- function(recid,
167167
"COVID19 ASSESSMENT" ~ "OOH-C19Ass",
168168
"COVID19 ADVICE" ~ "OOH-C19Adv",
169169
"COVID19 OTHER" ~ "OOH-C19Oth",
170-
.default = "OOH-Other"
170+
default = "OOH-Other"
171171
)
172172
} else {
173173
# Recids that can be recoded with no identifier
174-
smrtype <- dplyr::case_match(
174+
smrtype <- dplyr::recode_values(
175175
recid,
176176
"00B" ~ "Outpatient",
177177
"04B" ~ "Psych-IP",

R/calculate_measures.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ calculate_measures <- function(
8484
if (group_by == "recid") {
8585
pivot_data <- data %>%
8686
tidyr::pivot_longer(
87-
cols = !.data$recid,
87+
cols = !"recid",
8888
names_to = "measure",
8989
values_to = "value"
9090
)

R/convert_ca_to_lca.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#' @family code functions
1515
#' @seealso convert_sc_sending_location_to_lca
1616
convert_ca_to_lca <- function(ca_var) {
17-
lca <- dplyr::case_match(
17+
lca <- dplyr::recode_values(
1818
ca_var,
1919
c("S12000033", "Aberdeen City") ~ "01",
2020
c("S12000034", "Aberdeenshire") ~ "02",

R/convert_codes_to_name.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#'
1515
#' @family code functions
1616
convert_hscp_to_hscpnames <- function(hscp) {
17-
hscpnames <- dplyr::case_match(
17+
hscpnames <- dplyr::recode_values(
1818
hscp,
1919
"S37000001" ~ "Aberdeen City",
2020
"S37000002" ~ "Aberdeenshire",
@@ -67,7 +67,7 @@ convert_hscp_to_hscpnames <- function(hscp) {
6767
#'
6868
#' @family code functions
6969
convert_hb_to_hbnames <- function(hb) {
70-
hbnames <- dplyr::case_match(
70+
hbnames <- dplyr::recode_values(
7171
hb,
7272
"S08000015" ~ "Ayrshire and Arran",
7373
"S08000016" ~ "Borders",

R/convert_monthly_rows_to_vars.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ convert_monthly_rows_to_vars <- function(data,
1717
month_order <- tolower(month.abb[c(4L:12L, 1L:3L)])
1818

1919
data %>%
20-
dplyr::mutate(month_name = month_order[{{ month_num_var }}]) %>%
21-
dplyr::select(-{{ month_num_var }}) %>%
20+
dplyr::mutate(month_name = month_order[.data[[month_num_var]]]) %>%
21+
dplyr::select(-dplyr::all_of(month_num_var)) %>%
2222
dplyr::rename(
23-
cost = {{ cost_var }},
24-
beddays = {{ beddays_var }}
23+
cost = dplyr::all_of(cost_var),
24+
beddays = dplyr::all_of(beddays_var)
2525
) %>%
2626
tidyr::pivot_wider(
27-
names_from = .data$month_name,
27+
names_from = "month_name",
2828
names_glue = "{month_name}_{.value}",
29-
values_from = c(.data$cost, .data$beddays),
29+
values_from = c("cost", "beddays"),
3030
values_fill = 0.00
3131
) %>%
3232
dplyr::select(

R/convert_sc_sending_location_to_lca.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#'
1717
#' @seealso convert_ca_to_lca
1818
convert_sc_sending_location_to_lca <- function(sending_location) {
19-
lca <- dplyr::case_match(
19+
lca <- dplyr::recode_values(
2020
sending_location,
2121
100L ~ "01", # Aberdeen City
2222
110L ~ "02", # Aberdeenshire
@@ -50,7 +50,7 @@ convert_sc_sending_location_to_lca <- function(sending_location) {
5050
390L ~ "30", # Stirling
5151
400L ~ "31", # West Lothian
5252
235L ~ "32", # Na_h_Eileanan_Siar
53-
.default = NA_character_
53+
default = NA_character_
5454
)
5555

5656
return(lca)

R/create_demographic_lookup.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ create_demographic_cohorts <- function(
169169
TRUE ~ "Healthy and Low User"
170170
)) %>%
171171
# Reorder variables
172-
dplyr::relocate(.data$demographic_cohort, .after = .data$anon_chi)
172+
dplyr::relocate("demographic_cohort", .after = "anon_chi")
173173

174174
# Write to disk
175175
if (write_to_disk) {

R/create_episode_file.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,17 +435,17 @@ correct_cij_vars <- function(data) {
435435
),
436436
cij_pattype_code = dplyr::if_else(
437437
!is.na(.data$anon_chi) & .data$recid %in% c("01B", "04B", "GLS", "02B"),
438-
dplyr::case_match(
438+
dplyr::recode_values(
439439
.data$cij_admtype,
440440
c("41", "42") ~ 2L,
441441
c("40", "48", "99") ~ 9L,
442442
"18" ~ 0L,
443-
.default = as.integer(.data$cij_pattype_code)
443+
default = as.integer(.data$cij_pattype_code)
444444
),
445445
.data$cij_pattype_code
446446
),
447447
# Recode cij_pattype based on above
448-
cij_pattype = dplyr::case_match(
448+
cij_pattype = dplyr::recode_values(
449449
.data$cij_pattype_code,
450450
0L ~ "Non-Elective",
451451
1L ~ "Elective",

0 commit comments

Comments
 (0)