diff --git a/app/routes/patients.py b/app/routes/patients.py
index a9aa61176d57deac4d2a715912a79e1937c6a386..21ee034936218d250cfe20d7ee20c9abedb9253b 100644
--- a/app/routes/patients.py
+++ b/app/routes/patients.py
@@ -228,7 +228,7 @@ def new_referral(patient_id):
             reason=request.form.get('reason'),
             referral_status='new',
             priority=int(request.form.get('priority', 3)),
-            ml_prediction=False,
+            is_ml_recommended=False,
             notes=request.form.get('notes')
         )
         
diff --git a/app/routes/report.py b/app/routes/report.py
index 8456789fa5a6c8f1f5c7da0c8ee762ba0e05a425..600b7cf03e2eef02a2f53442c9d94daae700dd58 100644
--- a/app/routes/report.py
+++ b/app/routes/report.py
@@ -283,7 +283,7 @@ def generate():
         ).count(),
         'ml_prediction': Referral.query.filter(
             Referral.referralRequestedDateTime.between(start_date, end_date),
-            Referral.ml_prediction == True
+            Referral.is_ml_recommended == True
         ).count()
     }
     
@@ -292,11 +292,11 @@ def generate():
         'total': Procedure.query.filter(Procedure.procedureDateTime.between(start_date, end_date)).count(),
         'enteral_feeding': Procedure.query.filter(
             Procedure.procedureDateTime.between(start_date, end_date),
-            Procedure.procedure_type == 'enteral_feeding'
+            Procedure.procedureType == 'enteral_feeding'
         ).count(),
         'parenteral_nutrition': Procedure.query.filter(
             Procedure.procedureDateTime.between(start_date, end_date),
-            Procedure.procedure_type == 'parenteral_nutrition'
+            Procedure.procedureType == 'parenteral_nutrition'
         ).count()
     }
     
@@ -365,7 +365,8 @@ def generate():
         
         # Create temporary file
         temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.xlsx')
-        excel_file.save(temp_file.name)
+        temp_file.write(excel_file.getvalue())
+        temp_file.close()
         
         # Send the file
         return send_file(
@@ -392,7 +393,8 @@ def generate():
         
         # Create temporary file
         temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.xlsx')
-        excel_file.save(temp_file.name)
+        temp_file.write(excel_file.getvalue())
+        temp_file.close()
         
         # Send the file
         return send_file(
@@ -461,7 +463,7 @@ def create_stats_report(report_type):
         ).count(),
         'ml_prediction': Referral.query.filter(
             Referral.referralRequestedDateTime.between(start_date, end_date),
-            Referral.ml_prediction == True
+            Referral.is_ml_recommended == True
         ).count()
     }
     
@@ -470,11 +472,11 @@ def create_stats_report(report_type):
         'total': Procedure.query.filter(Procedure.procedureDateTime.between(start_date, end_date)).count(),
         'enteral_feeding': Procedure.query.filter(
             Procedure.procedureDateTime.between(start_date, end_date),
-            Procedure.procedure_type == 'enteral_feeding'
+            Procedure.procedureType == 'enteral_feeding'
         ).count(),
         'parenteral_nutrition': Procedure.query.filter(
             Procedure.procedureDateTime.between(start_date, end_date),
-            Procedure.procedure_type == 'parenteral_nutrition'
+            Procedure.procedureType == 'parenteral_nutrition'
         ).count()
     }
     
@@ -543,7 +545,8 @@ def create_stats_report(report_type):
         
         # Create temporary file
         temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.xlsx')
-        excel_file.save(temp_file.name)
+        temp_file.write(excel_file.getvalue())
+        temp_file.close()
         
         # Send the file
         return send_file(
@@ -570,7 +573,8 @@ def create_stats_report(report_type):
         
         # Create temporary file
         temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.xlsx')
-        excel_file.save(temp_file.name)
+        temp_file.write(excel_file.getvalue())
+        temp_file.close()
         
         # Send the file
         return send_file(