STU 3 Ballot

This page is part of the FHIR Specification (v1.6.0: STU 3 Ballot 4). The current version which supercedes this version is 5.0.0. For a full list of available versions, see the Directory of published versions

Testscript-example-rule.json

Raw JSON (canonical form)

Rule TestScript Example

{
  "resourceType": "TestScript",
  "id": "example-rule",
  "text": {
    "status": "generated",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: example</p><p><b>name</b>: Test Script 1</p><p><b>description</b>: Example Test Script with rule and ruleset</p><h3>Fixtures</h3><table><tr><td>-</td><td><b>Resource</b></td></tr><tr><td>*</td><td><a>Patient resource</a></td></tr></table><blockquote><p><b>test</b></p><p><b>name</b>: Read Patient</p><p><b>description</b>: Read a patient and validate response.</p><blockquote><p><b>metadata</b></p><h3>Links</h3><table><tr><td>-</td><td><b>Url</b></td><td><b>Description</b></td></tr><tr><td>*</td><td><a>http://hl7.org/implement/standards/FHIR-Develop/patient.html</a></td><td>FHIR Patient</td></tr></table><h3>Operations</h3><table><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Link</b></td><td><b>Required</b></td></tr><tr><td>*</td><td>create</td><td>Patient</td><td>Patient Create Operation</td><td><a>http://hl7.org/implement/standards/FHIR-Develop/http.html#create</a></td><td>true</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Operations</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote></blockquote></div>"
  },
  "url": "http://hl7.org/fhir/TestScript/example-rule",
  "version": "1.0",
  "name": "Test Script 1",
  "status": "draft",
  "identifier": {
    "system": "urn:ietf:rfc:3986",
    "value": "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9876"
  },
  "experimental": true,
  "publisher": "HL7",
  "contact": [
    {
      "name": "Support",
      "telecom": [
        {
          "system": "email",
          "value": "support@gmail.com",
          "use": "temp"
        }
      ]
    }
  ],
  "date": "2015-08-31",
  "description": "Example Test Script",
  "useContext": [
    {
      "coding": [
        {
          "system": "urn:iso:std:iso:3166",
          "code": "US",
          "display": "United States of America (the)"
        }
      ]
    }
  ],
  "requirements": "Patient Create, Read, and Update Operations",
  "copyright": "© HL7.org 2011+",
  "metadata": {
    "capability": [
      {
        "required": true,
        "description": "Patient Create, Read, and Update Operations",
        "destination": 1,
        "link": [
          "http://hl7.org/implement/standards/FHIR-Develop/http.html#create",
          "http://hl7.org/implement/standards/FHIR-Develop/http.html#read",
          "http://hl7.org/implement/standards/FHIR-Develop/http.html#update"
        ],
        "conformance": {
          "reference": "Conformance/example"
        }
      }
    ]
  },
  "fixture": [
    {
      "id": "F1",
      "autocreate": false,
      "autodelete": false,
      "resource": {
        "reference": "Patient/example",
        "display": "Patient resource"
      }
    }
  ],
  "profile": [
    {
      "id": "patient-profile",
      "reference": "http://hl7.org/fhir/StructureDefinition/Patient"
    }
  ],
  "rule": [
    {
      "id": "ruleResponseOkay",
      "resource": {
        "reference": "TestScript/example"
      },
      "param": [
        {
          "name": "expectedStatusCode",
          "value": "200"
        }
      ]
    }
  ],
  "ruleset": [
    {
      "id": "ruleset-responseResourcePatient",
      "resource": {
        "reference": "TestScript/example"
      },
      "rule": [
        {
          "ruleId": "RuleResponseContentType",
          "param": [
            {
              "name": "expectedContentType",
              "value": "JSON"
            }
          ]
        },
        {
          "ruleId": "RuleResponseStatusCode",
          "param": [
            {
              "name": "expectedStatusCode",
              "value": "200"
            }
          ]
        }
      ]
    }
  ],
  "setup": {
    "action": [
      {
        "operation": {
          "type": {
            "code": "create"
          },
          "label": "SetupPatient",
          "description": "Create patient resource on test server",
          "accept": "json",
          "responseId": "create-response",
          "sourceId": "F1"
        }
      },
      {
        "assert": {
          "label": "RuleReadOK",
          "direction": "request",
          "rule": {
            "ruleId": "ruleResponseOkay",
            "param": [
              {
                "name": "expectedStatusCode",
                "value": "201"
              }
            ]
          }
        }
      }
    ]
  },
  "test": [
    {
      "id": "READ01",
      "name": "Read Patient",
      "description": "Read a patient and validate response.",
      "action": [
        {
          "operation": {
            "type": {
              "code": "read"
            },
            "encodeRequestUrl": false,
            "responseId": "F1-read",
            "targetId": "F1"
          }
        },
        {
          "assert": {
            "label": "RuleReadOK",
            "rule": {
              "ruleId": "ruleResponseOkay"
            }
          }
        },
        {
          "assert": {
            "label": "RuleContentTypeResponse",
            "ruleset": {
              "rulesetId": "ruleset-responseResourcePatient",
              "rule": [
                {
                  "ruleId": "RuleResponseContentType",
                  "param": [
                    {
                      "name": "expectedContentType",
                      "value": "XML"
                    }
                  ]
                }
              ]
            }
          }
        },
        {
          "assert": {
            "headerField": "Last-Modified",
            "operator": "notEmpty",
            "warningOnly": true
          }
        },
        {
          "assert": {
            "resource": "Patient"
          }
        },
        {
          "assert": {
            "validateProfileId": "patient-profile"
          }
        },
        {
          "assert": {
            "operator": "equals",
            "path": "fhir:Patient/fhir:name/fhir:family/@value",
            "value": "Chalmers"
          }
        },
        {
          "assert": {
            "operator": "equals",
            "path": "fhir:Patient/fhir:name/fhir:family/@value",
            "sourceId": "F1",
            "value": "Chalmers"
          }
        },
        {
          "assert": {
            "compareToSourceId": "F1-read",
            "compareToSourcePath": "fhir:Patient/fhir:name/fhir:family/@value",
            "operator": "equals",
            "path": "fhir:Patient/fhir:name/fhir:family/@value"
          }
        },
        {
          "assert": {
            "compareToSourceId": "F1-read",
            "compareToSourcePath": "fhir:Patient/fhir:name/fhir:family/@value",
            "path": "fhir:Patient/fhir:name/fhir:family/@value",
            "sourceId": "F1"
          }
        },
        {
          "assert": {
            "minimumId": "F1-min"
          }
        }
      ]
    }
  ]
}

Usage note: every effort has been made to ensure that the examples are correct and useful, but they are not a normative part of the specification.