@@ -64,8 +64,8 @@ def display_header(st, m, p):
64
64
)
65
65
st .markdown (
66
66
"""*This tool was developed by the [Predictive Healthcare team](http://predictivehealthcare.pennmedicine.org/) at
67
- Penn Medicine to assist hospitals and public health officials with hospital capacity planning,
68
- but can be used anywhere in the world.
67
+ Penn Medicine to assist hospitals and public health officials with hospital capacity planning,
68
+ but can be used anywhere in the world.
69
69
Customize it for your region by modifying data inputs in the left panel.
70
70
For questions on how to use this tool see the [User docs]({docs_url}). Code can be found on [Github](https://github.com/CodeForPhilly/chime)*.
71
71
""" .format (docs_url = DOCS_URL )
@@ -76,15 +76,15 @@ def display_header(st, m, p):
76
76
confirmed cases in the region imply a **{detection_prob_str}** rate of detection. This is based on current inputs for
77
77
Hospitalizations (**{current_hosp}**), Hospitalization rate (**{hosp_rate:.0%}**), Region size (**{S}**),
78
78
and Hospital market share (**{market_share:.0%}**).
79
-
80
- {infection_warning_str}
79
+
80
+ {infection_warning_str}
81
81
{infected_population_warning_str}
82
82
83
83
An initial doubling time of **{doubling_time}** days and a recovery time of **{recovery_days}** days imply an $R_0$ of
84
- **{r_naught:.2f}** and daily growth rate of **{daily_growth:.2f}%**.
85
-
84
+ **{r_naught:.2f}** and daily growth rate of **{daily_growth:.2f}%**.
85
+
86
86
**Mitigation**: A **{relative_contact_rate:.0%}** reduction in social contact after the onset of the
87
- outbreak **{impact_statement:s} {doubling_time_t:.1f}** days, implying an effective $R_t$ of **${r_t:.2f}$**
87
+ outbreak **{impact_statement:s} {doubling_time_t:.1f}** days, implying an effective $R_t$ of **${r_t:.2f}$**
88
88
and daily growth rate of **{daily_growth_t:.2f}%**.
89
89
""" .format (
90
90
total_infections = m .infected ,
@@ -120,7 +120,7 @@ def __init__(self, st_obj, label, value, kwargs):
120
120
self .value = value
121
121
self .kwargs = kwargs
122
122
123
- def build (self ):
123
+ def __call__ (self ):
124
124
return self .st_obj (self .label , value = self .value , ** self .kwargs )
125
125
126
126
@@ -145,31 +145,31 @@ def display_sidebar(st, d: Constants) -> Parameters:
145
145
if d .known_infected < 1 :
146
146
raise ValueError ("Known cases must be larger than one to enable predictions." )
147
147
st_obj = st .sidebar
148
- current_hospitalized = NumberInputWrapper (
148
+ current_hospitalized_input = NumberInputWrapper (
149
149
st_obj ,
150
150
"Currently Hospitalized COVID-19 Patients" ,
151
151
min_value = 0 ,
152
152
value = d .current_hospitalized ,
153
153
step = 1 ,
154
154
format = "%i" ,
155
155
)
156
- n_days = NumberInputWrapper (
156
+ n_days_input = NumberInputWrapper (
157
157
st_obj ,
158
158
"Number of days to project" ,
159
159
min_value = 30 ,
160
160
value = d .n_days ,
161
161
step = 10 ,
162
162
format = "%i" ,
163
163
)
164
- doubling_time = NumberInputWrapper (
164
+ doubling_time_input = NumberInputWrapper (
165
165
st_obj ,
166
166
"Doubling time before social distancing (days)" ,
167
167
min_value = 0 ,
168
168
value = d .doubling_time ,
169
169
step = 1 ,
170
170
format = "%i" ,
171
171
)
172
- relative_contact_rate = NumberInputWrapper (
172
+ relative_contact_rate_input = NumberInputWrapper (
173
173
st_obj ,
174
174
"Social distancing (% reduction in social contact)" ,
175
175
min_value = 0 ,
@@ -178,7 +178,7 @@ def display_sidebar(st, d: Constants) -> Parameters:
178
178
step = 5 ,
179
179
format = "%i" ,
180
180
)
181
- hospitalized_rate = NumberInputWrapper (
181
+ hospitalized_rate_input = NumberInputWrapper (
182
182
st_obj ,
183
183
"Hospitalization %(total infections)" ,
184
184
min_value = 0.001 ,
@@ -187,7 +187,7 @@ def display_sidebar(st, d: Constants) -> Parameters:
187
187
step = 1.0 ,
188
188
format = "%f" ,
189
189
)
190
- icu_rate = NumberInputWrapper (
190
+ icu_rate_input = NumberInputWrapper (
191
191
st_obj ,
192
192
"ICU %(total infections)" ,
193
193
min_value = 0.0 ,
@@ -196,7 +196,7 @@ def display_sidebar(st, d: Constants) -> Parameters:
196
196
step = 1.0 ,
197
197
format = "%f" ,
198
198
)
199
- ventilated_rate = NumberInputWrapper (
199
+ ventilated_rate_input = NumberInputWrapper (
200
200
st_obj ,
201
201
"Ventilated %(total infections)" ,
202
202
min_value = 0.0 ,
@@ -205,31 +205,31 @@ def display_sidebar(st, d: Constants) -> Parameters:
205
205
step = 1.0 ,
206
206
format = "%f" ,
207
207
)
208
- hospitalized_los = NumberInputWrapper (
208
+ hospitalized_los_input = NumberInputWrapper (
209
209
st_obj ,
210
210
"Hospital Length of Stay" ,
211
211
min_value = 0 ,
212
212
value = d .hospitalized .length_of_stay ,
213
213
step = 1 ,
214
214
format = "%i" ,
215
215
)
216
- icu_los = NumberInputWrapper (
216
+ icu_los_input = NumberInputWrapper (
217
217
st_obj ,
218
218
"ICU Length of Stay" ,
219
219
min_value = 0 ,
220
220
value = d .icu .length_of_stay ,
221
221
step = 1 ,
222
222
format = "%i" ,
223
223
)
224
- ventilated_los = NumberInputWrapper (
224
+ ventilated_los_input = NumberInputWrapper (
225
225
st_obj ,
226
226
"Vent Length of Stay" ,
227
227
min_value = 0 ,
228
228
value = d .ventilated .length_of_stay ,
229
229
step = 1 ,
230
230
format = "%i" ,
231
231
)
232
- market_share = NumberInputWrapper (
232
+ market_share_input = NumberInputWrapper (
233
233
st_obj ,
234
234
"Hospital Market Share (%)" ,
235
235
min_value = 0.001 ,
@@ -238,69 +238,71 @@ def display_sidebar(st, d: Constants) -> Parameters:
238
238
step = 1.0 ,
239
239
format = "%f" ,
240
240
)
241
- susceptible = NumberInputWrapper (
241
+ susceptible_input = NumberInputWrapper (
242
242
st_obj ,
243
243
"Regional Population" ,
244
244
min_value = 1 ,
245
245
value = d .region .susceptible ,
246
246
step = 100000 ,
247
247
format = "%i" ,
248
248
)
249
- known_infected = NumberInputWrapper (
249
+ known_infected_input = NumberInputWrapper (
250
250
st_obj ,
251
251
"Currently Known Regional Infections (only used to compute detection rate - does not change projections)" ,
252
252
min_value = 0 ,
253
253
value = d .known_infected ,
254
254
step = 10 ,
255
255
format = "%i" ,
256
256
)
257
- as_date = CheckboxWrapper (st_obj , "Present result as dates instead of days" , value = False )
258
- max_y_axis_set = CheckboxWrapper (st_obj , "Set the Y-axis on graphs to a static value" )
257
+ as_date_input = CheckboxWrapper (st_obj , "Present result as dates instead of days" , value = False )
258
+ max_y_axis_set_input = CheckboxWrapper (st_obj , "Set the Y-axis on graphs to a static value" )
259
+ max_y_axis_input = NumberInputWrapper (st_obj , "Y-axis static value" , value = 500 , format = "%i" , step = 25 )
259
260
260
- max_y_axis = None
261
- if max_y_axis_set :
262
- max_y_axis = NumberInputWrapper (st_obj , "Y-axis static value" , value = 500 , format = "%i" , step = 25 )
263
261
264
262
# Build in desired order
265
263
st .sidebar .markdown ("### Regional Parameters [ℹ]({docs_url}/what-is-chime/parameters)" .format (docs_url = DOCS_URL ))
266
- susceptible . build ()
267
- market_share . build ()
268
- known_infected . build ()
269
- current_hospitalized . build ()
264
+ susceptible = susceptible_input ()
265
+ market_share = market_share_input ()
266
+ known_infected = known_infected_input ()
267
+ current_hospitalized = current_hospitalized_input ()
270
268
271
269
st .sidebar .markdown ("### Spread and Contact Parameters [ℹ]({docs_url}/what-is-chime/parameters)"
272
270
.format (docs_url = DOCS_URL ))
273
- doubling_time . build ()
274
- relative_contact_rate . build ()
271
+ doubling_time = doubling_time_input ()
272
+ relative_contact_rate = relative_contact_rate_input ()
275
273
276
274
st .sidebar .markdown ("### Severity Parameters [ℹ]({docs_url}/what-is-chime/parameters)" .format (docs_url = DOCS_URL ))
277
- hospitalized_rate . build ()
278
- icu_rate . build ()
279
- ventilated_rate . build ()
280
- hospitalized_los . build ()
281
- icu_los . build ()
282
- ventilated_los . build ()
275
+ hospitalized_rate = hospitalized_rate_input ()
276
+ icu_rate = icu_rate_input ()
277
+ ventilated_rate = ventilated_rate_input ()
278
+ hospitalized_los = hospitalized_los_input ()
279
+ icu_los = icu_los_input ()
280
+ ventilated_los = ventilated_los_input ()
283
281
284
282
st .sidebar .markdown ("### Display Parameters [ℹ]({docs_url}/what-is-chime/parameters)" .format (docs_url = DOCS_URL ))
285
- n_days .build ()
286
- max_y_axis .build ()
287
- as_date .build ()
283
+ n_days = n_days_input ()
284
+ max_y_axis_set = max_y_axis_set_input ()
285
+ as_date = as_date_input ()
286
+
287
+ max_y_axis = None
288
+ if max_y_axis_set :
289
+ max_y_axis = max_y_axis_input ()
288
290
289
291
return Parameters (
290
- as_date = as_date . value ,
291
- current_hospitalized = current_hospitalized . value ,
292
- market_share = market_share . value ,
293
- known_infected = known_infected . value ,
294
- doubling_time = doubling_time . value ,
292
+ as_date = as_date ,
293
+ current_hospitalized = current_hospitalized ,
294
+ market_share = market_share ,
295
+ known_infected = known_infected ,
296
+ doubling_time = doubling_time ,
295
297
296
- max_y_axis = max_y_axis . value ,
297
- n_days = n_days . value ,
298
- relative_contact_rate = relative_contact_rate . value / 100.0 ,
299
- susceptible = susceptible . value ,
298
+ max_y_axis = max_y_axis ,
299
+ n_days = n_days ,
300
+ relative_contact_rate = relative_contact_rate / 100.0 ,
301
+ susceptible = susceptible ,
300
302
301
- hospitalized = RateLos (hospitalized_rate . value / 100.0 , hospitalized_los . value ),
302
- icu = RateLos (icu_rate . value / 100.0 , icu_los . value ),
303
- ventilated = RateLos (ventilated_rate . value / 100.0 , ventilated_los . value ),
303
+ hospitalized = RateLos (hospitalized_rate / 100.0 , hospitalized_los ),
304
+ icu = RateLos (icu_rate / 100.0 , icu_los ),
305
+ ventilated = RateLos (ventilated_rate / 100.0 , ventilated_los ),
304
306
)
305
307
306
308
@@ -408,7 +410,7 @@ def show_more_info_about_this_tool(st, model, parameters, defaults, notes: str =
408
410
def write_definitions (st ):
409
411
st .subheader ("Guidance on Selecting Inputs" )
410
412
st .markdown (
411
- """**This information has been moved to the
413
+ """**This information has been moved to the
412
414
[User Documentation]({docs_url}/what-is-chime/parameters#guidance-on-selecting-inputs)**""" .format (docs_url = DOCS_URL )
413
415
)
414
416
0 commit comments