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

Sort variables with issues hbrescode (HB2018), datazone and hscp #746

Merged
merged 8 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
13 changes: 7 additions & 6 deletions R/fill_geographies.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"hbrescode",
"hscp",
"lca",
"datazone",
"datazone2011",
"hbpraccode",
"hbtreatcode",
"gpprac"
Expand Down Expand Up @@ -85,7 +85,7 @@
}

fill_postcode_geogs <- function(data) {
spd <- read_file(get_slf_postcode_path())
slf_pc_lookup <- read_file(get_slf_postcode_path())

filled_postcodes <- dplyr::left_join(
data,
Expand All @@ -102,7 +102,7 @@
) %>%
# Fill geographies
dplyr::left_join(
spd,
slf_pc_lookup,
by = "postcode",
suffix = c("_old", "")
) %>%
Expand All @@ -117,10 +117,11 @@
cascade_geographies() %>%
dplyr::mutate(
hbrescode = dplyr::coalesce(.data$hb2018, .data$hbrescode),
hscp = dplyr::coalesce(.data$hscp2018, .data$hscp),
lca = dplyr::coalesce(.data$lca, .data$lca_old)
hscp2018 = dplyr::coalesce(.data$hscp2018, .data$hscp),
lca = dplyr::coalesce(.data$lca, .data$lca_old),
datazone2011 = dplyr::coalesce(.data$datazone2011, .data$datazone2011_old)
) %>%
dplyr::select(!c("hb2018", "hscp2018", "lca_old", "most_recent_postcode"))
dplyr::select(!c("hb2018", "hscp2018", "lca_old", "datazone2011_old", "most_recent_postcode"))

Check warning on line 124 in R/fill_geographies.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/fill_geographies.R,line=124,col=81,[line_length_linter] Lines should not be more than 80 characters.
Moohan marked this conversation as resolved.
Show resolved Hide resolved

return(filled_postcodes)
}
Expand Down Expand Up @@ -161,13 +162,13 @@
#'
#' @return data with matched HSCP and LCA codes
cascade_geographies <- function(data) {
# TODO rework this function into a series of smaller functions which operate on vectors

Check warning on line 165 in R/fill_geographies.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/fill_geographies.R,line=165,col=81,[line_length_linter] Lines should not be more than 80 characters.
# e.g. cascade_hscp_lca <- function(hscp, lca) {...}
# Would take HSCP and populate any missing LCA using it
data <- data %>%
dplyr::mutate(
# If we can, 'cascade' the geographies upwards
# i.e. if they have an LCA use this to fill in HSCP2018 and so on for hbrescode

Check warning on line 171 in R/fill_geographies.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/fill_geographies.R,line=171,col=81,[line_length_linter] Lines should not be more than 80 characters.
# Codes are correct as at August 2018
lca = dplyr::case_when(
!is_missing(lca) ~ lca,
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 @@ -27,21 +27,21 @@
year = year,
# Set recid as 01B and flag GLS records
recid = dplyr::if_else(.data$GLS_record == "Y", "GLS", "01B"),
# Set IDPC marker for the episode

Check failure on line 30 in R/process_extract_acute.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`IDPC` is not a recognized word. (unrecognized-spelling)
ipdc = dplyr::case_when(
.data$ipdc == "IP" ~ "I",
.data$ipdc == "DC" ~ "D"
),
# Set IDPC marker for the cij

Check failure on line 35 in R/process_extract_acute.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`IDPC` is not a recognized word. (unrecognized-spelling)
cij_ipdc = dplyr::case_when(
.data$cij_ipdc == "IP" ~ "I",
.data$cij_ipdc == "DC" ~ "D"
)
) %>%
# Recode GP practice into 5 digit number
# We assume that if it starts with a letter it's an English practice and so recode to 99995.

Check warning on line 42 in R/process_extract_acute.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/process_extract_acute.R,line=42,col=81,[line_length_linter] Lines should not be more than 80 characters.
dplyr::mutate(gpprac = convert_eng_gpprac_to_dummy(.data$gpprac)) %>%
# Calculate the total length of stay (for the entire episode, not just within the financial year).

Check warning on line 44 in R/process_extract_acute.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/process_extract_acute.R,line=44,col=81,[line_length_linter] Lines should not be more than 80 characters.
dplyr::mutate(
stay = calculate_stay(year, .data$record_keydate1, .data$record_keydate2),
# create and populate SMRType
Expand All @@ -49,8 +49,8 @@
) %>%
# 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

Check warning on line 52 in R/process_extract_acute.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/process_extract_acute.R,line=52,col=81,[line_length_linter] Lines should not be more than 80 characters.
convert_monthly_rows_to_vars(.data$costmonthnum, .data$cost_total_net, .data$yearstay) %>%

Check warning on line 53 in R/process_extract_acute.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/process_extract_acute.R,line=53,col=81,[line_length_linter] Lines should not be more than 80 characters.
# add yearstay and cost_total_net variables
dplyr::mutate(
yearstay = rowSums(dplyr::across(tidyselect::ends_with("_beddays"))),
Expand Down Expand Up @@ -79,7 +79,7 @@
"hbrescode",
"lca",
"hscp",
"datazone",
"datazone2011",
"location",
"hbtreatcode",
"yearstay",
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 @@ -13,7 +13,7 @@
#' @return the final data as a [tibble][tibble::tibble-package].
#' @export
#' @family process extracts
process_extract_district_nursing <- function(

Check warning on line 16 in R/process_extract_district_nursing.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/process_extract_district_nursing.R,line=16,col=1,[object_length_linter] Variable and function names should not be longer than 30 characters.
data,
year,
costs = read_file(get_dn_costs_path()),
Expand Down Expand Up @@ -107,7 +107,7 @@
"gender",
"gpprac",
"postcode",
"datazone",
"datazone2011",
"lca",
"hscp",
"hbrescode",
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 @@ -13,8 +13,8 @@
#' @export
#' @family process extracts
process_extract_gp_ooh <- function(year, data_list, write_to_disk = TRUE) {
diagnosis_extract <- process_extract_ooh_diagnosis(data_list[["diagnosis"]], year)

Check warning on line 16 in R/process_extract_gp_ooh.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/process_extract_gp_ooh.R,line=16,col=81,[line_length_linter] Lines should not be more than 80 characters.
outcomes_extract <- process_extract_ooh_outcomes(data_list[["outcomes"]], year)

Check warning on line 17 in R/process_extract_gp_ooh.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/process_extract_gp_ooh.R,line=17,col=81,[line_length_linter] Lines should not be more than 80 characters.
consultations_extract <- process_extract_ooh_consultations(data_list[["consultations"]], year)


Expand Down Expand Up @@ -63,10 +63,10 @@
location = dplyr::na_if(.data$location, "UNKNOWN"),
recid = "OoH",
smrtype = add_smr_type(.data$recid, consultation_type = .data$consultation_type),
kis_accessed = factor(

Check failure on line 66 in R/process_extract_gp_ooh.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`kis` is not a recognized word. (unrecognized-spelling)
dplyr::case_when(
kis_accessed == "Y" ~ 1L,

Check failure on line 68 in R/process_extract_gp_ooh.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`kis` is not a recognized word. (unrecognized-spelling)
kis_accessed == "N" ~ 0L,

Check failure on line 69 in R/process_extract_gp_ooh.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`kis` is not a recognized word. (unrecognized-spelling)
TRUE ~ 9L
),
levels = c(0L, 1L, 9L),
Expand Down Expand Up @@ -111,12 +111,12 @@
"gpprac",
"postcode",
"hbrescode",
"datazone",
"datazone2011",
"hscp",
"hbtreatcode",
"location",
"attendance_status",
"kis_accessed",

Check failure on line 119 in R/process_extract_gp_ooh.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`kis` is not a recognized word. (unrecognized-spelling)
"refsource",
tidyselect::starts_with("diag"),
tidyselect::starts_with("ooh_outcome"),
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_mental_health.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ process_extract_mental_health <- function(data, year, write_to_disk = TRUE) {
"hbrescode",
"lca",
"hscp",
"datazone",
"datazone2011",
"location",
"hbtreatcode",
"stay",
Expand Down
2 changes: 1 addition & 1 deletion R/read_extract_acute.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ read_extract_acute <- function(year, file_path = get_boxi_extract_path(year = ye
disch = "Discharge Type Code",
falls_adm = "Falls Related Admission (01)",
lca = "Geo Council Area Code",
datazone = "Geo Data Zone 2011",
datazone2011 = "Geo Data Zone 2011",
postcode = "Geo Postcode [C]",
hscp = "Geo HSCP of Residence Code - current",
conc = "Lead Consultant/HCP Code",
Expand Down
2 changes: 1 addition & 1 deletion R/read_extract_district_nursing.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ read_extract_district_nursing <- function(
lca = "Patient Council Area Code (Contact)",
postcode = "Patient Postcode [C] (Contact)",
gpprac = "Practice Code (Contact)",
datazone = "Patient Data Zone 2011 (Contact)",
datazone2011 = "Patient Data Zone 2011 (Contact)",
hbpraccode = "Practice NHS Board Code 9 (Contact)",
hbtreatcode = "Treatment NHS Board Code 9",
chi = "UPI Number [C]",
Expand Down
2 changes: 1 addition & 1 deletion R/read_extract_mental_health.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ read_extract_mental_health <- function(
hbrescode = "NHS Board of Residence Code - current",
lca = "Geo Council Area Code",
hscp = "Geo HSCP of Residence Code - current",
datazone = "Geo Data Zone 2011",
datazone2011 = "Geo Data Zone 2011",
location = "Treatment Location Code",
hbtreatcode = "Treatment NHS Board Code - current",
yearstay = "Occupied Bed Days (04)",
Expand Down
2 changes: 1 addition & 1 deletion R/read_extract_nrs_deaths.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ read_extract_nrs_deaths <- function(
dplyr::rename(
death_location_code = "Death Location Code",
lca = "Geo Council Area Code",
datazone = "Geo Data Zone 2011",
datazone2011 = "Geo Data Zone 2011",
postcode = "Geo Postcode [C]",
hscp = "Geo HSCP of Residence Code - current",
death_board_occurrence = "NHS Board of Occurrence Code - current",
Expand Down
2 changes: 1 addition & 1 deletion R/read_extract_ooh_consultations.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"Consultation End Date Time" = readr::col_datetime(
format = "%Y/%m/%d %T"
),
"KIS Accessed" = readr::col_factor(levels = c("Y", "N")),

Check failure on line 23 in R/read_extract_ooh_consultations.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`KIS` is not a recognized word. (unrecognized-spelling)
# All other columns are character type
.default = readr::col_character()
)
Expand All @@ -34,7 +34,7 @@
postcode = "Patient Postcode [C]",
hbrescode = "Patient NHS Board Code 9 - current",
hscp = "HSCP of Residence Code Current",
datazone = "Patient Data Zone 2011",
datazone2011 = "Patient Data Zone 2011",
gpprac = "Practice Code",
ooh_case_id = "GUID",
attendance_status = "Consultation Recorded",
Expand All @@ -43,7 +43,7 @@
location = "Treatment Location Code",
location_description = "Treatment Location Description",
hbtreatcode = "Treatment NHS Board Code 9",
kis_accessed = "KIS Accessed",

Check failure on line 46 in R/read_extract_ooh_consultations.R

View workflow job for this annotation

GitHub Actions / Check Spelling

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

Check failure on line 46 in R/read_extract_ooh_consultations.R

View workflow job for this annotation

GitHub Actions / Check Spelling

`kis` is not a recognized word. (unrecognized-spelling)
refsource = "Referral Source",
consultation_type = "Consultation Type",
consultation_type_unmapped = "Consultation Type Unmapped"
Expand Down
2 changes: 1 addition & 1 deletion R/run_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ run_episode_file <- function(processed_data_list, year, write_to_disk = TRUE) {
"cij_dis_spec",
"cost_total_net",
"hscp",
"datazone",
"datazone2011",
"attendance_status",
"deathdiag1",
"deathdiag2",
Expand Down
Loading