feat: Refactor report generation to use async methods and improve error handling; enhance spirometry table extraction with better CSV formatting
This commit is contained in:
+7
-3
@@ -12,7 +12,6 @@ from pathlib import Path
|
||||
from fastapi import FastAPI, File, Form, HTTPException, UploadFile
|
||||
from fastapi.responses import FileResponse
|
||||
from pydantic import BaseModel
|
||||
|
||||
from services.report_generator import ReportGeneratorService
|
||||
|
||||
app = FastAPI(
|
||||
@@ -138,7 +137,7 @@ async def generate_report(
|
||||
}
|
||||
|
||||
# Generate report using the service
|
||||
result = report_service.generate_report(
|
||||
result = await report_service.generate_report(
|
||||
spirometry_pdf_path=str(spirometry_path),
|
||||
pnoe_csv_path=str(pnoe_path),
|
||||
seca_excel_path=str(seca_path),
|
||||
@@ -153,9 +152,14 @@ async def generate_report(
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
import traceback
|
||||
|
||||
error_details = traceback.format_exc()
|
||||
print(f"ERROR: {error_details}") # This will show in terminal
|
||||
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail=f"Error generating report: {str(e)}",
|
||||
detail=f"Error generating report: {str(e)}\n{error_details}",
|
||||
)
|
||||
finally:
|
||||
# Close file handles
|
||||
|
||||
Reference in New Issue
Block a user