diff --git a/R/process_extract_nrs_deaths.R b/R/process_extract_nrs_deaths.R index 438a398f7..ecb10d2e0 100644 --- a/R/process_extract_nrs_deaths.R +++ b/R/process_extract_nrs_deaths.R @@ -1,8 +1,7 @@ #' Process the Nation Records of Scotland (NRS) Deaths extract #' -#' @description This will read and process the -#' NRS deaths extract, it will return the final data -#' but also write this out an rds. +#' @description This will process the NRS deaths extract, it will return the +#' final data and write this out. #' #' @param data The extract to process #' @param year The year to process, in FY format. @@ -13,27 +12,20 @@ #' @export #' @family process extracts process_extract_nrs_deaths <- function(data, year, write_to_disk = TRUE) { - # Only run for a single year stopifnot(length(year) == 1L) - # Check that the supplied year is in the correct format year <- check_year_format(year) - # Data Cleaning --------------------------------------- - deaths_clean <- data %>% - dplyr::mutate(record_keydate2 = .data$record_keydate1) %>% - # create recid and year variables dplyr::mutate( + record_keydate2 = .data$record_keydate1, recid = "NRS", - year = year - ) %>% - # fix dummy gpprac codes - dplyr::mutate(gpprac = convert_eng_gpprac_to_dummy(.data$gpprac)) %>% - dplyr::mutate(smrtype = add_smr_type(.data$recid)) + year = year, + gpprac = convert_eng_gpprac_to_dummy(.data$gpprac), + smrtype = add_smr_type(.data$recid) + ) if (write_to_disk) { - # Save as rds file deaths_clean %>% write_file(get_source_extract_path(year, "Deaths", check_mode = "write")) } diff --git a/R/read_extract_nrs_deaths.R b/R/read_extract_nrs_deaths.R index 4e02ad69e..8fd2f26e9 100644 --- a/R/read_extract_nrs_deaths.R +++ b/R/read_extract_nrs_deaths.R @@ -3,9 +3,9 @@ #' @inherit read_extract_acute #' #' @export -#' -read_extract_nrs_deaths <- function(year, file_path = get_boxi_extract_path(year = year, type = "Deaths")) { - # Read BOXI extract +read_extract_nrs_deaths <- function( + year, + file_path = get_boxi_extract_path(year = year, type = "Deaths")) { extract_nrs_deaths <- read_file(file_path, col_types = cols_only( "Death Location Code" = col_character(), @@ -36,7 +36,6 @@ read_extract_nrs_deaths <- function(year, file_path = get_boxi_extract_path(year "GP practice code(99)" = col_character() ) ) %>% - # rename variables dplyr::rename( death_location_code = "Death Location Code", lca = "Geo Council Area Code", diff --git a/man/process_extract_nrs_deaths.Rd b/man/process_extract_nrs_deaths.Rd index 94243bcfd..724af5d87 100644 --- a/man/process_extract_nrs_deaths.Rd +++ b/man/process_extract_nrs_deaths.Rd @@ -18,9 +18,8 @@ process_extract_nrs_deaths(data, year, write_to_disk = TRUE) the final data as a \link[tibble:tibble-package]{tibble}. } \description{ -This will read and process the -NRS deaths extract, it will return the final data -but also write this out an rds. +This will process the NRS deaths extract, it will return the +final data and write this out. } \seealso{ Other process extracts: