Skip to content

Commit

Permalink
Bed charts and desc
Browse files Browse the repository at this point in the history
  • Loading branch information
mmastand committed Apr 1, 2020
1 parent 21e76df commit cc4307e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 13 deletions.
27 changes: 16 additions & 11 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
build_census_chart,
build_beds_chart,
build_descriptions,
build_bed_descriptions,
build_sim_sir_w_date_chart,
build_table,
)
Expand Down Expand Up @@ -92,18 +93,22 @@
st.dataframe(m.beds_df)##########
beds_chart = build_beds_chart(alt=alt, beds_floor_df=m.beds_df, max_y_axis=p.max_y_axis)
st.altair_chart(beds_chart, use_container_width=True)
# st.markdown(bed_chart_descriptions(beds_chart, p.bed_chart_desc))
# if st.checkbox("Show Projected Available COVID-19 Beds in tabular form"):
# if st.checkbox("Show Daily Available Bed Counts"):
# draw_beds_table(st, p, m.beds_df, p.labels, as_date=p.as_date, daily_count=True)
# else:
# draw_beds_table(st, p, m.beds_df, p.labels, as_date=p.as_date, daily_count=False)
# build_download_link(st,
# filename="projected_beds.csv",
# df=m.beds_df,
# parameters=p
# )
st.markdown(build_bed_descriptions(chart=beds_chart, labels=p.eqpt_chart_desc))
display_download_link(
st,
filename=f"{p.current_date}_projected_capacity.csv",
df=m.beds_df,
)

if st.checkbox("Show Projected Capacity in tabular form"):
beds_modulo = 1
if not st.checkbox("Show Daily Capacity Counts"):
beds_modulo = 7
table_df = build_table(
df=m.beds_floor_df,
labels=p.labels,
modulo=beds_modulo)
st.table(table_df)


st.subheader("Susceptible, Infected, and Recovered")
Expand Down
40 changes: 40 additions & 0 deletions src/penn_chime/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,46 @@ def build_descriptions(
messages.append("_* The max is at the upper bound of the data, and therefore may not be the actual max_")
return "\n\n".join(messages)

def build_bed_descriptions(
*,
chart: Chart,
labels: Dict[str, str],
suffix: str = ""
) -> str:
"""
:param chart: The alt chart to be used in finding max points
:param suffix: The assumption is that the charts have similar column names.
The census chart adds " Census" to the column names.
Make sure to include a space or underscore as appropriate
:return: Returns a multi-line string description of the results
"""
messages = []

cols = ["total", "icu", "ventilators"]
asterisk = False

# Add note if lines overlap.
if sum(np.where(chart.data["total"] == chart.data["icu"], 1, 0)) > 1:
messages.append("_The overlapping lines represent non-ICU patients being housed in the ICU._")

for col in cols:
if np.nanmin(chart.data[col]) > 0:
asterisk = True
messages.append("_{} are never exhausted._".format(labels[col]))
continue

on = chart.data["date"][chart.data[col].le(0).idxmax()]
on = datetime.strftime(on, "%b %d") # todo: bring this to an optional arg / i18n

messages.append(
"{} are exhausted on {}".format(
labels[col],
on,
)
)

return "\n\n".join(messages)

def build_table(
*,
Expand Down
4 changes: 2 additions & 2 deletions src/penn_chime/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ def __init__(
"total": "Total COVID-19 Admissions peaks at"
}

self.eqp_chart_desc = {
self.eqpt_chart_desc = {
"hospitalized": "Hospitalized COVID-19 Beds",
"icu": "Total ICU COVID-19 Beds",
"icu": "ICU COVID-19 Beds",
"ventilators": "COVID-19 Ventilators",
"total": "Total COVID-19 Beds"
}

0 comments on commit cc4307e

Please sign in to comment.