@@ -682,6 +682,46 @@ get_nhsn_data_archive <- function(disease_name) {
682682}
683683
684684up_to_date_nssp_state_archive <- function (disease = c(" covid" , " influenza" )) {
685+ disease <- arg_match(disease )
686+ nssp_national <- get_cast_api_data(
687+ source = " nssp" ,
688+ signal = glue :: glue(" pct_ed_visits_{disease}" ),
689+ geo_type = " nation" ,
690+ columns = c(" geo_value" , " time_value" , " value" , " report_ts_nominal_start" , " report_ts_nominal_end" ),
691+ limit = - 1
692+ )
693+ nssp_state <- get_cast_api_data(
694+ source = " nssp" ,
695+ signal = glue :: glue(" pct_ed_visits_{disease}" ),
696+ geo_type = " state" ,
697+ columns = c(" geo_value" , " time_value" , " value" , " report_ts_nominal_start" , " report_ts_nominal_end" ),
698+ limit = - 1
699+ )
700+ nssp_data <- nssp_state %> %
701+ rbind(nssp_national ) %> %
702+ select(geo_value , time_value , nssp = value , version = report_ts_nominal_start ) %> %
703+ mutate(
704+ geo_value = tolower(geo_value ),
705+ # Need to center the time_value on Wednesday of the week (rather than Saturday).
706+ time_value = time_value - 3 ,
707+ version = as.Date(version )
708+ ) %> %
709+ # Ensure uniqueness and convert to epi_archive
710+ arrange(geo_value , time_value , version ) %> %
711+ distinct(geo_value , time_value , version , .keep_all = TRUE )
712+
713+ # covid wyoming is missing nssp data
714+ if (disease == " covid" ) {
715+ nssp_data <- nssp_data %> % filter(geo_value != " wy" )
716+ }
717+ # Complete the rest of the conversion.
718+ nssp_data %> %
719+ # End of week to midweek correction.
720+ mutate(time_value = floor_date(time_value , " week" , week_start = 7 ) + 3 ) %> %
721+ as_epi_archive(compactify = TRUE )
722+ }
723+
724+ old_up_to_date_nssp_state_archive <- function (disease = c(" covid" , " influenza" )) {
685725 disease <- arg_match(disease )
686726 nssp_from_legacy_api <- bind_rows(
687727 retry_fn(
0 commit comments