Skip to content

FHIR Test Plan support

Bill Majurski edited this page Jul 13, 2017 · 8 revisions

FHIR Test Plan Support

The test client FHIR support includes transaction for CREATE, READ, and SEARCH. Here we show the support code and examples.

Introduction

Much of the flexibility of the test client is in the Report/UseReport (Pub/Sub) model for sharing values between transaction executions. One this that is new with the adaption of test client to FHIR is that FHIR has some standardized naming for the things we need to pass around using Report/UseReport.

As a reference, the HTML reference page of the FHIR spec can be handy.

FHIR defines the following concepts which we will use:

Base Address - The root of the URL described as http(s)://server{/path}

Base with type - Resource Manager - All the interactions for a type of resource go here. This adds the resource name to the base address as in https://server/path/Patient where https://server/path is the base address and Patient is the resource type. In toolkit (with the inclusion of HAPI) it is the ResourceProvider class that implements the Resource Manager.

Type_ID - this is not specifically called out as a type in the spec, but the idea of identifying a resource instance by the combination of resource type and the ID within that type is prevalent in FHIR. Many FHIR examples reference Patient/1 which is the Patient resource with assigned ID of 1. This is the server independent name of a resource instance. (Obviously if you preface it with the Base Address it is then server specific). Within Toolkit source code this type is represented by the class FhirId.

Ref - FHIR talks frequently about a reference to a resource. This is the URL of an instance of a type of resource. Using the above definitions this is Base_Address + Type_ID. A typical example is http://example.com/fhir/Patient/1.

In the Report/UseReport documentation below, these terms are used. Specifically, the names (with examples) are:

CREATE

TestPlan

A FHIR CREATE testplan looks like

    <TestPlan>
      <Test>FhirTestClientCreate/create</Test>
      <TestStep id="create">
        <ExpectedStatus>Success</ExpectedStatus>
        <FhirCreateTransaction>
            <ResourceFile>patient.json</ResourceFile>
            <UrlExtension>/Patient</UrlExtension>
        </FhirCreateTransaction>
      </TestStep>
  </TestPlan>
  • Test element - the value MUST be test-name/section-name

  • FHirCreateTransaction - this runs the FHIR CREATE transaction

  • ResourceFile - a JSON coded resource in the section directory (same directory as the testplan.xml file shown). The CREATE operation can only encode a single resource so there is only one file and it only contains a single resource. At the moment we only support JSON coding.

  • UrlExtension - the FHIR server URL is composed of two parts - the Base Url (for the entire server) followed by a slash ('/') and then then name of the resource type (Patient). UrlExtension is appended to the Base Url when creating the URL to use in the request.

Log File

log.xml looks like

<TestResults status="Pass">
   <Time>20170711134519.861</Time>
   <Site>bill__myfhirsys</Site>
   <Xdstest2_version/>
   <Xdstest2_args/>
   <testkit_version/>
   <Test>FhirTestClientCreate/create</Test>
   <TestStep id="create" status="Pass">
      <ExpectedStatus>Success</ExpectedStatus>
      <FhirCreateTransaction step="create">
         <ResourceFile>/Users/bill/git/iheos-toolkit2/it-tests/target/test-classes/war/toolkitx/testkit/tests/FhirTestClientCreate/create/patient.json</ResourceFile>
         <Endpoint>http://localhost:8889/xdstools2/fsim/bill__myfhirsys</Endpoint>
         <AssignedPatientId/>
         <AssignedUids/>
         <AssignedSourceId/>
         <Reports>
            <Report name="Url">http://localhost:8889/xdstools2/fsim/bill__myfhirsys/Patient</Report>
            <Report name="FhirId">Patient/50c105f4-de23-4f01-9102-eb35cad4466f</Report>
            <Report name="Ref">http://localhost:8889/xdstools2/fsim/bill__myfhirsys/Patient/50c105f4-de23-4f01-9102-eb35cad4466f</Report>
         </Reports>
      </FhirCreateTransaction>
      <Assertions>
         <CompiledAssertion>[]</CompiledAssertion>
         <RawAssertionData>
            <Data/>
         </RawAssertionData>
         <AssertionCount>0</AssertionCount>
      </Assertions>
   </TestStep>
</TestResults>
  • Endpoint - the FHIR Server Base URL used

  • Report Url - the URL the request was sent to

  • Report FhirId - the ID returned from the FHIR server - this is the ID that was assigned to the resource by the server

  • Report Ref - URL reference to the resource on the FHIR server. This is the value returned by the CREATE operation in the Location Header with the version information, if present, removed. This value can be used in an HTTP GET to retrieve the contents of the resource.

READ

TestPlan

A FHIR READ testplan looks like

<TestPlan>
    <Test>FhirTestClientCreate/read</Test>
    <TestStep id="read">
        <ExpectedStatus>Success</ExpectedStatus>
        <FhirReadTransaction>
            <UseReport test="FhirTestClientCreate" section="create" step="create" reportName="Ref" useAs="Ref"/>
        </FhirReadTransaction>
    </TestStep>
</TestPlan>
  • Test element - the value MUST be test-name/section-name

  • FhirReadTransaction - this runs the FHIR READ transaction

  • UseReport - useAs="Ref" - a UseReport with useAs="Ref" is required. The test, section, step, and reportName attributes point to the Report generated by a CREATE transaction which always generates a reportName="Ref" output. This statement links a READ operation back to the CREATE operation. This way the resource reference (the whole point of this UseReport) can be used to execute the READ operation. The name "Ref" in useAs="Ref" is required.

Log File

log.xml looks like

<TestResults status="Pass">
   <Time>20170711134521.141</Time>
   <Site>bill__myfhirsys</Site>
   <Xdstest2_version/>
   <Xdstest2_args/>
   <testkit_version/>
   <Test>FhirTestClientCreate/read</Test>
   <TestStep id="read" status="Pass">
      <ExpectedStatus>Success</ExpectedStatus>
      <FhirReadTransaction step="read">
         <Endpoint>http://localhost:8889/xdstools2/fsim/bill__myfhirsys</Endpoint>
         <UseReports>
            <UseReport test="FhirTestClientCreate"
                  section="create" step="create" reportName="Ref"
                  useAs="Ref" value="http://localhost:8889/xdstools2/fsim/bill__myfhirsys/Patient/50c105f4-de23-4f01-9102-eb35cad4466f"/>
         </UseReports>
         <AssignedPatientId/>
         <AssignedUids/>
         <AssignedSourceId/>
         <Result>FULL JSON CONTENT PLACED HERE - REMOVED FOR EXAMPLE</Result>
         <Reports>
            <Report name="Url">http://localhost:8889/xdstools2/fsim/bill__myfhirsys/Patient/50c105f4-de23-4f01-9102-eb35cad4466f</Report>
         </Reports>
      </FhirReadTransaction>
      <Assertions>
         <CompiledAssertion>[]</CompiledAssertion>
         <RawAssertionData>
            <Data/>
         </RawAssertionData>
         <AssertionCount>0</AssertionCount>
      </Assertions>
   </TestStep>
</TestResults>
  • Report Url - the URL used in the READ operation.

  • Result - the full JSON representation returned. Here we have removed that content to make the rest of the example readable.

TestPlan

A FHIR SEARCH testplan looks like

<TestPlan>
    <Test>FhirTestClientCreate/query</Test>
    <TestStep id="query">
        <ExpectedStatus>Success</ExpectedStatus>
        <FhirQueryTransaction>
            <UseReport test="FhirTestClientCreate" section="create" step="create" reportName="Url" useAs="Url"/>
            <QueryParams>?family=Chalmers</QueryParams>
        </FhirQueryTransaction>
    </TestStep>
</TestPlan>
  • Test element - the value MUST be test-name/section-name

  • FhirQueryTransaction - this runs the FHIR SEARCH transaction

  • UseReport useAs="Url" - this is a required UseReport that provides the URL to

Clone this wiki locally