Skip to content

Commit

Permalink
Fix the pkgdown site/job (#804)
Browse files Browse the repository at this point in the history
* Fix the pkgdown site/job

It generates this site: https://public-health-scotland.github.io/source-linkage-files/ although it hasn't been working for a while since any new function needs to be added to (or captured by) the `_pkgdown.yml` file.

This PR is a pretty minimal fix to get the site working again.

* Update documentation

* Update documentation

* Update `create_episode_file`

* Remove `run_episode_file`

* update documentation

---------

Co-authored-by: Jennit07 <[email protected]>
Co-authored-by: Jennit07 <[email protected]>
Co-authored-by: Jennifer Thom <[email protected]>
  • Loading branch information
4 people authored Sep 26, 2023
1 parent e76176e commit 81c2191
Show file tree
Hide file tree
Showing 52 changed files with 1,240 additions and 28 deletions.
2 changes: 1 addition & 1 deletion R/add_nsu_cohort.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @return A data frame containing the Non-Service Users as additional rows
#' @export
#'
#' @family episode file
#' @family episode_file
#' @seealso [get_nsu_path()]
add_nsu_cohort <- function(
data,
Expand Down
2 changes: 1 addition & 1 deletion R/add_ppa_flag.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param data A data frame
#'
#' @return A data frame to use as a lookup of PPAs
#' @family episode file
#' @family episode_file
add_ppa_flag <- function(data) {
check_variables_exist(
data,
Expand Down
2 changes: 2 additions & 0 deletions R/aggregate_by_chi.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @importFrom data.table .SD
#'
#' @inheritParams create_individual_file
#' @family individual_file
aggregate_by_chi <- function(episode_file) {
cli::cli_alert_info("Aggregate by CHI function started at {Sys.time()}")

Expand Down Expand Up @@ -196,6 +197,7 @@ vars_contain <- function(data, vars, ignore_case = FALSE) {
#' @description Aggregate CH variables by CHI and CIS.
#'
#' @inheritParams create_individual_file
#' @family individual_file
aggregate_ch_episodes <- function(episode_file) {
cli::cli_alert_info("Aggregate ch episodes function started at {Sys.time()}")

Expand Down
2 changes: 2 additions & 0 deletions R/cost_uplift.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @param data episode data
#'
#' @return episode data with uplifted costs
#' @family episode_file
apply_cost_uplift <- function(data) {
data <- data %>%
# attach a uplift scale as the last column
Expand Down Expand Up @@ -34,6 +35,7 @@ apply_cost_uplift <- function(data) {
#' @param data episode data
#'
#' @return episode data with a uplift scale
#' @family episode_file
lookup_uplift <- function(data) {
# We have set uplifts to use for 2020/21, 2021/22 and 2022/23,
# provided by Paul Leak.
Expand Down
8 changes: 8 additions & 0 deletions R/create_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#'
#' @return a [tibble][tibble::tibble-package] containing the episode file
#' @export
#' @family episode_file
create_episode_file <- function(
processed_data_list,
year,
Expand Down Expand Up @@ -158,6 +159,7 @@ create_episode_file <- function(
#' @param vars_to_keep a character vector of the variables to keep, all others
#' will be stored.
#'
#' @family episode_file
#' @return `data` with only the `vars_to_keep` kept
store_ep_file_vars <- function(data, year, vars_to_keep) {
tempfile_path <- get_file_path(
Expand Down Expand Up @@ -195,6 +197,7 @@ store_ep_file_vars <- function(data, year, vars_to_keep) {
#' @inheritParams create_episode_file
#' @inheritParams store_ep_file_vars
#'
#' @family episode_file
#' @return The full SLF data.
load_ep_file_vars <- function(data, year) {
tempfile_path <- get_file_path(
Expand Down Expand Up @@ -222,6 +225,7 @@ load_ep_file_vars <- function(data, year) {
#'
#' @inheritParams store_ep_file_vars
#'
#' @family episode_file
#' @return A data frame with CIJ markers filled in for those missing.
fill_missing_cij_markers <- function(data) {
fixable_data <- data %>%
Expand Down Expand Up @@ -276,6 +280,7 @@ fill_missing_cij_markers <- function(data) {
#'
#' @inheritParams store_ep_file_vars
#'
#' @family episode_file
#' @return The data with CIJ variables corrected.
correct_cij_vars <- function(data) {
check_variables_exist(
Expand Down Expand Up @@ -317,6 +322,7 @@ correct_cij_vars <- function(data) {
#'
#' @inheritParams store_ep_file_vars
#'
#' @family episode_file
#' @return The data with cost including dna.
create_cost_inc_dna <- function(data) {
check_variables_exist(data, c("cost_total_net", "attendance_status"))
Expand All @@ -341,6 +347,7 @@ create_cost_inc_dna <- function(data) {
#' @inheritParams store_ep_file_vars
#' @inheritParams create_demographic_cohorts
#'
#' @family episode_file
#' @return The data unchanged (the cohorts are written to disk)
create_cohort_lookups <- function(data, year, update = latest_update()) {
# Use future so the cohorts can be created simultaneously (in parallel)
Expand Down Expand Up @@ -377,6 +384,7 @@ create_cohort_lookups <- function(data, year, update = latest_update()) {
#' @inheritParams get_demographic_cohorts_path
#' @param demographic_cohort,service_use_cohort The cohort data
#'
#' @family episode_file
#' @return The data including the Demographic and Service Use lookups.
join_cohort_lookups <- function(
data,
Expand Down
38 changes: 33 additions & 5 deletions R/create_individual_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' @inheritParams create_episode_file
#'
#' @return The processed individual file
#' @family individual_file
#' @export
create_individual_file <- function(
episode_file,
Expand Down Expand Up @@ -99,7 +100,7 @@ create_individual_file <- function(
#' Remove blank CHI
#'
#' @description Convert blank strings to NA and remove NAs from CHI column
#'
#' @family individual_file
#' @inheritParams create_individual_file
remove_blank_chi <- function(episode_file) {
cli::cli_alert_info("Remove blank CHI function started at {Sys.time()}")
Expand All @@ -113,7 +114,7 @@ remove_blank_chi <- function(episode_file) {
#' Add CIJ-related columns
#'
#' @description Add new columns related to CIJ
#'
#' @family individual_file
#' @inheritParams create_individual_file
add_cij_columns <- function(episode_file) {
cli::cli_alert_info("Add cij columns function started at {Sys.time()}")
Expand Down Expand Up @@ -152,7 +153,7 @@ add_cij_columns <- function(episode_file) {
#'
#' @description Add new columns based on SMRType and recid which follow a pattern
#' of prefixed column names created based on some condition.
#'
#' @family individual_file
#' @inheritParams create_individual_file
add_all_columns <- function(episode_file) {
cli::cli_alert_info("Add all columns function started at {Sys.time()}")
Expand Down Expand Up @@ -203,6 +204,7 @@ add_all_columns <- function(episode_file) {
#' @inheritParams create_individual_file
#' @param prefix Prefix to add to related columns, e.g. "Acute"
#' @param condition Condition to create new columns based on
#' @family individual_file
add_acute_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -213,6 +215,7 @@ add_acute_columns <- function(episode_file, prefix, condition) {
#' Add Mat columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_mat_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -223,6 +226,7 @@ add_mat_columns <- function(episode_file, prefix, condition) {
#' Add MH columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_mh_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -233,6 +237,7 @@ add_mh_columns <- function(episode_file, prefix, condition) {
#' Add GLS columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_gls_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -243,6 +248,7 @@ add_gls_columns <- function(episode_file, prefix, condition) {
#' Add OP columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_op_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file <- episode_file %>%
Expand All @@ -265,6 +271,7 @@ add_op_columns <- function(episode_file, prefix, condition) {
#' Add AE columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_ae_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -275,6 +282,7 @@ add_ae_columns <- function(episode_file, prefix, condition) {
#' Add PIS columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_pis_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -285,6 +293,7 @@ add_pis_columns <- function(episode_file, prefix, condition) {
#' Add OoH columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_ooh_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file <- episode_file %>%
Expand Down Expand Up @@ -319,6 +328,7 @@ add_ooh_columns <- function(episode_file, prefix, condition) {
#' Add DN columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_dn_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
if ("total_no_dn_contacts" %in% names(episode_file)) {
Expand All @@ -341,6 +351,7 @@ add_dn_columns <- function(episode_file, prefix, condition) {
#' Add CMH columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_cmh_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -351,6 +362,7 @@ add_cmh_columns <- function(episode_file, prefix, condition) {
#' Add DD columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_dd_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
condition_delay <- substitute(condition & primary_delay_reason != "9")
Expand All @@ -371,6 +383,7 @@ add_dd_columns <- function(episode_file, prefix, condition) {
#' Add NSU columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_nsu_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -381,6 +394,7 @@ add_nsu_columns <- function(episode_file, prefix, condition) {
#' Add NRS columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_nrs_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -391,6 +405,7 @@ add_nrs_columns <- function(episode_file, prefix, condition) {
#' Add HL1 columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_hl1_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -400,6 +415,7 @@ add_hl1_columns <- function(episode_file, prefix, condition) {
#' Add CH columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_ch_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand Down Expand Up @@ -428,6 +444,7 @@ add_ch_columns <- function(episode_file, prefix, condition) {
#' Add HC columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_hc_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file <- episode_file %>%
Expand Down Expand Up @@ -470,6 +487,7 @@ add_hc_columns <- function(episode_file, prefix, condition) {
#' Add AT columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_at_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -483,6 +501,7 @@ add_at_columns <- function(episode_file, prefix, condition) {
#' Add SDS columns
#'
#' @inheritParams add_acute_columns
#' @family individual_file
add_sds_columns <- function(episode_file, prefix, condition) {
condition <- substitute(condition)
episode_file %>%
Expand All @@ -502,7 +521,9 @@ add_sds_columns <- function(episode_file, prefix, condition) {
#'
#' @inheritParams add_acute_columns
#' @param ipdc_d Whether to create columns based on IPDC = "D" (lgl)
#' @param elective Whether to create columns based on Elective/Non-Elective cij_pattype (lgl)
#' @param elective Whether to create columns based on Elective/Non-Elective
#' cij_pattype (lgl)
#' @family individual_file
add_ipdc_cols <- function(episode_file, prefix, condition, ipdc_d = TRUE, elective = TRUE) {
condition_i <- substitute(eval(condition) & ipdc == "I")
episode_file <- episode_file %>%
Expand Down Expand Up @@ -540,11 +561,13 @@ add_ipdc_cols <- function(episode_file, prefix, condition, ipdc_d = TRUE, electi

#' Add standard columns
#'
#' @description Add standard columns (DoB, postcode, gpprac, episodes, cost) to episode file.
#' @description Add standard columns (DoB, postcode, gpprac, episodes, cost)
#' to episode file.
#'
#' @inheritParams add_acute_columns
#' @param episode Whether to create prefix_episodes col, e.g. "Acute_episodes"
#' @param cost Whether to create prefix_cost col, e.g. "Acute_cost"
#' @family individual_file
add_standard_cols <- function(episode_file, prefix, condition, episode = FALSE, cost = FALSE) {
if (episode) {
episode_file <- dplyr::mutate(episode_file, "{prefix}_episodes" := dplyr::if_else(eval(condition), 1L, NA_integer_))
Expand All @@ -560,6 +583,7 @@ add_standard_cols <- function(episode_file, prefix, condition, episode = FALSE,
#' @description Clean up CH-related columns.
#'
#' @inheritParams create_individual_file
#' @family individual_file
clean_up_ch <- function(episode_file, year) {
cli::cli_alert_info("Clean up CH function started at {Sys.time()}")

Expand Down Expand Up @@ -602,6 +626,7 @@ clean_up_ch <- function(episode_file, year) {
#' @description Recode gender to 1.5 if 0 or 9.
#'
#' @inheritParams create_individual_file
#' @family individual_file
recode_gender <- function(episode_file) {
cli::cli_alert_info("Recode Gender function started at {Sys.time()}")

Expand All @@ -620,6 +645,7 @@ recode_gender <- function(episode_file) {
#' @description Returns chr vector of column names
#' which follow format "condition" and "condition_date" e.g.
#' "dementia" and "dementia_date"
#' @family individual_file
condition_cols <- function() {
conditions <- slfhelper::ltc_vars
date_cols <- paste0(conditions, "_date")
Expand All @@ -634,6 +660,7 @@ condition_cols <- function() {
#' are missing (instead returns NA)
#'
#' @param x Vector to return max of
#' @family helper_funs
max_no_inf <- function(x) {
dplyr::if_else(all(is.na(x)), NA, max(x, na.rm = TRUE))
}
Expand All @@ -645,6 +672,7 @@ max_no_inf <- function(x) {
#' are missing (instead returns NA)
#'
#' @param x Vector to return min of
#' @family helper_funs
min_no_inf <- function(x) {
dplyr::if_else(all(is.na(x)), NA, min(x, na.rm = TRUE))
}
Expand Down
2 changes: 1 addition & 1 deletion R/link_delayed_discharge_eps.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @return A data frame with the delayed discharge cohort added and linked
#' using the `cij_marker`
#'
#' @family episode file
#' @family episode_file
link_delayed_discharge_eps <- function(
episode_file,
year,
Expand Down
Loading

0 comments on commit 81c2191

Please sign in to comment.