Test Script

Name/FHIR4-0-0-Connectathon23/Patient-02-Formal/FHIRServer/01-RegisterPatient/patient-formal-c23-fhirserver-01-register-server-id-json
DescriptionPatient Track - Formal Testing - tests FHIR Server using the JSON format to register (create) a Patient resource instance where the server assigns the resource id. The destination server must support the create (POST) operation, search operation and conditional delete to insure the Patient resource does not exist or is removed prior to test execution.
Version2Latest2
Content
<?xml version="1.0" encoding="UTF-8"?>

<TestScript xmlns="http://hl7.org/fhir">  
    <id value="patient-formal-c23-fhirserver-01-register-server-id-json"/>  
    <meta> 
        <profile value="http://touchstone.aegis.net/touchstone/fhir/testing/StructureDefinition/testscript"/> 
    </meta>  
    <text> 
        <status value="generated"/>  
        <div xmlns="http://www.w3.org/1999/xhtml">
            <p>FHIR Connectathon 23 - Patient - Formal Testing - FHIR Server - Register - Server Assigned Resource Id - JSON</p>
        </div> 
    </text>  
    <extension url="http://touchstone.aegis.net/touchstone/fhir/testing/StructureDefinition/testscript-ruleset"> 
        <extension url="rulesetId"> 
            <valueId value="ruleset-versioning-headers"/> 
        </extension>  
        <extension url="path"> 
            <valueString value="/FHIRCommon/_reference/ruleset/RuleSet-VersioningHeaders-Groovy.xml"/> 
        </extension>  
        <extension url="rule"> 
            <extension url="ruleId"> 
                <valueId value="assertETagIfSupported"/> 
            </extension>  
            <extension url="param"> 
                <extension url="name"> 
                    <valueString value="resource"/> 
                </extension>  
                <extension url="value"> 
                    <valueString value="Patient"/> 
                </extension> 
            </extension> 
        </extension>  
        <extension url="rule"> 
            <extension url="ruleId"> 
                <valueId value="assertLastModifiedIfSupported"/> 
            </extension>  
            <extension url="param"> 
                <extension url="name"> 
                    <valueString value="resource"/> 
                </extension>  
                <extension url="value"> 
                    <valueString value="Patient"/> 
                </extension> 
            </extension> 
        </extension> 
    </extension>  
    <extension url="http://touchstone.aegis.net/touchstone/fhir/testing/StructureDefinition/testscript-ruleset"> 
        <extension url="rulesetId"> 
            <valueId value="ruleset-createok-headers-body"/> 
        </extension>  
        <extension url="path"> 
            <valueString value="/FHIRCommon/_reference/ruleset/RuleSet-CreateOkHeadersBody-Groovy.xml"/> 
        </extension>  
        <extension url="rule"> 
            <extension url="ruleId"> 
                <valueId value="assertContentTypeIfBody"/> 
            </extension> 
        </extension>  
        <extension url="rule"> 
            <extension url="ruleId"> 
                <valueId value="assertContentTypeCharsetIfBody"/> 
            </extension> 
        </extension>  
        <extension url="rule"> 
            <extension url="ruleId"> 
                <valueId value="assertResourceTypesIfBody"/> 
            </extension>  
            <extension url="param"> 
                <extension url="name"> 
                    <valueString value="resource"/> 
                </extension>  
                <extension url="value"> 
                    <valueString value="Patient,OperationOutcome"/> 
                </extension> 
            </extension> 
        </extension>  
        <extension url="rule"> 
            <extension url="ruleId"> 
                <valueId value="assertProfileIfOperationOutcome"/> 
            </extension>  
            <extension url="param"> 
                <extension url="name"> 
                    <valueString value="validateProfileId"/> 
                </extension>  
                <extension url="value"> 
                    <valueString value="operationoutcome-profile"/> 
                </extension> 
            </extension> 
        </extension>  
        <extension url="rule"> 
            <extension url="ruleId"> 
                <valueId value="assertProfileIfResource"/> 
            </extension>  
            <extension url="param"> 
                <extension url="name"> 
                    <valueString value="resource"/> 
                </extension>  
                <extension url="value"> 
                    <valueString value="Patient"/> 
                </extension> 
            </extension>  
            <extension url="param"> 
                <extension url="name"> 
                    <valueString value="validateProfileId"/> 
                </extension>  
                <extension url="value"> 
                    <valueString value="patient-profile"/> 
                </extension> 
            </extension> 
        </extension> 
    </extension>  
    <url value="http://wildfhir.aegis.net/fhir4-0-0/TestScript/patient-formal-c23-fhirserver-01-register-server-id-json"/>  
    <name value="FHIRC23PatientServerRegisterJSONServerd"/>  
    <title value="FHIR Connectathon 23 - Patient - Formal Testing - FHIR Server - Register - Server Assigned Resource Id - JSON"/>  
    <status value="active"/>  
    <date value="2020-01-23"/>  
    <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="Patient Track - Formal Testing - tests FHIR Server using the JSON format to register (create) a Patient resource instance where the server assigns the resource id. The destination server must support the create (POST) operation, search operation and conditional delete to insure the Patient resource does not exist or is removed prior to test execution."/>  
    <copyright value="(c) AEGIS.net, Inc. 2019"/>  
    <fixture id="patient-create"> 
        <autocreate value="false"/>  
        <autodelete value="false"/>  
        <resource> 
            <reference value="../_reference/resources/patient-create-server-id.json"/> 
        </resource> 
    </fixture>  
    <profile id="operationoutcome-profile"> 
        <reference value="http://hl7.org/fhir/StructureDefinition/OperationOutcome"/> 
    </profile>  
    <profile id="bundle-profile"> 
        <reference value="http://hl7.org/fhir/StructureDefinition/Bundle"/> 
    </profile>  
    <profile id="patient-profile"> 
        <reference value="http://hl7.org/fhir/StructureDefinition/Patient"/> 
    </profile>  
    <variable> 
        <name value="patientIdentifier"/>  
        <path value="Patient/identifier/value"/>  
        <sourceId value="patient-create"/> 
    </variable>  
    <variable> 
        <name value="patientFamilyName"/>  
        <path value="Patient/name/family"/>  
        <sourceId value="patient-create"/> 
    </variable>  
    <variable> 
        <name value="patientGivenName"/>  
        <path value="Patient/name/given"/>  
        <sourceId value="patient-create"/> 
    </variable>  
    <variable> 
        <name value="patientGender"/>  
        <path value="Patient/gender"/>  
        <sourceId value="patient-create"/> 
    </variable>  
    <variable> 
        <name value="patientBirthDate"/>  
        <path value="Patient/birthDate"/>  
        <sourceId value="patient-create"/> 
    </variable>  
    <setup> 
        <action> 
            <operation> 
                <type> 
                    <system value="http://terminology.hl7.org/CodeSystem/testscript-operation-codes"/>  
                    <code value="delete"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="System-generated search and delete operations from conditional delete on patient name to insure the patient does not exist on the server."/>  
                <accept value="json"/>  
                <encodeRequestUrl value="true"/>  
                <params value="?given=${patientGivenName}&amp;family=${patientFamilyName}"/> 
            </operation> 
        </action>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://terminology.hl7.org/CodeSystem/testscript-operation-codes"/>  
                    <code value="delete"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="System-generated search and delete operations from conditional delete on patient identifier to insure the patient does not exist on the server."/>  
                <accept value="json"/>  
                <encodeRequestUrl value="true"/>  
                <params value="?identifier=${patientIdentifier}"/> 
            </operation> 
        </action> 
    </setup>  
    <test id="01-RegisterNewPatient"> 
        <name value="RegisterNewPatient"/>  
        <description value="Create a new patient, no extensions where the client assigns the resource id using JSON. The expected response is 201 (Created). The expected response content is the created Patient resource in JSON format. An OperationOutcome or empty response is also allowed."/>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://terminology.hl7.org/CodeSystem/testscript-operation-codes"/>  
                    <code value="create"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="Create patient with server assigned resource id."/>  
                <accept value="json"/>  
                <contentType value="json"/>  
                <encodeRequestUrl value="true"/>  
                <sourceId value="patient-create"/> 
            </operation> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned HTTP status is 200(OK) or 201(Created)."/>  
                <direction value="response"/>  
                <operator value="in"/>  
                <responseCode value="200,201"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <extension url="http://touchstone.aegis.net/touchstone/fhir/testing/StructureDefinition/testscript-assert-ruleset"> 
                    <extension url="rulesetId"> 
                        <valueId value="ruleset-versioning-headers"/> 
                    </extension> 
                </extension>  
                <description value="Complex ruleset assertion to conditionally validate expected versioning HTTP Headers."/>  
                <direction value="response"/>  
                <warningOnly value="true"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <extension url="http://touchstone.aegis.net/touchstone/fhir/testing/StructureDefinition/testscript-assert-ruleset"> 
                    <extension url="rulesetId"> 
                        <valueId value="ruleset-createok-headers-body"/> 
                    </extension>  
                    <extension url="rule"> 
                        <extension url="ruleId"> 
                            <valueId value="assertContentTypeMimeTypeIfBody"/> 
                        </extension>  
                        <extension url="param"> 
                            <extension url="name"> 
                                <valueString value="headerExpectedValue"/> 
                            </extension>  
                            <extension url="value"> 
                                <valueString value="application/fhir+json"/> 
                            </extension> 
                        </extension> 
                    </extension> 
                </extension>  
                <description value="Complex ruleset assertion to conditionally validate expected create ok response HTTP Headers and body."/>  
                <direction value="response"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <operation> 
                <type> 
                    <system value="http://terminology.hl7.org/CodeSystem/testscript-operation-codes"/>  
                    <code value="search"/> 
                </type>  
                <resource value="Patient"/>  
                <description value="Search for the created patient by the unique patient identifier, family and given names and validate contents."/>  
                <accept value="json"/>  
                <encodeRequestUrl value="true"/>  
                <params value="?identifier=${patientIdentifier}&amp;given=${patientGivenName}&amp;family=${patientFamilyName}"/> 
            </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 format is the FHIR JSON format. Warning only to allow for review."/>  
                <direction value="response"/>  
                <contentType value="json"/>  
                <warningOnly value="true"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned resource type is Bundle."/>  
                <direction value="response"/>  
                <resource value="Bundle"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Validate that the returned resource conforms to the base FHIR Bundle profile."/>  
                <direction value="response"/>  
                <validateProfileId value="bundle-profile"/>  
                <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; however, the first entry is expected to contain the created Patient."/>  
                <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>  
        <action> 
            <assert> 
                <description value="Confirm that the returned resource contains the expected retained identifier element and value."/>  
                <direction value="response"/>  
                <operator value="contains"/>  
                <path value=".entry[0].resource.identifier[0].value"/>  
                <value value="${patientIdentifier}"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned resource contains the expected retained family name element and value."/>  
                <direction value="response"/>  
                <operator value="contains"/>  
                <path value=".entry[0].resource.name[0].family"/>  
                <value value="${patientFamilyName}"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned resource contains the expected retained birthDate element and value."/>  
                <direction value="response"/>  
                <operator value="contains"/>  
                <path value=".entry[0].resource.birthDate"/>  
                <value value="${patientBirthDate}"/>  
                <warningOnly value="false"/> 
            </assert> 
        </action>  
        <action> 
            <assert> 
                <description value="Confirm that the returned resource contains the expected retained elements and values. Warning only to allow for review."/>  
                <direction value="response"/>  
                <minimumId value="patient-create"/>  
                <warningOnly value="true"/> 
            </assert> 
        </action> 
    </test> 
</TestScript>