File size: 1,908 Bytes
4e9a3bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""Build report data from analysis results."""

import logging
from datetime import datetime
from uuid import uuid4

from src.reporting.schemas import ReportData, SegmentAnnotation
from src.scoring.schemas import SlurringResult
from src.risk.schemas import RiskAssessment

logger = logging.getLogger(__name__)


class ReportBuilder:
    """Build comprehensive report from analysis results."""

    def build(
        self,
        slurring_result: SlurringResult,
        risk_assessment: RiskAssessment,
        acoustic_summary: dict,
        segments: list[SegmentAnnotation],
        processing_time_ms: float,
        audio_duration_sec: float,
        patient_age: int | None = None,
        onset_hours: float | None = None,
    ) -> ReportData:
        """
        Build report data.

        Args:
            slurring_result: Slurring analysis result
            risk_assessment: Risk assessment
            acoustic_summary: Acoustic features summary
            segments: Annotated time segments
            processing_time_ms: Total processing time
            audio_duration_sec: Audio duration
            patient_age: Patient age (optional)
            onset_hours: Symptom onset hours (optional)

        Returns:
            ReportData ready for rendering
        """
        report_id = str(uuid4())

        logger.info(f"Building report: {report_id}")

        report = ReportData(
            report_id=report_id,
            generated_at=datetime.utcnow(),
            slurring_result=slurring_result,
            risk_assessment=risk_assessment,
            acoustic_summary=acoustic_summary,
            segments=segments,
            processing_time_ms=processing_time_ms,
            audio_duration_sec=audio_duration_sec,
            patient_age=patient_age,
            onset_hours=onset_hours,
        )

        logger.info(f"Report built: {report_id}")

        return report