# 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, PositiveInt
from typing import List as PyList, Literal

from fhirschemapy.R4B.base import (
    Annotation,
    Attachment,
    CodeableConcept,
    Identifier,
    Period,
    Reference,
)
from fhirschemapy.R4B.domain_resource import DomainResource


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

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

    based_on: PyList[Reference] | None = Field(
        None, alias="basedOn", serialization_alias="basedOn"
    )
    body_site: CodeableConcept | None = Field(
        None, alias="bodySite", serialization_alias="bodySite"
    )
    content: Attachment = Field(alias="content", serialization_alias="content")
    created_date_time: str | None = Field(
        None, alias="createdDateTime", serialization_alias="createdDateTime"
    )
    created_period: Period | None = Field(
        None, alias="createdPeriod", serialization_alias="createdPeriod"
    )
    device: Reference | None = Field(None, alias="device", serialization_alias="device")
    device_name: str | None = Field(
        None, alias="deviceName", serialization_alias="deviceName"
    )
    duration: float | None = Field(
        None, alias="duration", serialization_alias="duration"
    )
    encounter: Reference | None = Field(
        None, alias="encounter", serialization_alias="encounter"
    )
    frames: PositiveInt | None = Field(
        None, alias="frames", serialization_alias="frames"
    )
    height: PositiveInt | None = Field(
        None, alias="height", serialization_alias="height"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    issued: str | None = Field(None, alias="issued", serialization_alias="issued")
    modality: CodeableConcept | None = Field(
        None, alias="modality", serialization_alias="modality"
    )
    note: PyList[Annotation] | None = Field(
        None, alias="note", serialization_alias="note"
    )
    operator: Reference | None = Field(
        None, alias="operator", serialization_alias="operator"
    )
    part_of: PyList[Reference] | None = Field(
        None, alias="partOf", serialization_alias="partOf"
    )
    reason_code: PyList[CodeableConcept] | None = Field(
        None, alias="reasonCode", serialization_alias="reasonCode"
    )
    status: Literal[
        "preparation",
        "in-progress",
        "not-done",
        "on-hold",
        "stopped",
        "completed",
        "entered-in-error",
        "unknown",
    ] = 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")
    view: CodeableConcept | None = Field(None, alias="view", serialization_alias="view")
    width: PositiveInt | None = Field(None, alias="width", serialization_alias="width")

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