-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
2,408 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,22 @@ | ||
"""Registry for signal names.""" | ||
from delphi_utils import Smoother | ||
|
||
GEOS = [ | ||
"nation", | ||
"hhs", | ||
"state" | ||
] | ||
# FROM HHS | ||
CONFIRMED = "confirmed_admissions_covid_1d" | ||
SUM_CONF_SUSP = "sum_confirmed_suspected_admissions_covid_1d" | ||
CONFIRMED_PROP = "confirmed_admissions_covid_1d_prop" | ||
SUM_CONF_SUSP_PROP = "sum_confirmed_suspected_admissions_covid_1d_prop" | ||
CONFIRMED_FLU = "confirmed_admissions_influenza_1d" | ||
CONFIRMED_FLU_PROP = CONFIRMED_FLU+"_prop" | ||
|
||
# FROM CDC/METADATA | ||
CONFIRMED_COVID = "Weekly Total COVID-19 Admissions" | ||
HOSPITAL_CONFIRMED_COVID = "Percent Hospitals Reporting Total COVID-19 Admissions" | ||
|
||
ADULT_CONFIRMED_COVID = "Weekly Total Adult COVID-19 Admissions" | ||
PEDIATRIC_CONFIRMED_COVID = "Weekly Total Pediatric COVID-19 Admissions" | ||
|
||
CONFIRMED_COVID_ADULT_PERCENT = "Percent Adult COVID-19 Admissions" | ||
HOSPITAL_CONFIRMED_COVID_ADULT_PERCENT = "Percent Hospitals Reporting Adult COVID-19 Admissions" | ||
|
||
CONFIRMED_COVID_PEDIATRIC_PERCENT = "Percent Pediatric COVID-19 Admissions" | ||
HOSPITAL_COVID_CONFIRMED_PEDIATRIC_PERCENT = "Percent Hospitals Reporting Pediatric COVID-19 Admissions" | ||
|
||
CONFIRMED_FLU = "Weekly Total Influenza Admissions" | ||
HOSPITAL_CONFIRMED_FLU = "Percent Hospitals Reporting Influenza Admissions" | ||
|
||
CONFIRMED_FLU_ADULT_PERCENT = "Percent Adult Influenza Admissions" | ||
HOSPITAL_CONFIRMED_FLU_ADULT_PERCENT = "Percent Hospitals Reporting TotalPatients Hospitalized with Influenza" | ||
|
||
CONFIRMED_FLU_PEDIATRIC_PERCENT = "Percent Pediatric Influenza Admissions" | ||
HOSPTIAL_CONFIRMED_FLU_PEDIATRIC_PERCENT = "Percent Hospitals Reporting Pediatric Influenza Admissions" | ||
|
||
AGE_GROUPS = [ | ||
"0to4", | ||
"5to17", | ||
"18to49", | ||
"50to64", | ||
"65to74", | ||
"75plus", | ||
"unk" | ||
"state", | ||
"nation" | ||
] | ||
|
||
# column name from socrata | ||
TOTAL_ADMISSION_COVID_API = "totalconfc19newadm" | ||
ADULT_ADMISSION_COVID_API = "numconfc19newadmadult" | ||
TOTAL_ADULT_ADMISSION_COVID_API = "totalconfc19newadmadult" | ||
PEDIATRIC_ADMISSION_COVID_API = "numconfc19newadmped" | ||
TOTAL_PEDIATRIC_ADMISSION_COVID_API = "totalconfc19newadmped" | ||
|
||
PERCENT_ADULT_ADMISSION_COVID_API = "pctconfrsvnewadmadult" | ||
PERCENT_PEDIATRIC_ADMISSION_COVID_API = "pctconfrsvnewadmped" | ||
|
||
TOTAL_ADMISSION_FLU_API = "totalconfflunewadm" | ||
ADULT_ADMISSION_FLU_API = "numconffluhosppatsadult" | ||
TOTAL_ADULT_ADMISSION_FLU_API = "numconfflunewadmadult" | ||
PEDIATRIC_ADMISSION_FLU_API = "numconfflunewadmped" | ||
TOTAL_PEDIATRIC_ADMISSION_FLU_API = "totalconfflunewadmped" | ||
|
||
TOTAL_ADMISSION_RSV_API = "totalconfrsvnewadm" | ||
ADULT_ADMISSION_RSV_API = "numconfrsvnewadmadult" | ||
TOTAL_ADULT_ADMISSION_RSV_API = "totalconfrsvnewadmadult" | ||
PEDIATRIC_ADMISSION_RSV_API = "numconfrsvnewadmped" | ||
TOTAL_PEDIATRIC_ADMISSION_RSV_API = "totalconfrsvnewadmped" | ||
|
||
PARTIAL_SIGNALS = [ | ||
TOTAL_ADMISSION_COVID_API, | ||
ADULT_ADMISSION_COVID_API, | ||
TOTAL_ADULT_ADMISSION_COVID_API, | ||
PEDIATRIC_ADMISSION_COVID_API, | ||
TOTAL_PEDIATRIC_ADMISSION_COVID_API, | ||
PERCENT_ADULT_ADMISSION_COVID_API, | ||
PERCENT_PEDIATRIC_ADMISSION_COVID_API, | ||
TOTAL_ADMISSION_FLU_API, | ||
ADULT_ADMISSION_FLU_API, | ||
TOTAL_ADULT_ADMISSION_FLU_API, | ||
PEDIATRIC_ADMISSION_FLU_API, | ||
TOTAL_PEDIATRIC_ADMISSION_FLU_API, | ||
TOTAL_ADMISSION_RSV_API, | ||
ADULT_ADMISSION_RSV_API, | ||
TOTAL_ADULT_ADMISSION_RSV_API, | ||
PEDIATRIC_ADMISSION_RSV_API, | ||
TOTAL_PEDIATRIC_ADMISSION_RSV_API, | ||
] | ||
|
||
SIGNALS_MAP = { | ||
"confirmed_admissions_covid": [TOTAL_ADMISSION_COVID_API], | ||
"confirmed_admissions_flu": [TOTAL_ADMISSION_FLU_API], | ||
"confirmed_admissions_rsv": [TOTAL_ADMISSION_RSV_API], | ||
"confirmed_admissions_covid": TOTAL_ADMISSION_COVID_API, | ||
"confirmed_admissions_flu": TOTAL_ADMISSION_FLU_API, | ||
} | ||
|
||
TYPE_DICT = { | ||
"timestamp": "datetime64[ns]", | ||
"jurisdiction": str, | ||
} | ||
|
||
TYPE_DICT.update({key: float for key in PARTIAL_SIGNALS}) | ||
|
||
|
||
"geo_id": str, | ||
} | ||
|
||
SMOOTHERS = [ | ||
(Smoother("identity", impute_method=None), ""), | ||
(Smoother("moving_average", window_length=7), "_7dav"), | ||
] | ||
TYPE_DICT.update({signal: float for signal in SIGNALS_MAP.keys()}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import copy | ||
import json | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
from pathlib import Path | ||
|
||
from delphi_nhsn.run import run_module | ||
|
||
TEST_DIR = Path(__file__).parent | ||
|
||
# test data generated with following url with socrata: | ||
# https://data.cdc.gov/resource/ua7e-t2fy.json?$where=weekendingdate%20between%20%272023-08-19T00:00:00.000%27%20and%20%272023-10-19T00:00:00.000%27%20and%20jurisdiction%20in(%27CO%27,%27USA%27) | ||
# queries the nhsn data with timestamp (2021-08-19, 2021-10-19) with CO and USA data | ||
TEST_DATA = [] | ||
with open("test_data/page.json", "r") as f: | ||
TEST_DATA = json.load(f) | ||
|
||
@pytest.fixture(scope="session") | ||
def params(): | ||
params = { | ||
"common": { | ||
"export_dir": f"{TEST_DIR}/receiving", | ||
"log_filename": f"{TEST_DIR}/test.log", | ||
"backup_dir": f"{TEST_DIR}/backups", | ||
"custom_run": False | ||
}, | ||
"indicator": { | ||
"wip_signal": True, | ||
"export_start_date": "2020-08-01", | ||
"static_file_dir": "./static", | ||
"socrata_token": "test_token" | ||
}, | ||
"validation": { | ||
"common": { | ||
"span_length": 14, | ||
"min_expected_lag": {"all": "3"}, | ||
"max_expected_lag": {"all": "4"}, | ||
} | ||
} | ||
} | ||
return copy.deepcopy(params) | ||
|
||
@pytest.fixture | ||
def params_w_patch(params): | ||
params_copy = copy.deepcopy(params) | ||
params_copy["patch"] = { | ||
"start_issue": "2024-06-27", | ||
"end_issue": "2024-06-29", | ||
"patch_dir": "./patch_dir" | ||
} | ||
return params_copy | ||
@pytest.fixture | ||
def mock_get(request): | ||
with patch('sodapy.Socrata.get') as mock_get: | ||
mock_get.side_effect = [TEST_DATA,[]] | ||
yield mock_get | ||
|
||
@pytest.fixture(scope="function") | ||
def run_as_module(params, mock_get): | ||
|
||
run_module(params) | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.