# 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 ...commons.types.state import State
from ...encounter_providers.resources.v_2.types.billing_provider import BillingProvider
from ...encounter_providers.resources.v_2.types.rendering_provider import RenderingProvider
from ...encounters.resources.v_4.types.encounter_submission_expectation import EncounterSubmissionExpectation
from ...health_care_code_information.resources.v_1.types.health_care_code_information_create import (
    HealthCareCodeInformationCreate,
)
from ...service_lines.resources.v_2.types.universal_service_line_create import UniversalServiceLineCreate
from ...x_12.resources.v_1.types.patient_discharge_status_code import PatientDischargeStatusCode
from ...x_12.resources.v_1.types.point_of_origin_for_admission_or_visit_code import PointOfOriginForAdmissionOrVisitCode
from ...x_12.resources.v_1.types.type_of_admission_or_visit_code import TypeOfAdmissionOrVisitCode
from ...x_12.resources.v_1.types.type_of_bill_composite_update import TypeOfBillCompositeUpdate
from .universal_encounter_create_base import UniversalEncounterCreateBase


class UniversalEncounterCreate(UniversalEncounterCreateBase):
    billing_provider: BillingProvider = pydantic.Field()
    """
    The billing provider is the provider or business entity submitting the claim. Billing provider may be, but is not necessarily, the same person/NPI as the rendering provider. From a payer's perspective, this represents the person or entity being reimbursed. When a contract exists with the target payer, the billing provider should be the entity contracted with the payer. In some circumstances, this will be an individual provider. In that case, submit that provider's NPI and the tax ID (TIN) that the provider gave to the payer during contracting. In other cases, the billing entity will be a medical group. If so, submit the group NPI and the group's tax ID. Box 33 on the CMS-1500 claim or Form Locator 1 on a UB-04 claim form.
    """

    place_of_service_code: typing.Optional[FacilityTypeCode] = pydantic.Field(default=None)
    """
    Box 24B on the CMS-1500 claim form. 837p Loop2300, CLM-05-1. This box is not used on a UB-04 or 837i claim form. 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).
    """

    rendering_provider: typing.Optional[RenderingProvider] = pydantic.Field(default=None)
    """
    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.
    """

    service_lines: typing.Optional[typing.List[UniversalServiceLineCreate]] = None
    health_care_code_information: typing.Optional[HealthCareCodeInformationCreate] = pydantic.Field(default=None)
    """
    The health care code information associated with this encounter, which includes things such as diagnoses, vitals, procedures, occurrences, reason for visit, and numerous other code related fields.
    """

    submission_expectation: EncounterSubmissionExpectation = pydantic.Field()
    """
    Describes the currently expected target form for this encounter.  This can change later, but it orients this encounter in the pipeline and effects reporting.
    """

    attending_provider: typing.Optional[RenderingProvider] = pydantic.Field(default=None)
    """
    837i NM1 2500 variant for Loop ID-2310.  Used to indicate the individual whom has overall responsibility for the patient in institutional claims processing.
    """

    admission_hour: typing.Optional[int] = pydantic.Field(default=None)
    """
    837i Loop 2300 DTP-03
    Extension of the admission date with hour (0-23 integer) details.
    """

    admission_type_code: typing.Optional[TypeOfAdmissionOrVisitCode] = pydantic.Field(default=None)
    """
    837i Loop 2300 CL1-01 Code used to indicate the priority of an admission or visit. Equivalent to Form Locator 14 Priority of Admission on a UB-04 claim, not used on CMS-1500 claim forms.
    """

    admission_source_code: typing.Optional[PointOfOriginForAdmissionOrVisitCode] = pydantic.Field(default=None)
    """
    837i Loop 2300 CLI1-02 Code used to indicate the conditions under which an admission occurs. Equivalent to Form Locator 15 Point of Origin on a UB-04 claim, not used on CMS-1500 claim forms.
    """

    discharge_hour: typing.Optional[int] = pydantic.Field(default=None)
    """
    837i Loop 2300 DTP-03
    Extension of the discharge date with hour (0-23 integer) details.
    """

    discharge_status: typing.Optional[PatientDischargeStatusCode] = pydantic.Field(default=None)
    """
    837i CL1-03 or Form Locator 17 on a UB-04 claim form. This is a required field on UB-04 claims.
    Code indicating patient status as of the "statement covers through date" .
    """

    operating_provider: typing.Optional[RenderingProvider] = pydantic.Field(default=None)
    """
    837i NM1 2500 variant for Loop ID-2310.  Used to indicate the individual whom has primary responsibility for surgical procedures in institutional claims processing.
    """

    other_operating_provider: typing.Optional[RenderingProvider] = pydantic.Field(default=None)
    """
    837i NM1 2500 variant for Loop ID-2310.  Used to indicate the individual whom has secondary responsibility for surgical procedures in institutional claims processing.  Only used when operating_provider is also set.
    """

    type_of_bill: typing.Optional[TypeOfBillCompositeUpdate] = pydantic.Field(default=None)
    """
    Four digit code used in institutional forms to indicate the type of bill (e.g., hospital inpatient, hospital outpatient). First digit is a leading 0, followed by the type_of_facility, type_of_care, then frequency_code. Professional forms are not required to submit this attribute. You may send the 4 digit code via raw_code, or each individual digit separately via composite_codes.
    """

    accident_state_or_province_code: typing.Optional[State] = pydantic.Field(default=None)
    """
    837i-REF1000 -- an optional state indicating where an accident related to the encounter occurred.
    """

    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
