# 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 Extension, Narrative
from fhirschemapy.R4B.resource import Resource
from fhirschemapy.R4B.resource_families import ResourceFamily


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

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

    contained: PyList[ResourceFamily] | None = Field(
        None, alias="contained", serialization_alias="contained"
    )
    extension: PyList[Extension] | None = Field(
        None, alias="extension", serialization_alias="extension"
    )
    modifier_extension: PyList[Extension] | None = Field(
        None, alias="modifierExtension", serialization_alias="modifierExtension"
    )
    text: Narrative | None = Field(None, alias="text", serialization_alias="text")

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