Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
st.plotly_chart(
|
| 111 |
-
st.
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.**")
|