Skip to contents

R6 class storing health statistics for a list of hospital health units.

R6 class storing health statistics for a list of hospital health units.

Details

This R6 class is designed to store bed occupancy statistics for multiple hospitals. This class can be used to plot summary statistics and create shiny UI/server objects.

Super class

HealthDataScotland::health_unitgrp -> hospital_grp

Methods

Inherited methods


Method plot_types()

Get character vector of plot types for hospital grp.

Usage

hospital_grp$plot_types()


Method plot()

Plot hospital grp.

Usage

hospital_grp$plot(type, ...)

Arguments

type

(character(1))
Character specifying plot type. See plot_types for options.

...

Passed to plot functions.

Examples

x <- example_hospital_grp_unit()
x[["plot"]](type = "hospital_bar")


Method plot_data()

Generate plot data for hospital grp.

Usage

hospital_grp$plot_data(type, ...)

Arguments

type

(character(1))
Character specifying plot type. See plot_types for options.

...

Passed to plot data functions.

Examples

x <- example_hospital_grp_unit()
x[["plot_data"]](type = "hospital_bar")


Method plot_info()

Get plot info for hospital grp.

Usage

hospital_grp$plot_info(type, ...)

Arguments

type

(character(1))
Character specifying plot type. See plot_types for options.

...

Passed to plot info functions.

Examples

x <- example_hospital_grp_unit()
x[["plot_info"]](type = "hospital_bar")


Method ui()

Create UI for hospital group object.

Usage

hospital_grp$ui(...)

Arguments

...

Passed to functions.


Method server()

Create server for hospital group object.

Usage

hospital_grp$server()


Method clone()

The objects of this class are cloneable with this method.

Usage

hospital_grp$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

gps <- lapply(c("A101H", "A201H"), example_hospital_unit)
x <- hospital_grp[["new"]](gps, .id = "gp")
x[["ID"]]()
#> [1] "gp"
x[["IDs"]]()
#> [1] "A101H" "A201H"
x[["titles"]]()
#> [1] "Arran War Memorial Hospital" "Ailsa Hospital"             
x[["metadata"]]()
#> # A tibble: 2 × 16
#>   datasetID          ID    HospitalName AddressLine1 AddressLine2 AddressLine2QF
#>   <chr>              <chr> <chr>        <chr>        <chr>        <chr>         
#> 1 c698f450-eeed-41a… A101H Arran War M… Lamlash      Isle of Arr… NA            
#> 2 c698f450-eeed-41a… A201H Ailsa Hospi… Dalmellingt… Ayr          NA            
#> # ℹ 10 more variables: AddressLine3 <chr>, AddressLine3QF <chr>,
#> #   AddressLine4 <chr>, AddressLine4QF <chr>, Postcode <chr>, HBName <chr>,
#> #   HSCP <chr>, CouncilArea <chr>, IntermediateZone <chr>, DataZone <chr>
x[["data"]]()
#> [[1]]
#> <hospital>
#>   Inherits from: <health_unit>
#>   Public:
#>     .data: tbl_df, tbl, data.frame
#>     .metadata: tbl_df, tbl, data.frame
#>     ID: function () 
#>     address: function () 
#>     clone: function (deep = FALSE) 
#>     combine_data: function () 
#>     data: function () 
#>     datatable: function (type, ...) 
#>     health_board: function () 
#>     initialize: function (.metadata, .data) 
#>     metadata: function () 
#>     plot: function (type, ...) 
#>     plot_data: function (type, ...) 
#>     plot_info: function (type, ...) 
#>     plot_types: function () 
#>     popup_modal: function (ns) 
#>     server: function () 
#>     summary: function (type, ...) 
#>     summary_info: function (type, ...) 
#>     summary_types: function () 
#>     title: function () 
#>     ui: function (ns) 
#>     validate: function () 
#>   Private:
#>     annual_cols: function () 
#>     daily_cols: function () 
#>     required_data_cols: function () 
#>     required_metadata_cols: function () 
#>     specialty_choices: function () 
#>     specialty_line: function (...) 
#>     specialty_line_data: function (data_type = c("annual", "daily"), specialties = "All Specialties") 
#>     specialty_summary: function (data_type = c("annual", "daily"), specialties = private[["specialty_choices"]]()) 
#>     specialty_summary_info: function () 
#>     title_col: function () 
#> 
#> [[2]]
#> <hospital>
#>   Inherits from: <health_unit>
#>   Public:
#>     .data: tbl_df, tbl, data.frame
#>     .metadata: tbl_df, tbl, data.frame
#>     ID: function () 
#>     address: function () 
#>     clone: function (deep = FALSE) 
#>     combine_data: function () 
#>     data: function () 
#>     datatable: function (type, ...) 
#>     health_board: function () 
#>     initialize: function (.metadata, .data) 
#>     metadata: function () 
#>     plot: function (type, ...) 
#>     plot_data: function (type, ...) 
#>     plot_info: function (type, ...) 
#>     plot_types: function () 
#>     popup_modal: function (ns) 
#>     server: function () 
#>     summary: function (type, ...) 
#>     summary_info: function (type, ...) 
#>     summary_types: function () 
#>     title: function () 
#>     ui: function (ns) 
#>     validate: function () 
#>   Private:
#>     annual_cols: function () 
#>     daily_cols: function () 
#>     required_data_cols: function () 
#>     required_metadata_cols: function () 
#>     specialty_choices: function () 
#>     specialty_line: function (...) 
#>     specialty_line_data: function (data_type = c("annual", "daily"), specialties = "All Specialties") 
#>     specialty_summary: function (data_type = c("annual", "daily"), specialties = private[["specialty_choices"]]()) 
#>     specialty_summary_info: function () 
#>     title_col: function () 
#> 
x[["subset"]](id = "A201H")
#> <hospital_grp>
#>   Inherits from: <health_unitgrp>
#>   Public:
#>     .data: list
#>     .id: gp
#>     ID: function () 
#>     IDs: function () 
#>     addresses: function () 
#>     clone: function (deep = FALSE) 
#>     combine_data: function () 
#>     data: function () 
#>     datatable: function (type, ns = NULL, ...) 
#>     download_handler: function () 
#>     health_boards: function () 
#>     health_unit: function (id) 
#>     initialize: function (.data, .id) 
#>     metadata: function () 
#>     plot: function (type, ...) 
#>     plot_data: function (type, ...) 
#>     plot_info: function (type, ...) 
#>     plot_types: function () 
#>     server: function () 
#>     subset: function (id) 
#>     summary: function (type, ...) 
#>     summary_info: function (type, ...) 
#>     summary_types: function () 
#>     titles: function () 
#>     ui: function (...) 
#>     validate: function () 
#>   Private:
#>     bar_data: function (x, ...) 
#>     bar_echart: function (x, group = "HBName", x_axis = "", y_axis = "PercentageOccupancy") 
#>     dt_btn: function (ns) 
#>     health_board_bar: function (...) 
#>     health_board_bar_data: function (specialties = "All Specialties", health_boards = private[["health_board_choices"]]()) 
#>     health_board_bar_info: function () 
#>     health_board_choices: function () 
#>     health_board_data: function (specialties, health_boards) 
#>     health_board_trend: function (...) 
#>     health_board_trend_data: function (specialties = "All Specialties", health_boards = private[["health_board_choices"]]()) 
#>     health_board_trend_info: function () 
#>     hospital_bar: function (...) 
#>     hospital_bar_data: function (specialties = private[["specialty_choices"]](), hospitals = private[["unit_choices"]]()) 
#>     hospital_bar_info: function () 
#>     hospital_data: function (specialties, hospitals) 
#>     hospital_trend: function (...) 
#>     hospital_trend_data: function (specialties = "All Specialties", hospitals = private[["unit_choices"]]()) 
#>     hospital_trend_info: function () 
#>     id_name_labels: function (x, name) 
#>     id_name_selection: function () 
#>     lookup: function (...) 
#>     lookup_info: function (...) 
#>     map_combine: function (func, nms = self[["IDs"]](), id = "ID", ...) 
#>     national_trend: function (...) 
#>     national_trend_data: function (specialties = "All Specialties") 
#>     national_trend_info: function () 
#>     req_plot_cols: function () 
#>     specialty_choices: function () 
#>     summarise_percentage_occupancy: function (x, groups = colnames(x)) 
#>     trend_data: function (x, ...) 
#>     trend_echart: function (x) 
#>     unit_choices: function () 
x[["plot"]](type = "hospital_bar")
x[["plot_data"]](type = "hospital_bar") #> # A tibble: 4 × 8 #> # Groups: FinancialYear [2] #> FinancialYear ID HBName `All Specialties` `Community Grouping` #> <chr> <chr> <chr> <dbl> <dbl> #> 1 2022/23 A101H - Arran War… S0800… 77.4 77.4 #> 2 2022/23 A201H - Ailsa Hos… S0800… 77.9 NA #> 3 2023/24 A101H - Arran War… S0800… 68.5 68.5 #> 4 2023/24 A201H - Ailsa Hos… S0800… 72.6 NA #> # ℹ 3 more variables: `GP Other than Obstetrics` <dbl>, #> # `Mental Health Grouping` <dbl>, `Psychiatry of Old Age` <dbl> x[["plot_info"]](type = "hospital_bar") #> [1] "This bar chart shows the average hospital bed occupancy (y-axis)\n per hospital (x-axis) for each specialty (colour). Seetings can be\n used to show data for different specialties (default is all\n specialties) and hospitals." x[["summary"]](type = "lookup") #> Title ID Address #> 1 Arran War Memorial Hospital A101H Lamlash, Isle of Arran, KA278LF #> 2 Ailsa Hospital A201H Dalmellington Road, Ayr, KA6 6AB #> Health board #> 1 S08000015 #> 2 S08000015 x[["summary_info"]](type = "lookup") #> [1] "This lookup table presents data for all available hospitals\n in the data set. This table can be searched, filtered and\n the 'Plot' column allows the user to view statistics for a\n selected hospital." if (FALSE) { # \dontrun{ x[["ui"]]() x[["server"]]() } # } ## ------------------------------------------------ ## Method `hospital_grp$plot` ## ------------------------------------------------ x <- example_hospital_grp_unit() x[["plot"]](type = "hospital_bar")
## ------------------------------------------------ ## Method `hospital_grp$plot_data` ## ------------------------------------------------ x <- example_hospital_grp_unit() x[["plot_data"]](type = "hospital_bar") #> # A tibble: 4 × 8 #> # Groups: FinancialYear [2] #> FinancialYear ID HBName `All Specialties` `Community Grouping` #> <chr> <chr> <chr> <dbl> <dbl> #> 1 2022/23 A101H - Arran War… S0800… 77.4 77.4 #> 2 2022/23 A201H - Ailsa Hos… S0800… 77.9 NA #> 3 2023/24 A101H - Arran War… S0800… 68.5 68.5 #> 4 2023/24 A201H - Ailsa Hos… S0800… 72.6 NA #> # ℹ 3 more variables: `GP Other than Obstetrics` <dbl>, #> # `Mental Health Grouping` <dbl>, `Psychiatry of Old Age` <dbl> ## ------------------------------------------------ ## Method `hospital_grp$plot_info` ## ------------------------------------------------ x <- example_hospital_grp_unit() x[["plot_info"]](type = "hospital_bar") #> [1] "This bar chart shows the average hospital bed occupancy (y-axis)\n per hospital (x-axis) for each specialty (colour). Seetings can be\n used to show data for different specialties (default is all\n specialties) and hospitals."