File size: 1,829 Bytes
40cbaf1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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',
)