R6 class storing health statistics for a single hospital.
hospital.Rd
R6 class storing health statistics for a single hospital.
R6 class storing health statistics for a single hospital.
Details
This R6 class is designed to store bed occupancy statistics for a single hospital location. This class can be used to plot summary statistics and create shiny UI/server objects.
Super class
HealthDataScotland::health_unit
-> hospital
Methods
Inherited methods
HealthDataScotland::health_unit$ID()
HealthDataScotland::health_unit$address()
HealthDataScotland::health_unit$combine_data()
HealthDataScotland::health_unit$data()
HealthDataScotland::health_unit$health_board()
HealthDataScotland::health_unit$initialize()
HealthDataScotland::health_unit$metadata()
HealthDataScotland::health_unit$popup_modal()
HealthDataScotland::health_unit$title()
HealthDataScotland::health_unit$validate()
Method plot()
Plot hospital unit.
Arguments
type
(character(1))
Character specifying plot type. Seeavailable_plots
for options....
Passed to plot functions.
Examples
x <- example_hospital_unit()
x[["plot"]](type = "specialty_line", data_type = "annual")
Method plot_data()
Generate plot data for hospital unit.
Arguments
type
(character(1))
Character specifying plot type. Seeavailable_plots
for options....
Passed to plot data functions.
Examples
x <- example_hospital_unit()
x[["plot_data"]](type = "specialty_line", data_type = "annual")
Method plot_info()
Get plot info for hospital unit.
Arguments
type
(character(1))
Character specifying plot type. Seeavailable_plots
for options....
Passed to plot info functions.
Examples
x <- example_hospital_unit()
x[["plot_info"]](type = "specialty_line", data_type = "annual")
Examples
library(dplyr)
meta <- HealthDataScotland::example_hospital_metadata |>
rename("ID" = "HospitalCode", "HBName" = "HealthBoard") |>
filter(.data[["ID"]] == "A101H")
data <- HealthDataScotland::example_hospital_data |>
rename("ID" = "Location") |>
filter(.data[["ID"]] == "A101H")
x <- hospital[["new"]](meta, data)
x[["ID"]]()
#> [1] "A101H"
x[["title"]]()
#> [1] "Arran War Memorial Hospital"
x[["address"]]()
#> [1] "Lamlash, Isle of Arran, KA278LF"
x[["health_board"]]()
#> [1] "S08000015"
x[["metadata"]]()
#> # A tibble: 1 × 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
#> # ℹ 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"]]()
#> # A tibble: 21 × 23
#> datasetID FinancialYear FinancialYearQF HB HBQF ID LocationQF
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 d719af13-5fb3-430… 2022/23 NA S080… NA A101H NA
#> 2 d719af13-5fb3-430… 2022/23 NA S080… NA A101H NA
#> 3 d719af13-5fb3-430… 2022/23 NA S080… NA A101H NA
#> 4 d719af13-5fb3-430… 2022/23 NA S080… NA A101H NA
#> 5 d719af13-5fb3-430… 2022/23 NA S080… NA A101H NA
#> 6 d719af13-5fb3-430… 2022/23 NA S080… NA A101H NA
#> 7 d719af13-5fb3-430… 2022/23 NA S080… NA A101H NA
#> 8 d719af13-5fb3-430… 2022/23 NA S080… NA A101H NA
#> 9 d719af13-5fb3-430… 2022/23 NA S080… NA A101H NA
#> 10 d719af13-5fb3-430… 2022/23 NA S080… NA A101H NA
#> # ℹ 11 more rows
#> # ℹ 16 more variables: Specialty <chr>, SpecialtyQF <chr>, SpecialtyName <chr>,
#> # SpecialtyNameQF <chr>, SpecialtyGrouping <chr>, SpecialtyGroupingQF <chr>,
#> # AverageAvailableStaffedBeds <dbl>, AverageAvailableStaffedBedsQF <chr>,
#> # PercentageOccupancy <dbl>, PercentageOccupancyQF <chr>,
#> # AllStaffedBeds <dbl>, AllStaffedBedsQF <chr>, AverageOccupiedBeds <dbl>,
#> # AverageOccupiedBedsQF <chr>, TotalOccupiedBeds <dbl>, …
x[["plot"]](type = "specialty_line")
x[["plot_data"]](type = "specialty_line")
#> # A tibble: 4 × 7
#> ID FinancialYear HospitalName SpecialtyName PercentageOccupancy name value
#> <chr> <chr> <chr> <chr> <dbl> <chr> <dbl>
#> 1 A101H 2022/23 Arran War M… All Specialt… 77.4 Annu… 3263
#> 2 A101H 2022/23 Arran War M… All Specialt… 77.4 Annu… 2526
#> 3 A101H 2023/24 Arran War M… All Specialt… 68.5 Annu… 3631
#> 4 A101H 2023/24 Arran War M… All Specialt… 68.5 Annu… 2488
x[["plot_info"]](type = "specialty_line")
#> [1] "This line chart shows the annual number of\n available staffed beds and the number occupied (y-axis)\n across time (x-axis). Settings can be used to show data for\n different specialties (default is all specialities)."
if (FALSE) { # \dontrun{
x[["ui"]]()
x[["server"]]()
} # }
## ------------------------------------------------
## Method `hospital$plot`
## ------------------------------------------------
x <- example_hospital_unit()
x[["plot"]](type = "specialty_line", data_type = "annual")
## ------------------------------------------------
## Method `hospital$plot_data`
## ------------------------------------------------
x <- example_hospital_unit()
x[["plot_data"]](type = "specialty_line", data_type = "annual")
#> # A tibble: 4 × 7
#> ID FinancialYear HospitalName SpecialtyName PercentageOccupancy name value
#> <chr> <chr> <chr> <chr> <dbl> <chr> <dbl>
#> 1 A101H 2022/23 Arran War M… All Specialt… 77.4 Annu… 3263
#> 2 A101H 2022/23 Arran War M… All Specialt… 77.4 Annu… 2526
#> 3 A101H 2023/24 Arran War M… All Specialt… 68.5 Annu… 3631
#> 4 A101H 2023/24 Arran War M… All Specialt… 68.5 Annu… 2488
## ------------------------------------------------
## Method `hospital$plot_info`
## ------------------------------------------------
x <- example_hospital_unit()
x[["plot_info"]](type = "specialty_line", data_type = "annual")
#> [1] "This line chart shows the annual number of\n available staffed beds and the number occupied (y-axis)\n across time (x-axis). Settings can be used to show data for\n different specialties (default is all specialities)."