# 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 ...common.types.relationship import Relationship
from ...patients.types.patient_id import PatientId
from .coverage_status import CoverageStatus
from .insurance_plan import InsurancePlan
from .subscriber import Subscriber


class MutableCoverage(pydantic.BaseModel):
    status: CoverageStatus = pydantic.Field()
    """
    The status indiciating if the coverage is active or not.
    """

    subscriber: Subscriber = pydantic.Field()
    """
    The party who has signed-up for or 'owns' the contractual relationship to the policy or to whom the benefit of the policy for services rendered to them or their family is due.
    """

    relationship: Relationship = pydantic.Field()
    """
    The relationship of beneficiary (patient) to the subscriber. https://hl7.org/fhir/valueset-relationship.html
    """

    patient: PatientId = pydantic.Field()
    """
    The patient who benefits from the insurance coverage
    """

    insurance_plan: InsurancePlan = pydantic.Field(alias="insurancePlan")
    verified: bool = pydantic.Field()
    """
    A boolean indicating if the coverage has been verified by a user.
    """

    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.forbid
        json_encoders = {dt.datetime: serialize_datetime}
