Rammohan0504 commited on
Commit
cfa3c70
·
verified ·
1 Parent(s): 5192eb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -98,6 +98,13 @@ def get_risk_color(value, normal_range):
98
 
99
  # Function to build table for test results
100
  def build_table(title, rows):
 
 
 
 
 
 
 
101
  html = (
102
  f'<div style="margin-bottom: 25px; border-radius: 8px; overflow: hidden; border: 1px solid #e0e0e0;">'
103
  f'<div style="background: linear-gradient(135deg, #f5f7fa, #c3cfe2); padding: 12px 16px; border-bottom: 1px solid #e0e0e0;">'
@@ -117,7 +124,7 @@ def build_table(title, rows):
117
  else:
118
  value_str = f"{value:.2f}"
119
 
120
- html += f'<tr style="background:{row_bg};border-bottom:1px solid #e9ecef;"><td style="padding:10px 8px;color:#2c3e50;font-weight:500;">{label}</td><td style="padding:10px 8px;text-align:center;color:#2c3e50;font-weight:600;">{value_str}</td><td style="padding:10px 8px;text-align:center;color:#6c757d;font-size:12px;">{ref[0]} - {ref[1]}</td><td style="padding:10px 8px;text-align:center;font-weight:600;color:{"#28a745" if level == "Normal" else "#dc3545" if level == "High" else "#ffc107"};">{icon} {level}</td></tr>'
121
  html += '</tbody></table></div>'
122
  return html
123
 
@@ -199,6 +206,13 @@ def build_health_card(profile_image, test_results, summary, pdf_filepath, patien
199
 
200
  pdf_filename = os.path.basename(pdf_filepath) if pdf_filepath else "health_report.pdf"
201
 
 
 
 
 
 
 
 
202
  html = f"""
203
  <div id="health-card" style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 700px; margin: 20px auto; border-radius: 16px; background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%); border: 2px solid #ddd; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15); padding: 30px; color: #1a1a1a;">
204
 
@@ -247,12 +261,12 @@ def build_health_card(profile_image, test_results, summary, pdf_filepath, patien
247
  </div>
248
  </div>
249
  <style>
250
- @media print {
251
  /* Hide input sections during print */
252
- .gradio-container { display: block; }
253
  /* Keep only the health card visible */
254
- #health-card { display: block; }
255
- }
256
  </style>
257
  """
258
  return html
 
98
 
99
  # Function to build table for test results
100
  def build_table(title, rows):
101
+ # Define color mapping
102
+ color_map = {
103
+ "Normal": "#28a745",
104
+ "High": "#dc3545",
105
+ "Low": "#ffc107"
106
+ }
107
+
108
  html = (
109
  f'<div style="margin-bottom: 25px; border-radius: 8px; overflow: hidden; border: 1px solid #e0e0e0;">'
110
  f'<div style="background: linear-gradient(135deg, #f5f7fa, #c3cfe2); padding: 12px 16px; border-bottom: 1px solid #e0e0e0;">'
 
124
  else:
125
  value_str = f"{value:.2f}"
126
 
127
+ html += f'<tr style="background:{row_bg};border-bottom:1px solid #e9ecef;"><td style="padding:10px 8px;color:#2c3e50;font-weight:500;">{label}</td><td style="padding:10px 8px;text-align:center;color:#2c3e50;font-weight:600;">{value_str}</td><td style="padding:10px 8px;text-align:center;color:#6c757d;font-size:12px;">{ref[0]} - {ref[1]}</td><td style="padding:10px 8px;text-align:center;font-weight:600;color:{color_map[level]};">{icon} {level}</td></tr>'
128
  html += '</tbody></table></div>'
129
  return html
130
 
 
206
 
207
  pdf_filename = os.path.basename(pdf_filepath) if pdf_filepath else "health_report.pdf"
208
 
209
+ # Define color mapping for consistency
210
+ color_map = {
211
+ "Normal": "#28a745",
212
+ "High": "#dc3545",
213
+ "Low": "#ffc107"
214
+ }
215
+
216
  html = f"""
217
  <div id="health-card" style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 700px; margin: 20px auto; border-radius: 16px; background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%); border: 2px solid #ddd; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15); padding: 30px; color: #1a1a1a;">
218
 
 
261
  </div>
262
  </div>
263
  <style>
264
+ @media print {{
265
  /* Hide input sections during print */
266
+ .gradio-container {{ display: block; }}
267
  /* Keep only the health card visible */
268
+ #health-card {{ display: block; }}
269
+ }}
270
  </style>
271
  """
272
  return html