R6 Ballot (1st Draft)

This page is part of the FHIR Specification v6.0.0-ballot1: Release 6 Ballot (1st Draft) (see Ballot Notes). The current version is 5.0.0. For a full list of available versions, see the Directory of published versions

7.4 Resource TestScript - Content

FHIR Infrastructure icon Work GroupMaturity Level: 4 Trial UseSecurity Category: Anonymous Compartments: No defined compartments

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

This resource is a Quality Reporting & Testing resource from a FHIR Implementation Support perspective - see Implementation Support Module.

The TestScript resource is used to define tests that can be executed against one or more FHIR clients and servers. The TestScript resource will typically contain

  • a list of fixtures (required resources used in the tests)
  • setup procedures
  • a suite of thematically related tests
  • teardown procedures

For example, one TestScript might feature a set of tests focusing on searching Patients and validating the Bundle responses. The fixtures for such a test would contain a list of Patient resources that are required for the test to complete successfully. The setup procedures create the fixtures on the FHIR server being tested. A series of tests execute search operations with various search parameter combinations and evaluate the client requests and server responses for conformance and expected results. The teardown procedures could then clean up (delete) the fixtures on FHIR server that were created during the setup procedures.

The purpose of the TestScript is to encode in an executable representation tests that can be used

  1. to support end-to-end testing of business case workflow, such as patient coordination
  2. within an Ecosystem or Community of Systems-Under-Test
  3. to determine whether given FHIR clients and servers adhere and are conformant to the FHIR specification
  4. to determine whether the capabilities of two or more FHIR implementations capabilities are compatible and interoperable according to the FHIR specification
It might not be possible to fully automate the latter goal (especially with regards to business rules that might ride on top of different implementations), however the tests should be able to determine whether two servers support the operations, value sets, profiles, and extensions to exchange FHIR Resources; for example, the request sent and response returned from a Patient $everything operation.

Note to Implementers: At this time the scope and usage of TestScript resources is focused on the FHIR specification. The TestScript resource scope and usage may expand in the future to include support for other HL7 specifications such as C-CDA and V2 as HL7 aligns these specifications with FHIR-based nomenclature and definitions. Future support may also additionally include non-HL7 specifications that leverage the FHIR specification such as IHE profiles.

The TestScript resource should NOT be used to represent Clinical tests, Prescriptions, or any other Healthcare related concept. The TestScript resource is an infrastructure support resource used to represent standardized tests to determine a FHIR implementation's level of adherence to the FHIR specification.

TestScript is a part of the conformance framework and is used to validate the behavior of FHIR systems, specifically their correct implementation of StructureDefinition, ValueSet, OperationDefinition, CapabilityStatement and other FHIR resources that govern system behavior. TestScript instances may be included as part of ImplementationGuides to help define and test the desired behavior of systems that choose to comply with the implementation guide.

The following resources represent the FHIR conformance framework that are used to express the expected behavior of a FHIR compliant system:

The TestScript resource is designed to establish testing as a first class artifact within the FHIR specification. This resource allows defining a suite of tests that can be executed on one or more FHIR servers and clients.

Implementers should be familiar with the testing concepts and descriptions found in Testing FHIR before working with this resource.

Structure

NameFlagsCard.TypeDescription & Constraintsdoco
.. TestScript TUDomainResourceDescribes a set of tests
+ Warning: Name should be usable as an identifier for the module by machine processing applications such as code generation

Elements defined in Ancestors: id, meta, implicitRules, language, text, contained, extension, modifierExtension
Interfaces Implemented: CanonicalResource
... url ΣC0..1uriCanonical identifier for this test script, represented as a URI (globally unique)
+ Warning: URL should not contain | or # - these characters make processing canonical references problematic
... identifier Σ0..*IdentifierAdditional identifier for the test script

... version Σ0..1stringBusiness version of the test script
... versionAlgorithm[x] Σ0..1How to compare versions
Binding: Version Algorithm (Extensible)
.... versionAlgorithmStringstring
.... versionAlgorithmCodingCoding
... name ΣC1..1stringName for this test script (computer friendly)
... title ΣT0..1stringName for this test script (human friendly)
... status ?!Σ1..1codedraft | active | retired | unknown
Binding: PublicationStatus (Required)
... experimental Σ0..1booleanFor testing purposes, not real usage
... date Σ0..1dateTimeDate last changed
... publisher ΣT0..1stringName of the publisher/steward (organization or individual)
... contact Σ0..*ContactDetailContact details for the publisher

... description T0..1markdownNatural language description of the test script
... useContext Σ0..*UsageContextThe context that the content is intended to support

... jurisdiction ΣXD0..*CodeableConceptIntended jurisdiction for test script (if applicable)
Binding: Jurisdiction ValueSet (Extensible)

... purpose T0..1markdownWhy this test script is defined
... copyright T0..1markdownUse and/or publishing restrictions
... copyrightLabel T0..1stringCopyright holder and year(s)
... origin 0..*BackboneElementAn abstract server representing a client or sender in a message exchange

.... index 1..1integerThe index of the abstract origin server starting at 1
.... profile 1..1CodingFHIR-Client | FHIR-SDC-FormFiller
Binding: Test Script Profile Origin Type (Extensible)
.... url 0..1urlThe url path of the origin server
... destination 0..*BackboneElementAn abstract server representing a destination or receiver in a message exchange

.... index 1..1integerThe index of the abstract destination server starting at 1
.... profile 1..1CodingFHIR-Server | FHIR-SDC-FormManager | FHIR-SDC-FormReceiver | FHIR-SDC-FormProcessor
Binding: Test Script Profile Destination Type (Extensible)
.... url 0..1urlThe url path of the destination server
... metadata C0..1BackboneElementRequired capability that is assumed to function correctly on the FHIR server being tested
+ Rule: TestScript metadata capability SHALL contain required or validated or both.
.... link 0..*BackboneElementLinks to the FHIR specification

..... url 1..1uriURL to the specification
..... description 0..1stringShort description
.... capability C1..*BackboneElementCapabilities that are assumed to function correctly on the FHIR server being tested

..... required C1..1booleanAre the capabilities required?
..... validated C1..1booleanAre the capabilities validated?
..... description 0..1stringThe expected capabilities of the server
..... origin 0..*integerWhich origin server these requirements apply to

..... destination 0..1integerWhich server these requirements apply to
..... link 0..*uriLinks to the FHIR specification

..... capabilities 1..1canonical(CapabilityStatement)Required Capability Statement
... scope 0..*BackboneElementIndication of the artifact(s) that are tested by this test case

.... artifact 1..1canonical(Any)The specific conformance artifact being tested
.... conformance 0..1CodeableConceptrequired | optional | strict
Binding: Test Script Scope Conformance Type (Extensible)
.... phase 0..1CodeableConceptunit | integration | production
Binding: Test Script Scope Phase Type (Extensible)
... fixture 0..*BackboneElementFixture in the test script - by reference (uri)

.... autocreate 1..1booleanWhether or not to implicitly create the fixture during setup
.... autodelete 1..1booleanWhether or not to implicitly delete the fixture during teardown
.... resource 0..1Reference(Any)Reference of the resource
... profile 0..*canonical(StructureDefinition)Reference of the validation profile

... variable C0..*BackboneElementPlaceholder for evaluated elements
+ Rule: Variable can only contain one of expression, headerField or path.

.... name 1..1stringDescriptive name for this variable
.... defaultValue 0..1stringDefault, hard-coded, or user-defined value for this variable
.... description 0..1stringNatural language description of the variable
.... expression C0..1stringThe FHIRPath expression against the fixture body
.... headerField C0..1stringHTTP header field name for source
.... hint 0..1stringHint help text for default value to enter
.... path C0..1stringXPath or JSONPath against the fixture body
.... sourceId 0..1idFixture Id of source expression or headerField within this variable
... setup 0..1BackboneElementA series of required setup operations before tests are executed
.... action C1..*BackboneElementA setup operation or assert to perform
+ Rule: Setup action SHALL contain either an operation or assert but not both.

..... operation C0..1BackboneElementThe setup operation to perform
+ Rule: Setup operation SHALL contain either sourceId or targetId or params or url.
...... type C0..1CodingThe operation code type that will be executed
Binding: Test Script Operation Code (Extensible)
...... resource 0..1uriResource type
Binding: Concrete FHIR Types (Extensible)
...... label 0..1stringTracking/logging operation label
...... description 0..1stringTracking/reporting operation description
...... accept 0..1codeMime type to accept in the payload of the response, with charset etc
Binding: Mime Types (Required)
...... contentType 0..1codeMime type of the request payload contents, with charset etc
Binding: Mime Types (Required)
...... destination 0..1integerServer responding to the request
...... encodeRequestUrl 1..1booleanWhether or not to send the request url in encoded format
...... method 0..1codedelete | get | options | patch | post | put | head
Binding: Test Script Request Method Code (Required)
...... origin 0..1integerServer initiating the request
...... params C0..1stringExplicitly defined path parameters
...... requestHeader 0..*BackboneElementEach operation can have one or more header elements

....... field 1..1stringHTTP header field name
....... value 1..1stringHTTP headerfield value
...... requestId 0..1idFixture Id of mapped request
...... responseId 0..1idFixture Id of mapped response
...... sourceId C0..1idFixture Id of body for PUT and POST requests
...... targetId C0..1idId of fixture used for extracting the [id], [type], and [vid] for GET requests
...... url C0..1stringRequest URL
..... assert C0..1BackboneElementThe assertion to perform
+ Rule: Only a single assertion SHALL be present within setup action assert element.
+ Rule: Setup action assert SHALL contain either compareToSourceId and compareToSourceExpression, compareToSourceId and compareToSourcePath or neither.
+ Rule: Setup action assert response and responseCode SHALL be empty when direction equals request
...... label 0..1stringTracking/logging assertion label
...... description 0..1stringTracking/reporting assertion description
...... direction C0..1coderesponse | request
Binding: Assertion Direction Type (Required)
...... compareToSourceId C0..1stringId of the source fixture to be evaluated
...... compareToSourceExpression C0..1stringThe FHIRPath expression to evaluate against the source fixture
...... compareToSourcePath C0..1stringXPath or JSONPath expression to evaluate against the source fixture
...... contentType C0..1codeMime type to compare against the 'Content-Type' header
Binding: Mime Types (Required)
...... defaultManualCompletion 0..1codefail | pass | skip | stop
Binding: Assertion Manual Completion Type (Required)
...... expression C0..1stringThe FHIRPath expression to be evaluated
...... headerField C0..1stringHTTP header field name
...... minimumId C0..1stringFixture Id of minimum content resource
...... navigationLinks C0..1booleanPerform validation on navigation links?
...... operator 0..1codeequals | notEquals | in | notIn | greaterThan | lessThan | empty | notEmpty | contains | notContains | eval | manualEval
Binding: Assertion Operator Type (Required)
...... path C0..1stringXPath or JSONPath expression
...... requestMethod C0..1codedelete | get | options | patch | post | put | head
Binding: Test Script Request Method Code (Required)
...... requestURL 0..1stringRequest URL comparison value
...... resource C0..1uriResource type
Binding: Concrete FHIR Types (Extensible)
...... response C0..1codecontinue | switchingProtocols | okay | created | accepted | nonAuthoritativeInformation | noContent | resetContent | partialContent | multipleChoices | movedPermanently | found | seeOther | notModified | useProxy | temporaryRedirect | permanentRedirect | badRequest | unauthorized | paymentRequired | forbidden | notFound | methodNotAllowed | notAcceptable | proxyAuthenticationRequired | requestTimeout | conflict | gone | lengthRequired | preconditionFailed | contentTooLarge | uriTooLong | unsupportedMediaType | rangeNotSatisfiable | expectationFailed | misdirectedRequest | unprocessableContent | upgradeRequired | internalServerError | notImplemented | badGateway | serviceUnavailable | gatewayTimeout | httpVersionNotSupported
Binding: Assertion Response Types (Required)
...... responseCode C0..1stringHTTP response code to test
...... sourceId 0..1idFixture Id of source expression or headerField
...... stopTestOnFail 1..1booleanIf this assert fails, will the current test execution stop?
...... validateProfileId C0..1idProfile Id of validation profile reference
...... value 0..1stringThe value to compare to
...... warningOnly 1..1booleanWill this assert produce a warning only on error?
...... requirement 0..*BackboneElementLinks or references to the testing requirements

....... link[x] 0..1Link or reference to the testing requirement
........ linkUriuri
........ linkCanonicalcanonical(Requirements)
... test 0..*BackboneElementA test in this script

.... name 0..1stringTracking/logging name of this test
.... description 0..1stringTracking/reporting short description of the test
.... action C1..*BackboneElementA test operation or assert to perform
+ Rule: Test action SHALL contain either an operation or assert but not both.

..... operation C0..1see operationThe setup operation to perform
+ Rule: Test operation SHALL contain either sourceId or targetId or params or url.
..... assert C0..1see assertThe setup assertion to perform
+ Rule: Only a single assertion SHALL be present within test action assert element.
+ Rule: Test action assert SHALL contain either compareToSourceId and compareToSourceExpression, compareToSourceId and compareToSourcePath or neither.
+ Rule: Test action assert response and response and responseCode SHALL be empty when direction equals request
... teardown 0..1BackboneElementA series of required clean up steps
.... action 1..*BackboneElementOne or more teardown operations to perform

..... operation C1..1