# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .alert_severity import AlertSeverity
from .alert_type import AlertType


class Alert(UniversalBaseModel):
    """
    High-severity safety alert bubbled up from domain-level data.
    Alerts are generated when safety thresholds are exceeded.
    """

    severity: AlertSeverity = pydantic.Field()
    """
    Alert severity level.
    - `CRITICAL` — Immediate action required (e.g., BBW, contraindicated DDI, pregnancy risk 7)
    - `HIGH` — Significant risk requiring pharmacist review (e.g., major DDI, pregnancy risk 6)
    - `MODERATE` — Worth noting, may require monitoring
    - `LOW` — Informational
    """

    type: AlertType = pydantic.Field()
    """
    Alert source domain and trigger.
    - `ae_bbw` — Drug has a Black Box Warning
    - `ddi` — Major (severity 4) or contraindicated (severity 5) interaction
    - `pllr_pregnancy` — Pregnancy risk >= 6 (Contraindicated or Absolutely Contraindicated)
    - `pllr_lactation` — Lactation risk >= 6
    - `clinical_condition` — Clinical condition severity >= 4
    - `clinical_population` — Clinical population severity >= 4
    """

    message: str = pydantic.Field()
    """
    Human-readable alert message
    """

    drugs_involved: typing.List[str] = pydantic.Field()
    """
    Drug names involved in this alert
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
