# 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 .....organization_providers.resources.v_2.types.organization_provider import OrganizationProvider
from .....payers.resources.v_3.types.payer import Payer
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_id import ContractId
from .contract_service_facility import ContractServiceFacility


class ContractWithProvidersUnion_Professional(UniversalBaseModel):
    type: typing.Literal["professional"] = "professional"
    rendering_provider_ids: typing.Set[uuid.UUID]
    contract_id: ContractId
    contracting_provider: OrganizationProvider
    provider_count: int
    payer: Payer
    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 ContractWithProvidersUnion_Institutional(UniversalBaseModel):
    type: typing.Literal["institutional"] = "institutional"
    contract_service_facilities: typing.List[ContractServiceFacility]
    contract_id: ContractId
    contracting_provider: OrganizationProvider
    provider_count: int
    payer: Payer
    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


ContractWithProvidersUnion = typing_extensions.Annotated[
    typing.Union[ContractWithProvidersUnion_Professional, ContractWithProvidersUnion_Institutional],
    pydantic.Field(discriminator="type"),
]
