# -*- coding: utf-8 -*-
"""
Profile: http://hl7.org/fhir/StructureDefinition/TestScript
Release: R4
Version: 4.0.1
Build ID: 9346c8cc45
Last updated: 2019-11-01T09:29:23.356+11:00
"""
from typing import List as ListType
from typing import Union

from pydantic import Field

from . import backboneelement, domainresource, fhirtypes


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

    Describes a set of tests.
    A structured set of tests against a FHIR server or client implementation to
    determine compliance against the FHIR specification.
    """

    resource_type = Field("TestScript", const=True)

    contact: ListType[fhirtypes.ContactDetailType] = Field(
        None,
        alias="contact",
        title="Contact details for the publisher",
        description=(
            "Contact details to assist a user in finding and communicating with the"
            " publisher."
        ),
    )

    copyright: fhirtypes.Markdown = Field(
        None,
        alias="copyright",
        title="Use and/or publishing restrictions",
        description=(
            "A copyright statement relating to the test script and/or its contents."
            " Copyright statements are generally legal restrictions on the use and "
            "publishing of the test script."
        ),
    )
    copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_copyright", title="Extension field for ``copyright``."
    )

    date: fhirtypes.DateTime = Field(
        None,
        alias="date",
        title="Date last changed",
        description=(
            "The date  (and optionally time) when the test script was published. "
            "The date must change when the business version changes and it must "
            "change if the status code changes. In addition, it should change when "
            "the substantive content of the test script changes."
        ),
    )
    date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_date", title="Extension field for ``date``."
    )

    description: fhirtypes.Markdown = Field(
        None,
        alias="description",
        title="Natural language description of the test script",
        description=(
            "A free text natural language description of the test script from a "
            "consumer's perspective."
        ),
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_description", title="Extension field for ``description``."
    )

    destination: ListType[fhirtypes.TestScriptDestinationType] = Field(
        None,
        alias="destination",
        title=(
            "An abstract server representing a destination or receiver in a message"
            " exchange"
        ),
        description=(
            "An abstract server used in operations within this test script in the "
            "destination element."
        ),
    )

    experimental: bool = Field(
        None,
        alias="experimental",
        title="For testing purposes, not real usage",
        description=(
            "A Boolean value to indicate that this test script is authored for "
            "testing purposes (or education/evaluation/marketing) and is not "
            "intended to be used for genuine usage."
        ),
    )
    experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_experimental", title="Extension field for ``experimental``."
    )

    fixture: ListType[fhirtypes.TestScriptFixtureType] = Field(
        None,
        alias="fixture",
        title="Fixture in the test script - by reference (uri)",
        description=(
            "Fixture in the test script - by reference (uri). All fixtures are "
            "required for the test script to execute."
        ),
    )

    identifier: fhirtypes.IdentifierType = Field(
        None,
        alias="identifier",
        title="Additional identifier for the test script",
        description=(
            "A formal identifier that is used to identify this test script when it "
            "is represented in other formats, or referenced in a specification, "
            "model, design or an instance."
        ),
    )

    jurisdiction: ListType[fhirtypes.CodeableConceptType] = Field(
        None,
        alias="jurisdiction",
        title="Intended jurisdiction for test script (if applicable)",
        description=(
            "A legal or geographic region in which the test script is intended to "
            "be used."
        ),
    )

    metadata: fhirtypes.TestScriptMetadataType = Field(
        None,
        alias="metadata",
        title=(
            "Required capability that is assumed to function correctly on the FHIR "
            "server being tested"
        ),
        description=(
            "The required capability must exist and are assumed to function "
            "correctly on the FHIR server being tested."
        ),
    )

    name: fhirtypes.String = Field(
        ...,
        alias="name",
        title="Name for this test script (computer friendly)",
        description=(
            "A natural language name identifying the test script. This name should "
            "be usable as an identifier for the module by machine processing "
            "applications such as code generation."
        ),
    )
    name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_name", title="Extension field for ``name``."
    )

    origin: ListType[fhirtypes.TestScriptOriginType] = Field(
        None,
        alias="origin",
        title=(
            "An abstract server representing a client or sender in a message "
            "exchange"
        ),
        description=(
            "An abstract server used in operations within this test script in the "
            "origin element."
        ),
    )

    profile: ListType[fhirtypes.ReferenceType] = Field(
        None,
        alias="profile",
        title="Reference of the validation profile",
        description="Reference to the profile to be used for validation.",
        # note: Listed Resource Type(s) should be allowed as Reference.
        enum_reference_types=["Resource"],
    )

    publisher: fhirtypes.String = Field(
        None,
        alias="publisher",
        title="Name of the publisher (organization or individual)",
        description=(
            "The name of the organization or individual that published the test "
            "script."
        ),
    )
    publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_publisher", title="Extension field for ``publisher``."
    )

    purpose: fhirtypes.Markdown = Field(
        None,
        alias="purpose",
        title="Why this test script is defined",
        description=(
            "Explanation of why this test script is needed and why it has been "
            "designed as it has."
        ),
    )
    purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_purpose", title="Extension field for ``purpose``."
    )

    setup: fhirtypes.TestScriptSetupType = Field(
        None,
        alias="setup",
        title="A series of required setup operations before tests are executed",
        description=None,
    )

    status: fhirtypes.Code = Field(
        ...,
        alias="status",
        title="draft | active | retired | unknown",
        description=(
            "The status of this test script. Enables tracking the life-cycle of the"
            " content."
        ),
        # 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(
        None, alias="_status", title="Extension field for ``status``."
    )

    teardown: fhirtypes.TestScriptTeardownType = Field(
        None,
        alias="teardown",
        title="A series of required clean up steps",
        description=(
            "A series of operations required to clean up after all the tests are "
            "executed (successfully or otherwise)."
        ),
    )

    test: ListType[fhirtypes.TestScriptTestType] = Field(
        None, alias="test", title="A test in this script", description=None,
    )

    title: fhirtypes.String = Field(
        None,
        alias="title",
        title="Name for this test script (human friendly)",
        description="A short, descriptive, user-friendly title for the test script.",
    )
    title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_title", title="Extension field for ``title``."
    )

    url: fhirtypes.Uri = Field(
        ...,
        alias="url",
        title=(
            "Canonical identifier for this test script, represented as a URI "
            "(globally unique)"
        ),
        description=(
            "An absolute URI that is used to identify this test script 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 test script is (or will be) published. This URL can "
            "be the target of a canonical reference. It SHALL remain the same when "
            "the test script is stored on different servers."
        ),
    )
    url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_url", title="Extension field for ``url``."
    )

    useContext: ListType[fhirtypes.UsageContextType] = Field(
        None,
        alias="useContext",
        title="The context that the content is intended to support",
        description=(
            "The content was developed with a focus and intent of supporting the "
            "contexts that are listed. These contexts may be general categories "
            "(gender, age, ...) or may be references to specific programs "
            "(insurance plans, studies, ...) and may be used to assist with "
            "indexing and searching for appropriate test script instances."
        ),
    )

    variable: ListType[fhirtypes.TestScriptVariableType] = Field(
        None,
        alias="variable",
        title="Placeholder for evaluated elements",
        description=(
            "Variable is set based either on element value in response body or on "
            "header field value in the response headers."
        ),
    )

    version: fhirtypes.String = Field(
        None,
        alias="version",
        title="Business version of the test script",
        description=(
            "The identifier that is used to identify this version of the test "
            "script when it is referenced in a specification, model, design or "
            "instance. This is an arbitrary value managed by the test script 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 can be placed in a "
            "lexicographical sequence."
        ),
    )
    version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_version", title="Extension field for ``version``."
    )


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

    An abstract server representing a destination or receiver in a message
    exchange.
    An abstract server used in operations within this test script in the
    destination element.
    """

    resource_type = Field("TestScriptDestination", const=True)

    index: fhirtypes.Integer = Field(
        ...,
        alias="index",
        title="The index of the abstract destination server starting at 1",
        description=(
            "Abstract name given to a destination server in this test script.  The "
            "name is provided as a number starting at 1."
        ),
    )
    index__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_index", title="Extension field for ``index``."
    )

    profile: fhirtypes.CodingType = Field(
        ...,
        alias="profile",
        title=(
            "FHIR-Server | FHIR-SDC-FormManager | FHIR-SDC-FormReceiver | FHIR-SDC-"
            "FormProcessor"
        ),
        description="The type of destination profile the test system supports.",
    )


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

    Fixture in the test script - by reference (uri).
    Fixture in the test script - by reference (uri). All fixtures are required
    for the test script to execute.
    """

    resource_type = Field("TestScriptFixture", const=True)

    autocreate: bool = Field(
        ...,
        alias="autocreate",
        title="Whether or not to implicitly create the fixture during setup",
        description=(
            "Whether or not to implicitly create the fixture during setup. If true,"
            " the fixture is automatically created on each server being tested "
            "during setup, therefore no create operation is required for this "
            "fixture in the TestScript.setup section."
        ),
    )
    autocreate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_autocreate", title="Extension field for ``autocreate``."
    )

    autodelete: bool = Field(
        ...,
        alias="autodelete",
        title="Whether or not to implicitly delete the fixture during teardown",
        description=(
            "Whether or not to implicitly delete the fixture during teardown. If "
            "true, the fixture is automatically deleted on each server being tested"
            " during teardown, therefore no delete operation is required for this "
            "fixture in the TestScript.teardown section."
        ),
    )
    autodelete__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_autodelete", title="Extension field for ``autodelete``."
    )

    resource: fhirtypes.ReferenceType = Field(
        None,
        alias="resource",
        title="Reference of the resource",
        description=(
            "Reference to the resource (containing the contents of the resource "
            "needed for operations)."
        ),
        # note: Listed Resource Type(s) should be allowed as Reference.
        enum_reference_types=["Resource"],
    )


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

    Required capability that is assumed to function correctly on the FHIR
    server being tested.
    The required capability must exist and are assumed to function correctly on
    the FHIR server being tested.
    """

    resource_type = Field("TestScriptMetadata", const=True)

    capability: ListType[fhirtypes.TestScriptMetadataCapabilityType] = Field(
        ...,
        alias="capability",
        title=(
            "Capabilities  that are assumed to function correctly on the FHIR "
            "server being tested"
        ),
        description=(
            "Capabilities that must exist and are assumed to function correctly on "
            "the FHIR server being tested."
        ),
    )

    link: ListType[fhirtypes.TestScriptMetadataLinkType] = Field(
        None,
        alias="link",
        title="Links to the FHIR specification",
        description="A link to the FHIR specification that this test is covering.",
    )


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

    Capabilities  that are assumed to function correctly on the FHIR server
    being tested.
    Capabilities that must exist and are assumed to function correctly on the
    FHIR server being tested.
    """

    resource_type = Field("TestScriptMetadataCapability", const=True)

    capabilities: fhirtypes.Canonical = Field(
        ...,
        alias="capabilities",
        title="Required Capability Statement",
        description=(
            "Minimum capabilities required of server for test script to execute "
            "successfully.   If server does not meet at a minimum the referenced "
            "capability statement, then all tests in this script are skipped."
        ),
        # note: Listed Resource Type(s) should be allowed as Reference.
        enum_reference_types=["CapabilityStatement"],
    )
    capabilities__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_capabilities", title="Extension field for ``capabilities``."
    )

    description: fhirtypes.String = Field(
        None,
        alias="description",
        title="The expected capabilities of the server",
        description=(
            "Description of the capabilities that this test script is requiring the"
            " server to support."
        ),
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_description", title="Extension field for ``description``."
    )

    destination: fhirtypes.Integer = Field(
        None,
        alias="destination",
        title="Which server these requirements apply to",
        description=None,
    )
    destination__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_destination", title="Extension field for ``destination``."
    )

    link: ListType[fhirtypes.Uri] = Field(
        None,
        alias="link",
        title="Links to the FHIR specification",
        description=(
            "Links to the FHIR specification that describes this interaction and "
            "the resources involved in more detail."
        ),
    )
    link__ext: ListType[Union[fhirtypes.FHIRPrimitiveExtensionType, None]] = Field(
        None, alias="_link", title="Extension field for ``link``."
    )

    origin: ListType[fhirtypes.Integer] = Field(
        None,
        alias="origin",
        title="Which origin server these requirements apply to",
        description=None,
    )
    origin__ext: ListType[Union[fhirtypes.FHIRPrimitiveExtensionType, None]] = Field(
        None, alias="_origin", title="Extension field for ``origin``."
    )

    required: bool = Field(
        ...,
        alias="required",
        title="Are the capabilities required?",
        description=(
            "Whether or not the test execution will require the given capabilities "
            "of the server in order for this test script to execute."
        ),
    )
    required__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_required", title="Extension field for ``required``."
    )

    validated: bool = Field(
        ...,
        alias="validated",
        title="Are the capabilities validated?",
        description=(
            "Whether or not the test execution will validate the given capabilities"
            " of the server in order for this test script to execute."
        ),
    )
    validated__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_validated", title="Extension field for ``validated``."
    )


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

    Links to the FHIR specification.
    A link to the FHIR specification that this test is covering.
    """

    resource_type = Field("TestScriptMetadataLink", const=True)

    description: fhirtypes.String = Field(
        None,
        alias="description",
        title="Short description",
        description="Short description of the link.",
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_description", title="Extension field for ``description``."
    )

    url: fhirtypes.Uri = Field(
        ...,
        alias="url",
        title="URL to the specification",
        description=(
            "URL to a particular requirement or feature within the FHIR "
            "specification."
        ),
    )
    url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_url", title="Extension field for ``url``."
    )


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

    An abstract server representing a client or sender in a message exchange.
    An abstract server used in operations within this test script in the origin
    element.
    """

    resource_type = Field("TestScriptOrigin", const=True)

    index: fhirtypes.Integer = Field(
        ...,
        alias="index",
        title="The index of the abstract origin server starting at 1",
        description=(
            "Abstract name given to an origin server in this test script.  The name"
            " is provided as a number starting at 1."
        ),
    )
    index__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_index", title="Extension field for ``index``."
    )

    profile: fhirtypes.CodingType = Field(
        ...,
        alias="profile",
        title="FHIR-Client | FHIR-SDC-FormFiller",
        description="The type of origin profile the test system supports.",
    )


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

    A series of required setup operations before tests are executed.
    """

    resource_type = Field("TestScriptSetup", const=True)

    action: ListType[fhirtypes.TestScriptSetupActionType] = Field(
        ...,
        alias="action",
        title="A setup operation or assert to perform",
        description="Action would contain either an operation or an assertion.",
    )


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

    A setup operation or assert to perform.
    Action would contain either an operation or an assertion.
    """

    resource_type = Field("TestScriptSetupAction", const=True)

    assert_fhir: fhirtypes.TestScriptSetupActionAssertType = Field(
        None,
        alias="assert",
        title="The assertion to perform",
        description=(
            "Evaluates the results of previous operations to determine if the "
            "server under test behaves appropriately."
        ),
    )

    operation: fhirtypes.TestScriptSetupActionOperationType = Field(
        None,
        alias="operation",
        title="The setup operation to perform",
        description="The operation to perform.",
    )


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

    The assertion to perform.
    Evaluates the results of previous operations to determine if the server
    under test behaves appropriately.
    """

    resource_type = Field("TestScriptSetupActionAssert", const=True)

    compareToSourceExpression: fhirtypes.String = Field(
        None,
        alias="compareToSourceExpression",
        title="The FHIRPath expression to evaluate against the source fixture",
        description=(
            "The FHIRPath expression to evaluate against the source fixture. When "
            "compareToSourceId is defined, either compareToSourceExpression or "
            "compareToSourcePath must be defined, but not both."
        ),
    )
    compareToSourceExpression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None,
        alias="_compareToSourceExpression",
        title="Extension field for ``compareToSourceExpression``.",
    )

    compareToSourceId: fhirtypes.String = Field(
        None,
        alias="compareToSourceId",
        title="Id of the source fixture to be evaluated",
        description=(
            "Id of the source fixture used as the contents to be evaluated by "
            'either the "source/expression" or "sourceId/path" definition.'
        ),
    )
    compareToSourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None,
        alias="_compareToSourceId",
        title="Extension field for ``compareToSourceId``.",
    )

    compareToSourcePath: fhirtypes.String = Field(
        None,
        alias="compareToSourcePath",
        title="XPath or JSONPath expression to evaluate against the source fixture",
        description=(
            "XPath or JSONPath expression to evaluate against the source fixture. "
            "When compareToSourceId is defined, either compareToSourceExpression or"
            " compareToSourcePath must be defined, but not both."
        ),
    )
    compareToSourcePath__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None,
        alias="_compareToSourcePath",
        title="Extension field for ``compareToSourcePath``.",
    )

    contentType: fhirtypes.Code = Field(
        None,
        alias="contentType",
        title="Mime type to compare against the 'Content-Type' header",
        description=(
            "The mime-type contents to compare against the request or response "
            "message 'Content-Type' header."
        ),
    )
    contentType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_contentType", title="Extension field for ``contentType``."
    )

    description: fhirtypes.String = Field(
        None,
        alias="description",
        title="Tracking/reporting assertion description",
        description=(
            "The description would be used by test engines for tracking and "
            "reporting purposes."
        ),
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_description", title="Extension field for ``description``."
    )

    direction: fhirtypes.Code = Field(
        None,
        alias="direction",
        title="response | request",
        description="The direction to use for the assertion.",
        # note: Enum values can be used in validation,
        # but use in your own responsibilities, read official FHIR documentation.
        enum_values=["response", "request"],
    )
    direction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_direction", title="Extension field for ``direction``."
    )

    expression: fhirtypes.String = Field(
        None,
        alias="expression",
        title="The FHIRPath expression to be evaluated",
        description=(
            "The FHIRPath expression to be evaluated against the request or "
            "response message contents - HTTP headers and payload."
        ),
    )
    expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_expression", title="Extension field for ``expression``."
    )

    headerField: fhirtypes.String = Field(
        None,
        alias="headerField",
        title="HTTP header field name",
        description="The HTTP header field name e.g. 'Location'.",
    )
    headerField__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_headerField", title="Extension field for ``headerField``."
    )

    label: fhirtypes.String = Field(
        None,
        alias="label",
        title="Tracking/logging assertion label",
        description="The label would be used for tracking/logging purposes by test engines.",
    )
    label__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_label", title="Extension field for ``label``."
    )

    minimumId: fhirtypes.String = Field(
        None,
        alias="minimumId",
        title="Fixture Id of minimum content resource",
        description=(
            "The ID of a fixture.  Asserts that the response contains at a minimum "
            "the fixture specified by minimumId."
        ),
    )
    minimumId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_minimumId", title="Extension field for ``minimumId``."
    )

    navigationLinks: bool = Field(
        None,
        alias="navigationLinks",
        title="Perform validation on navigation links?",
        description=(
            "Whether or not the test execution performs validation on the bundle "
            "navigation links."
        ),
    )
    navigationLinks__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_navigationLinks", title="Extension field for ``navigationLinks``."
    )

    operator: fhirtypes.Code = Field(
        None,
        alias="operator",
        title=(
            "equals | notEquals | in | notIn | greaterThan | lessThan | empty | "
            "notEmpty | contains | notContains | eval"
        ),
        description=(
            "The operator type defines the conditional behavior of the assert. If "
            "not defined, the default is equals."
        ),
        # note: Enum values can be used in validation,
        # but use in your own responsibilities, read official FHIR documentation.
        enum_values=[
            "equals",
            "notEquals",
            "in",
            "notIn",
            "greaterThan",
            "lessThan",
            "empty",
            "notEmpty",
            "contains",
            "notContains",
            "eval",
        ],
    )
    operator__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_operator", title="Extension field for ``operator``."
    )

    path: fhirtypes.String = Field(
        None,
        alias="path",
        title="XPath or JSONPath expression",
        description=(
            "The XPath or JSONPath expression to be evaluated against the fixture "
            "representing the response received from server."
        ),
    )
    path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_path", title="Extension field for ``path``."
    )

    requestMethod: fhirtypes.Code = Field(
        None,
        alias="requestMethod",
        title="delete | get | options | patch | post | put | head",
        description=(
            "The request method or HTTP operation code to compare against that used"
            " by the client system under test."
        ),
        # note: Enum values can be used in validation,
        # but use in your own responsibilities, read official FHIR documentation.
        enum_values=["delete", "get", "options", "patch", "post", "put", "head"],
    )
    requestMethod__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_requestMethod", title="Extension field for ``requestMethod``."
    )

    requestURL: fhirtypes.String = Field(
        None,
        alias="requestURL",
        title="Request URL comparison value",
        description="The value to use in a comparison against the request URL path string.",
    )
    requestURL__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_requestURL", title="Extension field for ``requestURL``."
    )

    resource: fhirtypes.Code = Field(
        None,
        alias="resource",
        title="Resource type",
        description=(
            "The type of the resource.  See " "http://build.fhir.org/resourcelist.html."
        ),
    )
    resource__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_resource", title="Extension field for ``resource``."
    )

    response: fhirtypes.Code = Field(
        None,
        alias="response",
        title=(
            "okay | created | noContent | notModified | bad | forbidden | notFound "
            "| methodNotAllowed | conflict | gone | preconditionFailed | "
            "unprocessable"
        ),
        description=None,
        # note: Enum values can be used in validation,
        # but use in your own responsibilities, read official FHIR documentation.
        enum_values=[
            "okay",
            "created",
            "noContent",
            "notModified",
            "bad",
            "forbidden",
            "notFound",
            "methodNotAllowed",
            "conflict",
            "gone",
            "preconditionFailed",
            "unprocessable",
        ],
    )
    response__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_response", title="Extension field for ``response``."
    )

    responseCode: fhirtypes.String = Field(
        None,
        alias="responseCode",
        title="HTTP response code to test",
        description="The value of the HTTP response code to be tested.",
    )
    responseCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_responseCode", title="Extension field for ``responseCode``."
    )

    sourceId: fhirtypes.Id = Field(
        None,
        alias="sourceId",
        title="Fixture Id of source expression or headerField",
        description=(
            "Fixture to evaluate the XPath/JSONPath expression or the headerField  "
            "against."
        ),
    )
    sourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_sourceId", title="Extension field for ``sourceId``."
    )

    validateProfileId: fhirtypes.Id = Field(
        None,
        alias="validateProfileId",
        title="Profile Id of validation profile reference",
        description="The ID of the Profile to validate against.",
    )
    validateProfileId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None,
        alias="_validateProfileId",
        title="Extension field for ``validateProfileId``.",
    )

    value: fhirtypes.String = Field(
        None, alias="value", title="The value to compare to", description=None,
    )
    value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_value", title="Extension field for ``value``."
    )

    warningOnly: bool = Field(
        ...,
        alias="warningOnly",
        title="Will this assert produce a warning only on error?",
        description=(
            "Whether or not the test execution will produce a warning only on error"
            " for this assert."
        ),
    )
    warningOnly__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_warningOnly", title="Extension field for ``warningOnly``."
    )


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

    The setup operation to perform.
    The operation to perform.
    """

    resource_type = Field("TestScriptSetupActionOperation", const=True)

    accept: fhirtypes.Code = Field(
        None,
        alias="accept",
        title="Mime type to accept in the payload of the response, with charset etc.",
        description="The mime-type to use for RESTful operation in the 'Accept' header.",
    )
    accept__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_accept", title="Extension field for ``accept``."
    )

    contentType: fhirtypes.Code = Field(
        None,
        alias="contentType",
        title="Mime type of the request payload contents, with charset etc.",
        description=(
            "The mime-type to use for RESTful operation in the 'Content-Type' "
            "header."
        ),
    )
    contentType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_contentType", title="Extension field for ``contentType``."
    )

    description: fhirtypes.String = Field(
        None,
        alias="description",
        title="Tracking/reporting operation description",
        description=(
            "The description would be used by test engines for tracking and "
            "reporting purposes."
        ),
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_description", title="Extension field for ``description``."
    )

    destination: fhirtypes.Integer = Field(
        None,
        alias="destination",
        title="Server responding to the request",
        description=(
            "The server where the request message is destined for.  Must be one of "
            "the server numbers listed in TestScript.destination section."
        ),
    )
    destination__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_destination", title="Extension field for ``destination``."
    )

    encodeRequestUrl: bool = Field(
        ...,
        alias="encodeRequestUrl",
        title="Whether or not to send the request url in encoded format",
        description=(
            "Whether or not to implicitly send the request url in encoded format. "
            "The default is true to match the standard RESTful client behavior. Set"
            " to false when communicating with a server that does not support "
            "encoded url paths."
        ),
    )
    encodeRequestUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None,
        alias="_encodeRequestUrl",
        title="Extension field for ``encodeRequestUrl``.",
    )

    label: fhirtypes.String = Field(
        None,
        alias="label",
        title="Tracking/logging operation label",
        description="The label would be used for tracking/logging purposes by test engines.",
    )
    label__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_label", title="Extension field for ``label``."
    )

    method: fhirtypes.Code = Field(
        None,
        alias="method",
        title="delete | get | options | patch | post | put | head",
        description=(
            "The HTTP method the test engine MUST use for this operation regardless"
            " of any other operation details."
        ),
        # note: Enum values can be used in validation,
        # but use in your own responsibilities, read official FHIR documentation.
        enum_values=["delete", "get", "options", "patch", "post", "put", "head"],
    )
    method__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_method", title="Extension field for ``method``."
    )

    origin: fhirtypes.Integer = Field(
        None,
        alias="origin",
        title="Server initiating the request",
        description=(
            "The server where the request message originates from.  Must be one of "
            "the server numbers listed in TestScript.origin section."
        ),
    )
    origin__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_origin", title="Extension field for ``origin``."
    )

    params: fhirtypes.String = Field(
        None,
        alias="params",
        title="Explicitly defined path parameters",
        description=(
            "Path plus parameters after [type].  Used to set parts of the request "
            "URL explicitly."
        ),
    )
    params__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_params", title="Extension field for ``params``."
    )

    requestHeader: ListType[
        fhirtypes.TestScriptSetupActionOperationRequestHeaderType
    ] = Field(
        None,
        alias="requestHeader",
        title="Each operation can have one or more header elements",
        description="Header elements would be used to set HTTP headers.",
    )

    requestId: fhirtypes.Id = Field(
        None,
        alias="requestId",
        title="Fixture Id of mapped request",
        description="The fixture id (maybe new) to map to the request.",
    )
    requestId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_requestId", title="Extension field for ``requestId``."
    )

    resource: fhirtypes.Code = Field(
        None,
        alias="resource",
        title="Resource type",
        description=(
            "The type of the resource.  See " "http://build.fhir.org/resourcelist.html."
        ),
    )
    resource__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_resource", title="Extension field for ``resource``."
    )

    responseId: fhirtypes.Id = Field(
        None,
        alias="responseId",
        title="Fixture Id of mapped response",
        description="The fixture id (maybe new) to map to the response.",
    )
    responseId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_responseId", title="Extension field for ``responseId``."
    )

    sourceId: fhirtypes.Id = Field(
        None,
        alias="sourceId",
        title="Fixture Id of body for PUT and POST requests",
        description="The id of the fixture used as the body of a PUT or POST request.",
    )
    sourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_sourceId", title="Extension field for ``sourceId``."
    )

    targetId: fhirtypes.Id = Field(
        None,
        alias="targetId",
        title=(
            "Id of fixture used for extracting the [id],  [type], and [vid] for GET"
            " requests"
        ),
        description=None,
    )
    targetId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_targetId", title="Extension field for ``targetId``."
    )

    type: fhirtypes.CodingType = Field(
        None,
        alias="type",
        title="The operation code type that will be executed",
        description="Server interaction or operation type.",
    )

    url: fhirtypes.String = Field(
        None, alias="url", title="Request URL", description="Complete request URL.",
    )
    url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_url", title="Extension field for ``url``."
    )


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

    Each operation can have one or more header elements.
    Header elements would be used to set HTTP headers.
    """

    resource_type = Field("TestScriptSetupActionOperationRequestHeader", const=True)

    field: fhirtypes.String = Field(
        ...,
        alias="field",
        title="HTTP header field name",
        description='The HTTP header field e.g. "Accept".',
    )
    field__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_field", title="Extension field for ``field``."
    )

    value: fhirtypes.String = Field(
        ...,
        alias="value",
        title="HTTP headerfield value",
        description='The value of the header e.g. "application/fhir+xml".',
    )
    value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_value", title="Extension field for ``value``."
    )


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

    A series of required clean up steps.
    A series of operations required to clean up after all the tests are
    executed (successfully or otherwise).
    """

    resource_type = Field("TestScriptTeardown", const=True)

    action: ListType[fhirtypes.TestScriptTeardownActionType] = Field(
        ...,
        alias="action",
        title="One or more teardown operations to perform",
        description="The teardown action will only contain an operation.",
    )


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

    One or more teardown operations to perform.
    The teardown action will only contain an operation.
    """

    resource_type = Field("TestScriptTeardownAction", const=True)

    operation: fhirtypes.TestScriptSetupActionOperationType = Field(
        ...,
        alias="operation",
        title="The teardown operation to perform",
        description="An operation would involve a REST request to a server.",
    )


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

    A test in this script.
    """

    resource_type = Field("TestScriptTest", const=True)

    action: ListType[fhirtypes.TestScriptTestActionType] = Field(
        ...,
        alias="action",
        title="A test operation or assert to perform",
        description="Action would contain either an operation or an assertion.",
    )

    description: fhirtypes.String = Field(
        None,
        alias="description",
        title="Tracking/reporting short description of the test",
        description=(
            "A short description of the test used by test engines for tracking and "
            "reporting purposes."
        ),
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_description", title="Extension field for ``description``."
    )

    name: fhirtypes.String = Field(
        None,
        alias="name",
        title="Tracking/logging name of this test",
        description=(
            "The name of this test used for tracking/logging purposes by test "
            "engines."
        ),
    )
    name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_name", title="Extension field for ``name``."
    )


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

    A test operation or assert to perform.
    Action would contain either an operation or an assertion.
    """

    resource_type = Field("TestScriptTestAction", const=True)

    assert_fhir: fhirtypes.TestScriptSetupActionAssertType = Field(
        None,
        alias="assert",
        title="The setup assertion to perform",
        description=(
            "Evaluates the results of previous operations to determine if the "
            "server under test behaves appropriately."
        ),
    )

    operation: fhirtypes.TestScriptSetupActionOperationType = Field(
        None,
        alias="operation",
        title="The setup operation to perform",
        description="An operation would involve a REST request to a server.",
    )


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

    Placeholder for evaluated elements.
    Variable is set based either on element value in response body or on header
    field value in the response headers.
    """

    resource_type = Field("TestScriptVariable", const=True)

    defaultValue: fhirtypes.String = Field(
        None,
        alias="defaultValue",
        title="Default, hard-coded, or user-defined value for this variable",
        description="A default, hard-coded, or user-defined value for this variable.",
    )
    defaultValue__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_defaultValue", title="Extension field for ``defaultValue``."
    )

    description: fhirtypes.String = Field(
        None,
        alias="description",
        title="Natural language description of the variable",
        description=(
            "A free text natural language description of the variable and its "
            "purpose."
        ),
    )
    description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_description", title="Extension field for ``description``."
    )

    expression: fhirtypes.String = Field(
        None,
        alias="expression",
        title="The FHIRPath expression against the fixture body",
        description=(
            "The FHIRPath expression to evaluate against the fixture body. When "
            "variables are defined, only one of either expression, headerField or "
            "path must be specified."
        ),
    )
    expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_expression", title="Extension field for ``expression``."
    )

    headerField: fhirtypes.String = Field(
        None,
        alias="headerField",
        title="HTTP header field name for source",
        description=(
            "Will be used to grab the HTTP header field value from the headers that"
            " sourceId is pointing to."
        ),
    )
    headerField__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_headerField", title="Extension field for ``headerField``."
    )

    hint: fhirtypes.String = Field(
        None,
        alias="hint",
        title="Hint help text for default value to enter",
        description=(
            "Displayable text string with hint help information to the user when "
            "entering a default value."
        ),
    )
    hint__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_hint", title="Extension field for ``hint``."
    )

    name: fhirtypes.String = Field(
        ..., alias="name", title="Descriptive name for this variable", description=None,
    )
    name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_name", title="Extension field for ``name``."
    )

    path: fhirtypes.String = Field(
        None,
        alias="path",
        title="XPath or JSONPath against the fixture body",
        description=(
            "XPath or JSONPath to evaluate against the fixture body.  When "
            "variables are defined, only one of either expression, headerField or "
            "path must be specified."
        ),
    )
    path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_path", title="Extension field for ``path``."
    )

    sourceId: fhirtypes.Id = Field(
        None,
        alias="sourceId",
        title="Fixture Id of source expression or headerField within this variable",
        description=(
            "Fixture to evaluate the XPath/JSONPath expression or the headerField  "
            "against within this variable."
        ),
    )
    sourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
        None, alias="_sourceId", title="Extension field for ``sourceId``."
    )
