# 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,
    ContactDetail,
    UsageContext,
)
from fhirschemapy.R4B.domain_resource import DomainResource


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

    translation: bool | None = Field(
        None, alias="translation", serialization_alias="translation"
    )


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

    subsumption: bool | None = Field(
        None, alias="subsumption", serialization_alias="subsumption"
    )
    uri: str | None = Field(None, alias="uri", serialization_alias="uri")
    version: PyList[TerminologyCapabilitiesCodeSystemVersion] | None = Field(
        None, alias="version", serialization_alias="version"
    )


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

    code: str | None = Field(None, alias="code", serialization_alias="code")
    compositional: bool | None = Field(
        None, alias="compositional", serialization_alias="compositional"
    )
    filter: PyList[TerminologyCapabilitiesCodeSystemVersionFilter] | None = Field(
        None, alias="filter", serialization_alias="filter"
    )
    is_default: bool | None = Field(
        None, alias="isDefault", serialization_alias="isDefault"
    )
    language: PyList[str] | None = Field(
        None, alias="language", serialization_alias="language"
    )
    property: PyList[str] | None = Field(
        None, alias="property", serialization_alias="property"
    )


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

    code: str = Field(alias="code", serialization_alias="code")
    op: PyList[str] = Field(alias="op", serialization_alias="op")


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

    hierarchical: bool | None = Field(
        None, alias="hierarchical", serialization_alias="hierarchical"
    )
    incomplete: bool | None = Field(
        None, alias="incomplete", serialization_alias="incomplete"
    )
    paging: bool | None = Field(None, alias="paging", serialization_alias="paging")
    parameter: PyList[TerminologyCapabilitiesExpansionParameter] | None = Field(
        None, alias="parameter", serialization_alias="parameter"
    )
    text_filter: str | None = Field(
        None, alias="textFilter", serialization_alias="textFilter"
    )


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

    documentation: str | None = Field(
        None, alias="documentation", serialization_alias="documentation"
    )
    name: str = Field(alias="name", serialization_alias="name")


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

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


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

    name: str = Field(alias="name", serialization_alias="name")
    version: str | None = Field(None, alias="version", serialization_alias="version")


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

    needs_map: bool = Field(alias="needsMap", serialization_alias="needsMap")


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

    translations: bool = Field(alias="translations", serialization_alias="translations")


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

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

    closure: TerminologyCapabilitiesClosure | None = Field(
        None, alias="closure", serialization_alias="closure"
    )
    code_search: Literal["explicit", "all"] | None = Field(
        None, alias="codeSearch", serialization_alias="codeSearch"
    )
    code_system: PyList[TerminologyCapabilitiesCodeSystem] | None = Field(
        None, alias="codeSystem", serialization_alias="codeSystem"
    )
    contact: PyList[ContactDetail] | None = Field(
        None, alias="contact", serialization_alias="contact"
    )
    copyright: str | None = Field(
        None, alias="copyright", serialization_alias="copyright"
    )
    date: str = Field(alias="date", serialization_alias="date")
    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    expansion: TerminologyCapabilitiesExpansion | None = Field(
        None, alias="expansion", serialization_alias="expansion"
    )
    experimental: bool | None = Field(
        None, alias="experimental", serialization_alias="experimental"
    )
    implementation: TerminologyCapabilitiesImplementation | None = Field(
        None, alias="implementation", serialization_alias="implementation"
    )
    jurisdiction: PyList[CodeableConcept] | None = Field(
        None, alias="jurisdiction", serialization_alias="jurisdiction"
    )
    kind: Literal["instance", "capability", "requirements"] = Field(
        alias="kind", serialization_alias="kind"
    )
    locked_date: bool | None = Field(
        None, alias="lockedDate", serialization_alias="lockedDate"
    )
    name: str | None = Field(None, alias="name", serialization_alias="name")
    publisher: str | None = Field(
        None, alias="publisher", serialization_alias="publisher"
    )
    purpose: str | None = Field(None, alias="purpose", serialization_alias="purpose")
    software: TerminologyCapabilitiesSoftware | None = Field(
        None, alias="software", serialization_alias="software"
    )
    status: Literal["draft", "active", "retired", "unknown"] = Field(
        alias="status", serialization_alias="status"
    )
    title: str | None = Field(None, alias="title", serialization_alias="title")
    translation: TerminologyCapabilitiesTranslation | None = Field(
        None, alias="translation", serialization_alias="translation"
    )
    url: str | None = Field(None, alias="url", serialization_alias="url")
    use_context: PyList[UsageContext] | None = Field(
        None, alias="useContext", serialization_alias="useContext"
    )
    validate_code: TerminologyCapabilitiesValidateCode | None = Field(
        None, alias="validateCode", serialization_alias="validateCode"
    )
    version: str | None = Field(None, alias="version", serialization_alias="version")

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