# 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 ......core.pydantic_utilities import deep_union_pydantic_dicts
from .....commons.types.encounter_id import EncounterId
from .billing_note_base import BillingNoteBase
from .billing_note_id import BillingNoteId


class BillingNote(BillingNoteBase):
    """
    Examples
    --------
    import datetime
    import uuid

    from candid.resources.billing_notes.v_2 import BillingNote

    BillingNote(
        billing_note_id=uuid.UUID(
            "99882eea-936f-4e71-bc4f-520e4d14e3e2",
        ),
        encounter_id=uuid.UUID(
            "8bcfb6a8-2876-4111-9e3f-602b541fcf62",
        ),
        created_at=datetime.datetime.fromisoformat(
            "2023-01-01 00:00:00+00:00",
        ),
        author_auth_0_id="F0DE3BF9-F9A1-4FA7-BF6B-28C0B46BADD8",
        author_name="John Doe",
        text="Patient was billed for an MRI.",
    )
    """

    billing_note_id: BillingNoteId
    encounter_id: EncounterId
    created_at: dt.datetime = pydantic.Field()
    """
    An [RFC 3339, section 5.6 datetime](https://ijmacd.github.io/rfc3339-iso8601/).
    For example, 2017-07-21T17:32:28Z.
    """

    author_auth_0_id: typing.Optional[str] = pydantic.Field(alias="author_auth0_id", default=None)
    author_name: typing.Optional[str] = None

    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_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}

        return deep_union_pydantic_dicts(
            super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
        )

    class Config:
        frozen = True
        smart_union = True
        allow_population_by_field_name = True
        populate_by_name = True
        extra = pydantic.Extra.allow
        json_encoders = {dt.datetime: serialize_datetime}
