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


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

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

    active: bool | None = Field(None, alias="active", serialization_alias="active")
    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    image: PyList[Attachment] | None = Field(
        None, alias="image", serialization_alias="image"
    )
    location: CodeableConcept | None = Field(
        None, alias="location", serialization_alias="location"
    )
    location_qualifier: PyList[CodeableConcept] | None = Field(
        None, alias="locationQualifier", serialization_alias="locationQualifier"
    )
    morphology: CodeableConcept | None = Field(
        None, alias="morphology", serialization_alias="morphology"
    )
    patient: Reference = Field(alias="patient", serialization_alias="patient")

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