Ashar086 commited on
Commit
7eaf733
·
verified ·
1 Parent(s): 7825ad6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -52
app.py CHANGED
@@ -70,60 +70,62 @@ def create_gauge(title, value, max_value, domain, gauge_color):
70
  fig.update_layout(template='plotly_dark')
71
  return fig
72
 
73
- # Prepare data
74
- distribute_patients()
75
- total_treatments, successful_treatments, unsuccessful_treatments, patients_waiting = generate_treatment_metrics()
76
- doctor_actions = generate_doctor_actions(total_treatments)
77
- penalties = generate_penalties(total_treatments)
78
- feedback = generate_feedback(total_treatments)
79
-
80
  # Streamlit setup
81
  st.title("Interactive Healthcare Metrics")
82
 
83
- # Slider to choose the animation
84
- animation_index = st.slider("Select Animation", min_value=1, max_value=5, value=1)
85
-
86
- # Animation 1: Patient Conditions
87
- if animation_index == 1:
88
- st.subheader("Patients by Condition")
89
- for condition, count in condition_counts.items():
90
- fig = create_gauge(f"Patients with {condition}", count, agents["Patients"], {'x': [0, 1], 'y': [0, 1]}, 'blue')
91
- st.plotly_chart(fig, use_container_width=True)
92
- st.markdown("---")
93
-
94
- # Animation 2: Treatment Metrics
95
- elif animation_index == 2:
96
- st.subheader("Treatment Metrics")
97
- fig1 = create_gauge("Total Patients", agents["Patients"], agents["Patients"], {'x': [0, 0.5], 'y': [0, 1]}, 'green')
98
- fig2 = create_gauge("Successful Treatments", successful_treatments, total_treatments, {'x': [0.5, 1], 'y': [0, 0.5]}, 'orange')
99
- fig3 = create_gauge("Unsuccessful Treatments", unsuccessful_treatments, total_treatments, {'x': [0.5, 1], 'y': [0.5, 1]}, 'red')
100
- st.plotly_chart(fig1, use_container_width=True)
101
- st.plotly_chart(fig2, use_container_width=True)
102
- st.plotly_chart(fig3, use_container_width=True)
103
- st.markdown("---")
104
-
105
- # Animation 3: Doctor Actions
106
- elif animation_index == 3:
107
- st.subheader("Doctor Actions")
108
- for action, count in doctor_actions.items():
109
- fig = create_gauge(f"Doctor Action: {action}", count, total_treatments, {'x': [0, 1], 'y': [0, 1]}, 'purple')
110
- st.plotly_chart(fig, use_container_width=True)
111
- st.markdown("---")
112
-
113
- # Animation 4: Penalties
114
- elif animation_index == 4:
115
- st.subheader("Penalties")
116
- for penalty, count in penalties.items():
117
- fig = create_gauge(f"Penalty: {penalty}", count, total_treatments // 6, {'x': [0, 1], 'y': [0, 1]}, 'red')
118
- st.plotly_chart(fig, use_container_width=True)
119
- st.markdown("---")
120
-
121
- # Animation 5: Patient Feedback
122
- elif animation_index == 5:
123
- st.subheader("Patient Feedback")
124
- for fb, count in feedback.items():
125
- fig = create_gauge(f"Feedback: {fb}", count, total_treatments, {'x': [0, 1], 'y': [0, 1]}, 'blue')
126
- st.plotly_chart(fig, use_container_width=True)
127
  st.markdown("---")
128
 
129
- st.write("**End of Animations.**")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  fig.update_layout(template='plotly_dark')
71
  return fig
72
 
 
 
 
 
 
 
 
73
  # Streamlit setup
74
  st.title("Interactive Healthcare Metrics")
75
 
76
+ # Button to run the animations
77
+ if st.button("Run Animations"):
78
+ # Prepare data
79
+ distribute_patients()
80
+ total_treatments, successful_treatments, unsuccessful_treatments, patients_waiting = generate_treatment_metrics()
81
+ doctor_actions = generate_doctor_actions(total_treatments)
82
+ penalties = generate_penalties(total_treatments)
83
+ feedback = generate_feedback(total_treatments)
84
+
85
+ # Slider to choose the animation
86
+ animation_index = st.slider("Select Animation", min_value=1, max_value=5, value=1)
87
+
88
+ # Animation 1: Patient Conditions
89
+ if animation_index == 1:
90
+ st.subheader("Patients by Condition")
91
+ for condition, count in condition_counts.items():
92
+ fig = create_gauge(f"Patients with {condition}", count, agents["Patients"], {'x': [0, 1], 'y': [0, 1]}, 'blue')
93
+ st.plotly_chart(fig, use_container_width=True)
94
+ st.markdown("---")
95
+
96
+ # Animation 2: Treatment Metrics
97
+ elif animation_index == 2:
98
+ st.subheader("Treatment Metrics")
99
+ fig1 = create_gauge("Total Patients", agents["Patients"], agents["Patients"], {'x': [0, 0.5], 'y': [0, 1]}, 'green')
100
+ fig2 = create_gauge("Successful Treatments", successful_treatments, total_treatments, {'x': [0.5, 1], 'y': [0, 0.5]}, 'orange')
101
+ fig3 = create_gauge("Unsuccessful Treatments", unsuccessful_treatments, total_treatments, {'x': [0.5, 1], 'y': [0.5, 1]}, 'red')
102
+ st.plotly_chart(fig1, use_container_width=True)
103
+ st.plotly_chart(fig2, use_container_width=True)
104
+ st.plotly_chart(fig3, use_container_width=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  st.markdown("---")
106
 
107
+ # Animation 3: Doctor Actions
108
+ elif animation_index == 3:
109
+ st.subheader("Doctor Actions")
110
+ for action, count in doctor_actions.items():
111
+ fig = create_gauge(f"Doctor Action: {action}", count, total_treatments, {'x': [0, 1], 'y': [0, 1]}, 'purple')
112
+ st.plotly_chart(fig, use_container_width=True)
113
+ st.markdown("---")
114
+
115
+ # Animation 4: Penalties
116
+ elif animation_index == 4:
117
+ st.subheader("Penalties")
118
+ for penalty, count in penalties.items():
119
+ fig = create_gauge(f"Penalty: {penalty}", count, total_treatments // 6, {'x': [0, 1], 'y': [0, 1]}, 'red')
120
+ st.plotly_chart(fig, use_container_width=True)
121
+ st.markdown("---")
122
+
123
+ # Animation 5: Patient Feedback
124
+ elif animation_index == 5:
125
+ st.subheader("Patient Feedback")
126
+ for fb, count in feedback.items():
127
+ fig = create_gauge(f"Feedback: {fb}", count, total_treatments, {'x': [0, 1], 'y': [0, 1]}, 'blue')
128
+ st.plotly_chart(fig, use_container_width=True)
129
+ st.markdown("---")
130
+
131
+ st.write("**End of Animations.**")