import streamlit as st import pandas as pd import plotly.express as px import matplotlib.pyplot as plt # Load patient data df = pd.read_csv('patient_data.csv') # 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. """) # 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]}") # Visualization of Vital Signs st.header('Vital Signs Over Time') # Line Chart for Heart Rate fig = px.line(patient_data, x='date', y='heart_rate', title='Heart Rate Over Time') st.plotly_chart(fig) # Line Chart for Blood Pressure fig = px.line(patient_data, x='date', y='blood_pressure', title='Blood Pressure Over Time') st.plotly_chart(fig) # Line Chart for Blood Glucose fig = px.line(patient_data, x='date', y='blood_glucose', title='Blood Glucose Over Time') st.plotly_chart(fig) # Dropdown for selecting specific visit details st.header('Previous Visit Details') selected_date = st.selectbox('Select Visit Date', patient_data['date'].unique()) selected_visit = patient_data[patient_data['date'] == selected_date] st.write(f"**Visit Date:** {selected_date}") st.write(f"Heart Rate: {selected_visit['heart_rate'].values[0]}") st.write(f"Blood Pressure: {selected_visit['blood_pressure'].values[0]}") st.write(f"Blood Glucose: {selected_visit['blood_glucose'].values[0]}") # Alerts and Notifications st.header('Alerts') if selected_visit['heart_rate'].values[0] > 100: st.error('High heart rate detected!') if selected_visit['blood_pressure'].values[0] > 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', )