# 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 (
    Address,
    Attachment,
    BackboneElement,
    CodeableConcept,
    ContactPoint,
    HumanName,
    Identifier,
    Period,
    Reference,
)
from fhirschemapy.R4B.domain_resource import DomainResource


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

    code: CodeableConcept = Field(alias="code", serialization_alias="code")
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    issuer: Reference | None = Field(None, alias="issuer", serialization_alias="issuer")
    period: Period | None = Field(None, alias="period", serialization_alias="period")


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

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

    active: bool | None = Field(None, alias="active", serialization_alias="active")
    address: PyList[Address] | None = Field(
        None, alias="address", serialization_alias="address"
    )
    birth_date: str | None = Field(
        None, alias="birthDate", serialization_alias="birthDate"
    )
    communication: PyList[CodeableConcept] | None = Field(
        None, alias="communication", serialization_alias="communication"
    )
    gender: Literal["male", "female", "other", "unknown"] | None = Field(
        None, alias="gender", serialization_alias="gender"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    name: PyList[HumanName] | None = Field(
        None, alias="name", serialization_alias="name"
    )
    photo: PyList[Attachment] | None = Field(
        None, alias="photo", serialization_alias="photo"
    )
    qualification: PyList[PractitionerQualification] | None = Field(
        None, alias="qualification", serialization_alias="qualification"
    )
    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) -> Practitioner:
        return cls.model_validate_json(json)
