Friday, January 13, 2017

Faking it with the FHIR Basic Resource

The FHIR team created the Basic resource to support extensibility.  It works great except that HAPI only supports one read() method for each resource, and sometimes you have more than one thing for which you need to extend basic. For my needs, I've been looking at Account and Transaction (representing either a payment or a charge).  So, how do I use Basic to implement these non-FHIR "resources".

What I finally worked out was to use a named operation.

With one set of operation parameters, the operation responds as for FHIR Read and is idempotent.
With another set of parameters, it responds as for a FHIR Search (and also is idempotent).
With another set it would respond as for Create/Update, where the distinction between Create and Update merely depends on whether the resource included in the POST/PUT contains an identifier or not.

This gives the user of the profiled Basic resource an experience that is pretty close to what they would get with a true FHIR Resource (and consequently makes it easier to adopt new resources that have been profiled in this fashion).



Post a Comment