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

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from ......core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .type_of_bill_frequency_code import TypeOfBillFrequencyCode
from .type_of_care_code import TypeOfCareCode
from .type_of_facility_code import TypeOfFacilityCode


class TypeOfBillCompositeUpdate_RawCode(UniversalBaseModel):
    value: str
    type: typing.Literal["raw_code"] = "raw_code"

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

        class Config:
            frozen = True
            smart_union = True


class TypeOfBillCompositeUpdate_CompositeCodes(UniversalBaseModel):
    """
    A type of bill can either be seen as a compositio of structured parts, or as a literal string.
    This union represents the potential to express a type of bill either as one of those two shapes.
    Passing a string, this update will be seen as a complete 4 digit code, along with a padding code 0, that
    should match a valid composition.
    Passing as a structure, the update will be seen as three parts and will be joined together by the server
    to represent a valid composition for you.
    Which you use depends upon whether you are "passing through" coded information or making a decision about its
    structure explicitly.
    """

    type: typing.Literal["composite_codes"] = "composite_codes"
    type_of_facility: TypeOfFacilityCode
    type_of_care: TypeOfCareCode
    frequency_code: TypeOfBillFrequencyCode

    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


TypeOfBillCompositeUpdate = typing_extensions.Annotated[
    typing.Union[TypeOfBillCompositeUpdate_RawCode, TypeOfBillCompositeUpdate_CompositeCodes],
    pydantic.Field(discriminator="type"),
]
