Skip to content

Commit

Permalink
Rename function add_smrtype (#840)
Browse files Browse the repository at this point in the history
* rename to `add_smrtype`

* Rename script to `add_smrtype`

* update documentation

* Remove TODO comment

* Style code

* Update documentation

---------

Co-authored-by: Jennit07 <[email protected]>
Co-authored-by: Megan McNicol <[email protected]>
  • Loading branch information
3 people authored Oct 2, 2023
1 parent 99020b6 commit 570f395
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 26 deletions.
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/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
2 changes: 1 addition & 1 deletion R/process_extract_care_home.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ 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(
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
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.

0 comments on commit 570f395

Please sign in to comment.