vikramvasudevan commited on
Commit
987e752
·
verified ·
1 Parent(s): 6fd8766

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. graph.py +1 -1
  2. home.py +14 -9
  3. ui.py +4 -5
graph.py CHANGED
@@ -425,7 +425,7 @@ async def fn_interpreter_node(state: SheamiState):
425
  messages = [
426
  SystemMessage(
427
  content=(
428
- "Interpret the following medical trends and produce a clean, structured **HTML** report. "
429
  "The report should have: "
430
  "1. Patient summary (name, age, sex if available) "
431
  "2. Trend summaries (tables with Test Name, Value, Unit, Reference Range, and Status) "
 
425
  messages = [
426
  SystemMessage(
427
  content=(
428
+ "Interpret the following medical trends and produce a clean, structured **HTML** report without any markdown formatting like backquotes etc. "
429
  "The report should have: "
430
  "1. Patient summary (name, age, sex if available) "
431
  "2. Trend summaries (tables with Test Name, Value, Unit, Reference Range, and Status) "
home.py CHANGED
@@ -461,6 +461,7 @@ with gr.Blocks(
461
  )
462
  trend_plot = gr.Plot(label="Trend Chart")
463
  with gr.TabItem("✅ Final Reports"):
 
464
  final_df = gr.DataFrame(
465
  headers=[
466
  "final_report_id",
@@ -472,7 +473,7 @@ with gr.Blocks(
472
  wrap=True,
473
  interactive=False,
474
  )
475
-
476
  with Modal(visible=False) as final_report_download_modal:
477
  with gr.Row():
478
  gr.Column()
@@ -483,18 +484,20 @@ with gr.Blocks(
483
  )
484
 
485
  download_btn = gr.DownloadButton(
486
- "⬇️ Download PDF", variant="primary", scale=0
487
  )
488
  gr.Column()
489
 
490
  html_report_component = gr.HTML()
491
 
492
  # Function triggered when a row is selected
493
- def on_row_select(df_row):
 
 
494
  # df_row is a dict representing the selected row
495
- if df_row is None:
496
  return gr.update(visible=False), None
497
- report_id = df_row["final_report_id"][0]
498
  report_file_name = download_final_report(report_id)
499
  report_html_content = get_db().get_final_report_html(report_id)
500
  # Return modal visibility + the file to bind to download button
@@ -505,16 +508,15 @@ with gr.Blocks(
505
  report_html_content,
506
  ) # final_report_download_modal, report_id_in, download_btn, html_report
507
 
508
- final_df.select(close_side_bar, outputs=[sheami_sidebar]).then(
509
  on_row_select,
510
- inputs=[final_df],
511
  outputs=[
512
  final_report_download_modal,
513
  report_id_in,
514
  download_btn,
515
  html_report_component,
516
  ],
517
- )
518
  download_btn.click(
519
  fn=download_final_report,
520
  inputs=[report_id_in],
@@ -544,7 +546,10 @@ with gr.Blocks(
544
  selected_patient_info,
545
  reports_df_val,
546
  gr.update(choices=test_names),
547
- gr.update(headers=["final_report_id","generated_at"],value=format_final_reports(finals)),
 
 
 
548
  )
549
 
550
  patient_list.change(
 
461
  )
462
  trend_plot = gr.Plot(label="Trend Chart")
463
  with gr.TabItem("✅ Final Reports"):
464
+ gr.Markdown("Click on any row to view/download the report")
465
  final_df = gr.DataFrame(
466
  headers=[
467
  "final_report_id",
 
473
  wrap=True,
474
  interactive=False,
475
  )
476
+ gr.Markdown("Click on any row to view/download the report")
477
  with Modal(visible=False) as final_report_download_modal:
478
  with gr.Row():
479
  gr.Column()
 
484
  )
485
 
486
  download_btn = gr.DownloadButton(
487
+ "⬇️ Download PDF", variant="huggingface", scale=0
488
  )
489
  gr.Column()
490
 
491
  html_report_component = gr.HTML()
492
 
493
  # Function triggered when a row is selected
494
+ def on_row_select(evt: gr.SelectData):
495
+ df_selected_row = evt.row_value
496
+ print("Selected Row = ", df_selected_row)
497
  # df_row is a dict representing the selected row
498
+ if df_selected_row is None:
499
  return gr.update(visible=False), None
500
+ report_id = df_selected_row[0] # first column is report_id
501
  report_file_name = download_final_report(report_id)
502
  report_html_content = get_db().get_final_report_html(report_id)
503
  # Return modal visibility + the file to bind to download button
 
508
  report_html_content,
509
  ) # final_report_download_modal, report_id_in, download_btn, html_report
510
 
511
+ final_df.select(
512
  on_row_select,
 
513
  outputs=[
514
  final_report_download_modal,
515
  report_id_in,
516
  download_btn,
517
  html_report_component,
518
  ],
519
+ ).then(close_side_bar, outputs=[sheami_sidebar])
520
  download_btn.click(
521
  fn=download_final_report,
522
  inputs=[report_id_in],
 
546
  selected_patient_info,
547
  reports_df_val,
548
  gr.update(choices=test_names),
549
+ gr.update(
550
+ headers=["final_report_id", "generated_at"],
551
+ value=format_final_reports(finals),
552
+ ),
553
  )
554
 
555
  patient_list.change(
ui.py CHANGED
@@ -456,10 +456,9 @@ def get_gradio_block(container, user_email_state, patient_id_state):
456
  with gr.Accordion("Report Download"):
457
  gr.Markdown("# ✅Your health trends report is ready!")
458
  with gr.Row(equal_height=False):
459
- pdf_download = gr.File(
460
- label="Click on the link below to download 📊",
461
- scale=1,
462
- type="filepath",
463
  )
464
  # Populate file when button clicked
465
  upload_more_reports_btn = gr.Button(
@@ -476,7 +475,7 @@ def get_gradio_block(container, user_email_state, patient_id_state):
476
  with gr.Tab(
477
  "Run Statistics", id="my_status_container"
478
  ) as status_container:
479
- with gr.Row():
480
  (headers, empty_data) = generate_milestones_data()
481
 
482
  milestone_df = gr.DataFrame(
 
456
  with gr.Accordion("Report Download"):
457
  gr.Markdown("# ✅Your health trends report is ready!")
458
  with gr.Row(equal_height=False):
459
+ pdf_download = gr.DownloadButton(
460
+ label="Download 📊",
461
+ scale=0,
 
462
  )
463
  # Populate file when button clicked
464
  upload_more_reports_btn = gr.Button(
 
475
  with gr.Tab(
476
  "Run Statistics", id="my_status_container"
477
  ) as status_container:
478
+ with gr.Row(equal_height=True):
479
  (headers, empty_data) = generate_milestones_data()
480
 
481
  milestone_df = gr.DataFrame(