diff --git a/.github/workflows/document.yaml b/.github/workflows/document.yaml index 0858355fe..73626b610 100644 --- a/.github/workflows/document.yaml +++ b/.github/workflows/document.yaml @@ -35,6 +35,6 @@ jobs: shell: Rscript {0} - name: Commit and push changes - uses: stefanzweifel/git-auto-commit-action@v4 + uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: "Update documentation" diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index b8a242270..2efe6e4b7 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/style.yaml @@ -69,6 +69,6 @@ jobs: shell: Rscript {0} - name: Commit and push changes - uses: stefanzweifel/git-auto-commit-action@v4 + uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: "Style code" diff --git a/NAMESPACE b/NAMESPACE index df103f591..c9ffc03d2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,7 +14,7 @@ export(convert_fyyear_to_year) export(convert_hb_to_hbnames) export(convert_hscp_to_hscpnames) export(convert_numeric_to_date) -export(convert_sending_location_to_lca) +export(convert_sc_sending_location_to_lca) export(convert_year_to_fyyear) export(create_episode_file) export(create_homelessness_lookup) diff --git a/R/add_smr_type.R b/R/add_smrtype.R similarity index 93% rename from R/add_smr_type.R rename to R/add_smrtype.R index aa9e383bc..3d0959112 100644 --- a/R/add_smr_type.R +++ b/R/add_smrtype.R @@ -10,15 +10,12 @@ #' @return A vector of `smrtype` #' #' @family Codes -add_smr_type <- function(recid, - mpat = NULL, - ipdc = NULL, - hc_service = NULL, - main_applicant_flag = NULL, - consultation_type = NULL) { - # TODO rename this function to `add_smrtype()` to match the name of the - # variable. Need to make sure to change all places where it is used as well. - +add_smrtype <- function(recid, + mpat = NULL, + ipdc = NULL, + hc_service = NULL, + main_applicant_flag = NULL, + consultation_type = NULL) { # Situation where some recids are not in the accepted values if (!all(recid %in% c( "00B", @@ -188,7 +185,7 @@ add_smr_type <- function(recid, if (anyNA(smrtype)) { cli::cli_warn( - "Some {.var smrtype}s were not properly set by {.fun add_smr_type}." + "Some {.var smrtype}s were not properly set by {.fun add_smrtype}." ) } diff --git a/R/convert_ca_to_lca.R b/R/convert_ca_to_lca.R index 518d7e8fb..1bb803a5f 100644 --- a/R/convert_ca_to_lca.R +++ b/R/convert_ca_to_lca.R @@ -12,7 +12,7 @@ #' convert_ca_to_lca(ca) #' #' @family code functions -#' @seealso convert_sending_location_to_lca +#' @seealso convert_sc_sending_location_to_lca convert_ca_to_lca <- function(ca_var) { lca <- dplyr::case_match( ca_var, diff --git a/R/convert_sending_location_to_lca.R b/R/convert_sc_sending_location_to_lca.R similarity index 92% rename from R/convert_sending_location_to_lca.R rename to R/convert_sc_sending_location_to_lca.R index ff7e51db1..c78cfa602 100644 --- a/R/convert_sending_location_to_lca.R +++ b/R/convert_sc_sending_location_to_lca.R @@ -10,12 +10,12 @@ #' #' @examples #' sending_location <- c(100, 120) -#' convert_sending_location_to_lca(sending_location) +#' convert_sc_sending_location_to_lca(sending_location) #' #' @family code functions #' #' @seealso convert_ca_to_lca -convert_sending_location_to_lca <- function(sending_location) { +convert_sc_sending_location_to_lca <- function(sending_location) { lca <- dplyr::case_match( sending_location, 100L ~ "01", # Aberdeen City diff --git a/R/process_extract_acute.R b/R/process_extract_acute.R index c327f4b66..dcfdb47c0 100644 --- a/R/process_extract_acute.R +++ b/R/process_extract_acute.R @@ -45,7 +45,7 @@ process_extract_acute <- function(data, year, write_to_disk = TRUE) { dplyr::mutate( stay = calculate_stay(year, .data$record_keydate1, .data$record_keydate2), # create and populate SMRType - smrtype = add_smr_type(recid = .data$recid, ipdc = .data$ipdc) + smrtype = add_smrtype(recid = .data$recid, ipdc = .data$ipdc) ) %>% # Apply new costs for C3 specialty, these are taken from the 2017/18 file fix_c3_costs(year) %>% diff --git a/R/process_extract_ae.R b/R/process_extract_ae.R index 785797395..dd3823a36 100644 --- a/R/process_extract_ae.R +++ b/R/process_extract_ae.R @@ -62,7 +62,7 @@ process_extract_ae <- function(data, year, write_to_disk = TRUE) { # Create month variable dplyr::mutate( month = strftime(.data$record_keydate1, "%m"), - smrtype = add_smr_type(.data$recid) + smrtype = add_smrtype(.data$recid) ) %>% # Allocate the costs to the correct month create_day_episode_costs(.data$record_keydate1, .data$cost_total_net) diff --git a/R/process_extract_care_home.R b/R/process_extract_care_home.R index 177229755..210dae531 100644 --- a/R/process_extract_care_home.R +++ b/R/process_extract_care_home.R @@ -58,11 +58,11 @@ process_extract_care_home <- function( dplyr::mutate( year = year, recid = "CH", - smrtype = add_smr_type(recid = "CH") + smrtype = add_smrtype(recid = "CH") ) %>% # compute lca variable from sending_location dplyr::mutate( - sc_send_lca = convert_sending_location_to_lca(.data$sending_location) + sc_send_lca = convert_sc_sending_location_to_lca(.data$sending_location) ) %>% # bed days create_monthly_beddays(year, diff --git a/R/process_extract_cmh.R b/R/process_extract_cmh.R index bbce59f0f..418b95b00 100644 --- a/R/process_extract_cmh.R +++ b/R/process_extract_cmh.R @@ -32,7 +32,7 @@ process_extract_cmh <- function(data, # create recid, year, SMRType variables dplyr::mutate( recid = "CMH", - smrtype = add_smr_type(recid = .data$recid), + smrtype = add_smrtype(recid = .data$recid), year = year ) %>% # contact end time diff --git a/R/process_extract_district_nursing.R b/R/process_extract_district_nursing.R index 02f23719f..6254926f0 100644 --- a/R/process_extract_district_nursing.R +++ b/R/process_extract_district_nursing.R @@ -37,7 +37,7 @@ process_extract_district_nursing <- function( dplyr::mutate( year = year, recid = "DN", - smrtype = add_smr_type(recid = "DN") + smrtype = add_smrtype(recid = "DN") ) %>% # deal with gpprac dplyr::mutate(gpprac = convert_eng_gpprac_to_dummy(.data$gpprac)) diff --git a/R/process_extract_gp_ooh.R b/R/process_extract_gp_ooh.R index 3503888b6..37cfc8f3f 100644 --- a/R/process_extract_gp_ooh.R +++ b/R/process_extract_gp_ooh.R @@ -62,7 +62,7 @@ process_extract_gp_ooh <- function(year, data_list, write_to_disk = TRUE) { # Replace location unknown with NA location = dplyr::na_if(.data$location, "UNKNOWN"), recid = "OoH", - smrtype = add_smr_type(.data$recid, consultation_type = .data$consultation_type), + smrtype = add_smrtype(.data$recid, consultation_type = .data$consultation_type), kis_accessed = factor( dplyr::case_when( kis_accessed == "Y" ~ 1L, diff --git a/R/process_extract_homelessness.R b/R/process_extract_homelessness.R index c1afff837..ab674988b 100644 --- a/R/process_extract_homelessness.R +++ b/R/process_extract_homelessness.R @@ -37,7 +37,7 @@ process_extract_homelessness <- function( dplyr::mutate( year = as.character(year), recid = "HL1", - smrtype = add_smr_type( + smrtype = add_smrtype( recid = .data$recid, main_applicant_flag = .data$main_applicant_flag ) diff --git a/R/process_extract_maternity.R b/R/process_extract_maternity.R index 7bb016243..eab3fb713 100644 --- a/R/process_extract_maternity.R +++ b/R/process_extract_maternity.R @@ -55,7 +55,7 @@ process_extract_maternity <- function(data, year, write_to_disk = TRUE) { discondition = factor(.data$discondition, levels = c(1L:5L, 8L) ), - smrtype = add_smr_type(.data$recid, .data$mpat), + smrtype = add_smrtype(.data$recid, .data$mpat), ipdc = dplyr::case_match( .data$smrtype, "Matern-IP" ~ "I", diff --git a/R/process_extract_mental_health.R b/R/process_extract_mental_health.R index b8d89377d..4326630fe 100644 --- a/R/process_extract_mental_health.R +++ b/R/process_extract_mental_health.R @@ -64,7 +64,7 @@ process_extract_mental_health <- function(data, year, write_to_disk = TRUE) { .data$record_keydate2 ), # SMR type - smrtype = add_smr_type(.data$recid) + smrtype = add_smrtype(.data$recid) ) mh_processed <- mh_clean %>% diff --git a/R/process_extract_nrs_deaths.R b/R/process_extract_nrs_deaths.R index 71e19d456..e707e74f6 100644 --- a/R/process_extract_nrs_deaths.R +++ b/R/process_extract_nrs_deaths.R @@ -22,7 +22,7 @@ process_extract_nrs_deaths <- function(data, year, write_to_disk = TRUE) { recid = "NRS", year = year, gpprac = convert_eng_gpprac_to_dummy(.data$gpprac), - smrtype = add_smr_type(.data$recid) + smrtype = add_smrtype(.data$recid) ) if (write_to_disk) { diff --git a/R/process_extract_outpatients.R b/R/process_extract_outpatients.R index 86262e6b3..fdf4ee63d 100644 --- a/R/process_extract_outpatients.R +++ b/R/process_extract_outpatients.R @@ -28,7 +28,7 @@ process_extract_outpatients <- function(data, year, write_to_disk = TRUE) { # Set recid variable recid = "00B", # Set smrtype variable - smrtype = add_smr_type(.data$recid) + smrtype = add_smrtype(.data$recid) ) %>% dplyr::mutate(gpprac = convert_eng_gpprac_to_dummy(.data$gpprac)) %>% # compute record key date2 diff --git a/R/process_extract_prescribing.R b/R/process_extract_prescribing.R index c54a55b65..c79e0a513 100644 --- a/R/process_extract_prescribing.R +++ b/R/process_extract_prescribing.R @@ -37,7 +37,7 @@ process_extract_prescribing <- function(data, year, write_to_disk = TRUE) { record_keydate1 = end_fy(year), record_keydate2 = .data$record_keydate1, # Add SMR type variable - smrtype = add_smr_type(.data$recid) + smrtype = add_smrtype(.data$recid) ) # Issue a warning if rows were removed diff --git a/R/process_sc_all_alarms_telecare.R b/R/process_sc_all_alarms_telecare.R index 620b14cee..628bd7165 100644 --- a/R/process_sc_all_alarms_telecare.R +++ b/R/process_sc_all_alarms_telecare.R @@ -55,7 +55,7 @@ process_sc_all_alarms_telecare <- function( # Create person id variable person_id = stringr::str_glue("{sending_location}-{social_care_id}"), # Use function for creating sc send lca variables - sc_send_lca = convert_sending_location_to_lca(.data$sending_location) + sc_send_lca = convert_sc_sending_location_to_lca(.data$sending_location) ) %>% # when multiple social_care_id from sending_location for single CHI # replace social_care_id with latest diff --git a/R/process_sc_all_home_care.R b/R/process_sc_all_home_care.R index 5f2b4db49..2a990a386 100644 --- a/R/process_sc_all_home_care.R +++ b/R/process_sc_all_home_care.R @@ -199,7 +199,7 @@ process_sc_all_home_care <- function( create_person_id(type = "SC") %>% # compute lca variable from sending_location dplyr::mutate( - sc_send_lca = convert_sending_location_to_lca(.data$sending_location) + sc_send_lca = convert_sc_sending_location_to_lca(.data$sending_location) ) if (write_to_disk) { diff --git a/R/process_sc_all_sds.R b/R/process_sc_all_sds.R index c17f74f28..09ce430b8 100644 --- a/R/process_sc_all_sds.R +++ b/R/process_sc_all_sds.R @@ -80,7 +80,7 @@ process_sc_all_sds <- function( # Create person id variable person_id = stringr::str_glue("{sending_location}-{social_care_id}"), # Use function for creating sc send lca variables - sc_send_lca = convert_sending_location_to_lca(.data$sending_location) + sc_send_lca = convert_sc_sending_location_to_lca(.data$sending_location) ) %>% # when multiple social_care_id from sending_location for single CHI # replace social_care_id with latest diff --git a/man/add_smr_type.Rd b/man/add_smrtype.Rd similarity index 87% rename from man/add_smr_type.Rd rename to man/add_smrtype.Rd index 554e35575..1898ed05d 100644 --- a/man/add_smr_type.Rd +++ b/man/add_smrtype.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_smr_type.R -\name{add_smr_type} -\alias{add_smr_type} +% Please edit documentation in R/add_smrtype.R +\name{add_smrtype} +\alias{add_smrtype} \title{Add smrtype variable based on record ID} \usage{ -add_smr_type( +add_smrtype( recid, mpat = NULL, ipdc = NULL, diff --git a/man/convert_ca_to_lca.Rd b/man/convert_ca_to_lca.Rd index 25a8de018..ffb67960b 100644 --- a/man/convert_ca_to_lca.Rd +++ b/man/convert_ca_to_lca.Rd @@ -21,11 +21,11 @@ convert_ca_to_lca(ca) } \seealso{ -convert_sending_location_to_lca +convert_sc_sending_location_to_lca Other code functions: \code{\link{convert_hb_to_hbnames}()}, \code{\link{convert_hscp_to_hscpnames}()}, -\code{\link{convert_sending_location_to_lca}()} +\code{\link{convert_sc_sending_location_to_lca}()} } \concept{code functions} diff --git a/man/convert_hb_to_hbnames.Rd b/man/convert_hb_to_hbnames.Rd index 0cd2932bd..e104a11ce 100644 --- a/man/convert_hb_to_hbnames.Rd +++ b/man/convert_hb_to_hbnames.Rd @@ -24,6 +24,6 @@ convert_hb_to_hbnames(hb) Other code functions: \code{\link{convert_ca_to_lca}()}, \code{\link{convert_hscp_to_hscpnames}()}, -\code{\link{convert_sending_location_to_lca}()} +\code{\link{convert_sc_sending_location_to_lca}()} } \concept{code functions} diff --git a/man/convert_hscp_to_hscpnames.Rd b/man/convert_hscp_to_hscpnames.Rd index ac9bd023e..c423b8721 100644 --- a/man/convert_hscp_to_hscpnames.Rd +++ b/man/convert_hscp_to_hscpnames.Rd @@ -25,6 +25,6 @@ convert_hscp_to_hscpnames(hscp) Other code functions: \code{\link{convert_ca_to_lca}()}, \code{\link{convert_hb_to_hbnames}()}, -\code{\link{convert_sending_location_to_lca}()} +\code{\link{convert_sc_sending_location_to_lca}()} } \concept{code functions} diff --git a/man/convert_sending_location_to_lca.Rd b/man/convert_sc_sending_location_to_lca.Rd similarity index 69% rename from man/convert_sending_location_to_lca.Rd rename to man/convert_sc_sending_location_to_lca.Rd index 78bf475ba..10a0e952f 100644 --- a/man/convert_sending_location_to_lca.Rd +++ b/man/convert_sc_sending_location_to_lca.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/convert_sending_location_to_lca.R -\name{convert_sending_location_to_lca} -\alias{convert_sending_location_to_lca} +% Please edit documentation in R/convert_sc_sending_location_to_lca.R +\name{convert_sc_sending_location_to_lca} +\alias{convert_sc_sending_location_to_lca} \title{Convert Social Care Sending Location Codes into LCA Codes} \usage{ -convert_sending_location_to_lca(sending_location) +convert_sc_sending_location_to_lca(sending_location) } \arguments{ \item{sending_location}{vector of sending location codes} @@ -18,7 +18,7 @@ Local Council Authority Codes. } \examples{ sending_location <- c(100, 120) -convert_sending_location_to_lca(sending_location) +convert_sc_sending_location_to_lca(sending_location) } \seealso{ diff --git a/tests/testthat/_snaps/convert_sending_location_to_lca.md b/tests/testthat/_snaps/convert_sending_location_to_lca.md index 1fa02dc14..db223d6db 100644 --- a/tests/testthat/_snaps/convert_sending_location_to_lca.md +++ b/tests/testthat/_snaps/convert_sending_location_to_lca.md @@ -1,7 +1,7 @@ # Can convert a SC sending location to lca code Code - convert_sending_location_to_lca(c(100L, 110L, 120L, 130L, 355L, 150L, 395L, + convert_sc_sending_location_to_lca(c(100L, 110L, 120L, 130L, 355L, 150L, 395L, 170L, 180L, 190L, 200L, 210L, 220L, 230L, 240L, 250L, 260L, 270L, 280L, 290L, 300L, 310L, 320L, 330L, 340L, 350L, 360L, 370L, 380L, 390L, 400L, 235L, 999L, 0L, NA_integer_)) diff --git a/tests/testthat/test-convert_sending_location_to_lca.R b/tests/testthat/test-convert_sending_location_to_lca.R index eb66802a6..5d286311a 100644 --- a/tests/testthat/test-convert_sending_location_to_lca.R +++ b/tests/testthat/test-convert_sending_location_to_lca.R @@ -1,6 +1,6 @@ test_that("Can convert a SC sending location to lca code", { expect_snapshot( - convert_sending_location_to_lca( + convert_sc_sending_location_to_lca( c( 100L, 110L, @@ -44,9 +44,9 @@ test_that("Can convert a SC sending location to lca code", { test_that("Errors on unexpected input", { expect_error( - convert_sending_location_to_lca("100") + convert_sc_sending_location_to_lca("100") ) expect_error( - convert_sending_location_to_lca(c("100", 99L)) + convert_sc_sending_location_to_lca(c("100", 99L)) ) })