# 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 BaseModel, ConfigDict, Field

from fhirschemapy.R4B.base import Meta


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

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

    id: str | None = Field(None, alias="id", serialization_alias="id")
    implicit_rules: str | None = Field(
        None, alias="implicitRules", serialization_alias="implicitRules"
    )
    language: str | None = Field(None, alias="language", serialization_alias="language")
    meta: Meta | None = Field(None, alias="meta", serialization_alias="meta")

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