Rathapoom commited on
Commit
4faf225
1 Parent(s): 99dfc30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -18
app.py CHANGED
@@ -1,11 +1,15 @@
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:
@@ -21,21 +25,21 @@ if st.session_state["scene"] == 1:
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:
@@ -48,22 +52,23 @@ elif st.session_state["scene"] == 2:
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:
@@ -77,11 +82,13 @@ elif st.session_state["scene"] == 3:
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:
 
1
  import streamlit as st
2
  import time
3
 
4
+ # Initialize session state variables
5
  if "scene" not in st.session_state:
6
+ st.session_state["scene"] = 1 # Start at Scene 1
7
  if "pain_increase" not in st.session_state:
8
+ st.session_state["pain_increase"] = False # Tracks whether pain has worsened
9
+
10
+ # Function to change the scene
11
+ def change_scene(next_scene):
12
+ st.session_state["scene"] = next_scene
13
 
14
  # Scene 1: Patient arrives at ER
15
  if st.session_state["scene"] == 1:
 
25
  if choice == "Examine the leg":
26
  st.image("2.jpg", caption="Exam findings: Swollen leg, no significant tension", use_container_width=True)
27
  st.write("Findings: Swollen leg with mild tenderness. Compartment Syndrome is not confirmed.")
28
+ if st.button("Proceed to next step"):
29
+ change_scene(2)
30
 
31
  elif choice == "Send for X-ray":
32
  st.image("3.jpg", caption="X-ray: Tibial fracture observed", use_container_width=True)
33
  st.write("Findings: Tibial fracture confirmed. This does not rule out Compartment Syndrome.")
34
+ if st.button("Go Back to Scene 1"):
35
+ change_scene(1)
36
 
37
  elif choice == "Administer painkillers":
38
  st.image("4.jpg", caption="Painkillers administered", use_container_width=True)
39
  st.success("The patient reports feeling better for now.")
40
+ st.session_state["pain_increase"] = True # Set pain to increase later
41
+ if st.button("Proceed to next step"):
42
+ change_scene(2)
43
 
44
  # Scene 2: Monitoring or Further Action
45
  elif st.session_state["scene"] == 2:
 
52
 
53
  if choice == "Monitor and Wait":
54
  st.write("Monitoring the patient... Please wait.")
55
+ time.sleep(5) # Simulate waiting
56
  if st.session_state["pain_increase"]:
57
  st.warning("The patient reports severe pain again.")
58
+ if st.button("Proceed to next step"):
59
+ change_scene(3)
60
 
61
  elif choice == "Repeat Exam":
62
  st.image("5.jpg", caption="Repeat examination shows no major changes", use_container_width=True)
63
  st.write("Findings: The swelling remains mild. Compartment Pressure is not elevated yet.")
64
+ if st.button("Go Back to Scene 2"):
65
+ change_scene(2)
66
 
67
  elif choice == "Measure Compartment Pressure":
68
  st.image("6.jpg", caption="Compartment pressure measurement", use_container_width=True)
69
  st.write("Results: Compartment pressure is within normal limits at this time.")
70
+ if st.button("Proceed to next step"):
71
+ change_scene(2)
72
 
73
  # Scene 3: Progression of Symptoms
74
  elif st.session_state["scene"] == 3:
 
82
  if choice == "Re-check Compartment Pressure":
83
  st.image("7.jpg", caption="Re-measurement of Compartment Pressure", use_container_width=True)
84
  st.success("Pressure >30 mmHg. Confirmed Compartment Syndrome.")
85
+ if st.button("Proceed to next step"):
86
+ change_scene(4)
87
 
88
  elif choice == "Continue Monitoring":
89
  st.error("The patient's condition worsens further. Necrosis has begun.")
90
+ if st.button("Proceed to next step"):
91
+ change_scene(4)
92
 
93
  # Scene 4: Treatment
94
  elif st.session_state["scene"] == 4: