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

import typing

import pydantic
from ......core.pydantic_utilities import IS_PYDANTIC_V2
from .....commons.types.facility_type_code import FacilityTypeCode
from .....diagnoses.types.diagnosis_create import DiagnosisCreate
from .....encounter_providers.resources.v_2.types.rendering_provider import RenderingProvider
from .....encounters_universal.types.universal_encounter_create_from_pre_encounter_base import (
    UniversalEncounterCreateFromPreEncounterBase,
)
from .....service_lines.resources.v_2.types.service_line_create import ServiceLineCreate


class EncounterCreateFromPreEncounter(UniversalEncounterCreateFromPreEncounterBase):
    rendering_provider: RenderingProvider = pydantic.Field()
    """
    The rendering provider is the practitioner -- physician, nurse practitioner, etc. -- performing the service.
    For telehealth services, the rendering provider performs the visit, asynchronous communication, or other service. The rendering provider address should generally be the same as the service facility address.
    """

    place_of_service_code: FacilityTypeCode = pydantic.Field()
    """
    Box 24B on the CMS-1500 claim form. 837p Loop2300, CLM-05-1. 02 for telemedicine, 11 for in-person. Full list [here](https://www.cms.gov/Medicare/Coding/place-of-service-codes/Place_of_Service_Code_Set).
    """

    diagnoses: typing.List[DiagnosisCreate] = pydantic.Field()
    """
    Ideally, this field should contain no more than 12 diagnoses. However, more diagnoses
    may be submitted at this time, and coders will later prioritize the 12 that will be
    submitted to the payor.
    """

    service_lines: typing.Optional[typing.List[ServiceLineCreate]] = pydantic.Field(default=None)
    """
    Each service line must be linked to a diagnosis. Concretely,
    `service_line.diagnosis_pointers`must contain at least one entry which should be
    in bounds of the diagnoses list field.
    """

    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
