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


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

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

    classification: CodeableConcept | None = Field(
        None, alias="classification", serialization_alias="classification"
    )
    frequency_of_occurrence: CodeableConcept | None = Field(
        None, alias="frequencyOfOccurrence", serialization_alias="frequencyOfOccurrence"
    )
    population: PyList[Population] | None = Field(
        None, alias="population", serialization_alias="population"
    )
    subject: PyList[Reference] | None = Field(
        None, alias="subject", serialization_alias="subject"
    )
    symptom_condition_effect: CodeableConcept | None = Field(
        None,
        alias="symptomConditionEffect",
        serialization_alias="symptomConditionEffect",
    )

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