# WARNING: This file is autogenerated by FHIR Schema Codegen.
# https://github.com/fhir-schema/fhir-schema-codegen
# Any manual changes made to this file may be overwritten.

from __future__ import annotations
from pydantic import ConfigDict, Field
from typing import List as PyList, Literal

from fhirschemapy.R4B.base import (
    BackboneElement,
    CodeableConcept,
    ContactPoint,
    Identifier,
    Period,
    Reference,
)
from fhirschemapy.R4B.domain_resource import DomainResource


class PractitionerRoleAvailableTime(BackboneElement):
    model_config = ConfigDict(serialize_by_alias=True, extra="forbid")

    all_day: bool | None = Field(None, alias="allDay", serialization_alias="allDay")
    available_end_time: str | None = Field(
        None, alias="availableEndTime", serialization_alias="availableEndTime"
    )
    available_start_time: str | None = Field(
        None, alias="availableStartTime", serialization_alias="availableStartTime"
    )
    days_of_week: (
        PyList[Literal["mon", "tue", "wed", "thu", "fri", "sat", "sun"]] | None
    ) = Field(None, alias="daysOfWeek", serialization_alias="daysOfWeek")


class PractitionerRoleNotAvailable(BackboneElement):
    model_config = ConfigDict(serialize_by_alias=True, extra="forbid")

    description: str = Field(alias="description", serialization_alias="description")
    during: Period | None = Field(None, alias="during", serialization_alias="during")


class PractitionerRole(DomainResource):
    model_config = ConfigDict(serialize_by_alias=True, extra="forbid")

    resource_type: str = Field(
        default="PractitionerRole",
        alias="resourceType",
        serialization_alias="resourceType",
        frozen=True,
        pattern="PractitionerRole",
    )

    active: bool | None = Field(None, alias="active", serialization_alias="active")
    availability_exceptions: str | None = Field(
        None,
        alias="availabilityExceptions",
        serialization_alias="availabilityExceptions",
    )
    available_time: PyList[PractitionerRoleAvailableTime] | None = Field(
        None, alias="availableTime", serialization_alias="availableTime"
    )
    code: PyList[CodeableConcept] | None = Field(
        None, alias="code", serialization_alias="code"
    )
    endpoint: PyList[Reference] | None = Field(
        None, alias="endpoint", serialization_alias="endpoint"
    )
    healthcare_service: PyList[Reference] | None = Field(
        None, alias="healthcareService", serialization_alias="healthcareService"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    location: PyList[Reference] | None = Field(
        None, alias="location", serialization_alias="location"
    )
    not_available: PyList[PractitionerRoleNotAvailable] | None = Field(
        None, alias="notAvailable", serialization_alias="notAvailable"
    )
    organization: Reference | None = Field(
        None, alias="organization", serialization_alias="organization"
    )
    period: Period | None = Field(None, alias="period", serialization_alias="period")
    practitioner: Reference | None = Field(
        None, alias="practitioner", serialization_alias="practitioner"
    )
    specialty: PyList[CodeableConcept] | None = Field(
        None, alias="specialty", serialization_alias="specialty"
    )
    telecom: PyList[ContactPoint] | None = Field(
        None, alias="telecom", serialization_alias="telecom"
    )

    def to_json(self, indent: int | None = None) -> str:
        return self.model_dump_json(
            exclude_unset=True, exclude_none=True, indent=indent
        )

    @classmethod
    def from_json(cls, json: str) -> PractitionerRole:
        return cls.model_validate_json(json)
