netflypsb commited on
Commit
0a5028c
·
verified ·
1 Parent(s): ee89605

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -17
app.py CHANGED
@@ -1,7 +1,10 @@
1
  import streamlit as st
2
  import pandas as pd
3
- import matplotlib.pyplot as plt
4
  import plotly.express as px
 
 
 
 
5
 
6
  # Title and Description
7
  st.title('Patient Data Dashboard')
@@ -9,9 +12,6 @@ st.write("""
9
  This dashboard provides an overview of patient health metrics for better monitoring and decision-making.
10
  """)
11
 
12
- # Load Patient Data (Example DataFrame)
13
- df = pd.read_csv('patient_data.csv')
14
-
15
  # Sidebar for Patient Selection
16
  st.sidebar.header('Select Patient')
17
  patient_id = st.sidebar.selectbox('Patient ID', df['patient_id'].unique())
@@ -26,26 +26,36 @@ st.write(f"Age: {patient_data['age'].values[0]}")
26
  st.write(f"Gender: {patient_data['gender'].values[0]}")
27
  st.write(f"Medical History: {patient_data['medical_history'].values[0]}")
28
 
29
- # Visualize Vital Signs
30
  st.header('Vital Signs Over Time')
31
- fig, ax = plt.subplots()
32
- ax.plot(patient_data['date'], patient_data['heart_rate'], label='Heart Rate')
33
- ax.plot(patient_data['date'], patient_data['blood_pressure'], label='Blood Pressure')
34
- ax.set_xlabel('Date')
35
- ax.set_ylabel('Value')
36
- ax.legend()
37
- st.pyplot(fig)
38
-
39
- # Interactive Plotly Chart
40
- st.header('Blood Glucose Levels')
41
  fig = px.line(patient_data, x='date', y='blood_glucose', title='Blood Glucose Over Time')
42
  st.plotly_chart(fig)
43
 
 
 
 
 
 
 
 
 
 
 
44
  # Alerts and Notifications
45
  st.header('Alerts')
46
- if patient_data['heart_rate'].values[-1] > 100:
47
  st.error('High heart rate detected!')
48
- if patient_data['blood_pressure'].values[-1] > 140:
49
  st.error('High blood pressure detected!')
50
 
51
  # Download Button for Patient Data
 
1
  import streamlit as st
2
  import pandas as pd
 
3
  import plotly.express as px
4
+ import matplotlib.pyplot as plt
5
+
6
+ # Load patient data
7
+ df = pd.read_csv('patient_data.csv')
8
 
9
  # Title and Description
10
  st.title('Patient Data Dashboard')
 
12
  This dashboard provides an overview of patient health metrics for better monitoring and decision-making.
13
  """)
14
 
 
 
 
15
  # Sidebar for Patient Selection
16
  st.sidebar.header('Select Patient')
17
  patient_id = st.sidebar.selectbox('Patient ID', df['patient_id'].unique())
 
26
  st.write(f"Gender: {patient_data['gender'].values[0]}")
27
  st.write(f"Medical History: {patient_data['medical_history'].values[0]}")
28
 
29
+ # Visualization of Vital Signs
30
  st.header('Vital Signs Over Time')
31
+
32
+ # Line Chart for Heart Rate
33
+ fig = px.line(patient_data, x='date', y='heart_rate', title='Heart Rate Over Time')
34
+ st.plotly_chart(fig)
35
+
36
+ # Line Chart for Blood Pressure
37
+ fig = px.line(patient_data, x='date', y='blood_pressure', title='Blood Pressure Over Time')
38
+ st.plotly_chart(fig)
39
+
40
+ # Line Chart for Blood Glucose
41
  fig = px.line(patient_data, x='date', y='blood_glucose', title='Blood Glucose Over Time')
42
  st.plotly_chart(fig)
43
 
44
+ # Dropdown for selecting specific visit details
45
+ st.header('Previous Visit Details')
46
+ selected_date = st.selectbox('Select Visit Date', patient_data['date'].unique())
47
+ selected_visit = patient_data[patient_data['date'] == selected_date]
48
+
49
+ st.write(f"**Visit Date:** {selected_date}")
50
+ st.write(f"Heart Rate: {selected_visit['heart_rate'].values[0]}")
51
+ st.write(f"Blood Pressure: {selected_visit['blood_pressure'].values[0]}")
52
+ st.write(f"Blood Glucose: {selected_visit['blood_glucose'].values[0]}")
53
+
54
  # Alerts and Notifications
55
  st.header('Alerts')
56
+ if selected_visit['heart_rate'].values[0] > 100:
57
  st.error('High heart rate detected!')
58
+ if selected_visit['blood_pressure'].values[0] > 140:
59
  st.error('High blood pressure detected!')
60
 
61
  # Download Button for Patient Data