Skip to content

Commit

Permalink
Update NL deaths
Browse files Browse the repository at this point in the history
- NL deaths no longer reported at HR-level after 2023-06-21
- NL death data after this date is from PHAC dataset
- Start PHAC data on 2023-07-01 rather than 2023-06-24, because the cumulative data on 2023-06-24 would imply negative deaths since 2023-06-21
- ccodwg/CovidTimelineCanada#113
  • Loading branch information
jeanpaulrsoucy committed Sep 20, 2023
1 parent 5dd88b0 commit 9e87661
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
13 changes: 12 additions & 1 deletion R/assemble_final_datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,19 @@ assemble_final_datasets <- function() {
convert_hr_names(),
read_d("raw_data/static/nl/nl_deaths_hr_ts_2.csv") %>%
convert_hr_names(),
read_d("raw_data/active_cumul/nl/nl_deaths_hr_ts.csv")
read_d("raw_data/static/nl/nl_deaths_hr_ts_3.csv")
)
nl1 <- get_phac_d("deaths", "NL", keep_up_to_date = TRUE) %>%
dplyr::filter(.data$date >= as.Date("2023-07-01")) %>%
add_hr_col("Unknown")
deaths_hr <- deaths_nl |>
dplyr::filter(.data$date == max(.data$date)) |>
dplyr::pull(.data$value) |>
sum()
nl1$value <- nl1$value - deaths_hr # subtract deaths assigned to a health region
# started with 2023-07-01 instead of 2023-06-24 to avoid negative values for deaths
deaths_nl <- dplyr::bind_rows(deaths_nl, nl1)
rm(nl1, deaths_hr) # clean up

## ns
tryCatch(
Expand Down
12 changes: 0 additions & 12 deletions R/update_raw_datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,6 @@ update_active_cumul <- function(ds) {
as_of_date = max(as.Date(read_d("raw_data/active_ts/ab/ab_cases_hr_ts.csv")[["date"]]), na.rm = TRUE))
upload_active_cumul(ac_deaths_hr_ab, files, "covid19_cumul", "deaths_hr_ab")
sync_active_cumul("deaths_hr_ab", "deaths", "AB", as_of_date = TRUE)

# active_cumul - death data - nl
ac_deaths_hr_nl <- Covid19CanadaDataProcess::process_dataset(
uuid = "34f45670-34ed-415c-86a6-e14d77fcf6db",
val = "mortality",
fmt = "hr_cum_current",
ds = load_ds(ds, "34f45670-34ed-415c-86a6-e14d77fcf6db")) %>%
convert_hr_names() %>%
add_as_of_date(
as_of_date = lubridate::date(lubridate::with_tz(as.POSIXct(load_ds(ds, "34f45670-34ed-415c-86a6-e14d77fcf6db")$features$attributes$EditDate / 1000, origin = "1970-01-01")[1], tz = "America/St_Johns")))
upload_active_cumul(ac_deaths_hr_nl, files, "covid19_cumul", "deaths_hr_nl")
sync_active_cumul("deaths_hr_nl", "deaths", "NL", as_of_date = TRUE)
}

#' Update raw datasets for CovidTimelineCanada
Expand Down

0 comments on commit 9e87661

Please sign in to comment.