Rathapoom commited on
Commit
9d8fb1d
1 Parent(s): a2224e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +96 -47
app.py CHANGED
@@ -1,51 +1,100 @@
1
  import streamlit as st
 
2
 
3
- # Title and introduction
4
- st.title("Case-Based Learning: Compartment Syndrome")
5
- st.write("**Case:** A 25-year-old male with a tibial fracture from a motorcycle accident.")
6
- st.write("**Presentation:** Severe pain in the lower leg, swelling, and difficulty moving his toes.")
7
- st.image("1.jpg", caption="Initial Presentation", use_container_width=True)
8
-
9
- # Scene 1: Initial choice
10
- st.subheader("Scene 1: Patient Arrives at ER")
11
- choice_1 = st.radio(
12
- "What will you do first?",
13
- ["Select an option", "Examine the leg", "Send for X-ray", "Administer strong analgesics"]
14
- )
15
-
16
- # Proceed only if a valid option is selected
17
- if choice_1 == "Examine the leg":
18
- st.image("2.jpg", caption="Examination Findings", use_container_width=True)
19
- st.write("Findings: Swollen, tense leg with pain on passive stretching and decreased sensation.")
20
- st.subheader("What is your next step?")
21
- choice_2 = st.radio(
22
- "Choose an action:",
23
- ["Select an option", "Measure compartment pressure", "Monitor and wait", "Repeat physical exam after medication"]
24
  )
25
- if choice_2 == "Measure compartment pressure":
26
- st.image("3.jpg", caption="Pressure Measurement", use_container_width=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  st.success("Pressure >30 mmHg. Confirmed Compartment Syndrome.")
28
- st.write("**Action:** Perform fasciotomy immediately.")
29
- st.image("4.jpg", caption="Fasciotomy Procedure", use_container_width=True)
30
- st.success("Outcome: Patient improves, damage prevented.")
31
- elif choice_2 == "Monitor and wait":
32
- st.image("5.jpg", caption="Monitoring Patient", use_container_width=True)
33
- st.error("Condition worsens. Outcome: Permanent damage or amputation.")
34
- elif choice_2 == "Repeat physical exam after medication":
35
- st.image("6.jpg", caption="Repeat Examination", use_container_width=True)
36
- st.warning("Findings: Swelling worsens, sensory loss increases.")
37
- st.write("**Action:** Proceed to measure compartment pressure.")
38
- st.image("3.jpg", caption="Pressure Measurement", use_container_width=True)
39
- st.success("Outcome: Pressure >30 mmHg. Perform fasciotomy.")
40
-
41
- elif choice_1 == "Send for X-ray":
42
- st.image("7.jpg", caption="X-ray Findings", use_container_width=True)
43
- st.write("Findings: Tibial fracture noted. Still suspect Compartment Syndrome based on symptoms.")
44
- st.write("Proceed to re-evaluate the patient.")
45
-
46
- elif choice_1 == "Administer strong analgesics":
47
- st.image("8.jpg", caption="Administering Pain Relief", use_container_width=True)
48
- st.warning("Pain worsens despite medication. Signs of compartment syndrome persist.")
49
- st.write("**Action:** Reassess and proceed to examination or measure compartment pressure.")
50
- else:
51
- st.write("Please select an option to proceed.")
 
1
  import streamlit as st
2
+ import time
3
 
4
+ # Track the current scene
5
+ if "scene" not in st.session_state:
6
+ st.session_state["scene"] = 1 # Start with Scene 1
7
+ if "pain_increase" not in st.session_state:
8
+ st.session_state["pain_increase"] = False # Track pain progression
9
+
10
+ # Scene 1: Patient arrives at ER
11
+ if st.session_state["scene"] == 1:
12
+ st.title("Scene 1: Patient Arrives at ER")
13
+ st.image("1.jpg", caption="Patient presenting with leg pain and swelling", use_container_width=True)
14
+ st.write("The patient presents with severe pain in the lower leg after a motorcycle accident.")
15
+
16
+ choice = st.radio(
17
+ "What will you do first?",
18
+ ["Select an option", "Examine the leg", "Send for X-ray", "Administer painkillers"]
 
 
 
 
 
 
19
  )
20
+
21
+ if choice == "Examine the leg":
22
+ st.image("2.jpg", caption="Exam findings: Swollen leg, no significant tension", use_container_width=True)
23
+ st.write("Findings: Swollen leg with mild tenderness. Compartment Syndrome is not confirmed.")
24
+ if st.button("Proceed"):
25
+ st.session_state["scene"] = 2
26
+
27
+ elif choice == "Send for X-ray":
28
+ st.image("3.jpg", caption="X-ray: Tibial fracture observed", use_container_width=True)
29
+ st.write("Findings: Tibial fracture confirmed. This does not rule out Compartment Syndrome.")
30
+ if st.button("Go Back"):
31
+ st.session_state["scene"] = 1
32
+
33
+ elif choice == "Administer painkillers":
34
+ st.image("4.jpg", caption="Painkillers administered", use_container_width=True)
35
+ st.success("The patient reports feeling better for now.")
36
+ st.session_state["pain_increase"] = True # Pain will worsen later
37
+ if st.button("Proceed"):
38
+ st.session_state["scene"] = 2
39
+
40
+ # Scene 2: Monitoring or Further Action
41
+ elif st.session_state["scene"] == 2:
42
+ st.title("Scene 2: Monitoring or Further Action")
43
+ st.write("The patient is stable for now. What would you like to do?")
44
+ choice = st.radio(
45
+ "Choose your next step:",
46
+ ["Select an option", "Monitor and Wait", "Repeat Exam", "Measure Compartment Pressure"]
47
+ )
48
+
49
+ if choice == "Monitor and Wait":
50
+ st.write("Monitoring the patient... Please wait.")
51
+ time.sleep(5) # Simulate waiting time
52
+ if st.session_state["pain_increase"]:
53
+ st.warning("The patient reports severe pain again.")
54
+ st.session_state["scene"] = 3
55
+
56
+ elif choice == "Repeat Exam":
57
+ st.image("5.jpg", caption="Repeat examination shows no major changes", use_container_width=True)
58
+ st.write("Findings: The swelling remains mild. Compartment Pressure is not elevated yet.")
59
+ if st.button("Go Back"):
60
+ st.session_state["scene"] = 2
61
+
62
+ elif choice == "Measure Compartment Pressure":
63
+ st.image("6.jpg", caption="Compartment pressure measurement", use_container_width=True)
64
+ st.write("Results: Compartment pressure is within normal limits at this time.")
65
+ if st.button("Proceed"):
66
+ st.session_state["scene"] = 2
67
+
68
+ # Scene 3: Progression of Symptoms
69
+ elif st.session_state["scene"] == 3:
70
+ st.title("Scene 3: Worsening Symptoms")
71
+ st.write("The patient's symptoms are worsening: severe pain, tense swelling.")
72
+ choice = st.radio(
73
+ "Choose your next step:",
74
+ ["Select an option", "Re-check Compartment Pressure", "Continue Monitoring"]
75
+ )
76
+
77
+ if choice == "Re-check Compartment Pressure":
78
+ st.image("7.jpg", caption="Re-measurement of Compartment Pressure", use_container_width=True)
79
  st.success("Pressure >30 mmHg. Confirmed Compartment Syndrome.")
80
+ st.session_state["scene"] = 4
81
+
82
+ elif choice == "Continue Monitoring":
83
+ st.error("The patient's condition worsens further. Necrosis has begun.")
84
+ st.session_state["scene"] = 4
85
+
86
+ # Scene 4: Treatment
87
+ elif st.session_state["scene"] == 4:
88
+ st.title("Scene 4: Treatment")
89
+ st.write("What action will you take?")
90
+ choice = st.radio(
91
+ "Choose your treatment:",
92
+ ["Select an option", "Perform Fasciotomy", "Delay Treatment"]
93
+ )
94
+
95
+ if choice == "Perform Fasciotomy":
96
+ st.image("8.jpg", caption="Fasciotomy performed", use_container_width=True)
97
+ st.success("Outcome: Patient recovers with minimal damage.")
98
+ elif choice == "Delay Treatment":
99
+ st.image("9.jpg", caption="Delayed treatment leads to necrosis", use_container_width=True)
100
+ st.error("Outcome: Permanent damage or amputation required.")