Skip to content

Commit

Permalink
Add AB, ON hospital/ICU admissions and PT-level deaths
Browse files Browse the repository at this point in the history
- hosp_admissions and icu_admissions (ccodwg/CovidTimelineCanada#111)
- PT-level deaths time series for later use (ccodwg/CovidTimelineCanada#120)
  • Loading branch information
jeanpaulrsoucy committed Oct 11, 2023
1 parent c2dc865 commit 5df287a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
26 changes: 26 additions & 0 deletions R/assemble_final_datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,14 @@ assemble_final_datasets <- function() {

# hosp_admissions dataset

## ab
hosp_admissions_ab <- read_d("raw_data/active_ts/ab/ab_hosp_admissions_pt_ts.csv") |>
dplyr::transmute(
.data$name,
.data$region,
.data$date,
value = cumsum(.data$value_daily))

## mb
mb1 <- read_d("raw_data/static/mb/mb_hosp_admissions_pt_ts.csv") # up to 2022-03-19
mb2 <- read_d("raw_data/reports/mb/mb_weekly_report.csv") %>%
Expand All @@ -640,6 +648,16 @@ assemble_final_datasets <- function() {
hosp_admissions_mb <- append_daily_d(hosp_admissions_mb, mb3)
rm(mb1, mb2, mb3) # clean up

## on
hosp_admissions_on <- read_d("raw_data/reports/on/on_pho_outcomes.csv") |>
dplyr::filter(.data$outcome_weekly_type == "COVID-19 hospitalizations" & is.na(.data$sub_region_1)) |>
report_pluck("hosp_admissions", "outcome_weekly_value", "value_daily", "pt") |>
dplyr::transmute(
.data$name,
.data$region,
.data$date,
value = cumsum(.data$value_daily))

## qc
hosp_admissions_qc <- read_d("raw_data/active_ts/qc/qc_hosp_admissions_pt_ts.csv") |>
date_shift(1)
Expand All @@ -656,6 +674,14 @@ assemble_final_datasets <- function() {

# icu_admissions dataset

## ab
icu_admissions_ab <- read_d("raw_data/active_ts/ab/ab_icu_admissions_pt_ts.csv") |>
dplyr::transmute(
.data$name,
.data$region,
.data$date,
value = cumsum(.data$value_daily))

## mb
mb1 <- read_d("raw_data/static/mb/mb_icu_admissions_pt_ts.csv") # up to 2022-03-19
mb2 <- read_d("raw_data/reports/mb/mb_weekly_report.csv") %>%
Expand Down
2 changes: 2 additions & 0 deletions R/dl_datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dl_datasets <- function() {
# ab
"3e4fd9ff-48f9-4de1-a48a-97fd33b68337", NA, NA, # c
"2a11bbcc-7b43-47d1-952d-437cdc9b2ffb", NA, NA, # c, d
"e477791b-bced-4b20-b40b-f8d7629c9b69", NA, NA, # h_a, i_a
# bc
# can
"314c507d-7e48-476e-937b-965499f51e8e", NA, NA, # c, d
Expand All @@ -37,6 +38,7 @@ dl_datasets <- function() {
# nt
# nu
# on
"75dd0545-f728-4af5-8185-4269596785ef", NA, NA, # d (pt)
"4b214c24-8542-4d26-a850-b58fc4ef6a30", NA, NA, # h, i
# pe
# qc
Expand Down
34 changes: 34 additions & 0 deletions R/update_raw_datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ update_active_ts <- function(ds) {
# active_ts - death data
cat("Updating active_ts: death data", fill = TRUE)

## ab
Covid19CanadaDataProcess::process_dataset(
uuid = "e477791b-bced-4b20-b40b-f8d7629c9b69",
val = "mortality",
fmt = "prov_ts",
ds = load_ds(ds, "e477791b-bced-4b20-b40b-f8d7629c9b69")) %>%
add_name_col("deaths") %>%
write_ts("active_ts", "ab", "deaths")

## can
Covid19CanadaDataProcess::process_dataset(
uuid = "314c507d-7e48-476e-937b-965499f51e8e",
Expand All @@ -93,6 +102,15 @@ update_active_ts <- function(ds) {
add_name_col("deaths") %>%
write_ts("active_ts", "can", "deaths")

## on
Covid19CanadaDataProcess::process_dataset(
uuid = "75dd0545-f728-4af5-8185-4269596785ef",
val = "mortality",
fmt = "prov_ts",
ds = load_ds(ds, "75dd0545-f728-4af5-8185-4269596785ef")) %>%
add_name_col("deaths") %>%
write_ts("active_ts", "on", "deaths")

## qc
Covid19CanadaDataProcess::process_dataset(
uuid = "3b93b663-4b3f-43b4-a23d-cbf6d149d2c5",
Expand Down Expand Up @@ -159,6 +177,14 @@ update_active_ts <- function(ds) {
# active_ts - hosp_admissions data
cat("Updating active_ts: hosp admissions data", fill = TRUE)

## ab
Covid19CanadaDataProcess::process_dataset(
uuid = "e477791b-bced-4b20-b40b-f8d7629c9b69",
val = "hosp_admissions",
fmt = "prov_ts",
ds = load_ds(ds, "e477791b-bced-4b20-b40b-f8d7629c9b69")) %>%
write_ts("active_ts", "ab", "hosp_admissions")

## qc
Covid19CanadaDataProcess::process_dataset(
uuid = "3b93b663-4b3f-43b4-a23d-cbf6d149d2c5",
Expand All @@ -170,6 +196,14 @@ update_active_ts <- function(ds) {
# active_ts - icu_admissions data
cat("Updating active_ts: icu admissions data", fill = TRUE)

## ab
Covid19CanadaDataProcess::process_dataset(
uuid = "e477791b-bced-4b20-b40b-f8d7629c9b69",
val = "icu_admissions",
fmt = "prov_ts",
ds = load_ds(ds, "e477791b-bced-4b20-b40b-f8d7629c9b69")) %>%
write_ts("active_ts", "ab", "icu_admissions")

## qc
Covid19CanadaDataProcess::process_dataset(
uuid = "3b93b663-4b3f-43b4-a23d-cbf6d149d2c5",
Expand Down

0 comments on commit 5df287a

Please sign in to comment.