#SupplyDemand
Source code and data for an application (https://rush-covid19.herokuapp.com/) to aid US hospitals in planning their response to the ongoing COVID-19 pandemic. The application forecasts hospital visits, admits, discharges, and needs for hospital beds, ventilators, and personal protective equipment by coupling COVID-19 predictions to models of time lags, patient carry-over, and length-of-stay. Users can choose from seven COVID-19 models, customize 23 parameters, examine trends in testing and hospitalization, and download forecast data. The application accurately predicts the spread of COVID-19 across states and territories and its hospital-level forecasts are in continuous use by our home institution. The application is versatile, easy-to-use, and can help hospitals plan their response to the changing dynamics of COVID-19, while providing a platform for deeper study.
- Python 3.12 or greater
- werkzeug==3.0.6
- dash==3.0.1
- gunicorn==23.0.0
- numpy==2.2.4
- pandas==2.2.3
- scipy==1.15.2
- Flask==3.0.3
- plotly==6.0.1
- DateTime==5.5
- pathlib==1.0.1
- dash-core-components==2.0.0
- dash-html-components==2.0.0
Create a virtual environment for running this app with Python 3. Clone this repository and open your terminal/command prompt in the root folder.
python3.12 -m venv venv_python3_12
In Unix system:
source venv_python3_12/bin/activate
In Windows:
venv_python3_12\Scripts\activate
Install all required packages by running:
pip install -r requirements.txt
Run this app locally with:
python app.py
DataUpdate
A directory containing python scripts for updating data used by the application. To update data run the following scripts in the following order via your terminal window:
get_dataframe_dailyreports.py...downloads and formats state-level cumulative COVID-19 case data from the John's Hopkins CSSE github repository.get_US_dailyreports_JH_testing.py...downloads and formats state-level COVID-19 testing data from the John's Hopkins CSSE github repository.TestingData.py...downloads and formats state-level COVID-19 testing data from The Atlantic's COVID-19 Tracking Project.SEIR-SD_States_Update.py...Generates updated predictions for the SEIR-SD model for each US state and select territory
DataUpdate/data
A directory containing data files used by the application's app_fxns.py file. The data files are:
SEIR-SD_States_Update.txt...Latest updated version of SEIR-SD model predictionsTesting_Dataframe_Most_Recent_Day.pkl...Latest updated version of state-level COVID-19 testing results for the most recent day on record.Testing_Dataframe.pkl...Latest updated version of state-level COVID-19 testing results for all days on record.COVID-TESTING-DF...An intermediate file generated byget_US_dailyreports_JH_testing.pyand used byTestingData.pyto create the .pkl data files listed above.
ForManuscript:
A directory containing files and other directories needed to recreate figures in the associated manuscript. The files are directories are:
model_fxns.py...a script containing functions specific to the applications modelsModelFxns_Figs.py...a script to generate the general predicted forms of each model; associated with Figure 1 of the associated manuscript.results_dataframe.py...a script to generate results data for each model's predictive accuracy across time and US states and terroritories. The resulting filemodel_results_dataframe.pklis located in theForManuscript/datadirectory.ModelPerformance_Figs.py...a script to generate results figures for each model; associated with Figure 1 of the associated manuscript; uses themodel_results_dataframe.pklfile.
app.py
The application's main source code.
app_fxns.py
A python script containing functions needed by app.py.
model_fxns.py
A python script containing functions specific to the applications models
The following are files and directories that are necessary components of the plotly dash application structure
- venv & env -- a directory containing files and directories specific to the application environment and virtual environment
- flask -- a directory specific to enabling flask app functionality
- assets -- a directory of images used by the main application
- requirements.txt -- software requirements of the app
- runtime.txt -- python version required or best suited for running the app
- Procfile -- text file specific to gunicorn; contains a single line (web: gunicorn app:server )