# -*- coding: utf-8 -*-
"""
Profile: http://hl7.org/fhir/StructureDefinition/SubscriptionTopic
Release: R4B
Version: 4.3.0
Build ID: c475c22
Last updated: 2022-05-28T12:47:40.239+10:00
"""
import typing

from pydantic import Field

from . import backboneelement, domainresource, fhirtypes


class SubscriptionTopic(domainresource.DomainResource):
    """Disclaimer: Any field name ends with ``__ext`` doesn't part of
    Resource StructureDefinition, instead used to enable Extensibility feature
    for FHIR Primitive Data Types.

    The definition of a specific topic for triggering events within the
    Subscriptions framework.
    Describes a stream of resource state changes or events and annotated with
    labels useful to filter projections from this topic.
    """

    __resource_type__ = "SubscriptionTopic"

    approvalDate: fhirtypes.DateType = Field(  # type: ignore
        None,
        alias="approvalDate",
        title="When SubscriptionTopic is/was approved by publisher",
        description=(
            "The date on which the asset content was approved by the publisher. "
            "Approval happens once when the content is officially approved for "
            "usage."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_approvalDate", title="Extension field for ``approvalDate``."
    )

    canFilterBy: typing.List[fhirtypes.SubscriptionTopicCanFilterByType] = Field(  # type: ignore
        None,
        alias="canFilterBy",
        title=(
            "Properties by which a Subscription can filter notifications from the "
            "SubscriptionTopic"
        ),
        description=(
            "List of properties by which Subscriptions on the SubscriptionTopic can"
            " be filtered. May be defined Search Parameters (e.g., "
            "Encounter.patient) or parameters defined within this SubscriptionTopic"
            " context (e.g., hub.event)."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )

    contact: typing.List[fhirtypes.ContactDetailType] = Field(  # type: ignore
        None,
        alias="contact",
        title="Contact details for the publisher",
        description=(
            "Contact details to assist a user in finding and communicating with the"
            " publisher."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )

    copyright: fhirtypes.MarkdownType = Field(  # type: ignore
        None,
        alias="copyright",
        title="Use and/or publishing restrictions",
        description=(
            "A copyright statement relating to the SubscriptionTopic and/or its "
            "contents. Copyright statements are generally legal restrictions on the"
            " use and publishing of the SubscriptionTopic."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_copyright", title="Extension field for ``copyright``."
    )

    date: fhirtypes.DateTimeType = Field(  # type: ignore
        None,
        alias="date",
        title="Date status first applied",
        description=(
            "For draft definitions, indicates the date of initial creation.  For "
            "active definitions, represents the date of activation.  For withdrawn "
            "definitions, indicates the date of withdrawal."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_date", title="Extension field for ``date``."
    )

    derivedFrom: typing.List[typing.Optional[fhirtypes.CanonicalType]] = Field(  # type: ignore
        None,
        alias="derivedFrom",
        title="Based on FHIR protocol or definition",
        description=(
            "The canonical URL pointing to another FHIR-defined SubscriptionTopic "
            "that is adhered to in whole or in part by this SubscriptionTopic."
        ),
        json_schema_extra={
            "element_property": True,
            # note: Listed Resource Type(s) should be allowed as Reference.
            "enum_reference_types": ["SubscriptionTopic"],
        },
    )
    derivedFrom__ext: typing.List[typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None]] = Field(  # type: ignore
        None, alias="_derivedFrom", title="Extension field for ``derivedFrom``."
    )

    description: fhirtypes.MarkdownType = Field(  # type: ignore
        None,
        alias="description",
        title="Natural language description of the SubscriptionTopic",
        description=(
            "A free text natural language description of the Topic from the "
            "consumer's perspective."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_description", title="Extension field for ``description``."
    )

    effectivePeriod: fhirtypes.PeriodType = Field(  # type: ignore
        None,
        alias="effectivePeriod",
        title="The effective date range for the SubscriptionTopic",
        description=(
            "The period during which the SubscriptionTopic content was or is "
            "planned to be effective."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )

    eventTrigger: typing.List[fhirtypes.SubscriptionTopicEventTriggerType] = Field(  # type: ignore
        None,
        alias="eventTrigger",
        title="Event definitions the SubscriptionTopic",
        description="Event definition which can be used to trigger the SubscriptionTopic.",
        json_schema_extra={
            "element_property": True,
        },
    )

    experimental: bool = Field(  # type: ignore
        None,
        alias="experimental",
        title="If for testing purposes, not real usage",
        description=(
            "A flag to indicate that this TopSubscriptionTopicic is authored for "
            "testing purposes (or education/evaluation/marketing), and is not "
            "intended to be used for genuine usage."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_experimental", title="Extension field for ``experimental``."
    )

    identifier: typing.List[fhirtypes.IdentifierType] = Field(  # type: ignore
        None,
        alias="identifier",
        title="Business Identifier for this subscription topic",
        description=(
            "Business identifiers assigned to this subscription topic by the "
            "performer and/or other systems.  These identifiers remain constant as "
            "the resource is updated and propagates from server to server."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )

    jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field(  # type: ignore
        None,
        alias="jurisdiction",
        title="Intended jurisdiction of the SubscriptionTopic (if applicable)",
        description="A jurisdiction in which the Topic is intended to be used.",
        json_schema_extra={
            "element_property": True,
        },
    )

    lastReviewDate: fhirtypes.DateType = Field(  # type: ignore
        None,
        alias="lastReviewDate",
        title="Date the Subscription Topic was last reviewed by the publisher",
        description=(
            "The date on which the asset content was last reviewed. Review happens "
            "periodically after that, but doesn't change the original approval "
            "date."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``."
    )

    notificationShape: typing.List[fhirtypes.SubscriptionTopicNotificationShapeType] = Field(  # type: ignore
        None,
        alias="notificationShape",
        title=(
            "Properties for describing the shape of notifications generated by this"
            " topic"
        ),
        description=(
            "List of properties to describe the shape (e.g., resources) included in"
            " notifications from this Subscription Topic."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )

    publisher: fhirtypes.StringType = Field(  # type: ignore
        None,
        alias="publisher",
        title=(
            "The name of the individual or organization that published the "
            "SubscriptionTopic"
        ),
        description=(
            'Helps establish the "authority/credibility" of the SubscriptionTopic.'
            "  May also allow for contact."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_publisher", title="Extension field for ``publisher``."
    )

    purpose: fhirtypes.MarkdownType = Field(  # type: ignore
        None,
        alias="purpose",
        title="Why this SubscriptionTopic is defined",
        description=(
            "Explains why this Topic is needed and why it has been designed as it "
            "has."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_purpose", title="Extension field for ``purpose``."
    )

    resourceTrigger: typing.List[fhirtypes.SubscriptionTopicResourceTriggerType] = Field(  # type: ignore
        None,
        alias="resourceTrigger",
        title="Definition of a resource-based trigger for the subscription topic",
        description=(
            "A definition of a resource-based event that triggers a notification "
            "based on the SubscriptionTopic. The criteria may be just a human "
            "readable description and/or a full FHIR search string or FHIRPath "
            "expression. Multiple triggers are considered OR joined (e.g., a "
            "resource update matching ANY of the definitions will trigger a "
            "notification)."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )

    status: fhirtypes.CodeType = Field(  # type: ignore
        None,
        alias="status",
        title="draft | active | retired | unknown",
        description="The current state of the SubscriptionTopic.",
        json_schema_extra={
            "element_property": True,
            "element_required": True,
            # note: Enum values can be used in validation,
            # but use in your own responsibilities, read official FHIR documentation.
            "enum_values": ["draft", "active", "retired", "unknown"],
        },
    )
    status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_status", title="Extension field for ``status``."
    )

    title: fhirtypes.StringType = Field(  # type: ignore
        None,
        alias="title",
        title="Name for this subscription topic (Human friendly)",
        description=(
            "A short, descriptive, user-friendly title for the SubscriptionTopic, "
            'for example, "admission".'
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_title", title="Extension field for ``title``."
    )

    url: fhirtypes.UriType = Field(  # type: ignore
        None,
        alias="url",
        title=(
            "Canonical identifier for this subscription topic definition, "
            "represented as a URI (globally unique)"
        ),
        description=(
            "An absolute URI that is used to identify this subscription topic when "
            "it is referenced in a specification, model, design or an instance; "
            "also called its canonical identifier. This SHOULD be globally unique "
            "and SHOULD be a literal address at which at which an authoritative "
            "instance of this subscription topic is (or will be) published. This "
            "URL can be the target of a canonical reference. It SHALL remain the "
            "same when the subscription topic is stored on different servers."
        ),
        json_schema_extra={
            "element_property": True,
            "element_required": True,
        },
    )
    url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_url", title="Extension field for ``url``."
    )

    useContext: typing.List[fhirtypes.UsageContextType] = Field(  # type: ignore
        None,
        alias="useContext",
        title="Content intends to support these contexts",
        description=(
            "The content was developed with a focus and intent of supporting the "
            "contexts that are listed. These terms may be used to assist with "
            "indexing and searching of code system definitions."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )

    version: fhirtypes.StringType = Field(  # type: ignore
        None,
        alias="version",
        title="Business version of the subscription topic",
        description=(
            "The identifier that is used to identify this version of the "
            "subscription topic when it is referenced in a specification, model, "
            "design or instance. This is an arbitrary value managed by the Topic "
            "author and is not expected to be globally unique. For example, it "
            "might be a timestamp (e.g. yyyymmdd) if a managed version is not "
            "available. There is also no expectation that versions are orderable."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_version", title="Extension field for ``version``."
    )

    @classmethod
    def elements_sequence(cls):
        """returning all elements names from
        ``SubscriptionTopic`` according specification,
        with preserving original sequence order.
        """
        return [
            "id",
            "meta",
            "implicitRules",
            "language",
            "text",
            "contained",
            "extension",
            "modifierExtension",
            "url",
            "identifier",
            "version",
            "title",
            "derivedFrom",
            "status",
            "experimental",
            "date",
            "publisher",
            "contact",
            "description",
            "useContext",
            "jurisdiction",
            "purpose",
            "copyright",
            "approvalDate",
            "lastReviewDate",
            "effectivePeriod",
            "resourceTrigger",
            "eventTrigger",
            "canFilterBy",
            "notificationShape",
        ]

    def get_required_fields(self) -> typing.List[typing.Tuple[str, str]]:
        """https://www.hl7.org/fhir/extensibility.html#Special-Case
        In some cases, implementers might find that they do not have appropriate data for
        an element with minimum cardinality = 1. In this case, the element must be present,
        but unless the resource or a profile on it has made the actual value of the primitive
        data type mandatory, it is possible to provide an extension that explains why
        the primitive value is not present.
        """
        required_fields = [("status", "status__ext"), ("url", "url__ext")]
        return required_fields


class SubscriptionTopicCanFilterBy(backboneelement.BackboneElement):
    """Disclaimer: Any field name ends with ``__ext`` doesn't part of
    Resource StructureDefinition, instead used to enable Extensibility feature
    for FHIR Primitive Data Types.

    Properties by which a Subscription can filter notifications from the
    SubscriptionTopic.
    List of properties by which Subscriptions on the SubscriptionTopic can be
    filtered. May be defined Search Parameters (e.g., Encounter.patient) or
    parameters defined within this SubscriptionTopic context (e.g., hub.event).
    """

    __resource_type__ = "SubscriptionTopicCanFilterBy"

    description: fhirtypes.MarkdownType = Field(  # type: ignore
        None,
        alias="description",
        title="Description of this filter parameter",
        description="Description of how this filtering parameter is intended to be used.",
        json_schema_extra={
            "element_property": True,
        },
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_description", title="Extension field for ``description``."
    )

    filterDefinition: fhirtypes.UriType = Field(  # type: ignore
        None,
        alias="filterDefinition",
        title="Canonical URL for a filterParameter definition",
        description=(
            "Either the canonical URL to a search parameter (like "
            '"http://hl7.org/fhir/SearchParameter/encounter-patient") or the '
            "officially-defined URI for a shared filter concept (like "
            '"http://example.org/concepts/shared-common-event").'
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    filterDefinition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None,
        alias="_filterDefinition",
        title="Extension field for ``filterDefinition``.",
    )

    filterParameter: fhirtypes.StringType = Field(  # type: ignore
        None,
        alias="filterParameter",
        title=(
            "Human-readable and computation-friendly name for a filter parameter "
            "usable by subscriptions on this topic, via "
            "Subscription.filterBy.filterParameter"
        ),
        description=(
            "Either the canonical URL to a search parameter (like "
            '"http://hl7.org/fhir/SearchParameter/encounter-patient") or topic-'
            'defined parameter (like "hub.event") which is a label for the filter.'
        ),
        json_schema_extra={
            "element_property": True,
            "element_required": True,
        },
    )
    filterParameter__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_filterParameter", title="Extension field for ``filterParameter``."
    )

    modifier: typing.List[typing.Optional[fhirtypes.CodeType]] = Field(  # type: ignore
        None,
        alias="modifier",
        title=(
            "= | eq | ne | gt | lt | ge | le | sa | eb | ap | above | below | in | "
            "not-in | of-type"
        ),
        description=(
            "Allowable operators to apply when determining matches (Search "
            "Modifiers).  If the filterParameter is a SearchParameter, this list of"
            " modifiers SHALL be a strict subset of the modifiers defined on that "
            "SearchParameter."
        ),
        json_schema_extra={
            "element_property": True,
            # note: Enum values can be used in validation,
            # but use in your own responsibilities, read official FHIR documentation.
            "enum_values": [
                "=",
                "eq",
                "ne",
                "gt",
                "lt",
                "ge",
                "le",
                "sa",
                "eb",
                "ap",
                "above",
                "below",
                "in",
                "not-in",
                "of-type",
            ],
        },
    )
    modifier__ext: typing.List[typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None]] = Field(  # type: ignore
        None, alias="_modifier", title="Extension field for ``modifier``."
    )

    resource: fhirtypes.UriType = Field(  # type: ignore
        None,
        alias="resource",
        title="URL of the triggering Resource that this filter applies to",
        description=(
            "URL of the Resource that is the type used in this filter. This is the "
            '"focus" of the topic (or one of them if there are more than one). It '
            "will be the same, a generality, or a specificity of "
            "SubscriptionTopic.resourceTrigger.resource or "
            "SubscriptionTopic.eventTrigger.resource when they are present."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    resource__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_resource", title="Extension field for ``resource``."
    )

    @classmethod
    def elements_sequence(cls):
        """returning all elements names from
        ``SubscriptionTopicCanFilterBy`` according specification,
        with preserving original sequence order.
        """
        return [
            "id",
            "extension",
            "modifierExtension",
            "description",
            "resource",
            "filterParameter",
            "filterDefinition",
            "modifier",
        ]

    def get_required_fields(self) -> typing.List[typing.Tuple[str, str]]:
        """https://www.hl7.org/fhir/extensibility.html#Special-Case
        In some cases, implementers might find that they do not have appropriate data for
        an element with minimum cardinality = 1. In this case, the element must be present,
        but unless the resource or a profile on it has made the actual value of the primitive
        data type mandatory, it is possible to provide an extension that explains why
        the primitive value is not present.
        """
        required_fields = [("filterParameter", "filterParameter__ext")]
        return required_fields


class SubscriptionTopicEventTrigger(backboneelement.BackboneElement):
    """Disclaimer: Any field name ends with ``__ext`` doesn't part of
    Resource StructureDefinition, instead used to enable Extensibility feature
    for FHIR Primitive Data Types.

    Event definitions the SubscriptionTopic.
    Event definition which can be used to trigger the SubscriptionTopic.
    """

    __resource_type__ = "SubscriptionTopicEventTrigger"

    description: fhirtypes.MarkdownType = Field(  # type: ignore
        None,
        alias="description",
        title="Text representation of the event trigger",
        description=(
            "The human readable description of an event to trigger a notification "
            'for the SubscriptionTopic - for example, "Patient Admission, as '
            'defined in HL7v2 via message ADT^A01". Multiple values are considered '
            "OR joined (e.g., matching any single event listed)."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_description", title="Extension field for ``description``."
    )

    event: fhirtypes.CodeableConceptType = Field(  # type: ignore
        ...,
        alias="event",
        title="Event which can trigger a notification from the SubscriptionTopic",
        description=(
            "A well-defined event which can be used to trigger notifications from "
            "the SubscriptionTopic."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )

    resource: fhirtypes.UriType = Field(  # type: ignore
        None,
        alias="resource",
        title=(
            "Data Type or Resource (reference to definition) for this trigger "
            "definition"
        ),
        description=(
            "URL of the Resource that is the focus type used in this event trigger."
            "  Relative URLs are relative to the StructureDefinition root of the "
            "implemented FHIR version (e.g., "
            'http://hl7.org/fhir/StructureDefinition). For example, "Patient" maps '
            "to http://hl7.org/fhir/StructureDefinition/Patient.  For more "
            'information, see <a href="elementdefinition-definitions.html#ElementDe'
            'finition.type.code">ElementDefinition.type.code</a>.'
        ),
        json_schema_extra={
            "element_property": True,
            "element_required": True,
        },
    )
    resource__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_resource", title="Extension field for ``resource``."
    )

    @classmethod
    def elements_sequence(cls):
        """returning all elements names from
        ``SubscriptionTopicEventTrigger`` according specification,
        with preserving original sequence order.
        """
        return [
            "id",
            "extension",
            "modifierExtension",
            "description",
            "event",
            "resource",
        ]

    def get_required_fields(self) -> typing.List[typing.Tuple[str, str]]:
        """https://www.hl7.org/fhir/extensibility.html#Special-Case
        In some cases, implementers might find that they do not have appropriate data for
        an element with minimum cardinality = 1. In this case, the element must be present,
        but unless the resource or a profile on it has made the actual value of the primitive
        data type mandatory, it is possible to provide an extension that explains why
        the primitive value is not present.
        """
        required_fields = [("resource", "resource__ext")]
        return required_fields


class SubscriptionTopicNotificationShape(backboneelement.BackboneElement):
    """Disclaimer: Any field name ends with ``__ext`` doesn't part of
    Resource StructureDefinition, instead used to enable Extensibility feature
    for FHIR Primitive Data Types.

    Properties for describing the shape of notifications generated by this
    topic.
    List of properties to describe the shape (e.g., resources) included in
    notifications from this Subscription Topic.
    """

    __resource_type__ = "SubscriptionTopicNotificationShape"

    include: typing.List[typing.Optional[fhirtypes.StringType]] = Field(  # type: ignore
        None,
        alias="include",
        title="Include directives, rooted in the resource for this shape",
        description=(
            "Search-style _include directives, rooted in the resource for this "
            "shape. Servers SHOULD include resources listed here, if they exist and"
            " the user is authorized to receive them.  Clients SHOULD be prepared "
            "to receive these additional resources, but SHALL function properly "
            "without them."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    include__ext: typing.List[typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None]] = Field(  # type: ignore
        None, alias="_include", title="Extension field for ``include``."
    )

    resource: fhirtypes.UriType = Field(  # type: ignore
        None,
        alias="resource",
        title=(
            "URL of the Resource that is the focus (main) resource in a "
            "notification shape"
        ),
        description=(
            "URL of the Resource that is the type used in this shape. This is the "
            '"focus" of the topic (or one of them if there are more than one) and '
            "the root resource for this shape definition. It will be the same, a "
            "generality, or a specificity of "
            "SubscriptionTopic.resourceTrigger.resource or "
            "SubscriptionTopic.eventTrigger.resource when they are present."
        ),
        json_schema_extra={
            "element_property": True,
            "element_required": True,
        },
    )
    resource__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_resource", title="Extension field for ``resource``."
    )

    revInclude: typing.List[typing.Optional[fhirtypes.StringType]] = Field(  # type: ignore
        None,
        alias="revInclude",
        title="Reverse include directives, rooted in the resource for this shape",
        description=(
            "Search-style _revinclude directives, rooted in the resource for this "
            "shape. Servers SHOULD include resources listed here, if they exist and"
            " the user is authorized to receive them.  Clients SHOULD be prepared "
            "to receive these additional resources, but SHALL function properly "
            "without them."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    revInclude__ext: typing.List[typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None]] = Field(  # type: ignore
        None, alias="_revInclude", title="Extension field for ``revInclude``."
    )

    @classmethod
    def elements_sequence(cls):
        """returning all elements names from
        ``SubscriptionTopicNotificationShape`` according specification,
        with preserving original sequence order.
        """
        return [
            "id",
            "extension",
            "modifierExtension",
            "resource",
            "include",
            "revInclude",
        ]

    def get_required_fields(self) -> typing.List[typing.Tuple[str, str]]:
        """https://www.hl7.org/fhir/extensibility.html#Special-Case
        In some cases, implementers might find that they do not have appropriate data for
        an element with minimum cardinality = 1. In this case, the element must be present,
        but unless the resource or a profile on it has made the actual value of the primitive
        data type mandatory, it is possible to provide an extension that explains why
        the primitive value is not present.
        """
        required_fields = [("resource", "resource__ext")]
        return required_fields


class SubscriptionTopicResourceTrigger(backboneelement.BackboneElement):
    """Disclaimer: Any field name ends with ``__ext`` doesn't part of
    Resource StructureDefinition, instead used to enable Extensibility feature
    for FHIR Primitive Data Types.

    Definition of a resource-based trigger for the subscription topic.
    A definition of a resource-based event that triggers a notification based
    on the SubscriptionTopic. The criteria may be just a human readable
    description and/or a full FHIR search string or FHIRPath expression.
    Multiple triggers are considered OR joined (e.g., a resource update
    matching ANY of the definitions will trigger a notification).
    """

    __resource_type__ = "SubscriptionTopicResourceTrigger"

    description: fhirtypes.MarkdownType = Field(  # type: ignore
        None,
        alias="description",
        title="Text representation of the resource trigger",
        description=(
            "The human readable description of this resource trigger for the "
            "SubscriptionTopic -  for example, \"An Encounter enters the 'in-"
            "progress' state\"."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_description", title="Extension field for ``description``."
    )

    fhirPathCriteria: fhirtypes.StringType = Field(  # type: ignore
        None,
        alias="fhirPathCriteria",
        title="FHIRPath based trigger rule",
        description=(
            "The FHIRPath based rules that the server should use to determine when "
            "to trigger a notification for this topic."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    fhirPathCriteria__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None,
        alias="_fhirPathCriteria",
        title="Extension field for ``fhirPathCriteria``.",
    )

    queryCriteria: fhirtypes.SubscriptionTopicResourceTriggerQueryCriteriaType = Field(  # type: ignore
        None,
        alias="queryCriteria",
        title="Query based trigger rule",
        description=(
            "The FHIR query based rules that the server should use to determine "
            "when to trigger a notification for this subscription topic."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )

    resource: fhirtypes.UriType = Field(  # type: ignore
        None,
        alias="resource",
        title=(
            "Data Type or Resource (reference to definition) for this trigger "
            "definition"
        ),
        description=(
            "URL of the Resource that is the type used in this resource trigger.  "
            "Relative URLs are relative to the StructureDefinition root of the "
            "implemented FHIR version (e.g., "
            'http://hl7.org/fhir/StructureDefinition). For example, "Patient" maps '
            "to http://hl7.org/fhir/StructureDefinition/Patient.  For more "
            'information, see <a href="elementdefinition-definitions.html#ElementDe'
            'finition.type.code">ElementDefinition.type.code</a>.'
        ),
        json_schema_extra={
            "element_property": True,
            "element_required": True,
        },
    )
    resource__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_resource", title="Extension field for ``resource``."
    )

    supportedInteraction: typing.List[typing.Optional[fhirtypes.CodeType]] = Field(  # type: ignore
        None,
        alias="supportedInteraction",
        title="create | update | delete",
        description=(
            "The FHIR RESTful interaction which can be used to trigger a "
            "notification for the SubscriptionTopic. Multiple values are considered"
            " OR joined (e.g., CREATE or UPDATE)."
        ),
        json_schema_extra={
            "element_property": True,
            # note: Enum values can be used in validation,
            # but use in your own responsibilities, read official FHIR documentation.
            "enum_values": ["create", "update", "delete"],
        },
    )
    supportedInteraction__ext: typing.List[typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None]] = Field(  # type: ignore
        None,
        alias="_supportedInteraction",
        title="Extension field for ``supportedInteraction``.",
    )

    @classmethod
    def elements_sequence(cls):
        """returning all elements names from
        ``SubscriptionTopicResourceTrigger`` according specification,
        with preserving original sequence order.
        """
        return [
            "id",
            "extension",
            "modifierExtension",
            "description",
            "resource",
            "supportedInteraction",
            "queryCriteria",
            "fhirPathCriteria",
        ]

    def get_required_fields(self) -> typing.List[typing.Tuple[str, str]]:
        """https://www.hl7.org/fhir/extensibility.html#Special-Case
        In some cases, implementers might find that they do not have appropriate data for
        an element with minimum cardinality = 1. In this case, the element must be present,
        but unless the resource or a profile on it has made the actual value of the primitive
        data type mandatory, it is possible to provide an extension that explains why
        the primitive value is not present.
        """
        required_fields = [("resource", "resource__ext")]
        return required_fields


class SubscriptionTopicResourceTriggerQueryCriteria(backboneelement.BackboneElement):
    """Disclaimer: Any field name ends with ``__ext`` doesn't part of
    Resource StructureDefinition, instead used to enable Extensibility feature
    for FHIR Primitive Data Types.

    Query based trigger rule.
    The FHIR query based rules that the server should use to determine when to
    trigger a notification for this subscription topic.
    """

    __resource_type__ = "SubscriptionTopicResourceTriggerQueryCriteria"

    current: fhirtypes.StringType = Field(  # type: ignore
        None,
        alias="current",
        title="Rule applied to current resource state",
        description=(
            "The FHIR query based rules are applied to the current resource state "
            "(e.g., state after an update)."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    current__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_current", title="Extension field for ``current``."
    )

    previous: fhirtypes.StringType = Field(  # type: ignore
        None,
        alias="previous",
        title="Rule applied to previous resource state",
        description=(
            "The FHIR query based rules are applied to the previous resource state "
            "(e.g., state before an update)."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    previous__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_previous", title="Extension field for ``previous``."
    )

    requireBoth: bool = Field(  # type: ignore
        None,
        alias="requireBoth",
        title="Both must be true flag",
        description=(
            "If set to true, both current and previous criteria must evaluate true "
            "to  trigger a notification for this topic.  Otherwise a notification "
            "for this topic will be triggered if either one evaluates to true."
        ),
        json_schema_extra={
            "element_property": True,
        },
    )
    requireBoth__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_requireBoth", title="Extension field for ``requireBoth``."
    )

    resultForCreate: fhirtypes.CodeType = Field(  # type: ignore
        None,
        alias="resultForCreate",
        title="test-passes | test-fails",
        description=(
            'For "create" interactions, should the "previous" criteria count as an '
            "automatic pass or an automatic fail."
        ),
        json_schema_extra={
            "element_property": True,
            # note: Enum values can be used in validation,
            # but use in your own responsibilities, read official FHIR documentation.
            "enum_values": ["test-passes", "test-fails"],
        },
    )
    resultForCreate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_resultForCreate", title="Extension field for ``resultForCreate``."
    )

    resultForDelete: fhirtypes.CodeType = Field(  # type: ignore
        None,
        alias="resultForDelete",
        title="test-passes | test-fails",
        description=(
            'For "delete" interactions, should the "current" criteria count as an '
            "automatic pass or an automatic fail."
        ),
        json_schema_extra={
            "element_property": True,
            # note: Enum values can be used in validation,
            # but use in your own responsibilities, read official FHIR documentation.
            "enum_values": ["test-passes", "test-fails"],
        },
    )
    resultForDelete__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(  # type: ignore
        None, alias="_resultForDelete", title="Extension field for ``resultForDelete``."
    )

    @classmethod
    def elements_sequence(cls):
        """returning all elements names from
        ``SubscriptionTopicResourceTriggerQueryCriteria`` according specification,
        with preserving original sequence order.
        """
        return [
            "id",
            "extension",
            "modifierExtension",
            "previous",
            "resultForCreate",
            "current",
            "resultForDelete",
            "requireBoth",
        ]
