Spaces:
Sleeping
Sleeping
import streamlit as st | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import plotly.express as px | |
# Title and Description | |
st.title('Patient Data Dashboard') | |
st.write(""" | |
This dashboard provides an overview of patient health metrics for better monitoring and decision-making. | |
""") | |
# Load Patient Data (Example DataFrame) | |
df = pd.read_csv('patient_data.csv') | |
# Sidebar for Patient Selection | |
st.sidebar.header('Select Patient') | |
patient_id = st.sidebar.selectbox('Patient ID', df['patient_id'].unique()) | |
# Filter Data for Selected Patient | |
patient_data = df[df['patient_id'] == patient_id] | |
# Display Patient Profile | |
st.header('Patient Profile') | |
st.write(f"Name: {patient_data['name'].values[0]}") | |
st.write(f"Age: {patient_data['age'].values[0]}") | |
st.write(f"Gender: {patient_data['gender'].values[0]}") | |
st.write(f"Medical History: {patient_data['medical_history'].values[0]}") | |
# Visualize Vital Signs | |
st.header('Vital Signs Over Time') | |
fig, ax = plt.subplots() | |
ax.plot(patient_data['date'], patient_data['heart_rate'], label='Heart Rate') | |
ax.plot(patient_data['date'], patient_data['blood_pressure'], label='Blood Pressure') | |
ax.set_xlabel('Date') | |
ax.set_ylabel('Value') | |
ax.legend() | |
st.pyplot(fig) | |
# Interactive Plotly Chart | |
st.header('Blood Glucose Levels') | |
fig = px.line(patient_data, x='date', y='blood_glucose', title='Blood Glucose Over Time') | |
st.plotly_chart(fig) | |
# Alerts and Notifications | |
st.header('Alerts') | |
if patient_data['heart_rate'].values[-1] > 100: | |
st.error('High heart rate detected!') | |
if patient_data['blood_pressure'].values[-1] > 140: | |
st.error('High blood pressure detected!') | |
# Download Button for Patient Data | |
st.download_button( | |
label="Download Patient Data as CSV", | |
data=patient_data.to_csv().encode('utf-8'), | |
file_name=f'patient_{patient_id}_data.csv', | |
mime='text/csv', | |
) | |