-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathget_source_extract_path.R
More file actions
91 lines (84 loc) · 2.92 KB
/
Copy pathget_source_extract_path.R
File metadata and controls
91 lines (84 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#' Denodo file output path
#' @export
denodo_output_path <- function() {
"/sdl_byoc/byoc/output"
}
#' Source Extract File Path
#'
#' @description Get the file path for Source Extract for given extract and year
#'
#' @param year Year of extract
#' @param ... additional arguments passed to [get_file_path()]
#' @param type Name of clean source extract
#'
#' @return Path to clean source extract containing data for each dataset
#' @export
#'
#' @family extract file paths
get_source_extract_path <- function(year,
type = c(
"acute",
"ae",
"at",
"ch",
"client",
"cmh",
"dd",
"deaths",
"dn",
"gp_ooh",
"hc",
"homelessness",
"maternity",
"mh",
"outpatients",
"pis",
"sds"
),
BYOC_MODE,
...) {
if (year %in% type) {
cli::cli_abort("{.val {year}} was supplied to the {.arg year} argument.")
}
year <- check_year_format(year)
type <- match.arg(type)
if (!check_year_valid(year, type)) {
return(get_dummy_boxi_extract_path(BYOC_MODE = BYOC_MODE))
}
file_name <- dplyr::case_match(
type,
"acute" ~ "anon-acute_for_source",
"ae" ~ "anon-a_and_e_for_source",
"at" ~ "anon-alarms-telecare-for-source",
"ch" ~ "anon-care_home_for_source",
"cmh" ~ "anon-cmh_for_source",
"client" ~ "anon-client_for_source",
"dd" ~ "anon-delayed_discharge_for_source",
"deaths" ~ "anon-deaths_for_source",
"dn" ~ "anon-district_nursing_for_source",
"gp_ooh" ~ "anon-gp_ooh_for_source",
"hc" ~ "anon-home_care_for_source",
"homelessness" ~ "anon-homelessness_for_source",
"maternity" ~ "anon-maternity_for_source",
"mh" ~ "anon-mental_health_for_source",
"dd" ~ "anon-dd_for_source",
"outpatients" ~ "anon-outpatients_for_source",
"pis" ~ "anon-prescribing_file_for_source",
"sds" ~ "anon-sds-for-source"
) %>%
stringr::str_glue("-20{year}.parquet")
if (BYOC_MODE) {
source_extract_path <- file.path(
directory = denodo_output_path(),
# todo: waiting to be finalised
file_name = file_name
)
} else {
source_extract_path <- get_file_path(
directory = get_year_dir(year, BYOC_MODE = BYOC_MODE),
file_name = file_name,
...
)
}
return(source_extract_path)
}