Пример #1
0
def test_no_asterisk(admits_floor_df, param):
    param.n_days = 600

    chart = build_admits_chart(alt=alt, admits_floor_df=admits_floor_df)
    description = build_descriptions(chart=chart,
                                     labels=param.labels,
                                     prefix="admits_")
    assert "*" not in description
Пример #2
0
def test_census(census_floor_df, param):
    chart = build_census_chart(alt=alt, census_floor_df=census_floor_df)
    description = build_descriptions(chart=chart,
                                     labels=param.labels,
                                     prefix="census_")

    assert str(ceil(chart.data["census_ventilated"].max())) in description
    assert str(chart.data["census_icu"].idxmax()) not in description
    assert (datetime.strftime(
        chart.data.iloc[chart.data["census_icu"].idxmax()].date, "%b %d")
            in description)
Пример #3
0
def test_build_descriptions(admits_floor_df, param):
    chart = build_admits_chart(alt=alt, admits_floor_df=admits_floor_df)
    description = build_descriptions(chart=chart,
                                     labels=param.labels,
                                     prefix="admits_")

    hosp, icu, vent = description.split(
        "\n\n")  # break out the description into lines

    max_hosp = chart.data["admits_hospitalized"].max()
    assert str(ceil(max_hosp)) in hosp
Пример #4
0
if st.checkbox("Show more info about this tool"):
    notes = "The total size of the susceptible population will be the entire catchment area for Penn Medicine entities (HUP, PAH, PMC, CCH)"
    display_more_info(st=st,
                      model=m,
                      parameters=p,
                      defaults=DEFAULTS,
                      notes=notes)

st.subheader("New Admissions")
st.markdown(
    "Projected number of **daily** COVID-19 admissions at Penn hospitals")
admits_chart = build_admits_chart(alt=alt,
                                  admits_df=m.admits_df,
                                  max_y_axis=p.max_y_axis)
st.altair_chart(admits_chart, use_container_width=True)
st.markdown(build_descriptions(chart=admits_chart, labels=p.labels))
display_download_link(
    st,
    filename=f"{p.current_date}_projected_admits.csv",
    df=m.admits_df,
)

if st.checkbox("Show Projected Admissions in tabular form"):
    admits_modulo = 1
    if not st.checkbox("Show Daily Counts"):
        admits_modulo = 7
    table_df = build_table(df=m.admits_df,
                           labels=p.labels,
                           modulo=admits_modulo)
    st.table(table_df)
Пример #5
0
p = display_sidebar(st, d)
m = SimSirModel(p)

display_header(st, m, p)

st.subheader("New Admissions")
st.markdown(
    "Projected number of **daily** COVID-19 admissions. \n\n _NOTE: Now including estimates of prior admissions for comparison._"
)
admits_chart = build_admits_chart(alt=alt,
                                  admits_floor_df=m.admits_floor_df,
                                  max_y_axis=p.max_y_axis)
st.altair_chart(admits_chart, use_container_width=True)
st.markdown(
    build_descriptions(chart=admits_chart,
                       labels=p.labels,
                       prefix="admits_",
                       suffix=" Admissions"))
display_download_link(
    st,
    filename=f"{p.current_date}_projected_admits.csv",
    df=m.admits_df,
)

if st.checkbox("Show Projected Admissions in tabular form"):
    admits_modulo = 1
    if not st.checkbox("Show Daily Counts"):
        admits_modulo = 7
    table_df = build_table(df=m.admits_floor_df,
                           labels=p.labels,
                           modulo=admits_modulo)
    st.table(table_df)
Пример #6
0
def display_body_charts(m, p: "Parameters", d: "Parameters",
                        actuals: "pd.DataFrame", mode: "Mode"):

    st.subheader("New Hospital Admissions")
    admits_chart = build_admits_chart(alt=alt,
                                      admits_floor_df=m.admits_floor_df,
                                      p=p,
                                      actuals=actuals)
    st.altair_chart(admits_chart, use_container_width=True)
    zero_admits_warning(p)
    st.markdown(
        build_descriptions(
            chart=admits_chart,
            labels=p.admits_patient_chart_desc,
        ))
    display_download_link(
        filename=f"{p.current_date}_projected_admits.csv",
        df=m.admits_df,
    )

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

    st.subheader("Hospital Census")
    census_chart = build_census_chart(alt=alt,
                                      census_floor_df=m.census_floor_df,
                                      p=p,
                                      actuals=actuals)
    st.altair_chart(census_chart, use_container_width=True)
    # Display census mismatch message if appropriate
    census_mismatch_message(parameters=p, actuals=actuals, st=st)
    st.markdown(
        build_descriptions(
            chart=census_chart,
            labels=p.census_patient_chart_desc,
        ))
    display_download_link(
        filename=f"{p.current_date}_projected_census.csv",
        df=m.census_df,
    )
    if st.checkbox("Show Projected Census in tabular form"):
        census_modulo = 1
        if not st.checkbox("Show Daily Census Counts"):
            census_modulo = 7
        table_df = build_table(df=m.census_floor_df,
                               labels=p.labels,
                               modulo=census_modulo)
        st.table(table_df)

    st.subheader("COVID-19 Capacity")
    beds_chart = build_beds_chart(alt=alt,
                                  beds_floor_df=m.beds_df,
                                  parameters=p)
    st.altair_chart(beds_chart, use_container_width=True)
    st.markdown(
        build_bed_descriptions(chart=beds_chart, labels=p.beds_chart_desc))
    display_download_link(
        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")
    sim_sir_w_date_chart = build_sim_sir_w_date_chart(
        alt=alt,
        sim_sir_w_date_floor_df=m.sim_sir_w_date_floor_df,
        actuals=actuals,
        p=p)
    st.altair_chart(sim_sir_w_date_chart, use_container_width=True)
    display_download_link(
        filename=f"{p.current_date}_sim_sir_w_date.csv",
        df=m.sim_sir_w_date_df,
    )

    if st.checkbox("Show SIR Simulation in tabular form"):
        table_df = build_table(df=m.sim_sir_w_date_floor_df, labels=p.labels)
        st.table(table_df)

    ### PPE Section
    st.subheader("Personal Protection Equipment")
    show_ppe_section = st.checkbox("Show PPE Charts", value=p.show_ppe_section)
    p.show_ppe_section = show_ppe_section
    if show_ppe_section:
        st.markdown("Quantity of PPE required per day")
        for pc in list(p.ppe_labels.keys())[3:]:
            ppe_chart = build_ppe_chart(alt=alt,
                                        ppe_floor_df=m.ppe_floor_df,
                                        p=p,
                                        plot_columns=pc)
            st.altair_chart(ppe_chart, use_container_width=True)
            st.markdown(
                build_ppe_descriptions(chart=ppe_chart,
                                       label=p.ppe_labels[pc]["label"]))
            st.markdown("  \n  \n")
        display_download_link(
            filename=f"{p.current_date}_projected_ppe_required.csv",
            df=m.ppe_df,
        )
        if st.checkbox("Show Projected PPE Required in tabular form"):
            ppe_modulo = 1
            if not st.checkbox("Show Daily PPE Required"):
                ppe_modulo = 7
            table_df = build_table(df=m.ppe_floor_df,
                                   labels=p.labels,
                                   modulo=ppe_modulo)
            st.dataframe(table_df)

    ### Staffing Section
    st.subheader("Staffing")
    show_staffing_section = st.checkbox("Show Staffing Charts",
                                        value=p.show_staffing_section)
    p.show_staffing_section = show_staffing_section
    if show_staffing_section:
        st.markdown("Number of staff required per day")
        for pc in list(p.staffing_labels.keys())[3:]:
            staffing_chart = build_staffing_chart(
                alt=alt,
                staffing_floor_df=m.staffing_floor_df,
                p=p,
                plot_columns=pc)
            st.altair_chart(staffing_chart, use_container_width=True)
            st.markdown(
                build_staffing_descriptions(
                    chart=staffing_chart,
                    label=p.staffing_labels[pc]["label"],
                    shift_duration=p.shift_duration))
            st.markdown("  \n  \n")
        display_download_link(
            filename=f"{p.current_date}_projected_staffing_required.csv",
            df=m.staffing_df,
        )
        if st.checkbox("Show Projected Staffing Required in tabular form"):
            staffing_modulo = 1
            if not st.checkbox("Show Daily Staffing Required"):
                staffing_modulo = 7
            table_df = build_table(df=m.staffing_floor_df,
                                   labels=p.labels,
                                   modulo=staffing_modulo)
            st.dataframe(table_df)

    ### Export Full Data and Parameters
    st.header("Export Full Data and Parameters")
    df = build_data_and_params(projection_admits=m.admits_df,
                               census_df=m.census_df,
                               beds_df=m.beds_df,
                               ppe_df=m.ppe_df,
                               staffing_df=m.staffing_df,
                               model=m,
                               parameters=p)

    if st.checkbox("Show full data and parameters to be exported"):
        st.dataframe(df)

    filename = "Data" + "_" + p.author + "_" + p.scenario + "_" + (
        datetime.datetime.utcnow() -
        datetime.timedelta(hours=6)).isoformat() + ".csv"
    csv = dataframe_to_base64(df)
    st.markdown("""
            <a download="{filename}" href="data:text/plain;base64,{csv}">Download full table as CSV</a>
    """.format(csv=csv, filename=filename),
                unsafe_allow_html=True)

    if actuals is not None:
        if st.checkbox("Display Uploaded Actuals"):
            st.dataframe(actuals)