-
Notifications
You must be signed in to change notification settings - Fork 26
FHIR Test Plan support
The test client FHIR support includes transaction for CREATE, READ, and SEARCH. Here we show the support code and examples.
Much of the flexibility of the test client is in the Report/UseReport (Pub/Sub) model for sharing values between transaction executions. One thing 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 (some of these are slight extensions to the FHIR spec):
Base Address - The URL root of a FHIR server 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 instance. 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. This is the URL you can use in an HTTP GET to read the resource instance.
In the Report/UseReport documentation below, these terms are used. Specifically, the names (with examples) are:
-
Base - address of a server - http://example.com/fhir
-
Base_Type - combination of Base + resource type - http://example.com/fhir/Patient
-
Type_ID - combination of resource type and resource id - Patient/1
-
Ref - reference to a resource instance - Base + Type_ID - http://example.com/fhir/Patient/1
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.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="Base_Type">http://localhost:8889/xdstools2/fsim/bill__myfhirsys/Patient</Report>
<Report name="Type_ID">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 - FHIR server Base address
-
Report Base_Type - the URL the request was sent to (since this is a CREATE operation)
-
Report Type_ID - the type and ID returned from the FHIR server (in the Location HTTP Header) - 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.
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.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="Ref">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 Ref - 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.
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="Ref" useAs="Ref"/>
<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="Ref" - this is a required UseReport that provides the URL to
Toolkit
Downloads
Installing Toolkit
Configuring Toolkit for Imaging Tests
Reporting Toolkit Installation Problems
Environment
Test Session
Conformance Test Tool
Writing Conformance Tests
Overview of Imaging Tests
Test Context Definition
Launching Conformance Tool from Gazelle
Inspector
External Cache
Support Tools
Test Organization
Configuring Test Kits
Managing Multiple Test Kits
SAML Validation against Gazelle
Renaming Toolkit
Toolkit API
Managing system configurations
Configuring Toolkit for Connectathon
Developer's blog