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

Remove incorrect references to rds #798

Merged
merged 3 commits into from
Sep 25, 2023
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
18 changes: 12 additions & 6 deletions R/process_costs_rmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ process_costs_rmd <- function(file_name) {
stringr::fixed("Rmd", ignore_case = TRUE)
)) {
cli::cli_abort(
"{.arg file_name} must be an {.code .Rmd} not a {.code .{fs::path_ext(file_name)}}."
"{.arg file_name} must be an {.code .Rmd} not a
{.code .{fs::path_ext(file_name)}}."
)
}

Expand All @@ -34,7 +35,12 @@ process_costs_rmd <- function(file_name) {

output_file <- get_file_path(
directory = output_dir,
file_name = fs::path_ext_set(stringr::str_glue("{fs::path_ext_remove(file_name)}-{latest_update()}-{date_today}"), "html"),
file_name = fs::path_ext_set(
stringr::str_glue(
"{fs::path_ext_remove(file_name)}-{latest_update()}-{date_today}"
),
"html"
),
check_mode = "write"
)

Expand All @@ -55,7 +61,7 @@ process_costs_rmd <- function(file_name) {
#'
#' @description This will read and process the
#' District Nursing cost lookup, it will return the final data
#' but also write this out as a rds.
#' and write it to disk.
#'
#' @param file_path Path to the cost lookup.
#'
Expand All @@ -73,7 +79,7 @@ process_costs_dn_rmd <- function(file_path = get_dn_costs_path()) {
#'
#' @description This will read and process the
#' care homes cost lookup, it will return the final data
#' but also write this out as a rds.
#' and write it to disk.
#'
#' @inheritParams process_costs_dn_rmd
#'
Expand All @@ -91,7 +97,7 @@ process_costs_ch_rmd <- function(file_path = get_ch_costs_path()) {
#'
#' @description This will read and process the
#' GP ooh cost lookup, it will return the final data
#' but also write this out as a rds.
#' and write it to disk.
#'
#' @inheritParams process_costs_dn_rmd
#'
Expand All @@ -109,7 +115,7 @@ process_costs_gp_ooh_rmd <- function(file_path = get_gp_ooh_costs_path()) {
#'
#' @description This will read and process the
#' Home Care cost lookup, it will return the final data
#' but also write this out as a rds.
#' and write it to disk.
#'
#' @inheritParams process_costs_dn_rmd
#'
Expand Down
15 changes: 7 additions & 8 deletions R/process_extract_acute.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' acute extract, it will return the final data
#' but also write this out as an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down Expand Up @@ -61,9 +61,7 @@ process_extract_acute <- function(data, year, write_to_disk = TRUE) {
levels = 0L:8L
))


## save outfile ---------------------------------------
outfile <- acute_clean %>%
acute_processed <- acute_clean %>%
dplyr::select(
"year",
"recid",
Expand Down Expand Up @@ -113,10 +111,11 @@ process_extract_acute <- function(data, year, write_to_disk = TRUE) {
dplyr::arrange(.data$chi, .data$record_keydate1)

if (write_to_disk) {
# Save as rds file
outfile %>%
write_file(get_source_extract_path(year, "Acute", check_mode = "write"))
write_file(
acute_processed,
get_source_extract_path(year, "Acute", check_mode = "write")
)
}

return(outfile)
return(acute_processed)
}
15 changes: 7 additions & 8 deletions R/process_extract_ae.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' A&E extract, it will return the final data
#' but also write this out as an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down Expand Up @@ -237,9 +237,7 @@ process_extract_ae <- function(data, year, write_to_disk = TRUE) {
.data$keytime2
)


# Save outfile----------------------------------------
outfile <- matched_ae_data %>%
ae_processed <- matched_ae_data %>%
dplyr::select(
"year",
"recid",
Expand Down Expand Up @@ -294,10 +292,11 @@ process_extract_ae <- function(data, year, write_to_disk = TRUE) {
)

if (write_to_disk) {
# Save as rds file
outfile %>%
write_file(get_source_extract_path(year, "AE", check_mode = "write"))
write_file(
ae_processed,
get_source_extract_path(year, "AE", check_mode = "write")
)
}

return(outfile)
return(ae_processed)
}
2 changes: 1 addition & 1 deletion R/process_extract_alarms_telecare.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' (year specific) Alarms Telecare extract, it will return the final data
#' but also write this out as rds.
#' and (optionally) write it to disk.
#'
#' @inheritParams process_extract_care_home
#'
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_care_home.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' (year specific) Care Home extract, it will return the final data
#' but also write this out as rds.
#' and (optionally) write it to disk.
#'
#' @param data The full processed data which will be selected from to create
#' the year specific data.
Expand Down
15 changes: 7 additions & 8 deletions R/process_extract_cmh.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' CMH extract, it will return the final data
#' but also write this out as an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down Expand Up @@ -44,9 +44,7 @@ process_extract_cmh <- function(data,
# create blank diag 6
dplyr::mutate(diag6 = NA)

# Outfile --------------------------------------------

outfile <- cmh_clean %>%
cmh_processed <- cmh_clean %>%
dplyr::select(
"year",
"recid",
Expand All @@ -73,10 +71,11 @@ process_extract_cmh <- function(data,
)

if (write_to_disk) {
# Save as rds file
outfile %>%
write_file(get_source_extract_path(year, "CMH", check_mode = "write"))
write_file(
cmh_processed,
get_source_extract_path(year, "CMH", check_mode = "write")
)
}

return(outfile)
return(cmh_processed)
}
2 changes: 1 addition & 1 deletion R/process_extract_consultations.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' GP OOH Consultations extract, it will return the final data
#' but also write this out as an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand All @@ -19,7 +19,7 @@
# Consultations Data ---------------------------------
## Data Cleaning

fnc_consultation_types <- c(

Check failure on line 22 in R/process_extract_consultations.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`fnc` is not a recognized word. (unrecognized-spelling)
"ED APPOINTMENT",
"ED TELEPHONE ASSESSMENT",
"ED TO BOOK",
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_delayed_discharges.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' delayed discharges extract, it will return the final data
#' but also write this out as an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_district_nursing.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' District Nursing extract, it will return the final data
#' but also write this out an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_gp_ooh.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' GP OoH extract, it will return the final data
#' but also write this out an rds.
#' and (optionally) write it to disk.
#'
#' @param year The year to process, in FY format.
#' @param data_list A list containing the extracts.
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_home_care.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' (year specific) Home Care extract, it will return the final data
#' but also write this out as rds.
#' and (optionally) write it to disk.
#'
#' @inheritParams process_extract_care_home
#'
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 @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' homelessness extract, it will return the final data
#' and optionally write it out as rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process from [read_extract_homelessness()].
#' @param year The year to process, in FY format.
Expand Down
18 changes: 7 additions & 11 deletions R/process_extract_maternity.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' maternity extract, it will return the final data
#' but also write this out an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down Expand Up @@ -50,9 +50,9 @@
) %>%
# Calculate costs
create_monthly_costs() %>%
# Add discondition as a factor

Check failure on line 53 in R/process_extract_maternity.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`discondition` is not a recognized word. (unrecognized-spelling)
dplyr::mutate(
discondition = factor(.data$discondition,

Check failure on line 55 in R/process_extract_maternity.R

View workflow job for this annotation

GitHub Actions / Check Spelling

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

Check failure on line 55 in R/process_extract_maternity.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`discondition` is not a recognized word. (unrecognized-spelling)
levels = c(1L:5L, 8L)
),
smrtype = add_smr_type(.data$recid, .data$mpat),
Expand All @@ -63,10 +63,7 @@
)
)


# Save outfile------------------------------------------------

outfile <- maternity_clean %>%
maternity_processed <- maternity_clean %>%
dplyr::select(
"year",
"recid",
Expand Down Expand Up @@ -113,12 +110,11 @@
dplyr::arrange(.data$chi, .data$record_keydate1)

if (write_to_disk) {
# Save as rds file
outfile %>%
write_file(
get_source_extract_path(year, "Maternity", check_mode = "write")
)
write_file(
maternity_processed,
get_source_extract_path(year, "Maternity", check_mode = "write")
)
}

return(outfile)
return(maternity_processed)
}
16 changes: 7 additions & 9 deletions R/process_extract_mental_health.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' mental health extract, it will return the final data
#' but also write this out an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down Expand Up @@ -67,10 +67,7 @@ process_extract_mental_health <- function(data, year, write_to_disk = TRUE) {
smrtype = add_smr_type(.data$recid)
)


# Outfile ---------------------------------------

outfile <- mh_clean %>%
mh_processed <- mh_clean %>%
dplyr::arrange(.data$chi, .data$record_keydate1) %>%
dplyr::select(
"year",
Expand Down Expand Up @@ -118,10 +115,11 @@ process_extract_mental_health <- function(data, year, write_to_disk = TRUE) {
)

if (write_to_disk) {
outfile %>%
# Save as rds file
write_file(get_source_extract_path(year, "MH", check_mode = "write"))
write_file(
mh_processed,
get_source_extract_path(year, "MH", check_mode = "write")
)
}

return(outfile)
return(mh_processed)
}
2 changes: 1 addition & 1 deletion R/process_extract_ooh_diagnosis.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' GP OOH Diagnosis extract, it will return the final data
#' but also write this out an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down Expand Up @@ -97,13 +97,13 @@
readcodes_not_matched

# Give an error if any new 'bad' readcodes come up.
unrecognised_but_ok_codes <- c(

Check failure on line 100 in R/process_extract_ooh_diagnosis.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`unrecognised` is not a recognized word. (unrecognized-spelling)
"@1JX.",
"@1JXz",

Check failure on line 102 in R/process_extract_ooh_diagnosis.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`JXz` is not a recognized word. (unrecognized-spelling)
"@43jS",
"@65PW",
"@8CA.",
"@8CAK",

Check failure on line 106 in R/process_extract_ooh_diagnosis.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`CAK` is not a recognized word. (unrecognized-spelling)
"@A795"
)

Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_ooh_outcomes.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' GP OOH Outcomes extract, it will return the final data
#' but also write this out as an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down Expand Up @@ -31,8 +31,8 @@
"ADVISED TO CONTACT OWN GP SURGERY/GP TO CONTACT PATIENT" ~ "03",
"TREATMENT COMPLETED AT OOH/DISCHARGED/NO FOLLOW-UP" ~ "98",
"REFERRED TO A&E" ~ "21",
"REFERRED TO CPN/DISTRICT NURSE/MIDWIFE" ~ "22",

Check failure on line 34 in R/process_extract_ooh_outcomes.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`CPN` is not a recognized word. (unrecognized-spelling)
"REFERRED TO MIU" ~ "21",

Check failure on line 35 in R/process_extract_ooh_outcomes.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`MIU` is not a recognized word. (unrecognized-spelling)
"REFERRED TO SOCIAL SERVICES" ~ "24",
"OTHER HC REFERRAL/ADVISED TO CONTACT OTHER HCP (NON-EMERGENCY)" ~ "29",
"OTHER" ~ "99",
Expand Down
19 changes: 7 additions & 12 deletions R/process_extract_outpatients.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' outpatients extract, it will return the final data
#' but also write this out as an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down Expand Up @@ -41,7 +41,7 @@
# Factors ---------------------------------------
outpatients_clean <- outpatients_clean %>%
dplyr::mutate(
reftype = factor(.data$reftype,

Check failure on line 44 in R/process_extract_outpatients.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`reftype` is not a recognized word. (unrecognized-spelling)
levels = 1L:3L
),
clinic_type = factor(.data$clinic_type,
Expand All @@ -49,11 +49,7 @@
)
)


## save outfile ---------------------------------------

outfile <-
outpatients_clean %>%
outpatients_processed <- outpatients_clean %>%
dplyr::select(
"year",
"recid",
Expand Down Expand Up @@ -89,12 +85,11 @@
)

if (write_to_disk) {
# Save as rds file
outfile %>%
write_file(
get_source_extract_path(year, "Outpatients", check_mode = "write")
)
write_file(
outpatients_processed,
get_source_extract_path(year, "Outpatients", check_mode = "write")
)
}

return(outfile)
return(outpatients_processed)
}
9 changes: 5 additions & 4 deletions R/process_extract_prescribing.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description This will read and process the
#' prescribing extract, it will return the final data
#' but also write this out as an rds.
#' and (optionally) write it to disk.
#'
#' @param data The extract to process
#' @param year The year to process, in FY format.
Expand Down Expand Up @@ -50,9 +50,10 @@ process_extract_prescribing <- function(data, year, write_to_disk = TRUE) {
}

if (write_to_disk) {
# Save as rds file
pis_clean %>%
write_file(get_source_extract_path(year, "PIS", check_mode = "write"))
write_file(
pis_clean,
get_source_extract_path(year, "PIS", check_mode = "write")
)
}

return(pis_clean)
Expand Down
Loading
Loading