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


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

    medication_codeable_concept: CodeableConcept | None = Field(
        None,
        alias="medicationCodeableConcept",
        serialization_alias="medicationCodeableConcept",
    )
    medication_reference: Reference | None = Field(
        None, alias="medicationReference", serialization_alias="medicationReference"
    )
    therapy_relationship_type: CodeableConcept = Field(
        alias="therapyRelationshipType", serialization_alias="therapyRelationshipType"
    )


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

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

    comorbidity: PyList[CodeableConcept] | None = Field(
        None, alias="comorbidity", serialization_alias="comorbidity"
    )
    disease: CodeableConcept | None = Field(
        None, alias="disease", serialization_alias="disease"
    )
    disease_status: CodeableConcept | None = Field(
        None, alias="diseaseStatus", serialization_alias="diseaseStatus"
    )
    other_therapy: PyList[MedicinalProductContraindicationOtherTherapy] | None = Field(
        None, alias="otherTherapy", serialization_alias="otherTherapy"
    )
    population: PyList[Population] | None = Field(
        None, alias="population", serialization_alias="population"
    )
    subject: PyList[Reference] | None = Field(
        None, alias="subject", serialization_alias="subject"
    )
    therapeutic_indication: PyList[Reference] | None = Field(
        None, alias="therapeuticIndication", serialization_alias="therapeuticIndication"
    )

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