22# ' @param input,output,session Internal parameters for 'shiny'.
33# ' @noRd
44app_server <- function (input , output , session ) {
5+ cache <- cachem :: cache_disk(" .cache" )
6+ inputs_data_fn <- memoise :: memoise(
7+ get_all_geo_data ,
8+ cache = cache
9+ )
10+
511 # Variables ----
612 geographies <- c(
713 " New Hospital Programme (NHP) schemes" = " nhp" ,
@@ -11,26 +17,40 @@ app_server <- function(input, output, session) {
1117 baseline_year <- Sys.getenv(" BASELINE_YEAR" ) | > as.numeric()
1218
1319 # Data ----
14- inputs_container <- get_container(
15- container_name = Sys.getenv(" AZ_CONTAINER_INPUTS" )
16- )
17- inputs_data <- get_all_geo_data(inputs_container , geographies , data_types )
20+ inputs_data <- inputs_data_fn(geographies , data_types )
1821 age_sex_data <- shiny :: reactive({
19- shiny :: req(selected_geography())
20- inputs_data [[selected_geography() ]][[" age_sex" ]] | >
22+ sg <- shiny :: req(selected_geography())
23+ inputs_data [[sg ]][[" age_sex" ]] | >
2124 prepare_age_sex_data()
2225 })
2326 diagnoses_data <- shiny :: reactive({
24- shiny :: req(selected_geography())
25- inputs_data [[selected_geography() ]][[" diagnoses" ]]
27+ sg <- shiny :: req(selected_geography())
28+ inputs_data [[sg ]][[" diagnoses" ]]
2629 })
2730 procedures_data <- shiny :: reactive({
28- shiny :: req(selected_geography())
29- inputs_data [[selected_geography() ]][[" procedures" ]]
31+ sg <- shiny :: req(selected_geography())
32+ inputs_data [[sg ]][[" procedures" ]]
3033 })
3134 rates_data <- shiny :: reactive({
32- shiny :: req(selected_geography())
33- inputs_data [[selected_geography()]][[" rates" ]]
35+ sg <- shiny :: req(selected_geography())
36+ df <- inputs_data [[sg ]][[" rates" ]]
37+
38+ national <- df | >
39+ dplyr :: filter(.data $ provider == " national" ) | >
40+ dplyr :: select(
41+ " strategy" ,
42+ " fyear" ,
43+ national_rate = " std_rate"
44+ )
45+
46+ df | >
47+ dplyr :: filter(! .data $ provider %in% c(" national" , " unknown" )) | >
48+ dplyr :: inner_join(
49+ national ,
50+ by = c(" strategy" , " fyear" )
51+ ) | >
52+ dplyr :: rename(rate = " std_rate" ) | >
53+ dplyr :: select(- " crude_rate" )
3454 })
3555 nee_data <- readr :: read_csv(
3656 app_sys(" app" , " data" , " nee_table.csv" ),
@@ -118,7 +138,8 @@ app_server <- function(input, output, session) {
118138 mod_show_strategy_text_server(
119139 " mod_show_strategy_text" ,
120140 descriptions_lookup ,
121- selected_strategy
141+ selected_strategy ,
142+ cache
122143 )
123144 mod_plot_rates_server(
124145 " mod_plot_rates" ,
0 commit comments