-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
* Rename the IT CHI deaths file functions * Update documentation * [check-spelling] Update metadata Update for https://github.com/Public-Health-Scotland/source-linkage-files/actions/runs/5331531642/attempts/1 Accepted in #698 (comment) Signed-off-by: check-spelling-bot <[email protected]> --------- Signed-off-by: check-spelling-bot <[email protected]> Co-authored-by: Moohan <[email protected]> Co-authored-by: Jennit07 <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,4 +198,5 @@ xlsx | |
yearstay | ||
YYYYQX | ||
zsav | ||
zstd | ||
zstd | ||
zstd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#' Process the CHI deaths extract | ||
#' | ||
#' @description This will process the CHI deaths extract, it will return the | ||
#' final data and write the data out. | ||
#' | ||
#' @param data The extract to process | ||
#' @param write_to_disk (optional) Should the data be written to disk default is | ||
#' `TRUE` i.e. write the data to disk. | ||
#' | ||
#' @return the final data as a [tibble][tibble::tibble-package]. | ||
#' @export | ||
#' @family process extracts | ||
process_it_chi_deaths <- function(data, write_to_disk = TRUE) { | ||
it_chi_deaths_clean <- data %>% | ||
dplyr::arrange( | ||
dplyr::desc(.data$death_date_nrs), | ||
dplyr::desc(.data$death_date_chi) | ||
) %>% | ||
dplyr::distinct(.data$chi, .keep_all = TRUE) %>% | ||
# Use the NRS death_date unless it isn't there | ||
dplyr::mutate( | ||
death_date = dplyr::coalesce(.data$death_date_nrs, .data$death_date_chi) | ||
) | ||
|
||
if (write_to_disk) { | ||
it_chi_deaths_clean %>% | ||
write_file(get_slf_chi_deaths_path(check_mode = "write")) | ||
} | ||
|
||
return(it_chi_deaths_clean) | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,24 @@ | ||
#' Process the CHI deaths lookup | ||
#' | ||
#' @description This will read and process the | ||
#' CHI deaths lookup, it will return the final data | ||
#' but also write this out as an rds. | ||
#' Read the CHI deaths extract | ||
#' | ||
#' @description This will read the CHI deaths extract and return the data. | ||
#' @param file_path Path to CHI Deaths file | ||
#' | ||
#' @return the final data as a [tibble][tibble::tibble-package]. | ||
#' @export | ||
#' @family process extracts | ||
|
||
read_lookup_chi_deaths <- function(file_path = get_it_deaths_path()) { | ||
# Read data ------------------------------------------------------- | ||
deaths_data <- read_file(file_path, | ||
read_it_chi_deaths <- function(file_path = get_it_deaths_path()) { | ||
it_chi_deaths <- read_file(file_path, | ||
col_type = cols( | ||
"PATIENT_UPI [C]" = col_character(), | ||
"PATIENT DoD DATE (NRS)" = col_date(format = "%d-%m-%Y"), | ||
"PATIENT DoD DATE (CHI)" = col_date(format = "%d-%m-%Y") | ||
) | ||
) %>% | ||
# rename variables | ||
dplyr::rename( | ||
chi = "PATIENT_UPI [C]", | ||
death_date_nrs = "PATIENT DoD DATE (NRS)", | ||
death_date_chi = "PATIENT DoD DATE (CHI)" | ||
) | ||
|
||
return(deaths_data) | ||
return(it_chi_deaths) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.