diff --git a/.Renviron.example b/.Renviron.example index 2ec62af..1fb6340 100644 --- a/.Renviron.example +++ b/.Renviron.example @@ -4,3 +4,7 @@ # might be more appropriately kept as project-specific values.) # Contact a member of SU Data Science to get the required values for these. AZ_STORAGE_EP = +AZ_TABLE_EP = +RESKIT_GITHUB_APP_PAT= +RESKIT_GITHUB_APP_PRIVATE_KEY= +RESKIT_GITHUB_APP_ID= diff --git a/DESCRIPTION b/DESCRIPTION index f27e81b..3b3b782 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,7 +27,7 @@ Roxygen: list(markdown = TRUE) Config/testthat/edition: 3 Depends: R (>= 4.5.0) Imports: - azkit (>= 0.3.0), + azkit (>= 0.3.2), base64enc, dplyr, forcats, diff --git a/R/get_github_file.R b/R/get_github_file.R index ef8eebe..5faa011 100644 --- a/R/get_github_file.R +++ b/R/get_github_file.R @@ -1,48 +1,137 @@ -#' Read in a file from the NHP Outputs app GitHub repo +#' Read in a file from a Strategy Unit GitHub repo #' +#' @param repo string. The name of the repository in which to find the file +#' @param folder string. The folder where the file is located. Set to `""` to +#' use the root folder of the repo. #' @param file string. The name of the file to read in -#' @param folder string. The folder where the file is located. `"inst"` by -#' default. Set to `""` to use the root folder of the repo. +#' @param pat A GitHub Personal Access Token. Generated by [get_github_pat] by +#' default, via a custom Strategy Unit app, but you might pass in a personal +#' token if you prefer or if that pipeline is not working. If you have a token +#' stored as an environment variable called "RESKIT_GH_APP_PAT", this will be +#' be used, saving the need to make any API calls. #' @returns The file contents as a stream, to be passed to a reader function #' @keywords internal -get_outputs_gh_file <- function(file, folder = "inst") { - httr2::request("https://api.github.com") |> +get_su_gh_file <- function(repo, folder, file, pat = get_github_pat()) { + ua_string <- "The-Strategy-Unit/nhp_reskit R package" + resp <- httr2::request("https://api.github.com") |> httr2::req_url_path_append("repos") |> httr2::req_url_path_append("The-Strategy-Unit") |> - httr2::req_url_path_append("nhp_outputs") |> + httr2::req_url_path_append(repo) |> httr2::req_url_path_append("contents") |> httr2::req_url_path_append(folder) |> httr2::req_url_path_append(file) |> + httr2::req_headers(`User-Agent` = ua_string) |> + httr2::req_headers(`X-GitHub-Api-Version` = "2026-03-10") |> + httr2::req_headers(`Accept` = "application/vnd.github+json") |> + httr2::req_auth_bearer_token(pat) |> httr2::req_perform() |> - httr2::resp_check_status() |> - httr2::resp_body_json() |> - purrr::pluck("content") |> - base64enc::base64decode() + httr2::resp_check_status() + + base64enc::base64decode(httr2::resp_body_json(resp)[["content"]]) } -#' Read in a file from the TPMAs GitHub repo +#' Read in a file from the NHP Outputs app GitHub repo #' -#' @param file string. The name of the file to read in -#' @param folder string. The folder where the file is located. `"reference"` by -#' default. Set to `""` to use the root folder of the repo. -#' @returns The file contents as a stream, to be passed to a reader function +#' @param ... Pass the name of the file in via `...` #' @keywords internal -get_tpmas_gh_file <- function(file, folder = "reference") { - httr2::request("https://api.github.com") |> - httr2::req_url_path_append("repos") |> - httr2::req_url_path_append("The-Strategy-Unit") |> - httr2::req_url_path_append("TPMAs") |> - httr2::req_url_path_append("contents") |> - httr2::req_url_path_append(folder) |> - httr2::req_url_path_append(file) |> - httr2::req_perform() |> - httr2::resp_check_status() |> - httr2::resp_body_json() |> - purrr::pluck("content") |> - base64enc::base64decode() +get_outputs_gh_file <- function(...) { + purrr::partial(get_su_gh_file, repo = "nhp_outputs", folder = "inst")(...) } +#' Read in a file from the TPMAs GitHub repo +#' +#' @inheritParams get_outputs_gh_file +#' @keywords internal +get_tpmas_gh_file <- function(...) { + purrr::partial(get_su_gh_file, repo = "TPMAs", folder = "reference")(...) +} + possibly_get_outputs_gh_file <- \(...) purrr::possibly(get_outputs_gh_file)(...) possibly_get_tpmas_gh_file <- \(...) purrr::possibly(get_tpmas_gh_file)(...) + + +#' Return a GitHub access token +#' +#' If the envvar "RESKIT_GH_APP_PAT" is set, this will be used as the token. +#' Otherwise, the envvars "RESKIT_GH_APP_ID" and "RESKIT_GH_APP_PRIVATE_KEY" +#' must be set. The former as a string, the latter as a path to a PEM key. +#' @returns A personal access token (PAT) with permissions granted to the app +#' @keywords internal +get_github_pat <- function() { + pat <- Sys.getenv("RESKIT_GH_APP_PAT") + if (nzchar(pat)) { + pat + } else { + msg1 <- "Environment variable {.var RESKIT_GH_APP_ID} is not set" + msg2 <- "Environment variable {.var RESKIT_GH_APP_PRIVATE_KEY} is not set" + azkit::check_nzchar(Sys.getenv("RESKIT_GH_APP_ID"), msg1) + azkit::check_nzchar(Sys.getenv("RESKIT_GH_APP_PRIVATE_KEY"), msg2) + get_github_pat_via_api() + } +} + + +#' Return a GitHub PAT via the API using the reskit authentication GitHub app +#' +#' The envvars "RESKIT_GH_APP_ID" and "RESKIT_GH_APP_PRIVATE_KEY" must +#' be set. The former as a string, the latter as a path to a PEM key. +#' @returns An access token (PAT) as a string +#' @keywords internal +get_github_pat_via_api <- function() { + ua_string <- "The-Strategy-Unit/nhp_reskit R package" + jwt <- get_github_jwt() + installation_id <- get_github_app_installation_id(jwt) + req <- httr2::request("https://api.github.com/") + resp <- req |> + httr2::req_url_path_append("app") |> + httr2::req_url_path_append("installations") |> + httr2::req_url_path_append(installation_id) |> + httr2::req_url_path_append("access_tokens") |> + httr2::req_auth_bearer_token(jwt) |> + httr2::req_headers(`User-Agent` = ua_string) |> + httr2::req_headers(`X-GitHub-Api-Version` = "2026-03-10") |> + httr2::req_headers(`Accept` = "application/vnd.github+json") |> + httr2::req_method("POST") |> + httr2::req_perform() |> + httr2::resp_check_status() + + httr2::resp_body_json(resp)[["token"]] +} + + +#' Returns the installation ID for the reskit GitHub app +#' +#' The envvars "RESKIT_GH_APP_ID" and "RESKIT_GH_APP_PRIVATE_KEY" must +#' be set. The former as a string, the latter as a path to a PEM key. +#' @param jwt JWT for the app. Defaults to the output of `get_github_jwt()`. +#' @returns An installation ID as an integer +#' @keywords internal +get_github_app_installation_id <- function(jwt = get_github_jwt()) { + ua_string <- "The-Strategy-Unit/nhp_reskit R package" + req <- httr2::request("https://api.github.com/") + resp <- req |> + httr2::req_url_path_append("app") |> + httr2::req_url_path_append("installations") |> + httr2::req_auth_bearer_token(jwt) |> + httr2::req_headers(`User-Agent` = ua_string) |> + httr2::req_headers(`X-GitHub-Api-Version` = "2026-03-10") |> + httr2::req_headers(`Accept` = "application/vnd.github+json") |> + httr2::req_perform() |> + httr2::resp_check_status() + httr2::resp_body_json(resp)[[1]][["id"]] +} + + +#' Returns a GitHub JWT for the reskit authentication app +#' +#' The envvars "RESKIT_GH_APP_ID" and "RESKIT_GH_APP_PRIVATE_KEY" must +#' be set. The former as a string, the latter as a path to a PEM key. +#' @returns A JSON Web Token (JWT) as a string +#' @keywords internal +get_github_jwt <- function() { + claim <- httr2::jwt_claim(Sys.getenv("RESKIT_GH_APP_ID")) + key <- openssl::read_key(Sys.getenv("RESKIT_GH_APP_PRIVATE_KEY")) + httr2::jwt_encode_sig(claim, key) +} diff --git a/R/get_principal_pods.R b/R/get_principal_pods.R index 0adb092..5f3b98c 100644 --- a/R/get_principal_pods.R +++ b/R/get_principal_pods.R @@ -1,35 +1,20 @@ #' Prepare a lookup table with activity type labels and PoD labels for each PoD #' -#' @param use_local logical. Whether to use a local file (internal to the -#' reskit package) or attempt to pull the lookup file from GitHub. Default is -#' `FALSE`, meaning it will use the GitHub route. If you want to always use a -#' local file (for example, for fully offline working), you can set the -#' `reskit.local.lookups` option to `TRUE` using -#' `options(reskit.local.lookups = TRUE)` or `withr::with_options()` #' @returns A tibble #' @export -get_detailed_pods <- function(use_local = FALSE) { - use_local <- getOption("reskit.local.lookups") %||% use_local - yaml_data <- system.file("pod_measures.yml", package = "reskit") |> - yaml12::read_yaml() - yaml_data_from_gh <- NULL - if (!use_local) { - yaml_raw <- possibly_get_outputs_gh_file("golem-config.yml") - if (!is.null(yaml_raw)) { - yaml_data_from_gh <- yaml12::parse_yaml(readr::read_lines(yaml_raw)) |> - purrr::pluck("default") - } - } - yaml_data <- yaml_data_from_gh %||% yaml_data +get_detailed_pods <- function() { + yaml_raw <- possibly_get_outputs_gh_file("golem-config.yml") + msg <- "Unable to read POD lookup file from GitHub" + azkit::check_that(yaml_raw, is_not_null, msg) + yaml_data <- yaml12::parse_yaml(readr::read_lines(yaml_raw))[["default"]] yaml_data |> purrr::pluck("pod_measures") |> purrr::map(list_to_tbl) |> purrr::list_rbind() |> dplyr::mutate( dplyr::across("pod_label", forcats::fct_inorder), - dplyr::across("activity_type_label", \(x) sub("patients$", "patient", x)), dplyr::across("activity_type_label", \(x) { - forcats::fct(x, levels = c("Inpatient", "Outpatient", "A&E")) + forcats::fct(x, levels = c("Inpatients", "Outpatients", "A&E")) }) ) } @@ -42,8 +27,8 @@ get_detailed_pods <- function(use_local = FALSE) { #' @rdname get_detailed_pods #' @returns A tibble #' @export -get_principal_pods <- function(use_local = FALSE) { - get_detailed_pods(use_local) |> +get_principal_pods <- function() { + get_detailed_pods() |> dplyr::filter(dplyr::if_any("activity_type_label", \(x) x != "A&E")) |> dplyr::add_row( activity_type_label = "A&E", @@ -53,7 +38,7 @@ get_principal_pods <- function(use_local = FALSE) { dplyr::mutate( dplyr::across("pod_label", forcats::fct_inorder), dplyr::across("activity_type_label", \(x) { - forcats::fct(x, levels = c("Inpatient", "Outpatient", "A&E")) + forcats::fct(x, levels = c("Inpatients", "Outpatients", "A&E")) }) ) } diff --git a/R/helpers.R b/R/helpers.R index 30b29c9..7538fad 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -120,6 +120,7 @@ relabel_ip_activity_types <- function(tbl) { tbl |> dplyr::mutate( dplyr::across("activity_type_label", \(x) { + x <- sub("s$", "", x) dplyr::if_else( x == "Inpatient", paste0(x, " ", uppercase_init(.data[["measure"]])), @@ -177,36 +178,38 @@ get_tretspef_lookup <- function() { #' Prepare a lookup table for all current TPMAs #' -#' @param use_local logical. Whether to use a local file (internal to the -#' reskit package) or attempt to pull the lookup file from GitHub. Default is -#' `FALSE`, meaning it will use the GitHub route. If you want to always use a -#' local file (for example, for fully offline working), you can set the -#' `reskit.local.lookups` option to `TRUE` using -#' `options(reskit.local.lookups = TRUE)` or `withr::with_options()` -#' @returns A 4-column tibble, with columns `activity_type`, `change_factor`, -#' `strategy` and `tpma_label` +#' @returns A 4-column tibble, with columns `strategy`, `activity_type`, +#' `change_factor` and `tpma_label` #' @export -get_tpma_label_lookup <- function(use_local = FALSE) { - read_cols <- "cccc----c" - use_local <- getOption("reskit.local.lookups") %||% use_local - csv_data <- system.file("mitigator-lookup.csv", package = "reskit") |> - readr::read_csv(col_types = read_cols) - csv_data_from_gh <- NULL - if (!use_local) { - csv_data_raw <- possibly_get_tpmas_gh_file("mitigator-lookup.csv") - if (!is.null(csv_data_raw)) { - csv_data_from_gh <- readr::read_csv(csv_data_raw, col_types = read_cols) - } - } - csv_data <- csv_data_from_gh %||% csv_data +get_tpma_label_lookup <- function() { + csv_data_raw <- possibly_get_tpmas_gh_file("tpma-lookup.csv") + msg <- "Unable to read TPMA lookup table from GitHub" + azkit::check_that(csv_data_raw, is_not_null, msg) + csv_data <- readr::read_csv(csv_data_raw, col_types = "-ccccc---c") csv_data |> dplyr::filter(dplyr::if_any("active_to", is.na)) |> dplyr::select(!"active_to") |> - dplyr::rename( - change_factor = "mitigator_type", - strategy = "mitigator_variable", - tpma_label = "mitigator_name" - ) + dplyr::mutate( + tpma_label = glue::glue("{tpma_name} ({tpma_subtype})"), + dplyr::across("tpma_type", \(x) tolower(sub(" ", "_", x))), + dplyr::across("activity_type", convert_activity_type), + .keep = "unused" + ) |> + dplyr::rename(change_factor = "tpma_type", strategy = "tpma_variable") +} + + +#' Converts "In|Outpatients", "A&E" strings to "ip", "op" and "aae" +#' @param x A character vector +#' @returns A character vector +#' @keywords internal +convert_activity_type <- function(x) { + dplyr::recode_values( + x, + "A&E" ~ "aae", + "Inpatients" ~ "ip", + "Outpatients" ~ "op" + ) } @@ -216,3 +219,5 @@ get_tpma_label_lookup <- function(use_local = FALSE) { #' @returns A character vector: all values of x that match the regex in rx #' @keywords internal gregv <- \(x, rx, g = parent.frame()) grepv(glue::glue_data(g, rx), x) + +is_not_null <- \(x) !is.null(x) diff --git a/inst/mitigator-lookup.csv b/inst/mitigator-lookup.csv deleted file mode 100644 index 22ae295..0000000 --- a/inst/mitigator-lookup.csv +++ /dev/null @@ -1,97 +0,0 @@ -activity_type,mitigator_type,mitigator_variable,mitigator_name,mitigator_code,mitigator_subset,mitigator_grouping,active_from,active_to -aae,activity_avoidance,discharged_no_treatment_adult_ambulance,"A&E Discharged No Investigation or Treatment (Adult, Ambulance Conveyed)",AE-AA-001,Discharged No Treatment,Emergency department and acute medicine activity,v0.6.3,NA -aae,activity_avoidance,discharged_no_treatment_adult_walk-in,"A&E Discharged No Investigation or Treatment (Adult, Walk-in)",AE-AA-002,Discharged No Treatment,Emergency department and acute medicine activity,v0.6.3,NA -aae,activity_avoidance,discharged_no_treatment_child_ambulance,"A&E Discharged No Investigation or Treatment (Children, Ambulance Conveyed)",AE-AA-003,Discharged No Treatment,Emergency department and acute medicine activity,v0.6.3,NA -aae,activity_avoidance,discharged_no_treatment_child_walk-in,"A&E Discharged No Investigation or Treatment (Children, Walk-in)",AE-AA-004,Discharged No Treatment,Emergency department and acute medicine activity,v0.6.3,NA -aae,activity_avoidance,frequent_attenders_adult_ambulance,"A&E Frequent Attenders (Adult, Ambulance Conveyed)",AE-AA-005,Frequent Attenders,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,frequent_attenders_adult_walk-in,"A&E Frequent Attenders (Adult, Walk-in)",AE-AA-006,Frequent Attenders,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,frequent_attenders_child_ambulance,"A&E Frequent Attenders (Children, Ambulance Conveyed)",AE-AA-007,Frequent Attenders,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,frequent_attenders_child_walk-in,"A&E Frequent Attenders (Children, Walk-in)",AE-AA-008,Frequent Attenders,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,left_before_seen_adult_ambulance,"A&E Patients Left Before Being Treated (Adult, Ambulance Conveyed)",AE-AA-009,Left Before Seen,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,left_before_seen_adult_walk-in,"A&E Patients Left Before Being Treated (Adult, Walk-in)",AE-AA-010,Left Before Seen,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,left_before_seen_child_ambulance,"A&E Patients Left Before Being Treated (Children, Ambulance Conveyed)",AE-AA-011,Left Before Seen,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,left_before_seen_child_walk-in,"A&E Patients Left Before Being Treated (Children, Walk-in)",AE-AA-012,Left Before Seen,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,low_cost_discharged_adult_ambulance,"A&E Low Cost Discharged Attendances (Adult, Ambulance Conveyed)",AE-AA-013,Low-cost Discharged,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,low_cost_discharged_adult_walk-in,"A&E Low Cost Discharged Attendances (Adult, Walk-in)",AE-AA-014,Low-cost Discharged,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,low_cost_discharged_child_ambulance,"A&E Low Cost Discharged Attendances (Children, Ambulance Conveyed)",AE-AA-015,Low-cost Discharged,Emergency department and acute medicine activity,v0.6.0,NA -aae,activity_avoidance,low_cost_discharged_child_walk-in,"A&E Low Cost Discharged Attendances (Children, Walk-in)",AE-AA-016,Low-cost Discharged,Emergency department and acute medicine activity,v0.6.0,NA -ip,activity_avoidance,alcohol_partially_attributable_acute,Alcohol Related Admissions (Acute Conditions - Partially Attributable),IP-AA-001,Admission Avoidance,Hospital activity amenable to public health interventions,v0.6.0,NA -ip,activity_avoidance,alcohol_partially_attributable_chronic,Alcohol Related Admissions (Chronic Conditions - Partially Attributable),IP-AA-002,Admission Avoidance,Hospital activity amenable to public health interventions,v0.6.0,NA -ip,activity_avoidance,alcohol_wholly_attributable,Alcohol Related Admissions (Wholly Attributable),IP-AA-003,Admission Avoidance,Hospital activity amenable to public health interventions,v0.6.0,NA -ip,activity_avoidance,ambulatory_care_conditions_acute,Ambulatory Care Sensitive Admissions (Acute Conditions),IP-AA-004,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,activity_avoidance,ambulatory_care_conditions_chronic,Ambulatory Care Sensitive Admissions (Chronic Conditions),IP-AA-005,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,activity_avoidance,ambulatory_care_conditions_vaccine_preventable,Ambulatory Care Sensitive Admissions (Vaccine Preventable),IP-AA-006,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,activity_avoidance,cancelled_operations,Cancelled Operations,IP-AA-007,Admission Avoidance,Planned surgical activity (adult),v0.6.0,NA -ip,activity_avoidance,eol_care_2_days,End of Life Care Admissions (died within 2 days),IP-AA-008,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,activity_avoidance,eol_care_3_to_14_days,End of Life Care Admissions (died within 3-14 days),IP-AA-009,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,activity_avoidance,evidence_based_interventions_ent,Interventions with Limited Evidence (ENT),IP-AA-010,Admission Avoidance,Planned surgical activity (adult),v0.6.0,NA -ip,activity_avoidance,evidence_based_interventions_general_surgery,Interventions with Limited Evidence (General Surgery),IP-AA-011,Admission Avoidance,Planned surgical activity (adult),v0.6.0,NA -ip,activity_avoidance,evidence_based_interventions_gi_surgical,Interventions with Limited Evidence (GI Surgical),IP-AA-012,Admission Avoidance,Planned surgical activity (adult),v0.6.0,NA -ip,activity_avoidance,evidence_based_interventions_msk,Interventions with Limited Evidence (MSK),IP-AA-013,Admission Avoidance,Planned surgical activity (adult),v0.6.0,NA -ip,activity_avoidance,evidence_based_interventions_urology,Interventions with Limited Evidence (Urology),IP-AA-014,Admission Avoidance,Planned surgical activity (adult),v0.6.0,NA -ip,activity_avoidance,evidence_based_interventions_vascular_varicose_veins,Interventions with Limited Evidence (Vascular Varicose Veins),IP-AA-015,Admission Avoidance,Planned surgical activity (adult),v0.6.0,NA -ip,activity_avoidance,falls_related_admissions,Falls Related Admissions,IP-AA-016,Admission Avoidance,Hospital activity amenable to public health interventions,v0.6.0,NA -ip,activity_avoidance,frail_elderly_high,Older People with Frailty Admissions (High Frailty Risk),IP-AA-017,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,activity_avoidance,frail_elderly_intermediate,Older People with Frailty Admissions (Intermediate Frailty Risk),IP-AA-018,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,activity_avoidance,intentional_self_harm,Intentional Self Harm Admissions,IP-AA-019,Admission Avoidance,Hospital activity amenable to psychiatric liaison and community psychiatry,v0.6.0,NA -ip,activity_avoidance,medically_unexplained_related_admissions,Medically Unexplained Symptoms Admissions,IP-AA-020,Admission Avoidance,Hospital activity amenable to psychiatric liaison and community psychiatry,v0.6.0,NA -ip,activity_avoidance,medicines_related_admissions_explicit,Medicines Related Admissions (Explicit),IP-AA-021,Admission Avoidance,Hospital activity amenable to medicines management,v0.6.0,NA -ip,activity_avoidance,medicines_related_admissions_implicit_anti-diabetics,Medicines Related Admissions (Implicit - Anti-Diabetics),IP-AA-022,Admission Avoidance,Hospital activity amenable to medicines management,v0.6.0,NA -ip,activity_avoidance,medicines_related_admissions_implicit_benzodiasepines,Medicines Related Admissions (Implicit - Benzodiazepines),IP-AA-023,Admission Avoidance,Hospital activity amenable to medicines management,v0.6.0,NA -ip,activity_avoidance,medicines_related_admissions_implicit_diurectics,Medicines Related Admissions (Implicit - Diuretics),IP-AA-024,Admission Avoidance,Hospital activity amenable to medicines management,v0.6.0,NA -ip,activity_avoidance,medicines_related_admissions_implicit_nsaids,Medicines Related Admissions (Implicit - NSAIDs),IP-AA-025,Admission Avoidance,Hospital activity amenable to medicines management,v0.6.0,NA -ip,activity_avoidance,obesity_related_admissions,Obesity Related Admissions,IP-AA-026,Admission Avoidance,Hospital activity amenable to public health interventions,v0.6.0,NA -ip,activity_avoidance,raid_ae,Mental Health Admissions via Emergency Department,IP-AA-027,Admission Avoidance,Hospital activity amenable to psychiatric liaison and community psychiatry,v0.6.0,NA -ip,activity_avoidance,readmission_within_28_days,Emergency Readmissions Within 28 Days,IP-AA-028,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,activity_avoidance,smoking,Smoking Related Admissions,IP-AA-029,Admission Avoidance,Hospital activity amenable to public health interventions,v0.6.0,NA -ip,activity_avoidance,virtual_wards_activity_avoidance_ari,Virtual Wards Admission Avoidance (Acute Respiratory Infection),IP-AA-030,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v1.1.0,NA -ip,activity_avoidance,virtual_wards_activity_avoidance_heart_failure,Virtual Wards Admission Avoidance (Heart Failure),IP-AA-031,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v1.1.0,NA -ip,activity_avoidance,zero_los_no_procedure_adult,Admission With No Overnight Stay and No Procedure (Adults),IP-AA-032,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,activity_avoidance,zero_los_no_procedure_child,Admission With No Overnight Stay and No Procedure (Children),IP-AA-033,Admission Avoidance,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,efficiencies,ambulatory_emergency_care_high,Ambulatory Emergency Care (High Potential),IP-EF-001,Ambulatory Emergency Care Length of Stay Reduction,Emergency department and acute medicine activity,v0.6.0,v3.3.0 -ip,efficiencies,ambulatory_emergency_care_low,Ambulatory Emergency Care (Low Potential),IP-EF-002,Ambulatory Emergency Care Length of Stay Reduction,Emergency department and acute medicine activity,v0.6.0,v3.3.0 -ip,efficiencies,ambulatory_emergency_care_moderate,Ambulatory Emergency Care (Moderate Potential),IP-EF-003,Ambulatory Emergency Care Length of Stay Reduction,Emergency department and acute medicine activity,v0.6.0,v3.3.0 -ip,efficiencies,ambulatory_emergency_care_very_high,Ambulatory Emergency Care (Very High Potential),IP-EF-004,Ambulatory Emergency Care Length of Stay Reduction,Emergency department and acute medicine activity,v0.6.0,v3.3.0 -ip,efficiencies,day_procedures_occasionally_dc,Day Procedures: Occasionally performed as a Daycase,IP-EF-005,Day Procedures: Daycase,Planned surgical activity (adult),v1.1.0,NA -ip,efficiencies,day_procedures_occasionally_op,Day Procedures: Occasionally performed in Outpatients,IP-EF-006,Day Procedures: Outpatients,Planned surgical activity (adult),v1.1.0,NA -ip,efficiencies,day_procedures_usually_dc,Day Procedures: Usually performed as a Daycase,IP-EF-007,Day Procedures: Daycase,Planned surgical activity (adult),v1.1.0,NA -ip,efficiencies,day_procedures_usually_op,Day Procedures: Usually performed in Outpatients,IP-EF-008,Day Procedures: Outpatients,Planned surgical activity (adult),v1.1.0,NA -ip,efficiencies,emergency_elderly,Emergency Admission of Older People,IP-EF-009,Mean Length of Stay Reduction,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,efficiencies,enhanced_recovery_bladder,Enhanced Recovery (Bladder),IP-EF-010,Mean Length of Stay Reduction,Planned surgical activity (adult),v0.6.0,NA -ip,efficiencies,enhanced_recovery_breast,Enhanced Recovery (Breast),IP-EF-011,Mean Length of Stay Reduction,Planned surgical activity (adult),v0.6.0,NA -ip,efficiencies,enhanced_recovery_colectomy,Enhanced Recovery (Colectomy),IP-EF-012,Mean Length of Stay Reduction,Planned surgical activity (adult),v0.6.0,NA -ip,efficiencies,enhanced_recovery_hip,Enhanced Recovery (Hip),IP-EF-013,Mean Length of Stay Reduction,Planned surgical activity (adult),v0.6.0,NA -ip,efficiencies,enhanced_recovery_hysterectomy,Enhanced Recovery (Hysterectomy),IP-EF-014,Mean Length of Stay Reduction,Planned surgical activity (adult),v0.6.0,NA -ip,efficiencies,enhanced_recovery_knee,Enhanced Recovery (Knee),IP-EF-015,Mean Length of Stay Reduction,Planned surgical activity (adult),v0.6.0,NA -ip,efficiencies,enhanced_recovery_prostate,Enhanced Recovery (Prostate),IP-EF-016,Mean Length of Stay Reduction,Planned surgical activity (adult),v0.6.0,NA -ip,efficiencies,enhanced_recovery_rectum,Enhanced Recovery (Rectum),IP-EF-017,Mean Length of Stay Reduction,Planned surgical activity (adult),v0.6.0,NA -ip,efficiencies,excess_beddays_elective,Excess Beddays (Elective Admissions),IP-EF-018,Mean Length of Stay Reduction,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,efficiencies,excess_beddays_emergency,Excess Beddays (Emergency Admissions),IP-EF-019,Mean Length of Stay Reduction,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,efficiencies,general_los_reduction_elective,General LoS Reduction: Elective Admissions,IP-EF-020,Mean Length of Stay Reduction,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,efficiencies,general_los_reduction_emergency,General LoS Reduction: Emergency Admissions,IP-EF-021,Mean Length of Stay Reduction,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,efficiencies,pre-op_los_1-day,Pre-op Length of Stay of 1 day,IP-EF-022,Pre-op Length of Stay Reduction,Planned surgical activity (adult),v0.6.0,NA -ip,efficiencies,pre-op_los_2-day,Pre-op Length of Stay of 2 days,IP-EF-023,Pre-op Length of Stay Reduction,Planned surgical activity (adult),v0.6.0,NA -ip,efficiencies,raid_ip,Admissions with Mental Health Comorbidities,IP-EF-024,Mean Length of Stay Reduction,Hospital activity amenable to psychiatric liaison and community psychiatry,v0.6.0,NA -ip,efficiencies,stroke_early_supported_discharge,Stroke Early Supported Discharge,IP-EF-025,Mean Length of Stay Reduction,Hospital activity amenable to primary care and community interventions,v0.6.0,NA -ip,efficiencies,virtual_wards_efficiencies_ari,Virtual Wards LoS Reduction (Acute Respiratory Infection),IP-EF-026,Mean Length of Stay Reduction,Hospital activity amenable to primary care and community interventions,v1.1.0,NA -ip,efficiencies,virtual_wards_efficiencies_heart_failure,Virtual Wards LoS Reduction (Heart Failure),IP-EF-027,Mean Length of Stay Reduction,Hospital activity amenable to primary care and community interventions,v1.1.0,NA -ip,efficiencies,same_day_emergency_care_low,Same Day Emergency Care (Low Potential),IP-EF-028,Same Day Emergency Care Conversion,Emergency department and acute medicine activity,v3.4.0,NA -ip,efficiencies,same_day_emergency_care_moderate,Same Day Emergency Care (Moderate Potential),IP-EF-029,Same Day Emergency Care Conversion,Emergency department and acute medicine activity,v3.4.0,NA -ip,efficiencies,same_day_emergency_care_high,Same Day Emergency Care (High Potential),IP-EF-030,Same Day Emergency Care Conversion,Emergency department and acute medicine activity,v3.4.0,NA -ip,efficiencies,same_day_emergency_care_very_high,Same Day Emergency Care (Very High Potential),IP-EF-031,Same Day Emergency Care Conversion,Emergency department and acute medicine activity,v3.4.0,NA -op,activity_avoidance,consultant_to_consultant_reduction_adult_non-surgical,"Outpatient Consultant to Consultant Referrals (Adult, Non-Surgical)",OP-AA-001,Consultant Referrals,Planned medical activity (adult),v0.6.0,NA -op,activity_avoidance,consultant_to_consultant_reduction_adult_surgical,"Outpatient Consultant to Consultant Referrals (Adult, Surgical)",OP-AA-002,Consultant Referrals,Planned surgical activity (adult),v0.6.0,NA -op,activity_avoidance,consultant_to_consultant_reduction_child_non-surgical,"Outpatient Consultant to Consultant Referrals (Children, Non-Surgical)",OP-AA-003,Consultant Referrals,Planned medical activity (paediatric),v0.6.0,NA -op,activity_avoidance,consultant_to_consultant_reduction_child_surgical,"Outpatient Consultant to Consultant Referrals (Children, Surgical)",OP-AA-004,Consultant Referrals,Planned surgical activity (paediatric),v0.6.0,NA -op,activity_avoidance,followup_reduction_adult_non-surgical,"Outpatient Followup Appointment Reduction (Adult, Non-Surgical)",OP-AA-005,Follow-up Reduction,Planned medical activity (adult),v0.6.0,NA -op,activity_avoidance,followup_reduction_adult_surgical,"Outpatient Followup Appointment Reduction (Adult, Surgical)",OP-AA-006,Follow-up Reduction,Planned surgical activity (adult),v0.6.0,NA -op,activity_avoidance,followup_reduction_child_non-surgical,"Outpatient Followup Appointment Reduction (Children, Non-Surgical)",OP-AA-007,Follow-up Reduction,Planned medical activity (paediatric),v0.6.0,NA -op,activity_avoidance,followup_reduction_child_surgical,"Outpatient Followup Appointment Reduction (Children, Surgical)",OP-AA-008,Follow-up Reduction,Planned surgical activity (paediatric),v0.6.0,NA -op,activity_avoidance,gp_referred_first_attendance_reduction_adult_non-surgical,"Outpatient GP Referred First Attendance Reduction (Adult, Non-Surgical)",OP-AA-009,GP-referred First Attendance Reduction,Planned medical activity (adult),v0.6.3,NA -op,activity_avoidance,gp_referred_first_attendance_reduction_adult_surgical,"Outpatient GP Referred First Attendance Reduction (Adult, Surgical)",OP-AA-010,GP-referred First Attendance Reduction,Planned surgical activity (adult),v0.6.3,NA -op,activity_avoidance,gp_referred_first_attendance_reduction_child_non-surgical,"Outpatient GP Referred First Attendance Reduction (Children, Non-Surgical)",OP-AA-011,GP-referred First Attendance Reduction,Planned medical activity (paediatric),v0.6.3,NA -op,activity_avoidance,gp_referred_first_attendance_reduction_child_surgical,"Outpatient GP Referred First Attendance Reduction (Children, Surgical)",OP-AA-012,GP-referred First Attendance Reduction,Planned surgical activity (paediatric),v0.6.3,NA -op,efficiencies,convert_to_tele_adult_non-surgical,"Outpatient Convert to Tele-Attendance (Adult, Non-Surgical)",OP-EF-001,Convert to Tele,Planned medical activity (adult),v0.6.0,NA -op,efficiencies,convert_to_tele_adult_surgical,"Outpatient Convert to Tele-Attendance (Adult, Surgical)",OP-EF-002,Convert to Tele,Planned surgical activity (adult),v0.6.0,NA -op,efficiencies,convert_to_tele_child_non-surgical,"Outpatient Convert to Tele-Attendance (Children, Non-Surgical)",OP-EF-003,Convert to Tele,Planned medical activity (paediatric),v0.6.0,NA -op,efficiencies,convert_to_tele_child_surgical,"Outpatient Convert to Tele-Attendance (Children, Surgical)",OP-EF-004,Convert to Tele,Planned surgical activity (paediatric),v0.6.0,NA diff --git a/inst/mitigators.json b/inst/mitigators.json deleted file mode 100644 index 40d456f..0000000 --- a/inst/mitigators.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "alcohol_partially_attributable_acute": "Alcohol Related Admissions (Acute Conditions - Partially Attributable) (IP-AA-001)", - "alcohol_partially_attributable_chronic": "Alcohol Related Admissions (Chronic Conditions - Partially Attributable) (IP-AA-002)", - "alcohol_wholly_attributable": "Alcohol Related Admissions (Wholly Attributable) (IP-AA-003)", - "ambulatory_care_conditions_acute": "Ambulatory Care Sensitive Admissions (Acute Conditions) (IP-AA-004)", - "ambulatory_care_conditions_chronic": "Ambulatory Care Sensitive Admissions (Chronic Conditions) (IP-AA-005)", - "ambulatory_care_conditions_vaccine_preventable": "Ambulatory Care Sensitive Admissions (Vaccine Preventable) (IP-AA-006)", - "ambulatory_emergency_care_high": "Ambulatory Emergency Care (High Potential) (IP-EF-001)", - "ambulatory_emergency_care_low": "Ambulatory Emergency Care (Low Potential) (IP-EF-002)", - "ambulatory_emergency_care_moderate": "Ambulatory Emergency Care (Moderate Potential) (IP-EF-003)", - "ambulatory_emergency_care_very_high": "Ambulatory Emergency Care (Very High Potential) (IP-EF-004)", - "cancelled_operations": "Cancelled Operations (IP-AA-007)", - "consultant_to_consultant_reduction_adult_non-surgical": "Outpatient Consultant to Consultant Referrals (Adult, Non-Surgical) (OP-AA-001)", - "consultant_to_consultant_reduction_adult_surgical": "Outpatient Consultant to Consultant Referrals (Adult, Surgical) (OP-AA-002)", - "consultant_to_consultant_reduction_child_non-surgical": "Outpatient Consultant to Consultant Referrals (Children, Non-Surgical) (OP-AA-003)", - "consultant_to_consultant_reduction_child_surgical": "Outpatient Consultant to Consultant Referrals (Children, Surgical) (OP-AA-004)", - "convert_to_tele_adult_non-surgical": "Outpatient Convert to Tele-Attendance (Adult, Non-Surgical) (OP-EF-001)", - "convert_to_tele_adult_surgical": "Outpatient Convert to Tele-Attendance (Adult, Surgical) (OP-EF-002)", - "convert_to_tele_child_non-surgical": "Outpatient Convert to Tele-Attendance (Children, Non-Surgical) (OP-EF-003)", - "convert_to_tele_child_surgical": "Outpatient Convert to Tele-Attendance (Children, Surgical) (OP-EF-004)", - "day_procedures_occasionally_dc": "Day Procedures: Occasionally performed as a Daycase (IP-EF-005)", - "day_procedures_occasionally_op": "Day Procedures: Occasionally performed in Outpatients (IP-EF-006)", - "day_procedures_usually_dc": "Day Procedures: Usually performed as a Daycase (IP-EF-007)", - "day_procedures_usually_op": "Day Procedures: Usually performed in Outpatients (IP-EF-008)", - "discharged_no_treatment_adult_ambulance": "A&E Discharged No Investigation or Treatment (Adult, Ambulance Conveyed) (AE-AA-001)", - "discharged_no_treatment_adult_walk-in": "A&E Discharged No Investigation or Treatment (Adult, Walk-in) (AE-AA-002)", - "discharged_no_treatment_child_ambulance": "A&E Discharged No Investigation or Treatment (Children, Ambulance Conveyed) (AE-AA-003)", - "discharged_no_treatment_child_walk-in": "A&E Discharged No Investigation or Treatment (Children, Walk-in) (AE-AA-004)", - "emergency_elderly": "Emergency Admission of Older People (IP-EF-009)", - "enhanced_recovery_bladder": "Enhanced Recovery (Bladder) (IP-EF-010)", - "enhanced_recovery_breast": "Enhanced Recovery (Breast) (IP-EF-011)", - "enhanced_recovery_colectomy": "Enhanced Recovery (Colectomy) (IP-EF-012)", - "enhanced_recovery_hip": "Enhanced Recovery (Hip) (IP-EF-013)", - "enhanced_recovery_hysterectomy": "Enhanced Recovery (Hysterectomy) (IP-EF-014)", - "enhanced_recovery_knee": "Enhanced Recovery (Knee) (IP-EF-015)", - "enhanced_recovery_prostate": "Enhanced Recovery (Prostate) (IP-EF-016)", - "enhanced_recovery_rectum": "Enhanced Recovery (Rectum) (IP-EF-017)", - "eol_care_2_days": "End of Life Care Admissions (died within 2 days) (IP-AA-008)", - "eol_care_3_to_14_days": "End of Life Care Admissions (died within 3-14 days) (IP-AA-009)", - "evidence_based_interventions_ent": "Interventions with Limited Evidence (ENT) (IP-AA-010)", - "evidence_based_interventions_general_surgery": "Interventions with Limited Evidence (General Surgery) (IP-AA-011)", - "evidence_based_interventions_gi_surgical": "Interventions with Limited Evidence (GI Surgical) (IP-AA-012)", - "evidence_based_interventions_msk": "Interventions with Limited Evidence (MSK) (IP-AA-013)", - "evidence_based_interventions_urology": "Interventions with Limited Evidence (Urology) (IP-AA-014)", - "evidence_based_interventions_vascular_varicose_veins": "Interventions with Limited Evidence (Vascular Varicose Veins) (IP-AA-015)", - "excess_beddays_elective": "Excess Beddays (Elective Admissions) (IP-EF-018)", - "excess_beddays_emergency": "Excess Beddays (Emergency Admissions) (IP-EF-019)", - "falls_related_admissions": "Falls Related Admissions (IP-AA-016)", - "followup_reduction_adult_non-surgical": "Outpatient Followup Appointment Reduction (Adult, Non-Surgical) (OP-AA-005)", - "followup_reduction_adult_surgical": "Outpatient Followup Appointment Reduction (Adult, Surgical) (OP-AA-006)", - "followup_reduction_child_non-surgical": "Outpatient Followup Appointment Reduction (Children, Non-Surgical) (OP-AA-007)", - "followup_reduction_child_surgical": "Outpatient Followup Appointment Reduction (Children, Surgical) (OP-AA-008)", - "frail_elderly_high": "Older People with Frailty Admissions (High Frailty Risk) (IP-AA-017)", - "frail_elderly_intermediate": "Older People with Frailty Admissions (Intermediate Frailty Risk) (IP-AA-018)", - "frequent_attenders_adult_ambulance": "A&E Frequent Attenders (Adult, Ambulance Conveyed) (AE-AA-005)", - "frequent_attenders_adult_walk-in": "A&E Frequent Attenders (Adult, Walk-in) (AE-AA-006)", - "frequent_attenders_child_ambulance": "A&E Frequent Attenders (Children, Ambulance Conveyed) (AE-AA-007)", - "frequent_attenders_child_walk-in": "A&E Frequent Attenders (Children, Walk-in) (AE-AA-008)", - "general_los_reduction_elective": "General LoS Reduction: Elective Admissions (IP-EF-020)", - "general_los_reduction_emergency": "General LoS Reduction: Emergency Admissions (IP-EF-021)", - "gp_referred_first_attendance_reduction_adult_non-surgical": "Outpatient GP Referred First Attendance Reduction (Adult, Non-Surgical) (OP-AA-009)", - "gp_referred_first_attendance_reduction_adult_surgical": "Outpatient GP Referred First Attendance Reduction (Adult, Surgical) (OP-AA-010)", - "gp_referred_first_attendance_reduction_child_non-surgical": "Outpatient GP Referred First Attendance Reduction (Children, Non-Surgical) (OP-AA-011)", - "gp_referred_first_attendance_reduction_child_surgical": "Outpatient GP Referred First Attendance Reduction (Children, Surgical) (OP-AA-012)", - "intentional_self_harm": "Intentional Self Harm Admissions (IP-AA-019)", - "left_before_seen_adult_ambulance": "A&E Patients Left Before Being Treated (Adult, Ambulance Conveyed) (AE-AA-009)", - "left_before_seen_adult_walk-in": "A&E Patients Left Before Being Treated (Adult, Walk-in) (AE-AA-010)", - "left_before_seen_child_ambulance": "A&E Patients Left Before Being Treated (Children, Ambulance Conveyed) (AE-AA-011)", - "left_before_seen_child_walk-in": "A&E Patients Left Before Being Treated (Children, Walk-in) (AE-AA-012)", - "low_cost_discharged_adult_ambulance": "A&E Low Cost Discharged Attendances (Adult, Ambulance Conveyed) (AE-AA-013)", - "low_cost_discharged_adult_walk-in": "A&E Low Cost Discharged Attendances (Adult, Walk-in) (AE-AA-014)", - "low_cost_discharged_child_ambulance": "A&E Low Cost Discharged Attendances (Children, Ambulance Conveyed) (AE-AA-015)", - "low_cost_discharged_child_walk-in": "A&E Low Cost Discharged Attendances (Children, Walk-in) (AE-AA-016)", - "medically_unexplained_related_admissions": "Medically Unexplained Symptoms Admissions (IP-AA-020)", - "medicines_related_admissions_explicit": "Medicines Related Admissions (Explicit) (IP-AA-021)", - "medicines_related_admissions_implicit_anti-diabetics": "Medicines Related Admissions (Implicit - Anti-Diabetics) (IP-AA-022)", - "medicines_related_admissions_implicit_benzodiasepines": "Medicines Related Admissions (Implicit - Benzodiazepines) (IP-AA-023)", - "medicines_related_admissions_implicit_diurectics": "Medicines Related Admissions (Implicit - Diuretics) (IP-AA-024)", - "medicines_related_admissions_implicit_nsaids": "Medicines Related Admissions (Implicit - NSAIDs) (IP-AA-025)", - "obesity_related_admissions": "Obesity Related Admissions (IP-AA-026)", - "pre-op_los_1-day": "Pre-op Length of Stay of 1 day (IP-EF-022)", - "pre-op_los_2-day": "Pre-op Length of Stay of 2 days (IP-EF-023)", - "raid_ae": "Mental Health Admissions via Emergency Department (IP-AA-027)", - "raid_ip": "Admissions with Mental Health Comorbidities (IP-EF-024)", - "readmission_within_28_days": "Emergency Readmissions Within 28 Days (IP-AA-028)", - "same_day_emergency_care_low": "Same Day Emergency Care (Low Potential) (IP-EF-028)", - "same_day_emergency_care_moderate": "Same Day Emergency Care (Moderate Potential) (IP-EF-029)", - "same_day_emergency_care_high": "Same Day Emergency Care (High Potential) (IP-EF-030)", - "same_day_emergency_care_very_high": "Same Day Emergency Care (Very High Potential) (IP-EF-031)", - "smoking": "Smoking Related Admissions (IP-AA-029)", - "stroke_early_supported_discharge": "Stroke Early Supported Discharge (IP-EF-025)", - "virtual_wards_activity_avoidance_ari": "Virtual Wards Admission Avoidance (Acute Respiratory Infection) (IP-AA-030)", - "virtual_wards_activity_avoidance_heart_failure": "Virtual Wards Admission Avoidance (Heart Failure) (IP-AA-031)", - "virtual_wards_efficiencies_ari": "Virtual Wards LoS Reduction (Acute Respiratory Infection) (IP-EF-026)", - "virtual_wards_efficiencies_heart_failure": "Virtual Wards LoS Reduction (Heart Failure) (IP-EF-027)", - "zero_los_no_procedure_adult": "Admission With No Overnight Stay and No Procedure (Adults) (IP-AA-032)", - "zero_los_no_procedure_child": "Admission With No Overnight Stay and No Procedure (Children) (IP-AA-033)" -} diff --git a/inst/pod_measures.yml b/inst/pod_measures.yml deleted file mode 100644 index d2dc005..0000000 --- a/inst/pod_measures.yml +++ /dev/null @@ -1,79 +0,0 @@ -pod_measures: - ip: - name: "Inpatient" - pods: - ip_non-elective_admission: - name: "Non-Elective Admission" - measures: - - admissions - - beddays - ip_elective_admission: - name: "Elective Admission" - measures: - - admissions - - beddays - ip_elective_daycase: - name: "Daycase Admission" - measures: - - admissions - - beddays - ip_maternity_admission: - name: "Maternity Admission" - measures: - - admissions - - beddays - ip_regular_day_attender: - name: "Regular Day Attender Admission" - measures: - - admissions - - beddays - ip_regular_night_attender: - name: "Regular Night Attender Admission" - measures: - - admissions - - beddays - op: - name: "Outpatient" - pods: - op_first: - name: "First Outpatient Attendance" - measures: - - attendances - - tele_attendances - op_follow-up: - name: "Follow-up Outpatient Attendance" - measures: - - attendances - - tele_attendances - op_procedure: - name: "Outpatient Procedure" - measures: - - attendances - aae: - name: "A&E" - pods: - aae_type-01: - name: "Type 1 Department" - measures: - - walk-in - - ambulance - aae_type-02: - name: "Type 2 Department" - measures: - - walk-in - - ambulance - aae_type-03: - name: "Type 3 Department" - measures: - - walk-in - - ambulance - aae_type-04: - name: "Type 4 Department" - measures: - - walk-in - - ambulance - aae_type-05: - name: "Type 5 Department (SDEC)" - measures: - - walk-in - - ambulance diff --git a/man/convert_activity_type.Rd b/man/convert_activity_type.Rd new file mode 100644 index 0000000..8da2073 --- /dev/null +++ b/man/convert_activity_type.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\name{convert_activity_type} +\alias{convert_activity_type} +\title{Converts "In|Outpatients", "A&E" strings to "ip", "op" and "aae"} +\usage{ +convert_activity_type(x) +} +\arguments{ +\item{x}{A character vector} +} +\value{ +A character vector +} +\description{ +Converts "In|Outpatients", "A&E" strings to "ip", "op" and "aae" +} +\keyword{internal} diff --git a/man/get_detailed_pods.Rd b/man/get_detailed_pods.Rd index a28d98a..db13f59 100644 --- a/man/get_detailed_pods.Rd +++ b/man/get_detailed_pods.Rd @@ -5,17 +5,9 @@ \alias{get_principal_pods} \title{Prepare a lookup table with activity type labels and PoD labels for each PoD} \usage{ -get_detailed_pods(use_local = FALSE) +get_detailed_pods() -get_principal_pods(use_local = FALSE) -} -\arguments{ -\item{use_local}{logical. Whether to use a local file (internal to the -reskit package) or attempt to pull the lookup file from GitHub. Default is -\code{FALSE}, meaning it will use the GitHub route. If you want to always use a -local file (for example, for fully offline working), you can set the -\code{reskit.local.lookups} option to \code{TRUE} using -\code{options(reskit.local.lookups = TRUE)} or \code{withr::with_options()}} +get_principal_pods() } \value{ A tibble diff --git a/man/get_github_app_installation_id.Rd b/man/get_github_app_installation_id.Rd new file mode 100644 index 0000000..8300b87 --- /dev/null +++ b/man/get_github_app_installation_id.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_github_file.R +\name{get_github_app_installation_id} +\alias{get_github_app_installation_id} +\title{Returns the installation ID for the reskit GitHub app} +\usage{ +get_github_app_installation_id(jwt = get_github_jwt()) +} +\arguments{ +\item{jwt}{JWT for the app. Defaults to the output of \code{get_github_jwt()}.} +} +\value{ +An installation ID as an integer +} +\description{ +The envvars "RESKIT_GH_APP_ID" and "RESKIT_GH_APP_PRIVATE_KEY" must +be set. The former as a string, the latter as a path to a PEM key. +} +\keyword{internal} diff --git a/man/get_github_jwt.Rd b/man/get_github_jwt.Rd new file mode 100644 index 0000000..fcca969 --- /dev/null +++ b/man/get_github_jwt.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_github_file.R +\name{get_github_jwt} +\alias{get_github_jwt} +\title{Returns a GitHub JWT for the reskit authentication app} +\usage{ +get_github_jwt() +} +\value{ +A JSON Web Token (JWT) as a string +} +\description{ +The envvars "RESKIT_GH_APP_ID" and "RESKIT_GH_APP_PRIVATE_KEY" must +be set. The former as a string, the latter as a path to a PEM key. +} +\keyword{internal} diff --git a/man/get_github_pat.Rd b/man/get_github_pat.Rd new file mode 100644 index 0000000..fc58e77 --- /dev/null +++ b/man/get_github_pat.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_github_file.R +\name{get_github_pat} +\alias{get_github_pat} +\title{Return a GitHub access token} +\usage{ +get_github_pat() +} +\value{ +A personal access token (PAT) with permissions granted to the app +} +\description{ +If the envvar "RESKIT_GH_APP_PAT" is set, this will be used as the token. +Otherwise, the envvars "RESKIT_GH_APP_ID" and "RESKIT_GH_APP_PRIVATE_KEY" +must be set. The former as a string, the latter as a path to a PEM key. +} +\keyword{internal} diff --git a/man/get_github_pat_via_api.Rd b/man/get_github_pat_via_api.Rd new file mode 100644 index 0000000..1ff2538 --- /dev/null +++ b/man/get_github_pat_via_api.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_github_file.R +\name{get_github_pat_via_api} +\alias{get_github_pat_via_api} +\title{Return a GitHub PAT via the API using the reskit authentication GitHub app} +\usage{ +get_github_pat_via_api() +} +\value{ +An access token (PAT) as a string +} +\description{ +The envvars "RESKIT_GH_APP_ID" and "RESKIT_GH_APP_PRIVATE_KEY" must +be set. The former as a string, the latter as a path to a PEM key. +} +\keyword{internal} diff --git a/man/get_outputs_gh_file.Rd b/man/get_outputs_gh_file.Rd index 807b366..2f58760 100644 --- a/man/get_outputs_gh_file.Rd +++ b/man/get_outputs_gh_file.Rd @@ -4,16 +4,10 @@ \alias{get_outputs_gh_file} \title{Read in a file from the NHP Outputs app GitHub repo} \usage{ -get_outputs_gh_file(file, folder = "inst") +get_outputs_gh_file(...) } \arguments{ -\item{file}{string. The name of the file to read in} - -\item{folder}{string. The folder where the file is located. \code{"inst"} by -default. Set to \code{""} to use the root folder of the repo.} -} -\value{ -The file contents as a stream, to be passed to a reader function +\item{...}{Pass the name of the file in via \code{...}} } \description{ Read in a file from the NHP Outputs app GitHub repo diff --git a/man/get_su_gh_file.Rd b/man/get_su_gh_file.Rd new file mode 100644 index 0000000..93b0589 --- /dev/null +++ b/man/get_su_gh_file.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_github_file.R +\name{get_su_gh_file} +\alias{get_su_gh_file} +\title{Read in a file from a Strategy Unit GitHub repo} +\usage{ +get_su_gh_file(repo, folder, file, pat = get_github_pat()) +} +\arguments{ +\item{repo}{string. The name of the repository in which to find the file} + +\item{folder}{string. The folder where the file is located. Set to \code{""} to +use the root folder of the repo.} + +\item{file}{string. The name of the file to read in} + +\item{pat}{A GitHub Personal Access Token. Generated by \link{get_github_pat} by +default, via a custom Strategy Unit app, but you might pass in a personal +token if you prefer or if that pipeline is not working. If you have a token +stored as an environment variable called "RESKIT_GH_APP_PAT", this will be +be used, saving the need to make any API calls.} +} +\value{ +The file contents as a stream, to be passed to a reader function +} +\description{ +Read in a file from a Strategy Unit GitHub repo +} +\keyword{internal} diff --git a/man/get_tpma_label_lookup.Rd b/man/get_tpma_label_lookup.Rd index f83148e..dbba986 100644 --- a/man/get_tpma_label_lookup.Rd +++ b/man/get_tpma_label_lookup.Rd @@ -4,19 +4,11 @@ \alias{get_tpma_label_lookup} \title{Prepare a lookup table for all current TPMAs} \usage{ -get_tpma_label_lookup(use_local = FALSE) -} -\arguments{ -\item{use_local}{logical. Whether to use a local file (internal to the -reskit package) or attempt to pull the lookup file from GitHub. Default is -\code{FALSE}, meaning it will use the GitHub route. If you want to always use a -local file (for example, for fully offline working), you can set the -\code{reskit.local.lookups} option to \code{TRUE} using -\code{options(reskit.local.lookups = TRUE)} or \code{withr::with_options()}} +get_tpma_label_lookup() } \value{ -A 4-column tibble, with columns \code{activity_type}, \code{change_factor}, -\code{strategy} and \code{tpma_label} +A 4-column tibble, with columns \code{strategy}, \code{activity_type}, +\code{change_factor} and \code{tpma_label} } \description{ Prepare a lookup table for all current TPMAs diff --git a/man/get_tpmas_gh_file.Rd b/man/get_tpmas_gh_file.Rd index bd27243..dc733ed 100644 --- a/man/get_tpmas_gh_file.Rd +++ b/man/get_tpmas_gh_file.Rd @@ -4,16 +4,10 @@ \alias{get_tpmas_gh_file} \title{Read in a file from the TPMAs GitHub repo} \usage{ -get_tpmas_gh_file(file, folder = "reference") +get_tpmas_gh_file(...) } \arguments{ -\item{file}{string. The name of the file to read in} - -\item{folder}{string. The folder where the file is located. \code{"reference"} by -default. Set to \code{""} to use the root folder of the repo.} -} -\value{ -The file contents as a stream, to be passed to a reader function +\item{...}{Pass the name of the file in via \code{...}} } \description{ Read in a file from the TPMAs GitHub repo