SreekarB commited on
Commit
7a9920b
·
verified ·
1 Parent(s): b206e1d

Upload casl_analysis.py

Browse files
Files changed (1) hide show
  1. casl_analysis.py +43 -42
casl_analysis.py CHANGED
@@ -1611,37 +1611,6 @@ def create_interface():
1611
  status_msg
1612
  )
1613
 
1614
- # Function to load patient record into the report generator tab
1615
- def load_patient_record_to_report(record_id):
1616
- if not record_id:
1617
- return gr.update(selected=1), {}, "", "", "", "", "", ""
1618
-
1619
- record_data = load_patient_record(record_id)
1620
- if not record_data:
1621
- return gr.update(selected=1), "", "", "", "male", "", "", ""
1622
-
1623
- # Extract data
1624
- patient_info = record_data.get("patient_info", {})
1625
- analysis_results = record_data.get("analysis_results", {})
1626
-
1627
- # Get the raw analysis results as a string
1628
- raw_response = analysis_results.get("raw_response", "")
1629
-
1630
- # Create status message for the record loading
1631
- status_msg = f"✅ Record loaded successfully: {patient_info.get('name', 'Unknown')} ({record_id})"
1632
-
1633
- return (
1634
- gr.update(selected=2), # Switch to Report Generator tab
1635
- patient_info.get("name", ""),
1636
- patient_info.get("record_id", ""),
1637
- patient_info.get("age", ""),
1638
- patient_info.get("gender", "male"),
1639
- patient_info.get("assessment_date", ""),
1640
- patient_info.get("clinician", ""),
1641
- raw_response,
1642
- status_msg
1643
- )
1644
-
1645
  load_record_btn.click(
1646
  load_patient_record_to_analysis,
1647
  inputs=[selected_record_id],
@@ -1652,17 +1621,6 @@ def create_interface():
1652
  records_status
1653
  ]
1654
  )
1655
-
1656
- load_to_report_btn.click(
1657
- load_patient_record_to_report,
1658
- inputs=[selected_record_id],
1659
- outputs=[
1660
- main_tabs,
1661
- report_patient_name, report_record_id, report_age, report_gender,
1662
- report_date, report_clinician, report_results,
1663
- records_status
1664
- ]
1665
- )
1666
 
1667
  # ===============================
1668
  # Report Generator Tab
@@ -2340,6 +2298,49 @@ def create_interface():
2340
  q3_btn.click(lambda: "What activities help with word finding difficulties?", outputs=[question_input])
2341
  q4_btn.click(lambda: "When should I reassess a patient?", outputs=[question_input])
2342
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2343
  return app
2344
 
2345
  # ===============================
 
1611
  status_msg
1612
  )
1613
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1614
  load_record_btn.click(
1615
  load_patient_record_to_analysis,
1616
  inputs=[selected_record_id],
 
1621
  records_status
1622
  ]
1623
  )
 
 
 
 
 
 
 
 
 
 
 
1624
 
1625
  # ===============================
1626
  # Report Generator Tab
 
2298
  q3_btn.click(lambda: "What activities help with word finding difficulties?", outputs=[question_input])
2299
  q4_btn.click(lambda: "When should I reassess a patient?", outputs=[question_input])
2300
 
2301
+ # Function to load patient record into the report generator tab
2302
+ def load_patient_record_to_report(record_id):
2303
+ if not record_id:
2304
+ return gr.update(selected=1), "", "", "", "male", "", "", ""
2305
+
2306
+ record_data = load_patient_record(record_id)
2307
+ if not record_data:
2308
+ return gr.update(selected=1), "", "", "", "male", "", "", ""
2309
+
2310
+ # Extract data
2311
+ patient_info = record_data.get("patient_info", {})
2312
+ analysis_results = record_data.get("analysis_results", {})
2313
+
2314
+ # Get the raw analysis results as a string
2315
+ raw_response = analysis_results.get("raw_response", "")
2316
+
2317
+ # Create status message for the record loading
2318
+ status_msg = f"✅ Record loaded successfully: {patient_info.get('name', 'Unknown')} ({record_id})"
2319
+
2320
+ return (
2321
+ gr.update(selected=2), # Switch to Report Generator tab
2322
+ patient_info.get("name", ""),
2323
+ patient_info.get("record_id", ""),
2324
+ patient_info.get("age", ""),
2325
+ patient_info.get("gender", "male"),
2326
+ patient_info.get("assessment_date", ""),
2327
+ patient_info.get("clinician", ""),
2328
+ raw_response,
2329
+ status_msg
2330
+ )
2331
+
2332
+ # Connect the load_to_report_btn to its handler
2333
+ load_to_report_btn.click(
2334
+ load_patient_record_to_report,
2335
+ inputs=[selected_record_id],
2336
+ outputs=[
2337
+ main_tabs,
2338
+ report_patient_name, report_record_id, report_age, report_gender,
2339
+ report_date, report_clinician, report_results,
2340
+ records_status
2341
+ ]
2342
+ )
2343
+
2344
  return app
2345
 
2346
  # ===============================