Skip to content

Commit

Permalink
Add NB, SK hosp/ICU admission data
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanpaulrsoucy committed Nov 2, 2023
1 parent cabb4be commit 7fe8a54
Showing 1 changed file with 64 additions and 2 deletions.
66 changes: 64 additions & 2 deletions R/assemble_final_datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,20 @@ assemble_final_datasets <- function() {
hosp_admissions_mb <- append_daily_d(hosp_admissions_mb, mb3)
rm(mb1, mb2, mb3) # clean up

## nb
hosp_admissions_nb <- read_d("raw_data/reports/nb/nb_weekly_report.csv") |>
report_pluck("hosp_admissions", "cumulative_hosp_admissions", "value", "pt")
hosp_admissions_nb <- append_daily_d(
hosp_admissions_nb,
read_d("raw_data/reports/nb/nb_weekly_report_2.csv") |>
report_pluck("hosp_admissions", "new_hospitalizations", "value_daily", "pt")
)
hosp_admissions_nb <- append_daily_d(
hosp_admissions_nb,
read_d("raw_data/reports/nb/nb_weekly_report_3.csv") |>
report_pluck("hosp_admissions", "new_hospitalizations", "value_daily", "pt")
)

## ns
ns1 <- read_d("raw_data/static/ns/ns_hosp_admissions_pt_ts.csv") |>
dplyr::mutate(value = cumsum(value_daily)) |>
Expand Down Expand Up @@ -745,6 +759,21 @@ assemble_final_datasets <- function() {
.data$date,
value = cumsum(.data$value_daily))

## sk
hosp_admissions_sk <- append_daily_d(
read_d("raw_data/reports/sk/sk_monthly_report.csv") |>
report_pluck("hosp_admissions", "new_hospitalizations", "value_daily", "pt") |>
report_recent() |>
dplyr::transmute(
.data$name,
.data$region,
.data$date,
value = cumsum(.data$value_daily)),
read_d("raw_data/reports/sk/sk_crisp_report.csv") |>
report_pluck("hosp_admissions", "new_hospitalizations", "value_daily", "pt") |>
report_recent()
)

## qc
hosp_admissions_qc <- read_d("raw_data/active_ts/qc/qc_hosp_admissions_pt_ts.csv") |>
date_shift(1)
Expand All @@ -757,10 +786,12 @@ assemble_final_datasets <- function() {
hosp_admissions_pt <- collate_datasets("hosp_admissions") %>%
dataset_format("pt")

## censor daily value for first date of several PTs: MB, NT
## censor daily value for first date of several PTs: MB, NB, NT
## cumulative values are given but time series does not start at the beginning
hosp_admissions_pt[
hosp_admissions_pt$region == "MB" & hosp_admissions_pt$date == as.Date("2020-05-16"), "value_daily"] <- NA
hosp_admissions_pt[
hosp_admissions_pt$region == "NB" & hosp_admissions_pt$date == as.Date("2022-04-02"), "value_daily"] <- NA
hosp_admissions_pt[
hosp_admissions_pt$region == "NT" & hosp_admissions_pt$date == as.Date("2021-08-25"), "value_daily"] <- NA

Expand Down Expand Up @@ -791,22 +822,53 @@ assemble_final_datasets <- function() {
icu_admissions_mb <- append_daily_d(icu_admissions_mb, mb3)
rm(mb1, mb2, mb3) # clean up

## nb
icu_admissions_nb <- read_d("raw_data/reports/nb/nb_weekly_report.csv") |>
report_pluck("icu_admissions", "cumulative_icu_admissions", "value", "pt")
icu_admissions_nb <- append_daily_d(
icu_admissions_nb,
read_d("raw_data/reports/nb/nb_weekly_report_2.csv") |>
report_pluck("icu_admissions", "new_icu", "value_daily", "pt")
)
icu_admissions_nb <- append_daily_d(
icu_admissions_nb,
read_d("raw_data/reports/nb/nb_weekly_report_3.csv") |>
report_pluck("icu_admissions", "new_icu", "value_daily", "pt")
)

## nt
icu_admissions_nt <- read_d("raw_data/static/nt/nt_icu_admissions_pt_ts.csv")

## qc
icu_admissions_qc <- read_d("raw_data/active_ts/qc/qc_icu_admissions_pt_ts.csv") |>
date_shift(1)

## sk
icu_admissions_sk <- append_daily_d(
read_d("raw_data/reports/sk/sk_monthly_report.csv") |>
report_pluck("icu_admissions", "new_icu", "value_daily", "pt") |>
report_recent() |>
dplyr::transmute(
.data$name,
.data$region,
.data$date,
value = cumsum(.data$value_daily)),
read_d("raw_data/reports/sk/sk_crisp_report.csv") |>
report_pluck("icu_admissions", "new_icu", "value_daily", "pt") |>
report_recent()
)

## collate and process final dataset
suppressWarnings(rm(icu_admissions_pt)) # if re-running manually
icu_admissions_pt <- collate_datasets("icu_admissions") %>%
dataset_format("pt")

## censor daily value for first date of several PTs: MB, NT
## censor daily value for first date of several PTs: MB, NB, NT
## cumulative values are given but time series does not start at the beginning
icu_admissions_pt[
icu_admissions_pt$region == "MB" & icu_admissions_pt$date == as.Date("2020-05-16"), "value_daily"] <- NA
icu_admissions_pt[
icu_admissions_pt$region == "NB" & icu_admissions_pt$date == as.Date("2022-04-02"), "value_daily"] <- NA
icu_admissions_pt[
icu_admissions_pt$region == "NT" & icu_admissions_pt$date == as.Date("2021-09-08"), "value_daily"] <- NA

Expand Down

0 comments on commit 7fe8a54

Please sign in to comment.