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

import datetime as dt
import typing

import pydantic

from ......core.datetime_utils import serialize_datetime
from .....billing_notes.types.billing_note import BillingNote
from .....claims.types.claim import Claim
from .....commons.types.encounter_id import EncounterId
from .....commons.types.facility_type_code import FacilityTypeCode
from .....commons.types.link_url import LinkUrl
from .....diagnoses.types.diagnosis import Diagnosis
from .....encounter_providers.resources.v_2.types.encounter_provider import EncounterProvider
from .....individual.types.patient import Patient
from .....individual.types.subscriber import Subscriber
from .....patient_payments.resources.v_2.types.patient_payment import PatientPayment
from .....service_facility.types.encounter_service_facility import EncounterServiceFacility
from .....tags.types.tag import Tag
from .....work_queues.resources.v_1.types.work_queue import WorkQueue
from .clinical_note_category import ClinicalNoteCategory
from .coding_attribution_type import CodingAttributionType
from .encounter_base import EncounterBase
from .patient_history_category import PatientHistoryCategory


class Encounter(EncounterBase):
    encounter_id: EncounterId
    claims: typing.List[Claim]
    patient: Patient
    billing_provider: EncounterProvider
    rendering_provider: EncounterProvider
    referring_provider: typing.Optional[EncounterProvider]
    service_facility: EncounterServiceFacility
    subscriber_primary: typing.Optional[Subscriber]
    subscriber_secondary: typing.Optional[Subscriber]
    url: LinkUrl = pydantic.Field(description=("URL that links directly to the claim created in Candid\n"))
    diagnoses: typing.List[Diagnosis]
    clinical_notes: typing.List[ClinicalNoteCategory]
    billing_notes: typing.Optional[typing.List[BillingNote]] = pydantic.Field(
        description=(
            "Spot to store misc, human-readable, notes about this encounter to be\n" "used in the billing process.\n"
        )
    )
    place_of_service_code: typing.Optional[FacilityTypeCode]
    place_of_service_code_as_submitted: typing.Optional[FacilityTypeCode]
    patient_histories: typing.List[PatientHistoryCategory]
    patient_payments: typing.List[PatientPayment]
    tags: typing.List[Tag]
    coding_attribution: typing.Optional[CodingAttributionType]
    work_queue: typing.Optional[WorkQueue]

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().dict(**kwargs_with_defaults)

    class Config:
        frozen = True
        allow_population_by_field_name = True
        json_encoders = {dt.datetime: serialize_datetime}
