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


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

    identifier: Identifier | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    ref: Reference | None = Field(None, alias="ref", serialization_alias="ref")


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

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

    author: PyList[Reference] | None = Field(
        None, alias="author", serialization_alias="author"
    )
    content: PyList[Reference] = Field(alias="content", serialization_alias="content")
    created: str | None = Field(None, alias="created", serialization_alias="created")
    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    master_identifier: Identifier | None = Field(
        None, alias="masterIdentifier", serialization_alias="masterIdentifier"
    )
    recipient: PyList[Reference] | None = Field(
        None, alias="recipient", serialization_alias="recipient"
    )
    related: PyList[DocumentManifestRelated] | None = Field(
        None, alias="related", serialization_alias="related"
    )
    source: str | None = Field(None, alias="source", serialization_alias="source")
    status: Literal["current", "superseded", "entered-in-error"] = Field(
        alias="status", serialization_alias="status"
    )
    subject: Reference | None = Field(
        None, alias="subject", serialization_alias="subject"
    )
    type: 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) -> DocumentManifest:
        return cls.model_validate_json(json)
