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


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

    country: CodeableConcept | None = Field(
        None, alias="country", serialization_alias="country"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    jurisdiction: PyList[CodeableConcept] | None = Field(
        None, alias="jurisdiction", serialization_alias="jurisdiction"
    )
    legal_status_of_supply: CodeableConcept | None = Field(
        None, alias="legalStatusOfSupply", serialization_alias="legalStatusOfSupply"
    )
    validity_period: Period | None = Field(
        None, alias="validityPeriod", serialization_alias="validityPeriod"
    )


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

    application: PyList[MedicinalProductAuthorizationProcedure] | None = Field(
        None, alias="application", serialization_alias="application"
    )
    date_date_time: str | None = Field(
        None, alias="dateDateTime", serialization_alias="dateDateTime"
    )
    date_period: Period | None = Field(
        None, alias="datePeriod", serialization_alias="datePeriod"
    )
    identifier: Identifier | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    type: CodeableConcept = Field(alias="type", serialization_alias="type")


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

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

    country: PyList[CodeableConcept] | None = Field(
        None, alias="country", serialization_alias="country"
    )
    data_exclusivity_period: Period | None = Field(
        None, alias="dataExclusivityPeriod", serialization_alias="dataExclusivityPeriod"
    )
    date_of_first_authorization: str | None = Field(
        None,
        alias="dateOfFirstAuthorization",
        serialization_alias="dateOfFirstAuthorization",
    )
    holder: Reference | None = Field(None, alias="holder", serialization_alias="holder")
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    international_birth_date: str | None = Field(
        None,
        alias="internationalBirthDate",
        serialization_alias="internationalBirthDate",
    )
    jurisdiction: PyList[CodeableConcept] | None = Field(
        None, alias="jurisdiction", serialization_alias="jurisdiction"
    )
    jurisdictional_authorization: (
        PyList[MedicinalProductAuthorizationJurisdictionalAuthorization] | None
    ) = Field(
        None,
        alias="jurisdictionalAuthorization",
        serialization_alias="jurisdictionalAuthorization",
    )
    legal_basis: CodeableConcept | None = Field(
        None, alias="legalBasis", serialization_alias="legalBasis"
    )
    procedure: MedicinalProductAuthorizationProcedure | None = Field(
        None, alias="procedure", serialization_alias="procedure"
    )
    regulator: Reference | None = Field(
        None, alias="regulator", serialization_alias="regulator"
    )
    restore_date: str | None = Field(
        None, alias="restoreDate", serialization_alias="restoreDate"
    )
    status: CodeableConcept | None = Field(
        None, alias="status", serialization_alias="status"
    )
    status_date: str | None = Field(
        None, alias="statusDate", serialization_alias="statusDate"
    )
    subject: Reference | None = Field(
        None, alias="subject", serialization_alias="subject"
    )
    validity_period: Period | None = Field(
        None, alias="validityPeriod", serialization_alias="validityPeriod"
    )

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