Skip to content

Commit 747da48

Browse files
committed
fix: remove kludge from process_nhsn_data
1 parent 62122bf commit 747da48

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

R/aux_data_utils.R

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -624,15 +624,16 @@ gen_ili_data <- function(default_day_of_week = 1) {
624624
as_epi_archive(compactify = TRUE)
625625
}
626626

627+
#' Process Raw NHSN Data
628+
#'
629+
#' Turns the raw NHSN data into a tidy format with the following columns:
630+
#' - geo_value: the jurisdiction of the data
631+
#' - disease: the disease of the data
632+
#' - time_value: the date of the data
633+
#' - version: the version of the data
634+
#' - value: the value of the data
635+
#'
627636
process_nhsn_data <- function(raw_nhsn_data) {
628-
# These are exception dates when the data was available on a different day
629-
# than usual. In these two cases, it was the Thursday after. But to keep
630-
# the rest of the pipeline the same, we pretend it was available on Wednesday.
631-
remap_exceptions <- list(
632-
"2024-12-26" = "2024-12-25",
633-
"2025-01-02" = "2025-01-01"
634-
)
635-
fixed_version <- remap_exceptions[[as.character(Sys.Date())]] %||% Sys.Date()
636637
raw_nhsn_data %>%
637638
mutate(
638639
geo_value = tolower(jurisdiction),
@@ -644,7 +645,7 @@ process_nhsn_data <- function(raw_nhsn_data) {
644645
select(-weekendingdate, -jurisdiction, -starts_with("totalconf")) %>%
645646
pivot_longer(cols = starts_with("nhsn"), names_to = "disease") %>%
646647
filter(!is.na(value)) %>%
647-
mutate(version = fixed_version) %>%
648+
mutate(version = Sys.Date()) %>%
648649
relocate(geo_value, disease, time_value, version)
649650
}
650651

0 commit comments

Comments
 (0)