Skip to content

Commit 030b31c

Browse files
committed
a no-op for now, but allows easy expansion to flu column/signal
1 parent 3149c13 commit 030b31c

File tree

5 files changed

+47
-35
lines changed

5 files changed

+47
-35
lines changed

claims_hosp/delphi_claims_hosp/backfill.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def store_backfill_file(claims_filepath, _end_date, backfill_dir):
3939
backfilldata.rename({"ServiceDate": "time_value",
4040
"PatCountyFIPS": "fips",
4141
"Denominator": "den",
42-
"Covid_like": "num"},
42+
"Covid_like": "num",
43+
"Flu1": "num_flu"},
4344
axis=1, inplace=True)
4445
backfilldata = gmpr.add_geocode(backfilldata, from_code="fips", new_code="state_id",
4546
from_col="fips", new_col="state_id")
@@ -49,7 +50,7 @@ def store_backfill_file(claims_filepath, _end_date, backfill_dir):
4950
else:
5051
_start_date = _end_date.replace(year=_end_date.year-1)
5152
selected_columns = ['time_value', 'fips', 'state_id',
52-
'den', 'num']
53+
'den', 'num', 'num_flu']
5354
backfilldata = backfilldata.loc[(backfilldata["time_value"] >= _start_date)
5455
& (~backfilldata["fips"].isnull()),
5556
selected_columns]

claims_hosp/delphi_claims_hosp/config.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
class Config:
1414
"""Static configuration variables."""
1515

16-
signal_name = "smoothed_covid19_from_claims"
17-
signal_weekday_name = "smoothed_adj_covid19_from_claims"
16+
signal_name = {
17+
"Covid_like": "smoothed_covid19_from_claims",
18+
"Flu1": "smoothed_flu_from_claims",
19+
}
20+
signal_weekday_name = {
21+
"Covid_like": "smoothed_adj_covid19_from_claims",
22+
"Flu1": "smoothed_adj_flu_from_claims",
23+
}
1824

1925
# max number of CPUs available for pool
2026
MAX_CPU_POOL = 10
@@ -30,7 +36,7 @@ class Config:
3036
DAY_SHIFT = timedelta(days=0)
3137

3238
# data columns
33-
CLAIMS_COUNT_COLS = ["Denominator", "Covid_like"]
39+
CLAIMS_COUNT_COLS = ["Denominator", "Covid_like", "Flu1"]
3440
CLAIMS_DATE_COL = "ServiceDate"
3541
FIPS_COL = "fips"
3642
DATE_COL = "timestamp"
@@ -44,6 +50,7 @@ class Config:
4450
"PatCountyFIPS": str,
4551
"Denominator": float,
4652
"Covid_like": float,
53+
"Flu1": float,
4754
"PatAgeGroup": str,
4855
"Pat HRR ID": str,
4956
}

claims_hosp/delphi_claims_hosp/load_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def load_claims_data(claims_filepath, dropdate, base_geo):
5252

5353
return claims_data
5454

55-
def load_data(input_filepath, dropdate, base_geo):
55+
def load_data(input_filepath, dropdate, base_geo, numerator_name):
5656
"""
5757
Load in claims data, and combine them.
5858
@@ -71,7 +71,7 @@ def load_data(input_filepath, dropdate, base_geo):
7171

7272
# rename numerator and denominator
7373
data.fillna(0, inplace=True)
74-
data["num"] = data["Covid_like"]
74+
data["num"] = data[numerator_name]
7575
data["den"] = data["Denominator"]
7676
data = data[['num', 'den']]
7777
data.reset_index(inplace=True)

claims_hosp/delphi_claims_hosp/run.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -120,30 +120,34 @@ def run_module(params):
120120
else:
121121
logger.info("Starting no weekday adj", geo_type=geo)
122122

123-
signal_name = Config.signal_weekday_name if weekday else Config.signal_name
124-
if params["indicator"]["write_se"]:
125-
assert params["indicator"]["obfuscated_prefix"] is not None, \
126-
"supply obfuscated prefix in params.json"
127-
signal_name = params["indicator"]["obfuscated_prefix"] + "_" + signal_name
128-
129-
logger.info("Updating signal name", signal=signal_name)
130-
updater = ClaimsHospIndicatorUpdater(
131-
startdate,
132-
enddate,
133-
dropdate,
134-
geo,
135-
params["indicator"]["parallel"],
136-
weekday,
137-
params["indicator"]["write_se"],
138-
signal_name,
139-
logger,
140-
)
141-
updater.update_indicator(
142-
claims_file,
143-
params["common"]["export_dir"],
144-
)
145-
max_dates.append(updater.output_dates[-1])
146-
n_csv_export.append(len(updater.output_dates))
123+
124+
for numerator_name in ["Covid_like"]:#^H^H^H, "Flu1"]:
125+
126+
signal_name = Config.signal_weekday_name[numerator_name] if weekday else Config.signal_name[numerator_name]
127+
if params["indicator"]["write_se"]:
128+
assert params["indicator"]["obfuscated_prefix"] is not None, \
129+
"supply obfuscated prefix in params.json"
130+
signal_name = params["indicator"]["obfuscated_prefix"] + "_" + signal_name
131+
132+
logger.info("Updating signal name", signal=signal_name)
133+
updater = ClaimsHospIndicatorUpdater(
134+
startdate,
135+
enddate,
136+
dropdate,
137+
geo,
138+
params["indicator"]["parallel"],
139+
weekday,
140+
params["indicator"]["write_se"],
141+
signal_name,
142+
numerator_name,
143+
logger,
144+
)
145+
updater.update_indicator(
146+
claims_file,
147+
params["common"]["export_dir"],
148+
)
149+
max_dates.append(updater.output_dates[-1])
150+
n_csv_export.append(len(updater.output_dates))
147151
logger.info("Finished updating", geo_type=geo)
148152

149153
# Remove all the raw files

claims_hosp/delphi_claims_hosp/update_indicator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ClaimsHospIndicatorUpdater:
2727
# pylint: disable=too-many-instance-attributes, too-many-arguments
2828
# all variables are used
2929

30-
def __init__(self, startdate, enddate, dropdate, geo, parallel, weekday, write_se, signal_name, logger):
30+
def __init__(self, startdate, enddate, dropdate, geo, parallel, weekday, write_se, signal_name, numerator_name, logger):
3131
"""
3232
Initialize updater for the claims-based hospitalization indicator.
3333
@@ -45,8 +45,8 @@ def __init__(self, startdate, enddate, dropdate, geo, parallel, weekday, write_s
4545
self.startdate, self.enddate, self.dropdate = [pd.to_datetime(t) for t in
4646
(startdate, enddate, dropdate)]
4747

48-
self.geo, self.parallel, self.weekday, self.write_se, self.signal_name = \
49-
geo.lower(), parallel, weekday, write_se, signal_name
48+
self.geo, self.parallel, self.weekday, self.write_se, self.signal_name, self.numerator_name = \
49+
geo.lower(), parallel, weekday, write_se, signal_name, numerator_name
5050

5151
# init in shift_dates, declared here for pylint
5252
self.burnindate, self.fit_dates, self.burn_in_dates, self.output_dates = \
@@ -147,7 +147,7 @@ def update_indicator(self, input_filepath, outpath):
147147

148148
# load data
149149
base_geo = Config.HRR_COL if self.geo == Config.HRR_COL else Config.FIPS_COL
150-
data = load_data(input_filepath, self.dropdate, base_geo)
150+
data = load_data(input_filepath, self.dropdate, base_geo, self.numerator_name)
151151
data_frame = self.geo_reindex(data)
152152

153153
# handle if we need to adjust by weekday

0 commit comments

Comments
 (0)