diff --git a/claims_hosp/delphi_claims_hosp/config.py b/claims_hosp/delphi_claims_hosp/config.py index 8a05552cb..d21b46c21 100644 --- a/claims_hosp/delphi_claims_hosp/config.py +++ b/claims_hosp/delphi_claims_hosp/config.py @@ -64,8 +64,12 @@ class GeoConstants: NUM_HRRS = 308 NUM_MSAS = 392 + 52 # MSA + States NUM_STATES = 52 # including DC and PR + NUM_HHSS = 10 + NUM_NATIONS = 1 MAX_GEO = {"county": NUM_COUNTIES, "hrr": NUM_HRRS, "msa": NUM_MSAS, - "state": NUM_STATES} + "state": NUM_STATES, + "hhs": NUM_HHSS, + "nation": NUM_NATIONS} diff --git a/claims_hosp/delphi_claims_hosp/update_indicator.py b/claims_hosp/delphi_claims_hosp/update_indicator.py index 46f07d662..365e40e5a 100644 --- a/claims_hosp/delphi_claims_hosp/update_indicator.py +++ b/claims_hosp/delphi_claims_hosp/update_indicator.py @@ -37,7 +37,7 @@ def __init__(self, startdate, enddate, dropdate, geo, parallel, weekday, startdate: first indicator date (YYYY-mm-dd) enddate: last indicator date (YYYY-mm-dd) dropdate: data drop date (YYYY-mm-dd) - geo: geographic resolution, one of ["county", "state", "msa", "hrr"] + geo: geographic resolution, one of ["county", "state", "msa", "hrr", "hhs", "nation"] parallel: boolean to run the indicator update in parallel weekday: boolean to adjust for weekday effects write_se: boolean to write out standard errors, if true, use an obfuscated name @@ -60,8 +60,8 @@ def __init__(self, startdate, enddate, dropdate, geo, parallel, weekday, assert self.startdate < self.enddate, "start date >= end date" assert self.enddate <= self.dropdate, "end date > drop date" assert ( - geo in ['county', 'state', 'msa', 'hrr'] - ), f"{geo} is invalid, pick one of 'county', 'state', 'msa', 'hrr'" + geo in ['county', 'state', 'msa', 'hrr', 'hhs', 'nation'] + ), f"{geo} is invalid, pick one of 'county', 'state', 'msa', 'hrr', 'hhs', 'nation'" def shift_dates(self): """ @@ -107,15 +107,16 @@ def geo_reindex(self, data): new_col=self.geo, new_code="state_id") data_frame[self.geo] = data_frame[self.geo] - elif self.geo == "msa": + elif self.geo in ["msa", "hhs", "nation"]: data_frame = geo_map.replace_geocode(data, from_code="fips", new_code=self.geo) elif self.geo == "hrr": data_frame = data # data is already adjusted in aggregation step above else: - logging.error("%s is invalid, pick one of 'county', 'state', 'msa', 'hrr'", - self.geo) + logging.error( + "%s is invalid, pick one of 'county', 'state', 'msa', 'hrr', 'hhs', nation'", + self.geo) return False unique_geo_ids = pd.unique(data_frame[self.geo]) diff --git a/claims_hosp/tests/test_update_indicator.py b/claims_hosp/tests/test_update_indicator.py index 2b5c5b786..1524db178 100644 --- a/claims_hosp/tests/test_update_indicator.py +++ b/claims_hosp/tests/test_update_indicator.py @@ -73,7 +73,7 @@ def test_geo_reindex(self): assert (data_frame.sum() == (4200, 19000)).all() def test_update_indicator(self): - for geo in ["state", "hrr"]: + for geo in ["state", "hrr", "hhs", "nation"]: td = TemporaryDirectory() updater = ClaimsHospIndicatorUpdater( "02-01-2020",