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


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

    document_type: str | None = Field(
        None, alias="documentType", serialization_alias="documentType"
    )
    presentation_date: str | None = Field(
        None, alias="presentationDate", serialization_alias="presentationDate"
    )
    publication_date: str | None = Field(
        None, alias="publicationDate", serialization_alias="publicationDate"
    )
    reference: str | None = Field(
        None, alias="reference", serialization_alias="reference"
    )


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

    actor: Reference = Field(alias="actor", serialization_alias="actor")
    function: CodeableConcept | None = Field(
        None, alias="function", serialization_alias="function"
    )


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

    authority: Reference | None = Field(
        None, alias="authority", serialization_alias="authority"
    )
    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"
    )
    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"
    )
    target_disease: PyList[CodeableConcept] | None = Field(
        None, alias="targetDisease", serialization_alias="targetDisease"
    )


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

    date: str | None = Field(None, alias="date", serialization_alias="date")
    detail: Reference | None = Field(None, alias="detail", serialization_alias="detail")
    reported: bool | None = Field(
        None, alias="reported", serialization_alias="reported"
    )


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

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

    dose_quantity: Quantity | None = Field(
        None, alias="doseQuantity", serialization_alias="doseQuantity"
    )
    education: PyList[ImmunizationEducation] | None = Field(
        None, alias="education", serialization_alias="education"
    )
    encounter: Reference | None = Field(
        None, alias="encounter", serialization_alias="encounter"
    )
    expiration_date: str | None = Field(
        None, alias="expirationDate", serialization_alias="expirationDate"
    )
    funding_source: CodeableConcept | None = Field(
        None, alias="fundingSource", serialization_alias="fundingSource"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    is_subpotent: bool | None = Field(
        None, alias="isSubpotent", serialization_alias="isSubpotent"
    )
    location: Reference | None = Field(
        None, alias="location", serialization_alias="location"
    )
    lot_number: str | None = Field(
        None, alias="lotNumber", serialization_alias="lotNumber"
    )
    manufacturer: Reference | None = Field(
        None, alias="manufacturer", serialization_alias="manufacturer"
    )
    note: PyList[Annotation] | None = Field(
        None, alias="note", serialization_alias="note"
    )
    occurrence_date_time: str | None = Field(
        None, alias="occurrenceDateTime", serialization_alias="occurrenceDateTime"
    )
    occurrence_string: str | None = Field(
        None, alias="occurrenceString", serialization_alias="occurrenceString"
    )
    patient: Reference = Field(alias="patient", serialization_alias="patient")
    performer: PyList[ImmunizationPerformer] | None = Field(
        None, alias="performer", serialization_alias="performer"
    )
    primary_source: bool | None = Field(
        None, alias="primarySource", serialization_alias="primarySource"
    )
    program_eligibility: PyList[CodeableConcept] | None = Field(
        None, alias="programEligibility", serialization_alias="programEligibility"
    )
    protocol_applied: PyList[ImmunizationProtocolApplied] | None = Field(
        None, alias="protocolApplied", serialization_alias="protocolApplied"
    )
    reaction: PyList[ImmunizationReaction] | None = Field(
        None, alias="reaction", serialization_alias="reaction"
    )
    reason_code: PyList[CodeableConcept] | None = Field(
        None, alias="reasonCode", serialization_alias="reasonCode"
    )
    reason_reference: PyList[Reference] | None = Field(
        None, alias="reasonReference", serialization_alias="reasonReference"
    )
    recorded: str | None = Field(None, alias="recorded", serialization_alias="recorded")
    report_origin: CodeableConcept | None = Field(
        None, alias="reportOrigin", serialization_alias="reportOrigin"
    )
    route: CodeableConcept | None = Field(
        None, alias="route", serialization_alias="route"
    )
    site: CodeableConcept | None = Field(None, alias="site", serialization_alias="site")
    status: Literal["completed", "entered-in-error", "not-done"] = Field(
        alias="status", serialization_alias="status"
    )
    status_reason: CodeableConcept | None = Field(
        None, alias="statusReason", serialization_alias="statusReason"
    )
    subpotent_reason: PyList[CodeableConcept] | None = Field(
        None, alias="subpotentReason", serialization_alias="subpotentReason"
    )
    vaccine_code: CodeableConcept = Field(
        alias="vaccineCode", serialization_alias="vaccineCode"
    )

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