# 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 .daily_limit import DailyLimit
from .dose_component import DoseComponent
from .dosing_data_source import DosingDataSource
from .reference_dose import ReferenceDose


class DosingData(UniversalBaseModel):
    """
    Maximum daily dose data from Dose V3 — dual-source system combining
    WHO Defined Daily Dose (DDD) and OpenFDA Maximum Daily Dose (MDD).
    Covers 19,341 products (67.7% of database) with tier-based safety calculations.
    """

    tier: typing.Optional[int] = pydantic.Field(default=None)
    """
    Data quality tier.
    - `1` — Full reference data (WHO DDD + OpenFDA MDD available)
    - `2` — Regulatory label data only
    """

    max_units_per_day: typing.Optional[float] = pydantic.Field(default=None)
    """
    Maximum safe units (tablets, capsules) per day
    """

    max_ml_per_day: typing.Optional[float] = pydantic.Field(default=None)
    """
    Maximum safe volume per day for liquid forms
    """

    unit_label: typing.Optional[str] = pydantic.Field(default=None)
    """
    Unit type (tablets, capsules, ml, etc.)
    """

    flagged: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether dose calculation has caveats requiring attention
    """

    skip_reason: typing.Optional[str] = pydantic.Field(default=None)
    """
    Reason if dose calculation was skipped (e.g., topical, inhaled)
    """

    caveat: typing.Optional[str] = pydantic.Field(default=None)
    """
    Important caveat about the dose calculation
    """

    reference_dose: typing.Optional[ReferenceDose] = pydantic.Field(default=None)
    """
    WHO DDD reference dose data
    """

    daily_limit: typing.Optional[DailyLimit] = pydantic.Field(default=None)
    """
    OpenFDA maximum daily dose data
    """

    components: typing.Optional[typing.List[typing.Optional[DoseComponent]]] = pydantic.Field(default=None)
    """
    Per-ingredient dose data for combination drugs
    """

    source: typing.Optional[DosingDataSource] = pydantic.Field(default=None)
    """
    Data source for this dose calculation.
    - `reference_standard` — WHO DDD only
    - `regulatory_label` — OpenFDA MDD only
    - `dual_source` — Both WHO DDD and OpenFDA MDD available
    """

    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
