Test-Driven Development With FHIR

The following post is written by my colleague Peter Jordan – who was the HL7 New Zealand representative at the January Working Group Meeting in Orlando.

janct

While preparing for, and participating in, the recent FHIR Connectathon 11 held in Orlando, Florida, yet another benefit of FHIR’s implementer-friendly philosophy became apparent to me – the ability to facilitate Test-Driven Development (TDD).

TDD has been defined as “a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards.” Dating back to 2003, TDD is now considered by many developers to represent the state of their art – shining some much-needed light on the darkness might be another way of looking at it!

Having decided to register for the Terminology Services Track to put a nascent Terminology Server, built for my client Patients First Ltd, through its paces, I was able to locate a series of Test ValueSets and load them onto my Server before jetting to Orlando with test client in hand. The FHIR community had saved me the trouble of creating these resources myself and, for a bonus point, given me the benefit of refinements made in previous Connectathons, plus a list of the Operations to be executed against these artefacts – all clearly described, with examples galore, in the Terminology Service Section of the FHIR Specification.

Although many developers’ adoption of TDD is restricted to Unit Testing, it is actually applicable to any form of testing that can be injected into an agile-based project with iterative development cycles – including interoperability and conformance testing. Furthermore, it still allows the professional tester to be a developer’s best friend so, with this thought in mind, my first Connectathon task was to locate the representatives of Healthcare Information Exchange (HIE) compliance testing specialists, AEGIS .

Our relatively tall ships had collided on previous nights although, on this occasion, my smartphone overrode my body clock informing me that it was morning! Anyway, re-introductions over, I immediately posed the question…”I’d like to test my Terminology Server – what have you got for me” and received an instant response…the Touchstone Test Platform (Touchstone).

To precise the description that followed, this cloud-based tool provides highly-granular, professional-level, automated on-line testing with detailed reporting on both warnings and errors – using a set of pre-supplied test scripts and resources (covering, of course, all the Connectathon scenarios). “Sounds perfect, quick driving lesson please!” was my next request.

To their great credit, AEGIS was able to set up my account, provide a quick user tutorial and respond to issues (including one tiny glitch with a test script) throughout the day. In a room packed with over 120 participants, this was no mean feat! In the course the day, the Touchstone application threw both good and bad data at my server, highlighting a number of issues and weaknesses that necessitated three server upgrades. Post-Connectathon, from faraway New Zealand, I’ve continued to use Touchstone to re-run the full suite of tests after every published QA release of my Server and passed on suggestions and resources for additional tests. Like FHIR itself, this process is inclusive, engaging, productive and fun!

The tool itself is pretty easy to use with a pleasing user interface; the screenshot below gives a small flavour of “Touchstone Nirvana” – the tests all pass…

pic1.png

Now…most developers do not like to broadcast failures, and I’m no exception…but suffice to say there were more than a few on the day! However, I am happy to share a warning that details my various sins against the text element of a ValueSet.

pic2.png

Realistically, developers need to park their egos before logging into Touchstone: this Tool exposes your bugs and omissions – and that’s a good thing, right? It throws various combinations of good and bad data at a server, and demands that it be treated appropriately – strictly according to the specification. Generally speaking, developers write tests to prove that their software works – so-called “happy path” testing, whereas Touchstone place an equal, and compensating, importance on negative testing and – in all instances – supplies highly granular evidence to support its assertions, including full details of each request and response.

While any explanation of the inner workings of this wonderful tool is best left to its developers, one key aspect worth mentioning is the internal use of a FHIR Resource designed to aid its very purpose – the Testscript Resource. This Resource specifies a suite of tests against a FHIR server implementation to determine compliance against the FHIR specification. In other words, FHIR supplies a resource to test implementations – in a standardised way.

My parting thought is that FHIR’s almost native facilitation of the modern development methodology of TDD may well become one of its key value propositions. It also has the potential to close the HIE standards implementation “loop” by providing both standardisation and transparency to conformance testing processes. Adapting a fashionable FHIR slogan…“Build-Test-FHIR-Repeat”.

About David Hay
I'm an independent contractor working with a number of Organizations in the health IT space. I'm an HL7 Fellow, Chair Emeritus of HL7 New Zealand and a co-chair of the FHIR Management Group. I have a keen interest in health IT, especially health interoperability with HL7 and the FHIR standard. I'm the author of a FHIR training and design tool - clinFHIR - which is sponsored by InterSystems Ltd.

7 Responses to Test-Driven Development With FHIR

  1. FHIR is definitely opening up new patterns for integration. Admit to believing writing tests before the code as being an extra step but seeing much value in it now. I can now create a profile, create a test (including example code) and then pass this on to the developers (both application and integration developers).

    Should it be Profile-Test-Build-Repeat or FHIR-Red-Green-Refactor?

  2. I’d like to clarify that the Testing (http://build.fhir.org/testing.html) and TestingScript capabilities defined in the FHIR specification include the validate operation. This is defined in the TestScript as the assert element directive ‘validateProfileId’. The test engine we [AEGIS] have built into our Touchstone testing platform incorporates the FHIR Java RI ValidationEngine for each version of FHIR we support. You can see the output of a validateProfileId assert in the 2nd screen shot of Peter’s post.

    HTH

  3. jayashreesurnar says:

    hello David, can you please explain how can we load existing extensions in clinfhir like race, religion, ethnicity and use in patient profile.

    thank you.

    just for test, i have added the existing extension to patient profile and whenever i’m trying to create patient instance then it’s not displaying the newly added extension.

    • David Hay says:

      Hi Jayashree – can you tell me the server you used and the url (or id) of the extension definition and the profile? Also, how did you add it to the profile… cheers

  4. Ravindra says:

    Hi David, I am pretty new to it, can you share user guide for Touchstone Test Platform or redirect me in right direction. Thanks a lot in advance for your help.

Leave a Reply to David HayCancel reply

Discover more from Hay on FHIR

Subscribe now to keep reading and get access to the full archive.

Continue reading