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
FHIR Infrastructure Work Group | Maturity Level: 4 | Trial Use | Security 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
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
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
Name | Flags | Card. | Type | Description & Constraints |
---|---|---|---|---|
TestScript | TU | DomainResource | Describes 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 | ΣC | 0..1 | uri | Canonical 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..* | Identifier | Additional identifier for the test script |
version | Σ | 0..1 | string | Business version of the test script |
versionAlgorithm[x] | Σ | 0..1 | How to compare versions Binding: Version Algorithm (Extensible) | |
versionAlgorithmString | string | |||
versionAlgorithmCoding | Coding | |||
name | ΣC | 1..1 | string | Name for this test script (computer friendly) |
title | ΣT | 0..1 | string | Name for this test script (human friendly) |
status | ?!Σ | 1..1 | code | draft | active | retired | unknown Binding: PublicationStatus (Required) |
experimental | Σ | 0..1 | boolean | For testing purposes, not real usage |
date | Σ | 0..1 | dateTime | Date last changed |
publisher | ΣT | 0..1 | string | Name of the publisher/steward (organization or individual) |
contact | Σ | 0..* | ContactDetail | Contact details for the publisher |
description | T | 0..1 | markdown | Natural language description of the test script |
useContext | Σ | 0..* | UsageContext | The context that the content is intended to support |
jurisdiction | ΣXD | 0..* | CodeableConcept | Intended jurisdiction for test script (if applicable) Binding: Jurisdiction ValueSet (Extensible) |
purpose | T | 0..1 | markdown | Why this test script is defined |
copyright | T | 0..1 | markdown | Use and/or publishing restrictions |
copyrightLabel | T | 0..1 | string | Copyright holder and year(s) |
origin | 0..* | BackboneElement | An abstract server representing a client or sender in a message exchange | |
index | 1..1 | integer | The index of the abstract origin server starting at 1 | |
profile | 1..1 | Coding | FHIR-Client | FHIR-SDC-FormFiller Binding: Test Script Profile Origin Type (Extensible) | |
url | 0..1 | url | The url path of the origin server | |
destination | 0..* | BackboneElement | An abstract server representing a destination or receiver in a message exchange | |
index | 1..1 | integer | The index of the abstract destination server starting at 1 | |
profile | 1..1 | Coding | FHIR-Server | FHIR-SDC-FormManager | FHIR-SDC-FormReceiver | FHIR-SDC-FormProcessor Binding: Test Script Profile Destination Type (Extensible) | |
url | 0..1 | url | The url path of the destination server | |
metadata | C | 0..1 | BackboneElement | Required 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..* | BackboneElement | Links to the FHIR specification | |
url | 1..1 | uri | URL to the specification | |
description | 0..1 | string | Short description | |
capability | C | 1..* | BackboneElement | Capabilities that are assumed to function correctly on the FHIR server being tested |
required | C | 1..1 | boolean | Are the capabilities required? |
validated | C | 1..1 | boolean | Are the capabilities validated? |
description | 0..1 | string | The expected capabilities of the server | |
origin | 0..* | integer | Which origin server these requirements apply to | |
destination | 0..1 | integer | Which server these requirements apply to | |
link | 0..* | uri | Links to the FHIR specification | |
capabilities | 1..1 | canonical(CapabilityStatement) | Required Capability Statement | |
scope | 0..* | BackboneElement | Indication of the artifact(s) that are tested by this test case | |
artifact | 1..1 | canonical(Any) | The specific conformance artifact being tested | |
conformance | 0..1 | CodeableConcept | required | optional | strict Binding: Test Script Scope Conformance Type (Extensible) | |
phase | 0..1 | CodeableConcept | unit | integration | production Binding: Test Script Scope Phase Type (Extensible) | |
fixture | 0..* | BackboneElement | Fixture in the test script - by reference (uri) | |
autocreate | 1..1 | boolean | Whether or not to implicitly create the fixture during setup | |
autodelete | 1..1 | boolean | Whether or not to implicitly delete the fixture during teardown | |
resource | 0..1 | Reference(Any) | Reference of the resource | |
profile | 0..* | canonical(StructureDefinition) | Reference of the validation profile | |
variable | C | 0..* | BackboneElement | Placeholder for evaluated elements + Rule: Variable can only contain one of expression, headerField or path. |
name | 1..1 | string | Descriptive name for this variable | |
defaultValue | 0..1 | string | Default, hard-coded, or user-defined value for this variable | |
description | 0..1 | string | Natural language description of the variable | |
expression | C | 0..1 | string | The FHIRPath expression against the fixture body |
headerField | C | 0..1 | string | HTTP header field name for source |
hint | 0..1 | string | Hint help text for default value to enter | |
path | C | 0..1 | string | XPath or JSONPath against the fixture body |
sourceId | 0..1 | id | Fixture Id of source expression or headerField within this variable | |
setup | 0..1 | BackboneElement | A series of required setup operations before tests are executed | |
action | C | 1..* | BackboneElement | A setup operation or assert to perform + Rule: Setup action SHALL contain either an operation or assert but not both. |
operation | C | 0..1 | BackboneElement | The setup operation to perform + Rule: Setup operation SHALL contain either sourceId or targetId or params or url. |
type | C | 0..1 | Coding | The operation code type that will be executed Binding: Test Script Operation Code (Extensible) |
resource | 0..1 | uri | Resource type Binding: Concrete FHIR Types (Extensible) | |
label | 0..1 | string | Tracking/logging operation label | |
description | 0..1 | string | Tracking/reporting operation description | |
accept | 0..1 | code | Mime type to accept in the payload of the response, with charset etc Binding: Mime Types (Required) | |
contentType | 0..1 | code | Mime type of the request payload contents, with charset etc Binding: Mime Types (Required) | |
destination | 0..1 | integer | Server responding to the request | |
encodeRequestUrl | 1..1 | boolean | Whether or not to send the request url in encoded format | |
method | 0..1 | code | delete | get | options | patch | post | put | head Binding: Test Script Request Method Code (Required) | |
origin | 0..1 | integer | Server initiating the request | |
params | C | 0..1 | string | Explicitly defined path parameters |
requestHeader | 0..* | BackboneElement | Each operation can have one or more header elements | |
field | 1..1 | string | HTTP header field name | |
value | 1..1 | string | HTTP headerfield value | |
requestId | 0..1 | id | Fixture Id of mapped request | |
responseId | 0..1 | id | Fixture Id of mapped response | |
sourceId | C | 0..1 | id | Fixture Id of body for PUT and POST requests |
targetId | C | 0..1 | id | Id of fixture used for extracting the [id], [type], and [vid] for GET requests |
url | C | 0..1 | string | Request URL |
assert | C | 0..1 | BackboneElement | The 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..1 | string | Tracking/logging assertion label | |
description | 0..1 | string | Tracking/reporting assertion description | |
direction | C | 0..1 | code | response | request Binding: Assertion Direction Type (Required) |
compareToSourceId | C | 0..1 | string | Id of the source fixture to be evaluated |
compareToSourceExpression | C | 0..1 | string | The FHIRPath expression to evaluate against the source fixture |
compareToSourcePath | C | 0..1 | string | XPath or JSONPath expression to evaluate against the source fixture |
contentType | C | 0..1 | code | Mime type to compare against the 'Content-Type' header Binding: Mime Types (Required) |
defaultManualCompletion | 0..1 | code | fail | pass | skip | stop Binding: Assertion Manual Completion Type (Required) | |
expression | C | 0..1 | string | The FHIRPath expression to be evaluated |
headerField | C | 0..1 | string | HTTP header field name |
minimumId | C | 0..1 | string | Fixture Id of minimum content resource |
navigationLinks | C | 0..1 | boolean | Perform validation on navigation links? |
operator | 0..1 | code | equals | notEquals | in | notIn | greaterThan | lessThan | empty | notEmpty | contains | notContains | eval | manualEval Binding: Assertion Operator Type (Required) | |
path | C | 0..1 | string | XPath or JSONPath expression |
requestMethod | C | 0..1 | code | delete | get | options | patch | post | put | head Binding: Test Script Request Method Code (Required) |
requestURL | 0..1 | string | Request URL comparison value | |
resource | C | 0..1 | uri | Resource type Binding: Concrete FHIR Types (Extensible) |
response | C | 0..1 | code | continue | 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 | C | 0..1 | string | HTTP response code to test |
sourceId | 0..1 | id | Fixture Id of source expression or headerField | |
stopTestOnFail | 1..1 | boolean | If this assert fails, will the current test execution stop? | |
validateProfileId | C | 0..1 | id | Profile Id of validation profile reference |
value | 0..1 | string | The value to compare to | |
warningOnly | 1..1 | boolean | Will this assert produce a warning only on error? | |
requirement | 0..* | BackboneElement | Links or references to the testing requirements | |
link[x] | 0..1 | Link or reference to the testing requirement | ||
linkUri | uri | |||
linkCanonical | canonical(Requirements) | |||
test | 0..* | BackboneElement | A test in this script | |
name | 0..1 | string | Tracking/logging name of this test | |
description | 0..1 | string | Tracking/reporting short description of the test | |
action | C | 1..* | BackboneElement | A test operation or assert to perform + Rule: Test action SHALL contain either an operation or assert but not both. |
operation | C | 0..1 | see operation | The setup operation to perform + Rule: Test operation SHALL contain either sourceId or targetId or params or url. |
assert | C | 0..1 | see assert | The 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..1 | BackboneElement | A series of required clean up steps | |
action | 1..* | BackboneElement | One or more teardown operations to perform | |
operation | C | 1..1 |