dizzafizza1 commited on
Commit
efff3c6
β€’
1 Parent(s): 3f28219

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -16,8 +16,6 @@ st.markdown(
16
  <style>
17
  body {
18
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
19
- margin: 0;
20
- padding: 0;
21
  background-color: #f7f7f8;
22
  color: #333;
23
  }
@@ -66,8 +64,8 @@ st.markdown(
66
  )
67
 
68
  st.markdown('<div class="container">', unsafe_allow_html=True)
69
- st.markdown("<h1>Medication Tracker πŸ’Š</h1>")
70
- st.markdown("<p>Track your prescription medications easily and get helpful insights.</p>")
71
 
72
  # Initialize session state to store medication data
73
  if 'medications' not in st.session_state:
@@ -75,13 +73,13 @@ if 'medications' not in st.session_state:
75
 
76
  # Form to log medication
77
  st.markdown('<div class="log-form">', unsafe_allow_html=True)
78
- st.markdown("<h2>Log Your Medication</h2>")
79
  with st.form(key='log_medication'):
80
  medication_name = st.text_input("Medication Name", key='medication_name', placeholder="e.g., Aspirin")
81
  dosage = st.text_input("Dosage (e.g., 500 mg)", key='dosage', placeholder="e.g., 500 mg")
82
  time_of_day = st.selectbox("Time of Day", ["Morning", "Afternoon", "Evening", "Night"], key='time_of_day')
83
  date = st.date_input("Date", datetime.today(), key='date')
84
- submit_button = st.form_submit_button(label='Log Medication', help="Click to log your medication", on_click=None, type="primary")
85
 
86
  if submit_button and medication_name and dosage:
87
  new_entry = {"Medication": medication_name, "Dosage": dosage, "Time": time_of_day, "Date": date}
@@ -92,9 +90,9 @@ st.markdown('</div>', unsafe_allow_html=True)
92
 
93
  # Display logged medications
94
  st.markdown('<div class="logged-medications">', unsafe_allow_html=True)
95
- st.markdown("<h2>Logged Medications</h2>")
96
  if st.session_state.medications.empty:
97
- st.write("No medications logged yet.")
98
  else:
99
  for index, row in st.session_state.medications.iterrows():
100
  st.markdown(f'<div class="log-entry"><strong>{row["Medication"]}</strong><br>Dosage: {row["Dosage"]}<br>Time: {row["Time"]}<br>Date: {row["Date"]}</div>', unsafe_allow_html=True)
@@ -103,20 +101,20 @@ st.markdown('</div>', unsafe_allow_html=True)
103
 
104
  # Provide insights
105
  st.markdown('<div class="insights">', unsafe_allow_html=True)
106
- st.markdown("<h2>Insights</h2>")
107
  if not st.session_state.medications.empty:
108
  most_common_med = st.session_state.medications['Medication'].mode()[0]
109
- st.write(f"Most frequently taken medication: {most_common_med}")
110
 
111
  avg_dosage_time = st.session_state.medications.groupby('Time').size().idxmax()
112
- st.write(f"Most common time of day for taking medications: {avg_dosage_time}")
113
 
114
- st.write("Take your medications consistently at the same time each day to maintain stable drug levels in your body.")
115
- st.write("If you have multiple medications, consult your healthcare provider to ensure there are no adverse interactions.")
116
 
117
  st.markdown('</div>', unsafe_allow_html=True)
118
 
119
  # Footer
120
- st.markdown("<hr>")
121
- st.markdown("<p><strong>Disclaimer:</strong> This app is for tracking purposes only. Always consult with your healthcare provider for medical advice.</p>")
122
  st.markdown('</div>', unsafe_allow_html=True)
 
16
  <style>
17
  body {
18
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
 
 
19
  background-color: #f7f7f8;
20
  color: #333;
21
  }
 
64
  )
65
 
66
  st.markdown('<div class="container">', unsafe_allow_html=True)
67
+ st.markdown("<h1>Medication Tracker πŸ’Š</h1>", unsafe_allow_html=True)
68
+ st.markdown("<p>Track your prescription medications easily and get helpful insights.</p>", unsafe_allow_html=True)
69
 
70
  # Initialize session state to store medication data
71
  if 'medications' not in st.session_state:
 
73
 
74
  # Form to log medication
75
  st.markdown('<div class="log-form">', unsafe_allow_html=True)
76
+ st.markdown("<h2>Log Your Medication</h2>", unsafe_allow_html=True)
77
  with st.form(key='log_medication'):
78
  medication_name = st.text_input("Medication Name", key='medication_name', placeholder="e.g., Aspirin")
79
  dosage = st.text_input("Dosage (e.g., 500 mg)", key='dosage', placeholder="e.g., 500 mg")
80
  time_of_day = st.selectbox("Time of Day", ["Morning", "Afternoon", "Evening", "Night"], key='time_of_day')
81
  date = st.date_input("Date", datetime.today(), key='date')
82
+ submit_button = st.form_submit_button(label='Log Medication')
83
 
84
  if submit_button and medication_name and dosage:
85
  new_entry = {"Medication": medication_name, "Dosage": dosage, "Time": time_of_day, "Date": date}
 
90
 
91
  # Display logged medications
92
  st.markdown('<div class="logged-medications">', unsafe_allow_html=True)
93
+ st.markdown("<h2>Logged Medications</h2>", unsafe_allow_html=True)
94
  if st.session_state.medications.empty:
95
+ st.markdown("No medications logged yet.", unsafe_allow_html=True)
96
  else:
97
  for index, row in st.session_state.medications.iterrows():
98
  st.markdown(f'<div class="log-entry"><strong>{row["Medication"]}</strong><br>Dosage: {row["Dosage"]}<br>Time: {row["Time"]}<br>Date: {row["Date"]}</div>', unsafe_allow_html=True)
 
101
 
102
  # Provide insights
103
  st.markdown('<div class="insights">', unsafe_allow_html=True)
104
+ st.markdown("<h2>Insights</h2>", unsafe_allow_html=True)
105
  if not st.session_state.medications.empty:
106
  most_common_med = st.session_state.medications['Medication'].mode()[0]
107
+ st.markdown(f"Most frequently taken medication: {most_common_med}", unsafe_allow_html=True)
108
 
109
  avg_dosage_time = st.session_state.medications.groupby('Time').size().idxmax()
110
+ st.markdown(f"Most common time of day for taking medications: {avg_dosage_time}", unsafe_allow_html=True)
111
 
112
+ st.markdown("Take your medications consistently at the same time each day to maintain stable drug levels in your body.", unsafe_allow_html=True)
113
+ st.markdown("If you have multiple medications, consult your healthcare provider to ensure there are no adverse interactions.", unsafe_allow_html=True)
114
 
115
  st.markdown('</div>', unsafe_allow_html=True)
116
 
117
  # Footer
118
+ st.markdown("<hr>", unsafe_allow_html=True)
119
+ st.markdown("<p><strong>Disclaimer:</strong> This app is for tracking purposes only. Always consult with your healthcare provider for medical advice.</p>", unsafe_allow_html=True)
120
  st.markdown('</div>', unsafe_allow_html=True)