Skip to content

Commit f00bb5d

Browse files
authored
Merge pull request #618 from cmu-delphi/claimshosp-hhs-nation
Add nation and HHS to claims hosp
2 parents 0289b0f + 0703763 commit f00bb5d

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

claims_hosp/delphi_claims_hosp/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ class GeoConstants:
6464
NUM_HRRS = 308
6565
NUM_MSAS = 392 + 52 # MSA + States
6666
NUM_STATES = 52 # including DC and PR
67+
NUM_HHSS = 10
68+
NUM_NATIONS = 1
6769

6870
MAX_GEO = {"county": NUM_COUNTIES,
6971
"hrr": NUM_HRRS,
7072
"msa": NUM_MSAS,
71-
"state": NUM_STATES}
73+
"state": NUM_STATES,
74+
"hhs": NUM_HHSS,
75+
"nation": NUM_NATIONS}

claims_hosp/delphi_claims_hosp/update_indicator.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, startdate, enddate, dropdate, geo, parallel, weekday,
3737
startdate: first indicator date (YYYY-mm-dd)
3838
enddate: last indicator date (YYYY-mm-dd)
3939
dropdate: data drop date (YYYY-mm-dd)
40-
geo: geographic resolution, one of ["county", "state", "msa", "hrr"]
40+
geo: geographic resolution, one of ["county", "state", "msa", "hrr", "hhs", "nation"]
4141
parallel: boolean to run the indicator update in parallel
4242
weekday: boolean to adjust for weekday effects
4343
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,
6060
assert self.startdate < self.enddate, "start date >= end date"
6161
assert self.enddate <= self.dropdate, "end date > drop date"
6262
assert (
63-
geo in ['county', 'state', 'msa', 'hrr']
64-
), f"{geo} is invalid, pick one of 'county', 'state', 'msa', 'hrr'"
63+
geo in ['county', 'state', 'msa', 'hrr', 'hhs', 'nation']
64+
), f"{geo} is invalid, pick one of 'county', 'state', 'msa', 'hrr', 'hhs', 'nation'"
6565

6666
def shift_dates(self):
6767
"""
@@ -107,15 +107,16 @@ def geo_reindex(self, data):
107107
new_col=self.geo,
108108
new_code="state_id")
109109
data_frame[self.geo] = data_frame[self.geo]
110-
elif self.geo == "msa":
110+
elif self.geo in ["msa", "hhs", "nation"]:
111111
data_frame = geo_map.replace_geocode(data,
112112
from_code="fips",
113113
new_code=self.geo)
114114
elif self.geo == "hrr":
115115
data_frame = data # data is already adjusted in aggregation step above
116116
else:
117-
logging.error("%s is invalid, pick one of 'county', 'state', 'msa', 'hrr'",
118-
self.geo)
117+
logging.error(
118+
"%s is invalid, pick one of 'county', 'state', 'msa', 'hrr', 'hhs', nation'",
119+
self.geo)
119120
return False
120121

121122
unique_geo_ids = pd.unique(data_frame[self.geo])

claims_hosp/tests/test_update_indicator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_geo_reindex(self):
7373
assert (data_frame.sum() == (4200, 19000)).all()
7474

7575
def test_update_indicator(self):
76-
for geo in ["state", "hrr"]:
76+
for geo in ["state", "hrr", "hhs", "nation"]:
7777
td = TemporaryDirectory()
7878
updater = ClaimsHospIndicatorUpdater(
7979
"02-01-2020",

0 commit comments

Comments
 (0)