File size: 957 Bytes
25429d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pydantic import BaseModel, Field
from datetime import datetime, timezone
from typing import Dict, Optional


def _utc_now():
    return datetime.now(timezone.utc)


# --- Response Schema ---
# This guarantees our API always returns this exact structure to React
class PredictionResponse(BaseModel):
    status: str
    record_id: str
    prediction: str
    confidence: float
    heatmap_url: str
    original_url: str

# --- Database Record Schema ---
# This guarantees we never save messy or incomplete data to MongoDB
class DiagnosticRecordSchema(BaseModel):
    timestamp: datetime = Field(default_factory=_utc_now)
    original_image_url: str
    heatmap_image_url: str
    prediction: str
    confidence_score: float
    probabilities: Dict[str, float]
    model_variant: str = "DenseNet121_v1"
    physician_override: Optional[bool] = None
    
    

class OverrideRequest(BaseModel):
    physician_override: bool
    notes: Optional[str] = None