# 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

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


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

    address: Address | None = Field(
        None, alias="address", serialization_alias="address"
    )
    name: HumanName | None = Field(None, alias="name", serialization_alias="name")
    purpose: CodeableConcept | None = Field(
        None, alias="purpose", serialization_alias="purpose"
    )
    telecom: PyList[ContactPoint] | None = Field(
        None, alias="telecom", serialization_alias="telecom"
    )


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

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

    active: bool | None = Field(None, alias="active", serialization_alias="active")
    address: PyList[Address] | None = Field(
        None, alias="address", serialization_alias="address"
    )
    alias: PyList[str] | None = Field(None, alias="alias", serialization_alias="alias")
    contact: PyList[OrganizationContact] | None = Field(
        None, alias="contact", serialization_alias="contact"
    )
    endpoint: PyList[Reference] | None = Field(
        None, alias="endpoint", serialization_alias="endpoint"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    name: str | None = Field(None, alias="name", serialization_alias="name")
    part_of: Reference | None = Field(
        None, alias="partOf", serialization_alias="partOf"
    )
    telecom: PyList[ContactPoint] | None = Field(
        None, alias="telecom", serialization_alias="telecom"
    )
    type: PyList[CodeableConcept] | None = Field(
        None, alias="type", serialization_alias="type"
    )

    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) -> Organization:
        return cls.model_validate_json(json)
