Test Script

Name/FHIR3-3-0-Basic/P-R/Patient/Server Assigned Id/Patient-server-id-json
DescriptionFHIR Server Patient Basic Operation Tests - JSON - Server Assigned Resource Id - Create, Delete, History, Read, Search, Update, Vread. Support for referenced resource type Organization Create, Delete and Search is also required.
Content
<?xml version="1.0" encoding="UTF-8"?>

<TestScript xmlns="http://hl7.org/fhir">  
    <id value="Patient-server-id-json"/>  
    <url value="http://wildfhir.aegis.net/fhir3-3-0/TestScript/Patient-server-id-json"/>  
    <name value="FHIR Server Patient Basic Operation Tests - JSON - Server Assigned Resource Id"/>  
    <status value="active"/>  
    <date value="2018-04-06"/>  
    <publisher value="AEGIS.net, Inc."/>  
    <contact> 
        <name value="Touchstone Support"/>  
        <telecom> 
            <system value="email"/>  
            <value value="Touchstone_Support@aegis.net"/>  
            <use value="work"/> 
        </telecom> 
    </contact>  
    <description value="FHIR Server Patient Basic Operation Tests - JSON - Server Assigned Resource Id - Create, Delete, History, Read, Search, Update, Vread. Support for referenced resource type Organization Create, Delete and Search is also required."/>  
    <copyright value="© AEGIS.net, Inc. 2015+"/>  
    <fixture id="resource-create"> 
        <autocreate value="false"/>  
        <autodelete value="false"/>  
        <resource> 
            <reference value="../_reference/resources/Patient-create.json"/> 
        </resource> 
    </fixture>  
    <fixture id="resource-update"> 
        <autocreate value="false"/>  
        <autodelete value="false"/>  
        <resource> 
            <reference value="../_reference/resources/Patient-update.json"/> 
        </resource> 
    </fixture>  
    <fixture id="reference-organization-create"> 
        <autocreate value="false"/>  
        <autodelete value="false"/>  
        <resource> 
            <reference value="../_reference/resources/Organization-create.json"/> 
        </resource> 
    </fixture>  
    <profile id="bundle-profile"> 
        <reference value="http://hl7.org/fhir/StructureDefinition/Bundle"/> 
    </profile>  
    <profile id="operationoutcome-profile"> 
        <reference value="http://hl7.org/fhir/StructureDefinition/OperationOutcome"/> 
    </profile>  
    <profile id="resource-profile"> 
        <reference value="http://hl7.org/fhir/StructureDefinition/Patient"/> 
    </profile>  
    <variable> 
        <name value="createResourceId"/>  
        <path value="Patient/id"/>  
        <sourceId value="create-search-response"/> 
    </variable>  
    <variable> 
        <name value="createVersionId"/>  
        <path value="Patient/meta/versionId"/>  
        <sourceId value="create-search-response"/> 
    </variable>  
    <variable> 
        <name value="searchParamIdentifier"/>  
        <path value="Patient/identifier/value"/>  
        <sourceId value="resource-create"/> 
    </variable>  
    <variable> 
        <name value="referenceOrganizationResourceId"/>  
        <path value="Organization/id"/>  
        <sourceId value="setup-create-organization-search-response"/> 
    </variable>  
    <variable> 
        <name value="searchReferenceOrganizationIdentifier"/>  
        <path value="Organization/identifier/value"/>  
        <sourceId value="reference-organization-create"/> 
    </variable>  
    <rule id="rule-assertContentTypeIfBody"> 
        <resource> 
            <reference value="/FHIRCommon/_reference/rule/AssertHeaderIfBody.groovy"/> 
        </resource>  
        <param> 
            <name value="header"/>  
            <value value="Content-Type"/> 
        </param>  
        <param> 
            <name value="headerOperator"/>  
            <value value="notEmpty"/> 
        </param>  
        <param> 
            <name value="bodyOperator"/>  
            <value value="notEmpty"/> 
        </param> 
    </rule>  
    <ruleset id="ruleset-versioning-headers"> 
        <resource> 
            <reference value="/FHIRCommon/_reference/ruleset/RuleSet-VersioningHeaders-Groovy.xml"/> 
        </resource>  
        <rule> 
            <ruleId value="assertETagIfSupported"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertLastModifiedIfSupported"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient"/> 
            </param> 
        </rule> 
    </ruleset>  
    <ruleset id="ruleset-createok-headers-body"> 
        <resource> 
            <reference value="/FHIRCommon/_reference/ruleset/RuleSet-CreateOkHeadersBody-Groovy.xml"/> 
        </resource>  
        <rule> 
            <ruleId value="assertContentTypeIfBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertContentTypeCharsetIfBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertResourceTypesIfBody"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient,OperationOutcome"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertProfileIfOperationOutcome"/>  
            <param> 
                <name value="validateProfileId"/>  
                <value value="operationoutcome-profile"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertProfileIfResource"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient"/> 
            </param>  
            <param> 
                <name value="validateProfileId"/>  
                <value value="resource-profile"/> 
            </param> 
        </rule> 
    </ruleset>  
    <ruleset id="ruleset-updateok-headers-body"> 
        <resource> 
            <reference value="/FHIRCommon/_reference/ruleset/RuleSet-UpdateOkHeadersBody-Groovy.xml"/> 
        </resource>  
        <rule> 
            <ruleId value="assertContentTypeIfBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertContentTypeCharsetIfBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertResourceTypesIfBody"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient,OperationOutcome"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertProfileIfOperationOutcome"/>  
            <param> 
                <name value="validateProfileId"/>  
                <value value="operationoutcome-profile"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertProfileIfResource"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient"/> 
            </param>  
            <param> 
                <name value="validateProfileId"/>  
                <value value="resource-profile"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertVersionIdIfResourceAndSupported"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient"/> 
            </param>  
            <param> 
                <name value="resourceOperator"/>  
                <value value="equals"/> 
            </param> 
        </rule> 
    </ruleset>  
    <ruleset id="ruleset-vreadok-headers-body-if-versioning"> 
        <resource> 
            <reference value="/FHIRCommon/_reference/ruleset/RuleSet-VReadOkHeadersBodyIfVersioning-Groovy.xml"/> 
        </resource>  
        <rule> 
            <ruleId value="assertResponseCodeOkIfVersioning"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertResponseCodeNotFoundIfNotVersioning"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertETagIfSupported"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertLastModifiedIfSupported"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertContentTypeIfBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertContentTypeMimeTypeIfBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertContentTypeCharsetIfBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertResourceTypesIfBody"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient,OperationOutcome"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertProfileIfOperationOutcome"/>  
            <param> 
                <name value="validateProfileId"/>  
                <value value="operationoutcome-profile"/> 
            </param> 
        </rule>  
        <rule> 
            <ruleId value="assertProfileIfResource"/>  
            <param> 
                <name value="resource"/>  
                <value value="Patient"/> 
            </param>  
            <param> 
                <name value="validateProfileId"/>  
                <value value="resource-profile"/> 
            </param> 
        </rule> 
    </ruleset>  
    <ruleset id="ruleset-deletevalid-headers-body"> 
        <resource> 
            <reference value="/FHIRCommon/_reference/ruleset/RuleSet-DeleteValidHeadersBody-Groovy.xml"/> 
        </resource>  
        <rule> 
            <ruleId value="assertResponseCodeOkIfBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertResponseCodeNoContentIfNoBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertETagIfSupported"/> 
        </rule>  
        <rule> 
            <ruleId value="assertContentTypeIfBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertContentTypeCharsetIfBody"/> 
        </rule>  
        <rule> 
            <ruleId value="assertOperationOutcomeIfError"/> 
        </rule>  
        <rule> 
            <ruleId value="assertProfileIfOperationOutcome"/>  
            <param> 
                <name value="validateProfileId"/>  
                <value value="operationoutcome-profile"/> 
            </param> 
        </rule> 
    </ruleset>  
    <setup> 
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="delete"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="System-generated search and delete operations from conditional delete to ensure the Patient does not exist on the server."/>  
                <accept value="json"/>  
                <contentType value="none"/>  
                <encodeRequestUrl value="true"/>  
                <params value="?identifier=${searchParamIdentifier}"/> 
            </operation> 
        </action>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="delete"/> 
                </type>  
                <resource value="Organization"/>  
                <description value="System-generated search and delete operations from conditional delete to ensure the referenced Organization does not exist on the server."/>  
                <accept value="json"/>  
                <contentType value="none"/>  
                <encodeRequestUrl value="true"/>  
                <params value="?identifier=${searchReferenceOrganizationIdentifier}"/> 
            </operation> 
        </action>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="create"/> 
                </type>  
                <description value="Create the referenced Organization resource needed for referential integrity from the Patient."/>  
                <accept value="json"/>  
                <contentType value="json"/>  
                <encodeRequestUrl value="true"/>  
                <sourceId value="reference-organization-create"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is 201(Created)."/>  
                <response value="created"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="search"/> 
                </type>  
                <resource value="Organization"/>  
                <description value="Search for the created Organization by the unique identifier."/>  
                <accept value="json"/>  
                <contentType value="none"/>  
                <encodeRequestUrl value="true"/>  
                <params value="?identifier=${searchReferenceOrganizationIdentifier}"/>  
                <responseId value="setup-create-organization-search-response"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is 200(OK)."/>  
                <response value="okay"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action> 
    </setup>  
    <test id="Step1-CreateNewPatient"> 
        <name value="Step1-CreateNewPatient"/>  
        <description value="Create a new Patient in JSON format where the server assigns the resource id. The expected response code is 201 (Created) with a content of either the created Patient resource in JSON format, an OperationOutcome resource in JSON format or an empty payload."/>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="create"/> 
                </type>  
                <description value="Patient create operation with HTTP Header Accept and Content-Type set to JSON format."/>  
                <accept value="json"/>  
                <contentType value="json"/>  
                <encodeRequestUrl value="true"/>  
                <sourceId value="resource-create"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is 201(Created)."/>  
                <direction value="response"/>  
                <response value="created"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Complex ruleset assertion to conditionally validate expected versioning HTTP Headers."/>  
                <direction value="response"/>  
                <ruleset> 
                    <rulesetId value="ruleset-versioning-headers"/> 
                </ruleset>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Complex ruleset assertion to conditionally validate expected create ok response HTTP Headers and body."/>  
                <direction value="response"/>  
                <ruleset> 
                    <rulesetId value="ruleset-createok-headers-body"/>  
                    <rule> 
                        <ruleId value="assertContentTypeMimeTypeIfBody"/>  
                        <param> 
                            <name value="headerExpectedValue"/>  
                            <value value="application/fhir+json"/> 
                        </param> 
                    </rule> 
                </ruleset>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="search"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="Search for the created Patient by the unique identifier."/>  
                <accept value="json"/>  
                <contentType value="none"/>  
                <encodeRequestUrl value="true"/>  
                <params value="?identifier=${searchParamIdentifier}"/>  
                <responseId value="create-search-response"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is 200(OK)."/>  
                <direction value="response"/>  
                <response value="okay"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned content format is JSON ('application/fhir+json')."/>  
                <direction value="response"/>  
                <contentType value="json"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the response payload contains the Bundle resource type."/>  
                <direction value="response"/>  
                <resource value="Bundle"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Validate that the returned resource conforms to the corresponding FHIR bundle profile."/>  
                <direction value="response"/>  
                <validateProfileId value="bundle-profile"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action> 
    </test>  
    <test id="Step2-ReadPatient"> 
        <name value="Step2-ReadPatient"/>  
        <description value="Read the Patient in JSON format created in step 1. The expected response code is 200 (OK) with a content of the found Patient resource in JSON format."/>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="read"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="Patient read operation with HTTP Header Accept set to JSON format."/>  
                <accept value="json"/>  
                <contentType value="none"/>  
                <encodeRequestUrl value="true"/>  
                <params value="/${createResourceId}"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is 200(OK)."/>  
                <direction value="response"/>  
                <response value="okay"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP Header Content-Type is present."/>  
                <direction value="response"/>  
                <headerField value="Content-Type"/>  
                <operator value="notEmpty"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Complex ruleset assertion to conditionally validate expected versioning HTTP Headers."/>  
                <direction value="response"/>  
                <ruleset> 
                    <rulesetId value="ruleset-versioning-headers"/> 
                </ruleset>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned resource type is Patient."/>  
                <direction value="response"/>  
                <resource value="Patient"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Validate that the returned resource conforms to the corresponding FHIR resource profile."/>  
                <direction value="response"/>  
                <validateProfileId value="resource-profile"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action> 
    </test>  
    <test id="Step3-UpdatePatient"> 
        <name value="Step3-UpdatePatient"/>  
        <description value="Update the Patient created in step 1 in JSON format. The expected response code is 200 (OK) with a content of either the updated Patient resource in JSON format, an OperationOutcome resource in JSON format or an empty payload."/>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="update"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="Patient update operation with JSON content."/>  
                <accept value="json"/>  
                <contentType value="json"/>  
                <encodeRequestUrl value="true"/>  
                <params value="/${createResourceId}"/>  
                <sourceId value="resource-update"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is 200(OK)."/>  
                <direction value="response"/>  
                <responseCode value="200"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Complex ruleset assertion to conditionally validate expected versioning HTTP Headers."/>  
                <direction value="response"/>  
                <ruleset> 
                    <rulesetId value="ruleset-versioning-headers"/> 
                </ruleset>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Complex ruleset assertion to conditionally validate expected update ok response HTTP Headers and body."/>  
                <direction value="response"/>  
                <ruleset> 
                    <rulesetId value="ruleset-updateok-headers-body"/>  
                    <rule> 
                        <ruleId value="assertContentTypeMimeTypeIfBody"/>  
                        <param> 
                            <name value="headerExpectedValue"/>  
                            <value value="application/fhir+json"/> 
                        </param> 
                    </rule> 
                </ruleset>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="read"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="Read the Patient in order to verify the updated contents."/>  
                <accept value="json"/>  
                <contentType value="none"/>  
                <encodeRequestUrl value="true"/>  
                <params value="/${createResourceId}"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is 200(OK)."/>  
                <direction value="response"/>  
                <responseCode value="200"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned content format is JSON ('application/fhir+json')."/>  
                <direction value="response"/>  
                <contentType value="json"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Validate that the returned resource conforms to the corresponding FHIR resource profile."/>  
                <direction value="response"/>  
                <validateProfileId value="resource-profile"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action> 
    </test>  
    <test id="Step4-PatientHistoryInstance"> 
        <name value="Step4-PatientHistoryInstance"/>  
        <description value="Retrieve the updated Patient instance's history in JSON format. The expected response code is 200 (OK) with a Bundle resource in JSON format of type history containing the created and updated versions of the Patient."/>  
        <action> 
            <operation> 
                <resource value="Patient"/>  
                <description value="Retrieve the history for a single, known Patient."/>  
                <accept value="json"/>  
                <contentType value="none"/>  
                <encodeRequestUrl value="true"/>  
                <params value="/${createResourceId}/_history"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is 200(OK)."/>  
                <direction value="response"/>  
                <responseCode value="200"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned content format is JSON ('application/fhir+json')."/>  
                <direction value="response"/>  
                <contentType value="json"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the response payload contains the Bundle resource type."/>  
                <direction value="response"/>  
                <resource value="Bundle"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Validate that the returned resource conforms to the corresponding FHIR bundle profile."/>  
                <direction value="response"/>  
                <validateProfileId value="bundle-profile"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the Bundle type is 'history'."/>  
                <direction value="response"/>  
                <operator value="equals"/>  
                <path value="/Bundle/type"/>  
                <value value="history"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that there is more than one resource instance returned. There should be at least two from the create and update operations."/>  
                <direction value="response"/>  
                <operator value="greaterThan"/>  
                <path value="/Bundle/total"/>  
                <value value="1"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the Bundle total value matches or is greater than the number of entries in the Bundle"/>  
                <direction value="response"/>  
                <expression value="Bundle.total.toInteger() &gt;= entry.count()"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action> 
    </test>  
    <test id="Step5-PatientVersionRead"> 
        <name value="Step5-PatientVersionRead"/>  
        <description value="Retrieve a initially created version of a Patient instance in JSON format. The expected response code, if versioning is supported, is 200 (OK) with a content of the updated Patient resource in JSON format; if versioning is not supported, a 404 (Not Found) with an OperationOutcome resource in JSON format or an empty payload."/>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="vread"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="Retrieve initially created version of the Patient instance."/>  
                <accept value="json"/>  
                <contentType value="none"/>  
                <encodeRequestUrl value="true"/>  
                <params value="/${createResourceId}/_history/${createVersionId}"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Complex ruleset assertion to conditionally validate expected vread ok response code, HTTP Headers and body."/>  
                <direction value="response"/>  
                <ruleset> 
                    <rulesetId value="ruleset-vreadok-headers-body-if-versioning"/>  
                    <rule> 
                        <ruleId value="assertContentTypeMimeTypeIfBody"/>  
                        <param> 
                            <name value="headerExpectedValue"/>  
                            <value value="application/fhir+json"/> 
                        </param> 
                    </rule> 
                </ruleset>  
                <warningOnly value="false"/> 
            </assert> 
        </action> 
    </test>  
    <test id="Step6-PatientSearchType"> 
        <name value="Step6-PatientSearchType"/>  
        <description value="Search for Patient resources in JSON format with an identifier equal to ${searchParamIdentifier}. The expected response code is 200 (OK) with a Bundle resource in JSON format of type history containing the found instances of the Patient."/>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="search"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="Search for the Patient by identifier."/>  
                <accept value="json"/>  
                <contentType value="none"/>  
                <encodeRequestUrl value="true"/>  
                <params value="?identifier=${searchParamIdentifier}"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is 200(OK)."/>  
                <direction value="response"/>  
                <responseCode value="200"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned content format is JSON ('application/fhir+json')."/>  
                <direction value="response"/>  
                <contentType value="json"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the response payload contains the Bundle resource type."/>  
                <direction value="response"/>  
                <resource value="Bundle"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Validate that the returned resource conforms to the corresponding FHIR bundle profile."/>  
                <direction value="response"/>  
                <validateProfileId value="bundle-profile"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the Bundle type is 'searchset'."/>  
                <direction value="response"/>  
                <operator value="equals"/>  
                <path value="/Bundle/type"/>  
                <value value="searchset"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that there is at least one record returned. There could be other Patient records returned."/>  
                <direction value="response"/>  
                <operator value="greaterThan"/>  
                <path value="/Bundle/total"/>  
                <value value="0"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the Bundle total value matches or is greater than the number of entries in the Bundle"/>  
                <direction value="response"/>  
                <expression value="Bundle.total.toInteger() &gt;= entry.count()"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action> 
    </test>  
    <test id="Step7-PatientDelete"> 
        <name value="Step7-PatientDelete"/>  
        <description value="Delete a Patient instance in JSON format. The expected response is either a 200 (OK) with an optional OperationOutcome in JSON format or 204 (No Content) and the content is empty; i.e. no content."/>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://hl7.org/fhir/testscript-operation-codes"/>  
                    <code value="delete"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="Delete the Patient instance."/>  
                <accept value="json"/>  
                <contentType value="none"/>  
                <encodeRequestUrl value="true"/>  
                <params value="/${createResourceId}"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is either 200(OK), 204(No Content) or 404(Not Found)."/>  
                <direction value="response"/>  
                <operator value="in"/>  
                <responseCode value="200,204,404"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Complex ruleset assertion to conditionally validate expected delete ok response HTTP Headers and body."/>  
                <direction value="response"/>  
                <ruleset> 
                    <rulesetId value="ruleset-deletevalid-headers-body"/>  
                    <rule> 
                        <ruleId value="assertContentTypeMimeTypeIfBody"/>  
                        <param> 
                            <name value="headerExpectedValue"/>  
                            <value value="application/fhir+json"/> 
                        </param> 
                    </rule> 
                </ruleset>  
                <warningOnly value="false"/> 
            </assert> 
        </action> 
    </test> 
</TestScript>