Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion claims_hosp/delphi_claims_hosp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
13 changes: 7 additions & 6 deletions claims_hosp/delphi_claims_hosp/update_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion claims_hosp/tests/test_update_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down