Skip to content

Commit

Permalink
Merge pull request #3 from BrianThomasRoss/dash-app
Browse files Browse the repository at this point in the history
Push to remote devel
  • Loading branch information
BrianThomasRoss authored Mar 24, 2020
2 parents e5dfa31 + a1a38c9 commit 8cc5443
Show file tree
Hide file tree
Showing 50 changed files with 225 additions and 11,324 deletions.
2 changes: 1 addition & 1 deletion src/chime_dash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This directory should provide the interface for a dash app.
E.g., it contains the actual app which pieces together individual parts which could potentially live on their own.
This makes it easier to modularize and reuse parts.

![Current interface](interface.png)
![Current interface](docs/assets/interface.png)

## Todo
Plots & callbacks
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Combines all components
The `sidbar` component cobines all the inputs while other components potentially
The `sidebar` component combines all the inputs while other components potentially
have callbacks.
To add or remove components, adjust the `setup`.
Expand All @@ -14,13 +14,14 @@

from penn_chime.defaults import Constants

from chime_dash.layout import sidebar
from chime_dash.layout import header
from chime_dash.layout import intro
from chime_dash.layout import additions
from chime_dash.layout import visualizations
from chime_dash.layout import definitions
from chime_dash.layout import footer
from chime_dash.app.components import sidebar
from chime_dash.app.components import header
from chime_dash.app.components import intro
from chime_dash.app.components import additions
from chime_dash.app.components import visualizations
from chime_dash.app.components import definitions
from chime_dash.app.components import footer
from chime_dash.app.components import navbar


EXTERNAL_STYLESHEETS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from penn_chime.utils import add_date_column
from penn_chime.parameters import Parameters

from chime_dash.utils import read_localization_yaml, df_to_html_table
from chime_dash.plotting import plot_dataframe
from chime_dash.app.utils.templates import read_localization_yaml, df_to_html_table
from chime_dash.app.services.plotting import plot_dataframe


LOCALIZATION_FILE = "additions.yml"
Expand Down
41 changes: 41 additions & 0 deletions src/chime_dash/app/components/menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Initializes dropdown menu
"""
import dash_bootstrap_components as dbc


def setup ():
menu = dbc.DropdownMenu(
children=[
dbc.DropdownMenuItem(
"Penn Medicine",
header=True),
dbc.DropdownMenuItem(
"Predictive Healthcare",
href='http://predictivehealthcare.pennmedicine.org/',
external_link=True
),
dbc.DropdownMenuItem(
"Contact Us",
href='http://predictivehealthcare.pennmedicine.org/contact/',
external_link=True
),
dbc.DropdownMenuItem(
"User Docs",
href="https://code-for-philly.gitbook.io/chime/",
external_link=True
),
dbc.DropdownMenuItem(
"GitHub",
href="https://github.com/CodeForPhilly/chime",
external_link=True
),
dbc.DropdownMenuItem(
"Slack",
href="https://codeforphilly.org/chat?channel=covid19-chime-penn"
)
],
in_navbar=True,
label="Learn More",
color="light"
)
return menu
35 changes: 35 additions & 0 deletions src/chime_dash/app/components/navbar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Navigation bar view
"""
from typing import List
from chime_dash.app.static import header
from chime_dash.app.components import menu

import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.development.base_component import ComponentMeta


def setup (language: str) -> List[ComponentMeta]:
"""Initialize the navigation bar
"""
nav = dbc.Navbar(
dbc.Container(
[
html.A(
dbc.Row(
children=[
dbc.Col(header.setup(language)),
dbc.Col(
dbc.NavbarBrand(
children='Penn Medicine CHIME',
href='/')
)
],
align="center",
no_gutters=True,
),
href='https://www.pennmedicine.org/'),
menu.setup()
]
))
return nav
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from penn_chime.defaults import RateLos, Constants
from penn_chime.parameters import Parameters

from chime_dash.utils import read_localization_yaml
from chime_dash.app.utils.templates import read_localization_yaml

LOCALIZATION_FILE = "sidebar.yml"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from penn_chime.parameters import Parameters


from chime_dash.utils import read_localization_yaml, df_to_html_table
from chime_dash.plotting import plot_dataframe
from chime_dash.app.utils.templates import read_localization_yaml, df_to_html_table
from chime_dash.app.services.plotting import plot_dataframe

LOCALIZATION_FILE = "visualizations.yml"

Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions src/chime_dash/app/pages/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""pages/index
Homepage
"""
from typing import List

import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.development.base_component import ComponentMeta

from chime_dash.app.components import navbar
from chime_dash.app.static.homepage import introducing_chime, latest_updates


def render (language: str) -> List[ComponentMeta]:
"""Initializes page
"""
layout = html.Div(
[
dbc.Row(navbar.setup(language)),
dbc.Col(
children=introducing_chime('en')
),
dbc.Col(
children=latest_updates('en')
)
]
)
return layout
4 changes: 4 additions & 0 deletions src/chime_dash/app/services/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
app/services
"""
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from dash.development.base_component import ComponentMeta

from chime_dash.utils import read_localization_markdown
from chime_dash.app.utils.templates import read_localization_markdown
from dash_core_components import Markdown


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dash.development.base_component import ComponentMeta
from dash_core_components import Markdown

from chime_dash.utils import read_localization_markdown
from chime_dash.app.utils.templates import read_localization_markdown

LOCALIZATION_FILE = "footer.md"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dash.development.base_component import ComponentMeta
from dash_html_components import Div, A

from chime_dash.utils import read_localization_yaml
from chime_dash.app.utils.templates import read_localization_yaml

LOCALIZATION_FILE = "header.yml"

Expand Down
25 changes: 25 additions & 0 deletions src/chime_dash/app/static/homepage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import List

from dash.development.base_component import ComponentMeta
from dash_core_components import Markdown

from chime_dash.app.utils.templates import read_localization_markdown

LOCALIZATION_FILE_1 = "chime-intro.md"
LOCALIZATION_FILE_2 = "latest-updates.md"


def introducing_chime (language: str) -> List[ComponentMeta]:
"""Initializes the header dash html
"""
content = read_localization_markdown(LOCALIZATION_FILE_1, language)

return [Markdown(content)]


def latest_updates (language: str) -> List[ComponentMeta]:
"""Initializes the header dash html
"""
content = read_localization_markdown(LOCALIZATION_FILE_2, language)

return [Markdown(content)]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from penn_chime.defaults import Constants
from penn_chime.parameters import Parameters

from chime_dash.utils import read_localization_markdown
from chime_dash.app.utils.templates import read_localization_markdown

LOCALIZATION_FILE_1 = "intro.md"
LOCALIZATION_FILE_2 = "tool-details.md"
Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions src/chime_dash/app/templates/en/chime-intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# CHIME
### A Tool for COVID-19 Capacity Planning

As we prepare for the additional demands that the COVID-19
outbreak will place on our hospital system, our operational
leaders need up-to-date projections of what additional resources
will be required. Informed estimates of how many patients will
need hospitalization, ICU beds, and mechanical ventilation over
the coming days and weeks will be crucial inputs to readiness responses
and mitigation strategies.

CHIME allows hospitals to enter information about their population and modify assumptions around the spread and behavior of COVID-19. It then runs a standard SIR model to project the number of new hospital admissions each day, along with the daily hospital census. These projections can then be used to create best- and worst-case scenarios to assist with capacity planning. We’re announcing today that we’re open-sourcing CHIME and making it available to the healthcare community.

While the default parameters are customized and continually updated to reflect the situation at Penn Medicine, CHIME can be adapted for use by any hospital system by modifying parameters to reflect local contexts.

The most impactful parameter in a SIR model is the Doubling Time. This parameter defines how rapidly a disease spreads. Experiences in other geographical contexts suggest that doubling time may range from 3 to 13 days or more, with notable examples:

Wuhan, China: 6 days
South Korea: 13 days (As of March 14, 2020)
Italy: 5 days (As of March 14, 2020)
This value is particularly important because of the exponential nature of the spread of infectious diseases such as COVID-19. This is also why public health officials recommend measures like social distancing and hand washing: the more we can slow down the spread of COVID-19, the lower the peak demand on our healthcare system. Try out our live version of CHIME and see what happens when you modify the Doubling Time parameter. You can also experiment with scenarios involving different levels of incidence severity and average lengths of stay for each severity class.

We’ve put effort into determining good estimates for all model parameters and have set default values accordingly. Some of the default values are based on the current situation in our home region of Philadelphia. If you’re working somewhere outside of the Philadelphia region you can simply modify the following parameters to suit your patient population:

Currently Known Regional Infections
Currently Hospitalized COVID-19 Patients
Hospital Market Share (%)
As local spread progresses, revised estimates can be made for some of the values in CHIME. We will try our best to keep things up to date with the latest research, but if you find an issue with any of the values we are using we’d appreciate your feedback and contributions. We also set up a Slack channel if you’d like to chat with us.

– Penn Predictive Healthcare Team
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions src/chime_dash/app/templates/en/latest-updates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Latest Updates

## [CHIME 0.5.0 released with major updates](http://predictivehealthcare.pennmedicine.org/2020/03/23/admissions_bug_fix.html)
---
###### Mar 23, 2020

What was fixed Unfortunately, the COVID-19 crisis forces us to move quickly and one downside
of moving quickly is it’s easier to make mistakes. Our latest release of CHIME contains
a major bug fix to the way we were calculating daily admissions and census. In the previous
version of CHIME, we were not properly accounting for recovered (previously infected)
patients in our accounting of newly admitted patients. This was resulting in an undercount
of admissions...
[Read More >](http://predictivehealthcare.pennmedicine.org/2020/03/23/admissions_bug_fix.html)

## [CHIME comparison with Imperial College COVID-19 Publication](http://predictivehealthcare.pennmedicine.org/2020/03/18/compare-chime.html)
---
###### Mar 18, 2020

A few days ago we launched CHIME, a tool for COVID-19 hospital capacity planning. CHIME’s
simplified model design and interface enables quick support for hospital planners to assess
potential demand for resources over time. It also allows transparent and understandable
parameters for our partners to interrogate and modify as more information becomes available.
The recent paper from Imperial College COVID-19 Response Team gives us a window into
another model, set of assumptions, and resulting projections....
[Read More >](http://predictivehealthcare.pennmedicine.org/2020/03/18/compare-chime.html)

## [Announcing CHIME, A tool for COVID-19 capacity planning](http://predictivehealthcare.pennmedicine.org/2020/03/14/accouncing-chime.html)
---
###### Mar 14, 2020

As we prepare for the additional demands that the COVID-19 outbreak will place on our hospital
system, our operational leaders need up-to-date projections of what additional resources will
be required. Informed estimates of how many patients will need hospitalization, ICU beds,
and mechanical ventilation over the coming days and weeks will be crucial inputs to readiness
responses and mitigation strategies. To this end, the Predictive Healthcare team at
Penn Medicine has developed a tool that...
[Read More >](http://predictivehealthcare.pennmedicine.org/2020/03/14/accouncing-chime.html)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def read_localization_yaml(file: str, language: str) -> Dict[str, Any]:
Arguments:
file: Name of the section plus `.yml`
langage: Localization info
language: Localization info
Raises:
KeyError: If no template for file/language exists.
"""
file_address = path.join(TEMPLATE_DIR, language, file)
if not path.exists(file_address):
raise KeyError(
"No template found for langage '{language}' and section '{file}'".format(
"No template found for language '{language}' and section '{file}'".format(
file=file, language=language
)
)
Expand All @@ -42,7 +42,7 @@ def read_localization_markdown(file: str, language: str) -> str:
Arguments:
file: Name of the section plus `.md`
langage: Localization info
language: Localization info
Raises:
KeyError: If no template for file/language exists.
Expand Down
File renamed without changes
5 changes: 3 additions & 2 deletions src/dash_app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Script which launches dash app
"""
from dash import Dash
from flask import Flask

from penn_chime.settings import DEFAULTS

from chime_dash.layout import setup, EXTERNAL_STYLESHEETS, EXTERNAL_SCRIPTS
from chime_dash.layout import CALLBACK_INPUTS, CALLBACK_OUTPUTS, callback_body
from chime_dash.app.components import setup, EXTERNAL_STYLESHEETS, EXTERNAL_SCRIPTS
from chime_dash.app.components import CALLBACK_INPUTS, CALLBACK_OUTPUTS, callback_body

LANGUAGE = "en"

Expand Down
32 changes: 0 additions & 32 deletions src/dash_run.py

This file was deleted.

Empty file removed src/penn_chime_dash/.init
Empty file.
Loading

0 comments on commit 8cc5443

Please sign in to comment.