# 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 CodeableConcept, Identifier, Period, Reference
from fhirschemapy.R4B.domain_resource import DomainResource


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

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

    author: Reference | None = Field(None, alias="author", serialization_alias="author")
    category: PyList[CodeableConcept] | None = Field(
        None, alias="category", serialization_alias="category"
    )
    code: CodeableConcept = Field(alias="code", serialization_alias="code")
    encounter: Reference | None = Field(
        None, alias="encounter", serialization_alias="encounter"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    period: Period | None = Field(None, alias="period", serialization_alias="period")
    status: Literal["active", "inactive", "entered-in-error"] = Field(
        alias="status", serialization_alias="status"
    )
    subject: Reference = Field(alias="subject", serialization_alias="subject")

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