Spaces:
Build error
Build error
| import streamlit as st | |
| import time | |
| # Initialize session state variables | |
| if "scene" not in st.session_state: | |
| st.session_state["scene"] = 1 # Start at Scene 1 | |
| if "pain_increase" not in st.session_state: | |
| st.session_state["pain_increase"] = False # Tracks whether pain has worsened | |
| # Function to change the scene | |
| def change_scene(next_scene): | |
| st.session_state["scene"] = next_scene | |
| # Scene 1: Patient arrives at ER | |
| if st.session_state["scene"] == 1: | |
| st.title("Scene 1: Patient Arrives at ER") | |
| st.image("1.jpg", caption="Patient presenting with leg pain and swelling", use_container_width=True) | |
| st.write("The patient presents with severe pain in the lower leg after a motorcycle accident.") | |
| choice = st.radio( | |
| "What will you do first?", | |
| ["Select an option", "Examine the leg", "Send for X-ray", "Administer painkillers"] | |
| ) | |
| if choice == "Examine the leg": | |
| st.image("2.jpg", caption="Exam findings: Swollen leg, no significant tension", use_container_width=True) | |
| st.write("Findings: Swollen leg with mild tenderness. Compartment Syndrome is not confirmed.") | |
| if st.button("Proceed to next step"): | |
| change_scene(2) | |
| elif choice == "Send for X-ray": | |
| st.image("3.jpg", caption="X-ray: Tibial fracture observed", use_container_width=True) | |
| st.write("Findings: Tibial fracture confirmed. This does not rule out Compartment Syndrome.") | |
| if st.button("Go Back to Scene 1"): | |
| change_scene(1) | |
| elif choice == "Administer painkillers": | |
| st.image("4.jpg", caption="Painkillers administered", use_container_width=True) | |
| st.success("The patient reports feeling better for now.") | |
| st.session_state["pain_increase"] = True # Set pain to increase later | |
| if st.button("Proceed to next step"): | |
| change_scene(2) | |
| # Scene 2: Monitoring or Further Action | |
| elif st.session_state["scene"] == 2: | |
| st.title("Scene 2: Monitoring or Further Action") | |
| st.write("The patient is stable for now. What would you like to do?") | |
| choice = st.radio( | |
| "Choose your next step:", | |
| ["Select an option", "Observe and Monitor", "Repeat Exam", "Measure Compartment Pressure"] | |
| ) | |
| if choice == "Observe and Monitor": | |
| st.write("Monitoring the patient... Please wait.") | |
| time.sleep(5) # Simulate waiting | |
| st.warning("The patient reports severe pain again.") | |
| if st.button("Proceed to next step"): | |
| change_scene(3) | |
| elif choice == "Repeat Exam": | |
| st.image("5.jpg", caption="Repeat examination shows no major changes", use_container_width=True) | |
| st.write("Findings: The swelling remains mild. Compartment Pressure is not elevated yet.") | |
| if st.button("Go Back to Scene 2"): | |
| change_scene(2) | |
| elif choice == "Measure Compartment Pressure": | |
| st.image("6.jpg", caption="Compartment pressure measurement", use_container_width=True) | |
| st.write("Results: Compartment pressure is within normal limits at this time.") | |
| if st.button("Proceed to next step"): | |
| change_scene(2) | |
| # Scene 3: Progression of Symptoms | |
| elif st.session_state["scene"] == 3: | |
| st.title("Scene 3: Worsening Symptoms") | |
| st.write("The patient's symptoms are worsening: severe pain, tense swelling.") | |
| choice = st.radio( | |
| "Choose your next step:", | |
| ["Select an option", "Re-check Compartment Pressure", "Administer additional painkillers", "Continue Observation"] | |
| ) | |
| if choice == "Re-check Compartment Pressure": | |
| st.image("7.jpg", caption="Re-measurement of Compartment Pressure", use_container_width=True) | |
| st.success("Pressure >30 mmHg. Confirmed Compartment Syndrome.") | |
| if st.button("Proceed to next step"): | |
| change_scene(4) | |
| elif choice == "Administer additional painkillers": | |
| st.image("4.jpg", caption="Painkillers administered again", use_container_width=True) | |
| st.warning("The patient reports temporary relief but symptoms persist.") | |
| if st.button("Go Back to Scene 3"): | |
| change_scene(3) | |
| elif choice == "Continue Observation": | |
| st.error("The patient's condition worsens further. Necrosis has begun.") | |
| if st.button("Proceed to next step"): | |
| change_scene(4) | |
| # Scene 4: Treatment | |
| elif st.session_state["scene"] == 4: | |
| st.title("Scene 4: Treatment") | |
| st.write("What action will you take?") | |
| choice = st.radio( | |
| "Choose your treatment:", | |
| ["Select an option", "Perform Fasciotomy", "Observe further without Fasciotomy"] | |
| ) | |
| if choice == "Perform Fasciotomy": | |
| st.image("8.jpg", caption="Fasciotomy performed", use_container_width=True) | |
| st.success("Outcome: Patient recovers with minimal damage.") | |
| elif choice == "Observe further without Fasciotomy": | |
| st.image("9.jpg", caption="Continued observation leads to necrosis", use_container_width=True) | |
| st.error("Outcome: Permanent damage or amputation required.") | |