PackagesCanonicalsLogsProblems
    Packages
    hl7.fhir.r2.core@1.0.2
    http://hl7.org/fhir/StructureDefinition/TestScript
description: Base StructureDefinition for TestScript Resource
package_name: hl7.fhir.r2.core
name: TestScript
type: null
elements:
  description: {type: string, short: Natural language description of the TestScript, comments: 'This field can be used for things such as why the TestScript was written, comments about misuse, instructions for clinical use and interpretation, literature references, examples from the paper world, etc.  It is *not* a rendering of the TestScript as conveyed in TestScript.text. This item SHOULD be populated unless the information is available from context.', isSummary: true, index: 11}
  requirements: {type: string, short: Scope and Usage this Test Script is for, comments: 'This element does not describe the usage of the Test Script (that''s done in comments), rather it''s for traceability of *why* the element is either needed or why the constraints exist as they do.  This may be used to point to source materials or specifications that drove the structure of this data element.', index: 13}
  date: {short: Date for this version of the TestScript, comments: Additional specific dates may be added as extensions., type: dateTime, isSummary: true, index: 10}
  variable:
    type: BackboneElement
    short: Placeholder for evaluated elements
    comments: Variables would be set based either on XPath/JsonPath expressions against fixtures (static and response), or headerField evaluations against response headers. If variable evaluates to nodelist or anything other than a primitive value, then test engine would report error.  Variables would be used to perform clean replacements in "operation.params", "operation.requestHeader.value", and "operation.url" element values during operation calls and in "assert.value" during assertion evaluations. This limits the places that test engines would need to look for placeholders "${}".  Variables are scoped to the whole script. They are NOT evaluated at declaration. They are evaluated by test engine when used for substitutions in "operation.params", "operation.requestHeader.value", and "operation.url" element values during operation calls and in "assert.value" during assertion evaluations.  See example testscript-search.xml.
    constraint:
      inv-4: {human: Variable cannot contain both headerField and path., severity: error}
    array: true
    index: 32
    elements:
      name: {type: string, short: Descriptive name for this variable, comments: 'Placeholders would contain the variable name wrapped in ${} in "operation.params", "operation.requestHeader.value", and "operation.url" elements.  These placeholders would need to be replaced by the variable value before the operation is executed.', index: 33}
      headerField: {type: string, short: HTTP header field name for source, comments: 'If headerField is defined, then the variable will be evaluated against the headers that sourceId is pointing to.  If path is defined, then the variable will be evaluated against the fixture body that sourceId is pointing to.  It is an error to define both headerField and path.', index: 34}
      path: {type: string, short: XPath or JSONPath against the fixture body, comments: 'If headerField is defined, then the variable will be evaluated against the headers that sourceId is pointing to.  If path is defined, then the variable will be evaluated against the fixture body that sourceId is pointing to.  It is an error to define both headerField and path.', index: 35}
      sourceId: {type: id, short: Fixture Id of source expression or headerField within this variable, comments: This can be a statically defined fixture (at the top of the testscript) or a dynamically set fixture created by responseId of the action.operation element., index: 36}
    required: [name]
  publisher: {short: Name of the publisher (Organization or individual), comments: 'Usually an organization, but may be an individual. This item SHOULD be populated unless the information is available from context.', type: string, isSummary: true, index: 6}
  name: {type: string, short: Informal name for this TestScript, comments: Not expected to be globally unique., isSummary: true, index: 2}
  useContext: {short: Content intends to support these contexts, type: CodeableConcept, array: true, isSummary: true, index: 12}
  copyright: {type: string, short: Use and/or publishing restrictions, index: 14}
  experimental: {short: 'If for testing purposes, not real usage', type: boolean, isSummary: true, index: 5}
  setup:
    type: BackboneElement
    short: A series of required setup operations before tests are executed
    index: 37
    elements:
      metadata:
        short: Capabilities  that are assumed to function correctly on the FHIR server being tested
        constraint:
          inv-6: {human: Setup metadata capability SHALL contain required or validated or both., severity: error}
        nameReference: metadata
        index: 38
      action:
        constraint:
          inv-1: {human: Setup action SHALL contain either an operation or assert but not both., severity: error}
        min: 1
        short: A setup operation or assert to perform
        index: 39
        comments: An action should contain either an operation or an assertion but not both.  It can contain any number of variables.
        type: BackboneElement
        array: true
        elements:
          operation:
            name: operation
            type: BackboneElement
            short: The setup operation to perform
            constraint:
              inv-10: {human: Setup operation SHALL contain either sourceId or targetId or params or url., severity: error}
            index: 40
            elements:
              description: {type: string, short: Tracking/reporting operation description, comments: This has no impact on the verification itself., index: 44}
              targetId: {type: id, short: 'Id of fixture used for extracting the [id],  [type], and [vid] for GET requests', comments: 'If "url" element is specified, then "targetId", "params", and "resource" elements will be ignored as "url" element will have everything needed for constructing the request url.  If "params" element is specified, then "targetId" element is ignored.  For FHIR operations that require a resource (e.g. "read" and "vread" operations), the "resource" element must be specified when "params" element is specified.  If "url" and "params" elements are absent, then the request url will be constructed from "targetId" fixture if present.  For "read" operation, the resource and id values will be extracted from "targetId" fixture and used to construct the url.  For "vread" and "history" operations, the versionId value will also be used.', index: 55}
              requestHeader:
                type: BackboneElement
                short: Each operation can have one ore more header elements
                comments: 'This gives control to test-script writers to set headers explicitly based on test requirements.  It will allow for testing using:  - "If-Modified-Since" and "If-None-Match" headers.  See http://hl7-fhir.github.io/http.html#2.1.0.5.1 - "If-Match" header.  See http://hl7-fhir.github.io/http.html#2.1.0.11 - Conditional Create using "If-None-Exist".  See http://hl7-fhir.github.io/http.html#2.1.0.13.1 - Invalid "Content-Type" header for negative testing. - etc.'
                array: true
                index: 50
                elements:
                  field: {type: string, short: HTTP header field name, comments: 'If header element is specified, then field is required.', index: 51}
                  value: {type: string, short: HTTP headerfield value, comments: 'If header element is specified, then value is required.  No conversions will be done by Test Engine e.g. "xml" to "application/xml+fhir".  The values will be set in HTTP headers "as-is".  Test engines do have to look for placeholders (${}) and replace the variable placeholders with the variable values at runtime before sending the request.', index: 52}
                required: [value, field]
              params: {type: string, short: Explicitly defined path parameters, comments: 'If "url" element is specified, then "targetId", "params", and "resource" elements will be ignored as "url" element will have everything needed for constructing the request url.  If "params" element is specified, then "targetId" element is ignored.  For FHIR operations that require a resource (e.g. "read" and "vread" operations), the "resource" element must be specified when "params" element is specified.  If "url" and "params" elements are absent, then the request url will be constructed from "targetId" fixture if present.  For "read" operation, the resource and id values will be extracted from "targetId" fixture and used to construct the url.  For "vread" and "history" operations, the versionId value will also be used.   Test engines would append whatever is specified for "params" to the URL after the resource type without tampering with the string (beyond encoding the URL for HTTP).  The "params" element does not correspond exactly to "search parameters".  Nor is it the "path".  It corresponds to the part of the URL that comes after the [type] (when "resource" element is specified); e.g. It corresponds to "/[id]/_history/[vid] {?_format=[mime-type]}" in the following operation: GET [base]/[type]/[id]/_history/[vid] {?_format=[mime-type]}  Test engines do have to look for placeholders (${}) and replace the variable placeholders with the variable values at runtime before sending the request.', index: 49}
              type: {type: Coding, short: The setup operation type that will be executed, comments: 'See http://hl7-fhir.github.io/http.html for list of server interactions.', index: 41}
              encodeRequestUrl: {type: boolean, short: Whether or not to send the request url in encoded format, defaultValueBoolean: true, index: 48}
              label: {type: string, short: Tracking/logging operation label, comments: This has no impact on the verification itself., index: 43}
              resource: {type: code, short: Resource type, comments: 'If "url" element is specified, then "targetId", "params", and "resource" elements will be ignored as "url" element will have everything needed for constructing the request url.  If "params" element is specified, then "targetId" element is ignored. For FHIR operations that require a resource (e.g. "read" and "vread" operations), the "resource" element must be specified when "params" element is specified.  If "url" and "params" elements are absent, then the request url will be constructed from "targetId" fixture if present. For "read" operation, the resource and id values will be extracted from "targetId" fixture and used to construct the url. For "vread" and "history" operations, the versionId value will also be used.', index: 42}
              url: {type: string, short: Request URL, comments: 'Used to set the request URL explicitly.  If "url" element is defined, then "targetId", "resource", and "params" elements will be ignored.  Test engines would use whatever is specified in "url" without tampering with the string (beyond encoding the URL for HTTP).  Test engines do have to look for placeholders (${}) and replace the variable placeholders with the variable values at runtime before sending the request.', index: 56}
              contentType: {short: xml | json, comments: 'If this is specified, then test engine shall set the ''Content-Type'' header to the corresponding value.    If ''xml'' is specified, then ''Content-Type'' header of ''application/xml+fhir'' will be set.    If ''json'' is specified, then ''application/json+fhir'' will be used.    If you''d like to explicitly set the ''Content-Type'' to some other value then use the ''requestHeader'' element.', type: code, meaningWhenMissing: xml, index: 46}
              sourceId: {type: id, short: Fixture Id of body for PUT and POST requests, index: 54}
              responseId: {type: id, short: Fixture Id of mapped response, comments: 'If a responseId is supplied, and the server responds, then the resulting response (both headers and body) is mapped to the fixture ID (which may be entirely new and previously undeclared) designated by "responseId".  If responseId is not specified, it is the Test Engine''s responsibility to store the response and use it as sourceId in subsequent assertions when assertion path and/or headerField is specified and sourceId is not specified.', index: 53}
              destination: {type: integer, short: Which server to perform the operation on, defaultValueInteger: 0, index: 47}
              accept: {short: xml | json, comments: 'If this is specified, then test engine shall set the ''Accept'' header to the corresponding value.    If ''xml'' is specified, then ''Accept'' header of ''application/xml+fhir'' will be set.  If ''json'' is specified, then ''application/json+fhir'' will be used.    If you''d like to explicitly set the ''Accept'' to some other value then use the ''requestHeader'' element.', type: code, meaningWhenMissing: xml, index: 45}
          assert:
            constraint:
              inv-13: {human: Setup action assert shall contain both compareToSourceId and compareToSourcePath or neither., severity: error}
              inv-8: {human: Only a single assertion SHALL be present within setup action assert element., severity: error}
            short: The assertion to perform
            name: assert
            comments: In order to evaluate an assertion, the request, response, and results of the most recently executed operation must always be maintained by the test engine.
            type: BackboneElement
            index: 57
            elements:
              response: {type: code, short: okay | created | noContent | notModified | bad | forbidden | notFound | methodNotAllowed | conflict | gone | preconditionFailed | unprocessable, comments: 'This is a shorter way of achieving similar verifications via "assert.responseCode".  If you need more control, then use "assert.responseCode"  e.g.      .', index: 70}
              description: {type: string, short: Tracking/reporting assertion description, comments: This has no impact on the verification itself., index: 59}
              path: {type: string, short: XPath or JSONPath expression, comments: 'If both "path" and "fixtureId" are specified, then the path will be evaluated against the responseBody mapped to the fixtureId.  If "path" is specified and "fixtureId" is not, then the path will be evaluated against the responseBody of the last operation.  Test engines are to store the response body and headers of the last operation at all times for subsequent assertions.', index: 68}
              headerField: {type: string, short: HTTP header field name, comments: 'If "headerField" is specified then "value" must be specified.  If "sourceId" is not specified, then "headerField" will be evaluated against the last operation''s response headers.  Test engines are to keep track of the last operation''s response body and response headers.', index: 64}
              compareToSourceId: {type: string, short: Id of fixture used to compare the "sourceId/path" evaluations to, comments: The id of the fixture used to make comparisons to., index: 61}
              value: {type: string, short: The value to compare to, comments: 'The string-representation of a number, string, or boolean that is expected.  Test engines do have to look for placeholders (${}) and replace the variable placeholders with the variable values at runtime before comparing this value to the actual value.', index: 74}
              warningOnly: {type: boolean, short: 'Will this assert produce a warning only on error?', comments: 'If this element is specified and it is true, then assertion failures can be logged by test engine but should not stop the test script execution from proceeding.  There are likely cases where the spec is not clear on what should happen. If the spec says something is optional (maybe a response header for example), but a server doesn’t do it, we could choose to issue a warning.', defaultValueBoolean: false, index: 75}
              label: {type: string, short: Tracking/logging assertion label, comments: This has no impact on the verification itself., index: 58}
              resource: {type: code, short: Resource type, comments: 'This will be expected resource type in response body e.g. in read, vread, search, etc.  See http://hl7-fhir.github.io/resourcelist.html for complete list of resource types; e.g.  .', index: 69}
              responseCode: {type: string, short: HTTP response code to test, comments: 'To be used with "operator" attribute value. Asserts that the response code equals this value if "operator" is not specified.   If the operator is "in" or "notIn" then the responseCode would be a comma-separated list of values e.g. "200,201". Otherwise, it''s expected to be a numeric value.   If "fixture" is not specified, then the "responseBodyId" value of the last operation is assumed.', index: 71}
              minimumId: {type: string, short: Fixture Id of minimum content resource, comments: Asserts that the response contains all the element/content in another fixture pointed to by minimumId.  This can be a statically defined fixture or one that is dynamically set via responseId., index: 65}
              operator: {type: code, short: equals | notEquals | in | notIn | greaterThan | lessThan | empty | notEmpty | contains | notContains, comments: 'Operators come handy especially for negative testing.  If operator is not specified, then the "equals" operator is assumed; e.g.                                                   .', index: 67}
              contentType: {short: xml | json, comments: 'If this is specified, then test engine shall confirm that the content-type of the last operation''s headers is set to this value.  If "assert.sourceId" element is specified, then the evaluation will be done against the headers mapped to that sourceId (and not the last operation''s headers).    If ''xml'' is specified, then ''Content-Type'' header of ''application/xml+fhir'' will be confirmed. If ''json'' is specified, then ''application/json+fhir'' will be used. If you''d like to have more control over the string, then use ''assert.headerField'' instead.', type: code, meaningWhenMissing: xml, index: 63}
              compareToSourcePath: {type: string, short: XPath or JSONPath expression against fixture used to compare the "sourceId/path" evaluations to, comments: The XPath or JSONPath expression to be evaluated against the expected fixture to compare to. Ignored if "assert.value" is used. The evaluation will be done before the assertion is evaluated., index: 62}
              validateProfileId: {type: id, short: Profile Id of validation profile reference, comments: The ID of a Profile fixture. Asserts that the response is valid according to the Profile specified by validateProfileId., index: 73}
              sourceId: {type: id, short: Fixture Id of source expression or headerField, comments: This can be a statically defined fixture (at the top of the testscript) or a dynamically set fixture created by responseId of the action.operation element., index: 72}
              direction: {type: code, short: response | request, index: 60}
              navigationLinks: {type: boolean, short: 'Perform validation on navigation links?', comments: 'Asserts that the Bundle contains first, last, and next links.', index: 66}
    required: [action]
  status: {isModifier: true, short: draft | active | retired, type: code, isSummary: true, index: 3}
  url: {short: Absolute URL used to reference this TestScript, type: uri, isSummary: true, index: 0}
  identifier: {type: Identifier, short: External identifier, isSummary: true, index: 4}
  fixture:
    type: BackboneElement
    short: Fixture in the test script - by reference (uri)
    array: true
    index: 27
    elements:
      autocreate: {type: boolean, short: Whether or not to implicitly create the fixture during setup, meaningWhenMissing: 'False', index: 28}
      autodelete: {type: boolean, short: Whether or not to implicitly delete the fixture during teardown, meaningWhenMissing: 'False', index: 29}
      resource: {type: Reference, short: Reference of the resource, comments: 'See http://hl7-fhir.github.io/resourcelist.html for complete list of resource types.', index: 30}
  version: {short: Logical id for this version of the TestScript, type: string, isSummary: true, index: 1}
  teardown:
    type: BackboneElement
    short: A series of required clean up steps
    index: 83
    elements:
      action:
        constraint:
          inv-3: {human: Teardown action SHALL contain an operation., severity: error}
        min: 1
        short: One or more teardown operations to perform
        index: 84
        comments: An action should contain either an operation or an assertion but not both.  It can contain any number of variables.
        type: BackboneElement
        array: true
        elements:
          operation:
            short: The teardown operation to perform
            constraint:
              inv-12: {human: Teardown operation SHALL contain either sourceId or targetId or params or url., severity: error}
            nameReference: operation
            index: 85
    required: [action]
  contact:
    type: BackboneElement
    short: Contact details of the publisher
    comments: May be a web site, an email address, a telephone number (tel:), etc.
    isSummary: true
    array: true
    index: 7
    elements:
      name: {type: string, short: Name of a individual to contact, comments: 'If there is no named individual, the telecom is for the organization as a whole.', isSummary: true, index: 8}
      telecom: {type: ContactPoint, short: Contact details for individual or publisher, isSummary: true, array: true, index: 9}
  metadata:
    name: metadata
    type: BackboneElement
    short: Required capability that is assumed to function correctly on the FHIR server being tested
    constraint:
      inv-5: {human: TestScript metadata capability SHALL contain required or validated or both., severity: error}
    index: 15
    elements:
      link:
        type: BackboneElement
        short: Links to the FHIR specification
        array: true
        index: 16
        elements:
          url: {type: uri, short: URL to the specification, index: 17}
          description: {type: string, short: Short description, index: 18}
        required: [url]
      capability:
        min: 1
        short: Capabilities  that are assumed to function correctly on the FHIR server being tested
        index: 19
        comments: When the metadata capabilities section is defined at TestScript.metadata or at TestScript.setup.metadata, and the server's conformance statement does not contain the elements defined in the minimal conformance statement, then all the tests in the TestScript are skipped.  When the metadata capabilities section is defined at TestScript.test.metadata and the server's conformance statement does not contain the elements defined in the minimal conformance statement, then only that test is skipped.  The "metadata.capabilities.required" and "metadata.capabilities.validated" elements only indicate whether the capabilities are the primary focus of the test script or not.  The do not impact the skipping logic.  Capabilities whose "metadata.capabilities.validated" flag is true are the primary focus of the test script.
        type: BackboneElement
        array: true
        elements:
          required: {type: boolean, short: 'Are the capabilities required?', defaultValueBoolean: false, index: 20}
          validated: {type: boolean, short: 'Are the capabilities validated?', defaultValueBoolean: false, index: 21}
          description: {type: string, short: The expected capabilities of the server, index: 22}
          destination: {type: integer, short: Which server these requirements apply to, index: 23}
          link: {type: uri, short: Links to the FHIR specification, array: true, index: 24}
          conformance: {type: Reference, short: Required Conformance, comments: The conformance statement of the server has to contain at a minimum the contents of the reference pointed to by this element., index: 25}
        required: [conformance]
    required: [capability]
  test:
    type: BackboneElement
    short: A test in this script
    array: true
    index: 76
    elements:
      name: {type: string, short: Tracking/logging name of this test, index: 77}
      description: {type: string, short: Tracking/reporting short description of the test, index: 78}
      metadata:
        short: Capabilities  that are expected to function correctly on the FHIR server being tested
        constraint:
          inv-7: {human: Test metadata capability SHALL contain required or validated or both., severity: error}
        nameReference: metadata
        index: 79
      action:
        constraint:
          inv-2: {human: Test action SHALL contain either an operation or assert but not both., severity: error}
        min: 1
        short: A test operation or assert to perform
        index: 80
        comments: An action should contain either an operation or an assertion but not both.  It can contain any number of variables.
        type: BackboneElement
        array: true
        elements:
          operation:
            short: The setup operation to perform
            constraint:
              inv-11: {human: Test operation SHALL contain either sourceId or targetId or params or url., severity: error}
            nameReference: operation
            index: 81
          assert:
            short: The setup assertion to perform
            comments: In order to evaluate an assertion, the request, response, and results of the most recently executed operation must always be maintained by the test engine.
            constraint:
              inv-14: {human: Test action assert shall contain both compareToSourceId and compareToSourcePath or neither., severity: error}
              inv-9: {human: Only a single assertion SHALL be present within test action assert element., severity: error}
            nameReference: assert
            index: 82
    required: [action]
  profile: {type: Reference, short: Reference of the validation profile, comments: 'See http://hl7-fhir.github.io/resourcelist.html for complete list of resource types.', array: true, index: 31}
  multiserver: {type: boolean, short: Whether or not the tests apply to more than one FHIR server, meaningWhenMissing: 'False', index: 26}
package_version: 1.0.2
class: resource
kind: resource
url: http://hl7.org/fhir/StructureDefinition/TestScript
version: null
required: [url, name, status]