import streamlit as st from .parameters import Parameters, Mode from .model_base import SimSirModelBase as Model from .hc_actuals import actuals_download_widget
def display_empirical_long(): st.markdown( """ Rather than using a fixed infection spread rate modified by a single social distancing effective impact adjustment, "Empirical Model Mode" estimates future COVID-19 cases based upon case history to date.
There is not a single best approach to estimating infection spread and
forecasting methods across all regions. Typically, it is possible to
arrive at a reasonable approach through visual inspection and selecting
the combination of "Infection Spread Measure" and "Forecast Method"
accordingly.
* Infection spread: Use either "Doubling Time" using the approach of [Hall, 2014] (https://doi.org/10.1093/molbev/mst187) or "Reproduction Rate" using the approach of [Cori, 2013] (https://doi.org/10.1093/aje/kwt133).
* Forecast: Select from exponential smoothing or local (LOESS), spline, or linear regression.
These calcualtions are done using [R] (https://www.r-project.org/)
New hospital admissions, census, and other demand estimates are still
derived from the SIR model. What is different is how SIR (specifically
the "I" (Infected) calculation is done:
* Where actual new cases are available, this determines "I" directly.
* For future days, the $\\beta$ term is derived dynamically based upon your selection of the Infection Spread and Forecast Method.
By allowing dynamic infection spread, it is possible to capture the
dynamic nature of epidemic spread and counter measures.
Note that the forecast model will adjust for changes in contributors
such as social distancing effectiveness and testing rates. However, it
will take some time for the model to adjust and extra caution should be
applied in interpretation during times of rapid change.
In addition, please note that the hospital admission and ventilator use
percentage defaults should be inspected carefully when using actual
infection data. In many regions, testing was done disproportionately in
patients presenting to the hospital--not the general population. You may
need to increase your hospital admission and ventilator use rates to gets
appropriate volume in your region of interest.
"""
)
def display_empirical_short(): st.markdown( """ Empirical Model Mode uses county data reported by the New York Times and 2019 census data from the [U.S. Census] (https://www2.census.gov/programs-surveys/popest/datasets/2010-2019/counties/totals/) * Actuals presented from {start actuals date} to {end actual date} * Daily cases through {max date} estimated by applying the {Forecast Method} to the {Forecasted Metric} """ )
def display_app_title(): st.subheader("Health Catalyst® COVID-19 Capacity Planning Tool")
def display_app_description(): st.markdown( f""" Forecast local COVID-19 demand in the context of local system capacity to set expectations and inform mitigation strategy: * Built on the outstanding Penn Med [epidemic model] (https://penn-chime.phl.io/) *
style="color:red;">Forecast based upon county level infection and population data
* Manage, use, and save scenarios, bed and ventilator capacity, and actual data * Estimate demand for personal protective equipment (PPE) and staff Important note on definitions (different from Penn Med model): * Non-ICU: Inpatient hospital beds outside of critical care * ICU: Beds used for critical care patients * Total: Sum of beds/patients in non-ICU plus ICU * Ventilators: Devices used to assist with patient breathing, counted independently of beds (not a subset of ICU or Total patients/beds) Questions, comments, support, or requests: [email protected]See Application Guidance section below for more information.
""", unsafe_allow_html=True, ) def display_disclaimer(): st.markdown( """ Notice: There is a high degree of uncertainty about the details of COVID-19 infection, transmission, and the effectiveness of social distancing measures. Long-term projections made using this simplified model of outbreak progression should be treated with extreme caution. """ ) def display_parameter_text(m: "Model", p: Parameters): infected_population_warning_str = ( """(Warning: The number of estimated infections is greater than the total regional population. Please verify the values entered in the sidebar.)""" if m.infected > p.population else "" )st.markdown(
"""The estimated number of currently infected individuals is **{total_infections:.0f}**. This is based on current inputs for
Hospitalizations (**{current_hosp}**), Hospitalization rate (**{hosp_rate:.2%}**), Region size (**{S}**),
and Hospital market share (**{market_share:.0%}**).
{infected_population_warning_str}
An initial doubling time of {doubling_time} days and a recovery time of {recovery_days} days imply an
The model's parameters,
- there are more contacts between people
- when the pathogen is more virulent
- when people have the pathogen for longer periods of time
A doubling time of {doubling_time} days and a recovery time of {recovery_days} days imply an
$R_0$ of {r_naught:.2f}.
After the beginning of the outbreak, actions to reduce social contact will lower the parameter
We need to express the two parameters
-
$\gamma$ : the CDC is recommending 14 days of self-quarantine, we'll use$\gamma = 1/{recovery_days}$ . - To estimate
$$\beta$$ directly, we'd need to know transmissibility and social contact rates. since we don't know these things, we can extract it from known doubling times. The AHA says to expect a doubling time$T_d$ of 7-10 days. That means an early-phase rate of growth can be computed by using the doubling time formula: """.format( doubling_time=parameters.doubling_time, recovery_days=parameters.infectious_days, r_naught=model.r_naught, relative_contact_rate=parameters.relative_contact_rate, doubling_time_t=model.doubling_time_t, r_t=model.r_t, ) ) st.latex("g = 2^{1/T_d} - 1") st.markdown( """ - Since the rate of new infections in the SIR model is
$g = \beta S - \gamma$ , and we've already computed$\gamma$ ,$\beta$ becomes a function of the initial population size of susceptible individuals.$$\beta = (g + \gamma)$$ .
-
{notes} \n """.format( notes=notes ) ) return None def display_actuals_definitions(): st.markdown("""""", unsafe_allow_html=True) st.header("Application Guidance") st.subheader("Working with Scenarios") st.markdown(""" This tool has the ability to load and save parameters, as well as save parameters and calculations. Enable these features by changing the Author Name and Scenario Name to values of your choosing. Rather than create the parameter file from scratch we highly recommend using the "Save Parameters" button to create a parameter file which can then be edited by hand if desired. Please note however that it is easy to inadvertently produce an invalid JSON file when editing by hand. If you wish to update a set of existing parameters we recommend loading in the parameters, editing them in the UI, and re-exporting a new version of the parameters.
Saving Parameters: At the bottom of the left sidebar, a download link will appear to save your parameters as a file. Click to save the file. This file is .json and can be opened in a text editor.
Loading Parameters: At the top of the left sidebar, browse for a parameter file (in the same format as the exported parameters) or drag and drop. Parameter values will update.
Saving Calculations: At the bottom of the main page, a link will appear to save all model parameters and calculations as a .csv file. Click the link to save the file. """) st.markdown( """For more details on input selection, please refer here: User Documentation""" ) st.markdown("""""", unsafe_allow_html=True) st.subheader("Working with Actuals") st.markdown( """ Using the parameters in the sidebar it is possible to configure theoretical projections that are driven by the SIR model. However you may also upload actual data which will be displayed along with the projections in the appropriate chart above. To upload actual data please use the file upload widget at the bottom of the sidebar. Uploaded files must be in the comma-separated-value (CSV) format. Below is a list of columns that you may include in the uploaded CSV file along with a description of each column. Please note that column names are case sensitive.
date
: The date corresponding to the measurements below. One or more of the following columns must also be present:
total_admissions_actual
: The total number of COVID-19 patients admitted ondate
. icu_admissions_actual
: The number of COVID-19 patients who entered the ICU ondate
. intubated_actual
: The number of COVID-19 patients who were intubated ondate
. total_census_actual
: The total hospital COVID-19 census ondate
. icu_census_actual
: The ICU COVID-19 census ondate
. ventilators_in_use_actual
: The number of ventilators in use for COVID-19 patients ondate
. cumulative_regional_infections
: The total number of infections in your region or catchment area ondate
. This number must be cumulative rather than a count of currently infected people. A non-cumulative version of this column is generated before it is displayed in the SIR chart above, nameddaily_regional_infections
. """ ) actuals_download_widget() def display_footer(): st.header("References & Acknowledgements") st.markdown( """* This application is based on the work that is developed and made freely available (under MIT license) by Penn Medicine (https://github.com/CodeForPhilly/chime). """ )st.markdown("""""", unsafe_allow_html=True) st.subheader("Features and Enhancements History") if st.checkbox("Show Features and Enhancements History"): st.markdown("""
V: 2.0.1 (Friday, 1, 2020) * Added "emprical forecasts". Leverages county infection and population data to forecast future infections.**V: 1.7.1 (Tuesday, April 14, 2020)** * Added Non-ICU to all charts. This corresponds to Hospitalized in Penn Med. * Changed Total color to black, other colors match Penn Med.
V: 1.6.0 (Monday, April 13, 2020) * Added ability to select a social distancing start date that is independent of the current date. This is to maintain consistency with Penn Med's functionality. V: 1.5.3 (Thursday, April 09, 2020) * Added staffing functionality * Changed exported column name to "VentilatorsAdmissions" * Moved capacity parameters to lower on sidebar * Fixed a bug where first row contained NaNs in full downloaded data
**V: 1.4.0 (Wednesday, April 08, 2020)**
* Added **PPE/patient/day functionality**
* Changed minimum days to project to 7
V: 1.3.7 (Tuesday, April 07, 2020) * Fixed estimated start day bug when "Number of Days to Project" was low * Fixed total census to be a sum of ICU and non-ICU V: 1.3.5 (Monday, April 06, 2020) * Added support for providing historical data and incorporating it in the hospital admission/census/COVID-19 capacity charts/projections
**V: 1.2.11 (Thursday, April 02, 2020):**
* Incorporated changes made by **Penn Med to ensure replicability**
* Created parameter categories in the left menu for better organization
* Added support for specifying the date of the first hospitalized case
V: 1.1.1 (Friday, March 27, 2020):
* Added support for **loading and saving capacity planning scenarios**
* Added support for **understanding capacity** as well as demand by specifying Numbers of Total Beds, ICU Beds, and Ventilators for COVID-19 Patients
* Added support for exporting full dataset and capacity scenario as a csv file
""")
st.markdown("© 2020, Health Catalyst Inc.")