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


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

    item_codeable_concept: CodeableConcept | None = Field(
        None, alias="itemCodeableConcept", serialization_alias="itemCodeableConcept"
    )
    item_reference: Reference | None = Field(
        None, alias="itemReference", serialization_alias="itemReference"
    )


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

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

    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    effect: CodeableConcept | None = Field(
        None, alias="effect", serialization_alias="effect"
    )
    incidence: CodeableConcept | None = Field(
        None, alias="incidence", serialization_alias="incidence"
    )
    interactant: PyList[MedicinalProductInteractionInteractant] | None = Field(
        None, alias="interactant", serialization_alias="interactant"
    )
    management: CodeableConcept | None = Field(
        None, alias="management", serialization_alias="management"
    )
    subject: PyList[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) -> MedicinalProductInteraction:
        return cls.model_validate_json(json)
