# 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, Literal

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


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

    actor_id: str = Field(alias="actorId", serialization_alias="actorId")
    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    name: str | None = Field(None, alias="name", serialization_alias="name")
    type: Literal["person", "entity"] = Field(alias="type", serialization_alias="type")


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

    contained_instance: PyList[ExampleScenarioInstanceContainedInstance] | None = Field(
        None, alias="containedInstance", serialization_alias="containedInstance"
    )
    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    name: str | None = Field(None, alias="name", serialization_alias="name")
    resource_id: str = Field(alias="resourceId", serialization_alias="resourceId")
    resource_type: Literal[
        "Account",
        "ActivityDefinition",
        "AdverseEvent",
        "AllergyIntolerance",
        "Appointment",
        "AppointmentResponse",
        "AuditEvent",
        "Basic",
        "Binary",
        "BiologicallyDerivedProduct",
        "BodyStructure",
        "Bundle",
        "CapabilityStatement",
        "CarePlan",
        "CareTeam",
        "CatalogEntry",
        "ChargeItem",
        "ChargeItemDefinition",
        "Claim",
        "ClaimResponse",
        "ClinicalImpression",
        "CodeSystem",
        "Communication",
        "CommunicationRequest",
        "CompartmentDefinition",
        "Composition",
        "ConceptMap",
        "Condition",
        "Consent",
        "Contract",
        "Coverage",
        "CoverageEligibilityRequest",
        "CoverageEligibilityResponse",
        "DetectedIssue",
        "Device",
        "DeviceDefinition",
        "DeviceMetric",
        "DeviceRequest",
        "DeviceUseStatement",
        "DiagnosticReport",
        "DocumentManifest",
        "DocumentReference",
        "DomainResource",
        "EffectEvidenceSynthesis",
        "Encounter",
        "Endpoint",
        "EnrollmentRequest",
        "EnrollmentResponse",
        "EpisodeOfCare",
        "EventDefinition",
        "Evidence",
        "EvidenceVariable",
        "ExampleScenario",
        "ExplanationOfBenefit",
        "FamilyMemberHistory",
        "Flag",
        "Goal",
        "GraphDefinition",
        "Group",
        "GuidanceResponse",
        "HealthcareService",
        "ImagingStudy",
        "Immunization",
        "ImmunizationEvaluation",
        "ImmunizationRecommendation",
        "ImplementationGuide",
        "InsurancePlan",
        "Invoice",
        "Library",
        "Linkage",
        "List",
        "Location",
        "Measure",
        "MeasureReport",
        "Media",
        "Medication",
        "MedicationAdministration",
        "MedicationDispense",
        "MedicationKnowledge",
        "MedicationRequest",
        "MedicationStatement",
        "MedicinalProduct",
        "MedicinalProductAuthorization",
        "MedicinalProductContraindication",
        "MedicinalProductIndication",
        "MedicinalProductIngredient",
        "MedicinalProductInteraction",
        "MedicinalProductManufactured",
        "MedicinalProductPackaged",
        "MedicinalProductPharmaceutical",
        "MedicinalProductUndesirableEffect",
        "MessageDefinition",
        "MessageHeader",
        "MolecularSequence",
        "NamingSystem",
        "NutritionOrder",
        "Observation",
        "ObservationDefinition",
        "OperationDefinition",
        "OperationOutcome",
        "Organization",
        "OrganizationAffiliation",
        "Parameters",
        "Patient",
        "PaymentNotice",
        "PaymentReconciliation",
        "Person",
        "PlanDefinition",
        "Practitioner",
        "PractitionerRole",
        "Procedure",
        "Provenance",
        "Questionnaire",
        "QuestionnaireResponse",
        "RelatedPerson",
        "RequestGroup",
        "ResearchDefinition",
        "ResearchElementDefinition",
        "ResearchStudy",
        "ResearchSubject",
        "Resource",
        "RiskAssessment",
        "RiskEvidenceSynthesis",
        "Schedule",
        "SearchParameter",
        "ServiceRequest",
        "Slot",
        "Specimen",
        "SpecimenDefinition",
        "StructureDefinition",
        "StructureMap",
        "Subscription",
        "Substance",
        "SubstanceNucleicAcid",
        "SubstancePolymer",
        "SubstanceProtein",
        "SubstanceReferenceInformation",
        "SubstanceSourceMaterial",
        "SubstanceSpecification",
        "SupplyDelivery",
        "SupplyRequest",
        "Task",
        "TerminologyCapabilities",
        "TestReport",
        "TestScript",
        "ValueSet",
        "VerificationResult",
        "VisionPrescription",
    ] = Field(alias="resourceType", serialization_alias="resourceType")
    version: PyList[ExampleScenarioInstanceVersion] | None = Field(
        None, alias="version", serialization_alias="version"
    )


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

    resource_id: str = Field(alias="resourceId", serialization_alias="resourceId")
    version_id: str | None = Field(
        None, alias="versionId", serialization_alias="versionId"
    )


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

    description: str = Field(alias="description", serialization_alias="description")
    version_id: str = Field(alias="versionId", serialization_alias="versionId")


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

    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    post_conditions: str | None = Field(
        None, alias="postConditions", serialization_alias="postConditions"
    )
    pre_conditions: str | None = Field(
        None, alias="preConditions", serialization_alias="preConditions"
    )
    step: PyList[ExampleScenarioProcessStep] | None = Field(
        None, alias="step", serialization_alias="step"
    )
    title: str = Field(alias="title", serialization_alias="title")


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

    alternative: PyList[ExampleScenarioProcessStepAlternative] | None = Field(
        None, alias="alternative", serialization_alias="alternative"
    )
    operation: ExampleScenarioProcessStepOperation | None = Field(
        None, alias="operation", serialization_alias="operation"
    )
    pause: bool | None = Field(None, alias="pause", serialization_alias="pause")
    process: PyList[ExampleScenarioProcess] | None = Field(
        None, alias="process", serialization_alias="process"
    )


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

    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    step: PyList[ExampleScenarioProcessStep] | None = Field(
        None, alias="step", serialization_alias="step"
    )
    title: str = Field(alias="title", serialization_alias="title")


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

    description: str | None = Field(
        None, alias="description", serialization_alias="description"
    )
    initiator: str | None = Field(
        None, alias="initiator", serialization_alias="initiator"
    )
    initiator_active: bool | None = Field(
        None, alias="initiatorActive", serialization_alias="initiatorActive"
    )
    name: str | None = Field(None, alias="name", serialization_alias="name")
    number: str = Field(alias="number", serialization_alias="number")
    receiver: str | None = Field(None, alias="receiver", serialization_alias="receiver")
    receiver_active: bool | None = Field(
        None, alias="receiverActive", serialization_alias="receiverActive"
    )
    request: ExampleScenarioInstanceContainedInstance | None = Field(
        None, alias="request", serialization_alias="request"
    )
    response: ExampleScenarioInstanceContainedInstance | None = Field(
        None, alias="response", serialization_alias="response"
    )
    type: str | None = Field(None, alias="type", serialization_alias="type")


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

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

    actor: PyList[ExampleScenarioActor] | None = Field(
        None, alias="actor", serialization_alias="actor"
    )
    contact: PyList[ContactDetail] | None = Field(
        None, alias="contact", serialization_alias="contact"
    )
    copyright: str | None = Field(
        None, alias="copyright", serialization_alias="copyright"
    )
    date: str | None = Field(None, alias="date", serialization_alias="date")
    experimental: bool | None = Field(
        None, alias="experimental", serialization_alias="experimental"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    instance: PyList[ExampleScenarioInstance] | None = Field(
        None, alias="instance", serialization_alias="instance"
    )
    jurisdiction: PyList[CodeableConcept] | None = Field(
        None, alias="jurisdiction", serialization_alias="jurisdiction"
    )
    name: str | None = Field(None, alias="name", serialization_alias="name")
    process: PyList[ExampleScenarioProcess] | None = Field(
        None, alias="process", serialization_alias="process"
    )
    publisher: str | None = Field(
        None, alias="publisher", serialization_alias="publisher"
    )
    purpose: str | None = Field(None, alias="purpose", serialization_alias="purpose")
    status: Literal["draft", "active", "retired", "unknown"] = Field(
        alias="status", serialization_alias="status"
    )
    url: str | None = Field(None, alias="url", serialization_alias="url")
    use_context: PyList[UsageContext] | None = Field(
        None, alias="useContext", serialization_alias="useContext"
    )
    version: str | None = Field(None, alias="version", serialization_alias="version")
    workflow: PyList[str] | None = Field(
        None, alias="workflow", serialization_alias="workflow"
    )

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