DSTU2

This page is part of the FHIR Specification (v1.0.2: DSTU 2). 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-search.json

Raw JSON (canonical form)

Search TestScript Example

{
  "resourceType": "TestScript",
  "id": "search",
  "text": {
    "status": "generated",
    "div": "<div><p><b>Generated Narrative with Details</b></p><p><b>id</b>: search</p><p><b>name</b>: Read, Search and Conditional Create and Delete</p><p><b>description</b>: Test Script for testing search, read, and conditional create and delete</p><h3>Fixtures</h3><table><tr><td>-</td><td><b>Resource</b></td></tr><tr><td>*</td><td><a>Patient/patient-example.xml</a></td></tr></table><blockquote><p><b>variable</b></p><p><b>name</b>: V1</p><p><b>sourceId</b>: R1</p><p><b>headerField</b>: Location</p></blockquote><blockquote><p><b>variable</b></p><p><b>name</b>: V2</p><p><b>sourceId</b>: R3</p><p><b>path</b>: fhir:Patient/fhir:name/fhir:given/@value</p></blockquote><blockquote><p><b>setup</b></p><blockquote><p><b>action</b></p><h3>Operations</h3><table><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Params</b></td></tr><tr><td>*</td><td>delete</td><td>Patient</td><td>given=John&amp;family=Doe</td></tr></table></blockquote></blockquote><blockquote><p><b>test</b></p><p><b>name</b>: Create</p><p><b>description</b>: Create, read, search, conditional create, conditional delete.</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><blockquote><p><b>operation</b></p><p><b>type</b>: create</p><p><b>resource</b>: Patient</p><p><b>description</b>: Conditional Create Operation</p><p><b>link</b>: <a>http://hl7-fhir.github.io/http.html#2.1.0.13.1</a></p><p><b>required</b>: true</p><p><b>validated</b>: true</p></blockquote><blockquote><p><b>operation</b></p><p><b>type</b>: delete</p><p><b>resource</b>: Patient</p><p><b>description</b>: Conditional Delete Operation</p><p><b>link</b>: <a>http://hl7-fhir.github.io/http.html#2.1.0.12.1</a></p><p><b>required</b>: true</p><p><b>validated</b>: true</p></blockquote><blockquote><p><b>operation</b></p><p><b>type</b>: read</p><p><b>resource</b>: Patient</p><p><b>description</b>: Patient Read Operation</p><p><b>link</b>: <a>http://hl7.org/implement/standards/FHIR-Develop/http.html#read</a></p><p><b>validated</b>: true</p></blockquote><blockquote><p><b>operation</b></p><p><b>type</b>: search</p><p><b>resource</b>: Patient</p><p><b>description</b>: Patient Search Operation</p><p><b>link</b>: <a>http://hl7-fhir.github.io/http.html#2.1.0.14</a></p><p><b>validated</b>: true</p></blockquote></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>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>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>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>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>Operations</h3><table><tr><td>-</td></tr><tr><td>*</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></div>"
  },
  "url": "http://hl7.org/fhir/TestScript/search",
  "name": "Read, Search and Conditional Create and Delete",
  "status": "draft",
  "description": "Test Script for testing search, read, and conditional create and delete",
  "metadata": {
    "capability": [
      {
        "required": true,
        "description": "Patient Create and Read Operations",
        "link": [
          "http://hl7.org/implement/standards/FHIR-Develop/http.html#create",
          "http://hl7.org/implement/standards/FHIR-Develop/http.html#read"
        ],
        "conformance": {
          "reference": "Conformance/example"
        }
      },
      {
        "required": true,
        "description": "Patient Conditional Delete Operation",
        "link": [
          "http://hl7-fhir.github.io/http.html#2.1.0.12.1"
        ],
        "conformance": {
          "reference": "Conformance/example"
        }
      },
      {
        "required": true,
        "description": "Patient Conditional Create Operation",
        "link": [
          "http://hl7-fhir.github.io/http.html#2.1.0.13.1"
        ],
        "conformance": {
          "reference": "Conformance/example"
        }
      }
    ]
  },
  "fixture": [
    {
      "id": "example-patient",
      "resource": {
        "reference": "Patient/example"
      }
    }
  ],
  "variable": [
    {
      "name": "V1",
      "headerField": "Location",
      "sourceId": "R1"
    },
    {
      "name": "V2",
      "path": "fhir:Patient/fhir:name/fhir:given/@value",
      "sourceId": "R3"
    }
  ],
  "setup": {
    "action": [
      {
        "fhir_comments": [
          "    Conditional Delete    "
        ],
        "operation": {
          "type": {
            "code": "delete"
          },
          "resource": "Patient",
          "params": "given=John&family=Doe"
        }
      }
    ]
  },
  "test": [
    {
      "id": "Test1",
      "name": "Create",
      "description": "Create, read, search, conditional create, conditional delete.",
      "metadata": {
        "link": [
          {
            "url": "http://hl7.org/implement/standards/FHIR-Develop/patient.html",
            "description": "FHIR Patient"
          }
        ],
        "capability": [
          {
            "validated": true,
            "description": "Patient Search Operation",
            "link": [
              "http://hl7.org/implement/standards/FHIR-Develop/http.html#search"
            ],
            "conformance": {
              "reference": "Conformance/example"
            }
          }
        ]
      },
      "action": [
        {
          "fhir_comments": [
            "    Create the patient using fixture    "
          ],
          "operation": {
            "type": {
              "code": "create"
            },
            "sourceId": "example-patient"
          }
        },
        {
          "assert": {
            "responseCode": "201"
          }
        },
        {
          "fhir_comments": [
            "    Patient search by name.  Save the responseBody in 'F1' fixture.\n\t\t\t\tSave the responseHeader in H1    "
          ],
          "operation": {
            "type": {
              "code": "search"
            },
            "resource": "Patient",
            "contentType": "json",
            "params": "?given=John&family=Doe",
            "responseId": "R1"
          }
        },
        {
          "fhir_comments": [
            "    Verify that the Location in response-header is valid    "
          ],
          "assert": {
            "headerField": "Location",
            "operator": "notEmpty",
            "warningOnly": true
          }
        },
        {
          "fhir_comments": [
            "    Verify that the birthdate got persisted and is being returned properly    "
          ],
          "assert": {
            "operator": "equals",
            "path": "fhir:Patient/fhir:birthDate/@value",
            "sourceId": "R1",
            "value": "1974-12-31"
          }
        },
        {
          "fhir_comments": [
            "    Verify that the navigation links are valid    "
          ],
          "assert": {
            "navigationLinks": true,
            "warningOnly": true
          }
        },
        {
          "fhir_comments": [
            "    Use the Location returned earlier to grab the resource\n\t\t \t\tto verify that Location was pointing to correct resource.    "
          ],
          "operation": {
            "type": {
              "code": "search"
            },
            "accept": "json",
            "responseId": "R2",
            "url": "${V1}"
          }
        },
        {
          "assert": {
            "contentType": "json"
          }
        },
        {
          "assert": {
            "response": "okay"
          }
        },
        {
          "fhir_comments": [
            "    Search for the resource but this time using the birthdate \n\t\t\t\tas a search parameter to make sure search by birthDate works    "
          ],
          "operation": {
            "type": {
              "code": "search"
            },
            "resource": "Patient",
            "accept": "json",
            "params": "?given=John&family=Doe&birthdate=1974-12-31",
            "responseId": "R3"
          }
        },
        {
          "assert": {
            "contentType": "json"
          }
        },
        {
          "assert": {
            "response": "okay"
          }
        },
        {
          "fhir_comments": [
            "    Verify that the birthDate matches expectations    "
          ],
          "assert": {
            "compareToSourceId": "R2",
            "compareToSourcePath": "fhir:Patient/fhir:birthDate/@value",
            "path": "fhir:Patient/fhir:birthDate/@value",
            "sourceId": "R3"
          }
        },
        {
          "fhir_comments": [
            "    Verify that the name matches expectations    "
          ],
          "assert": {
            "path": "fhir:Patient/fhir:name/fhir:given/@value",
            "sourceId": "R3",
            "value": "John"
          }
        },
        {
          "fhir_comments": [
            "    Conditional Create    "
          ],
          "operation": {
            "type": {
              "code": "create"
            },
            "requestHeader": [
              {
                "field": "If-None-Exist",
                "value": "Patient?given=John&Doe&birthdate=1974-12-31"
              }
            ],
            "sourceId": "F1"
          }
        },
        {
          "fhir_comments": [
            "    The response code of 200 verifies that the resource \n\t\t\t\talready exists and did not get created    "
          ],
          "assert": {
            "responseCode": "200"
          }
        },
        {
          "fhir_comments": [
            "    Conditional Delete    "
          ],
          "operation": {
            "type": {
              "code": "delete"
            },
            "resource": "Patient",
            "params": "?given=John&family=Doe&birthdate=1974-12-31"
          }
        },
        {
          "fhir_comments": [
            "    Search again and make sure the patient has been deleted.\n\t\t \t\t This time perform read by id using variable    "
          ],
          "operation": {
            "type": {
              "code": "read"
            },
            "resource": "Patient",
            "params": "/${V2}"
          }
        },
        {
          "assert": {
            "responseCode": "410"
          }
        }
      ]
    }
  ]
}

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.