Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennit07 committed Oct 20, 2023
2 parents 7283953 + 47f4609 commit fa7a7e5
Show file tree
Hide file tree
Showing 28 changed files with 46 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/document.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion .github/workflows/style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 7 additions & 10 deletions R/add_smr_type.R → R/add_smrtype.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}."
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/convert_ca_to_lca.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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) %>%
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_ae.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions R/process_extract_care_home.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_cmh.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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))
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 @@ -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,
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 @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_maternity.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
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 @@ -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 %>%
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_nrs_deaths.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_outpatients.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/process_extract_prescribing.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/process_sc_all_alarms_telecare.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/process_sc_all_home_care.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion R/process_sc_all_sds.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions man/add_smr_type.Rd → man/add_smrtype.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/convert_ca_to_lca.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/convert_hb_to_hbnames.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/convert_hscp_to_hscpnames.Rd

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.

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/convert_sending_location_to_lca.md
Original file line number Diff line number Diff line change
@@ -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_))
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-convert_sending_location_to_lca.R
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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))
)
})

0 comments on commit fa7a7e5

Please sign in to comment.