From 9c439771538861c7428bbfbd38ea3565d6f8f452 Mon Sep 17 00:00:00 2001 From: TomMonks Date: Tue, 23 Apr 2024 16:17:59 +0100 Subject: [PATCH] PAGES: removed old interative sim page --- index.html | 7 +- pages/0_Interactive_simulation.py | 149 ------------------ ...ulation_Model.py => 0_Simulation_Model.py} | 0 3 files changed, 2 insertions(+), 154 deletions(-) delete mode 100644 pages/0_Interactive_simulation.py rename pages/{8_Simulation_Model.py => 0_Simulation_Model.py} (100%) diff --git a/index.html b/index.html index 994e6f8..8390a6c 100644 --- a/index.html +++ b/index.html @@ -30,8 +30,8 @@ "Overview.py": { url: "https://raw.githubusercontent.com/pythonhealthdatascience/stars-stlite-example/main/Overview.py" }, -"pages/0_Interactive_simulation": { - url: "https://raw.githubusercontent.com/pythonhealthdatascience/stars-stlite-example/main/pages/0_Interactive_simulation.py" +"pages/0_Simulation_Model.py": { + url: "https://raw.githubusercontent.com/pythonhealthdatascience/stars-stlite-example/main/pages/0_Simulation_Model.py" }, "pages/1_💾_Preset_Experiments": { url: "https://raw.githubusercontent.com/pythonhealthdatascience/stars-stlite-example/main/pages/1_💾_Preset_Experiments.py" @@ -54,9 +54,6 @@ "pages/7_🗒️_Change_Log.py": { url: "https://raw.githubusercontent.com/pythonhealthdatascience/stars-stlite-example/main/pages/7_🗒️_Change_Log.py" }, -"pages/8_Simulation_Model.py": { - url: "https://raw.githubusercontent.com/pythonhealthdatascience/stars-stlite-example/main/pages/8_Simulation_Model.py" -}, "model.py": { url: "https://raw.githubusercontent.com/pythonhealthdatascience/stars-stlite-example/main/model.py" }, diff --git a/pages/0_Interactive_simulation.py b/pages/0_Interactive_simulation.py deleted file mode 100644 index 31b54f5..0000000 --- a/pages/0_Interactive_simulation.py +++ /dev/null @@ -1,149 +0,0 @@ -import streamlit as st -import pandas as pd -import numpy as np -import model as md -# from PIL import Image - -# Modification -> upgrade from matplotlib -from utility import get_arrival_chart - -# Modifcation use of Plotly implementation of MORE plot -from more_plot import more_plotly - -INFO_1 = '''**A simple simulation model of a urgent care and treatment centre.**''' -INFO_1a = '''**Change the model parameters and rerun to see the effect on waiting times and -utilisation of rooms**''' - -INFO_2 = '**Run 5 pre-specified scenarios and compare results.**' - -INFO_3 = '''**Trauma arrivals:** -patients with severe illness and trauma that must first be stablised in a -trauma room. These patients then undergo treatment in a cubicle before being -discharged.''' - -INFO_4 = '''**Non-trauma arrivals** -patients with minor illness and no trauma go through registration and -examination activities. A proportion of non-trauma patients require treatment -in a cubicle before being dicharged. ''' - -SC_TABLE = ''' -| | Scenario | Description | -|---|-------------------------|----------------------------------------------------------------------| -| 1 | As-is | Uses default settings - represents how the system currently operates | -| 2 | Triage + 1 | Add an additional triage bay for new patients | -| 3 | Exam + 1 | Add an additional examination cubicle for the non-trauma pathway | -| 4 | Treat + 1 | Add an extra non-trauma treatment cubicle | -| 5 | Swap Exam & Treat | Convert an exam room into a non_trauma treatment cubicle | -| 6 | Scenario 5 + short exam | Scenario 5 changes + examination takes 4 mins less on average | - -''' - - - -st.set_page_config( - #page_title="Ex-stream-ly Cool App", - page_icon="🧊", - layout="wide", - initial_sidebar_state="expanded", - menu_items={ - # 'Get Help': 'https://www.extremelycoolapp.com/help', - # 'Report a bug': "https://www.extremelycoolapp.com/bug", - 'About': "## Treatment centre sim. Adapted from Nelson (2013)." - } - ) - -st.title('Treatment Centre Simulation Model') - -# image = Image.open('img/nihr.png') -# st.image(image) - -st.markdown(INFO_1) - -# Using "with" notation -with st.sidebar: - st.markdown('# Parameters') - - st.markdown('## Capacity constraints') - - triage_bays = st.slider('Triage bays', 1, 5, md.DEFAULT_N_TRIAGE) - exam_rooms = st.slider('Exam rooms', 1, 5, md.DEFAULT_N_EXAM) - treat_rooms = st.slider('Non-Trauma Treatment cubicles', 1, 5, md.DEFAULT_N_CUBICLES_1, - help='Set the number of non trauma pathway treatment cubicles') - - st.markdown('## Trauma Pathway') - # proportion of patients triaged as trauma - trauma_p = st.slider('Probability trauma patient', 0.0, 1.0, - md.DEFAULT_PROB_TRAUMA, 0.01) - - trauma_mean = st.slider('Mean treatment time', 0.0, 100.0, - md.DEFAULT_TRAUMA_TREAT_MEAN, 1.0) - - trauma_var = st.slider('Variance of treatment time', 0.0, 10.0, - md.DEFAULT_TRAUMA_TREAT_VAR, 0.5) - - st.markdown('## Non-Trauma Pathway') - - #examination mean - exam_mean = st.slider('Mean examination time', 0.0, 45.0, - md.DEFAULT_EXAM_MEAN, 1.0) - - exam_var = st.slider('Variance of examination time', 0.0, 15.0, - md.DEFAULT_EXAM_VAR, 0.5) - - # proportion of non-trauma patients that require treatment - nontrauma_treat = st.slider('Probability non-trauma treatment', 0.0, 1.0, - md.DEFAULT_NON_TRAUMA_TREAT_P) - - nt_trauma_mean = st.slider('Mean treatment time', 0.0, 100.0, - md.DEFAULT_NON_TRAUMA_TREAT_MEAN, 1.0) - - nt_trauma_var = st.slider('Variance of treatment time', 0.0, 10.0, - md.DEFAULT_NON_TRAUMA_TREAT_VAR, 0.5) - -# put info in columns -col1, col2 = st.columns(2) -with col1.expander('Treatment process', expanded=False): - st.image('img/process_flow_img.jpg') - st.markdown(INFO_3) - st.markdown(INFO_4) - -with col2.expander('Daily Arrival Pattern', expanded=False): - st.plotly_chart(get_arrival_chart(), use_container_width=True) - -st.markdown(INFO_1a) - -# set up scenario -args = md.Scenario() -args.n_triage = triage_bays -args.n_exam = exam_rooms -args.n_cubicles_1 = treat_rooms -args.treat_trauma_mean = trauma_mean -args.treat_trauma_var = trauma_var -args.nt_treat_prob = nontrauma_treat -args.nt_treat_mean = nt_trauma_mean -args.nt_treat_var = nt_trauma_var -args.prob_trauma = trauma_p -args.exam_mean = exam_mean -args.exam_var = exam_var - -# MODFICATION - moved from the sidebar. -replications = st.number_input("Multiple runs", value=10, placeholder="Enter no. replications to run...") - -if st.button('Simulate treatment centre'): - # Get results - with st.spinner('Simulating the treatment centre...'): - results = md.multiple_replications(args, n_reps = replications) - - st.success('Done!') - - col1, col2 = st.columns(2) - with col1.expander('Tabular results', expanded=True): - summary_series = results.mean().round(1) - summary_series.name = 'Mean' - st.table(summary_series) - - with col2.expander('MORE Plot', expanded=True): - more_fig = more_plotly(results['09_throughput'].to_numpy(), - x_label='Average Daily Throughput') - st.plotly_chart(more_fig, use_container_width=True) - diff --git a/pages/8_Simulation_Model.py b/pages/0_Simulation_Model.py similarity index 100% rename from pages/8_Simulation_Model.py rename to pages/0_Simulation_Model.py