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

from __future__ import annotations

import typing
import uuid

import pydantic
import typing_extensions
from ......core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .....commons.types.date import Date
from .....commons.types.regions import Regions
from ...v_2.types.authorized_signatory import AuthorizedSignatory
from ...v_2.types.contract_status import ContractStatus
from ...v_2.types.insurance_types import InsuranceTypes
from .contract_service_facility_base import ContractServiceFacilityBase
from .contract_type import ContractType
from .contracting_provider_id import ContractingProviderId
from .rendering_providerid import RenderingProviderid


class ContractCreateUnion_Professional(UniversalBaseModel):
    type: typing.Literal["professional"] = "professional"
    rendering_provider_ids: typing.Set[RenderingProviderid]
    contract_type: ContractType
    contracting_provider_id: ContractingProviderId
    payer_uuid: uuid.UUID
    effective_date: Date
    expiration_date: typing.Optional[Date] = None
    regions: Regions
    contract_status: typing.Optional[ContractStatus] = None
    authorized_signatory: typing.Optional[AuthorizedSignatory] = None
    commercial_insurance_types: InsuranceTypes
    medicare_insurance_types: InsuranceTypes
    medicaid_insurance_types: InsuranceTypes

    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


class ContractCreateUnion_Institutional(UniversalBaseModel):
    type: typing.Literal["institutional"] = "institutional"
    contract_service_facilities: typing.List[ContractServiceFacilityBase]
    contract_type: ContractType
    contracting_provider_id: ContractingProviderId
    payer_uuid: uuid.UUID
    effective_date: Date
    expiration_date: typing.Optional[Date] = None
    regions: Regions
    contract_status: typing.Optional[ContractStatus] = None
    authorized_signatory: typing.Optional[AuthorizedSignatory] = None
    commercial_insurance_types: InsuranceTypes
    medicare_insurance_types: InsuranceTypes
    medicaid_insurance_types: InsuranceTypes

    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


ContractCreateUnion = typing_extensions.Annotated[
    typing.Union[ContractCreateUnion_Professional, ContractCreateUnion_Institutional],
    pydantic.Field(discriminator="type"),
]
