# 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

from fhirschemapy.R4B.base import (
    BackboneElement,
    CodeableConcept,
    Identifier,
    Reference,
)
from fhirschemapy.R4B.domain_resource import DomainResource


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

    contraindicated_vaccine_code: PyList[CodeableConcept] | None = Field(
        None,
        alias="contraindicatedVaccineCode",
        serialization_alias="contraindicatedVaccineCode",
    )
    date_criterion: (
        PyList[ImmunizationRecommendationRecommendationDateCriterion] | None
    ) = Field(None, alias="dateCriterion", serialization_alias="dateCriterion")
    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    dose_number_positive_int: PositiveInt | None = Field(
        None, alias="doseNumberPositiveInt", serialization_alias="doseNumberPositiveInt"
    )
    dose_number_string: str | None = Field(
        None, alias="doseNumberString", serialization_alias="doseNumberString"
    )
    forecast_reason: PyList[CodeableConcept] | None = Field(
        None, alias="forecastReason", serialization_alias="forecastReason"
    )
    forecast_status: CodeableConcept = Field(
        alias="forecastStatus", serialization_alias="forecastStatus"
    )
    series: str | None = Field(None, alias="series", serialization_alias="series")
    series_doses_positive_int: PositiveInt | None = Field(
        None,
        alias="seriesDosesPositiveInt",
        serialization_alias="seriesDosesPositiveInt",
    )
    series_doses_string: str | None = Field(
        None, alias="seriesDosesString", serialization_alias="seriesDosesString"
    )
    supporting_immunization: PyList[Reference] | None = Field(
        None,
        alias="supportingImmunization",
        serialization_alias="supportingImmunization",
    )
    supporting_patient_information: PyList[Reference] | None = Field(
        None,
        alias="supportingPatientInformation",
        serialization_alias="supportingPatientInformation",
    )
    target_disease: CodeableConcept | None = Field(
        None, alias="targetDisease", serialization_alias="targetDisease"
    )
    vaccine_code: PyList[CodeableConcept] | None = Field(
        None, alias="vaccineCode", serialization_alias="vaccineCode"
    )


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

    code: CodeableConcept = Field(alias="code", serialization_alias="code")
    value: str = Field(alias="value", serialization_alias="value")


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

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

    authority: Reference | None = Field(
        None, alias="authority", serialization_alias="authority"
    )
    date: str = Field(alias="date", serialization_alias="date")
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    patient: Reference = Field(alias="patient", serialization_alias="patient")
    recommendation: PyList[ImmunizationRecommendationRecommendation] = Field(
        alias="recommendation", serialization_alias="recommendation"
    )

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