"""Hospital visit model for hospital visits."""
from datetime import UTC, datetime
from functools import partial
from typing import Annotated, List, Optional

from pydantic import Field, StringConstraints

from .base import BaseDocument
from .types import PyObjectId

class HospitalVisit(BaseDocument):
    """Hospital visit model representing hospital visits."""
    patientId: PyObjectId = Field(description="ID of the patient")
    hospital: Annotated[
        str,
        StringConstraints(min_length=1, strip_whitespace=True)
    ] = Field(description="Hospital name")
    visitDate: datetime = Field(
        default_factory=partial(datetime.now, UTC),
        description="Date of the hospital visit in UTC"
    )
    admissionDate: Optional[datetime] = Field(
        default=None, description="Admission date/time"
    )
    dischargeDate: Optional[datetime] = Field(
        default=None, description="Discharge date/time"
    )
    doctorName: Optional[str] = Field(
        default=None, description="Name of the attending doctor"
    )
    department: Optional[str] = Field(
        default=None, description="Hospital department"
    )
    dischargeSummary: Optional[str] = Field(
        default=None, description="Summary upon discharge"
    )
    diagnoses: List[PyObjectId] = Field(
        default_factory=list, description="List of diagnosis IDs associated with this visit"
    )
