This page describes how to embed 'fragments' of a resource within a page, possibly ellipsing out portions of the instance to only show the portions that are relevant to what the surrounding text needs to talk about.
To embed content from an instance, use the following structure:
{% raw %}{% fragment ResourceType/id syntax %}{% endraw %}
where:
ResourceType is 'Patient', 'Observation', etc. For a logical model instance, this will be 'Binary'.id is the unique resource id of the resource within the IG.syntax is either 'XML' or 'JSON'. (TTL is not yet supported.)For example, {% raw %}{% fragment Patient/example XML %}{% endraw %} in this IG evaluates to
However, often examples can be somewhat sizeable and you don't necessarily want to include the entire example in the flow of your narrative - you only need a portion. To filter to a limited portion of the specified resource, you need to declare a 'base' element within that resource that will be included as your fragment. The 'base' is expressed as a FHIRPath expression evaluated against the root of the resource.
For example, {% raw %}{% fragment Patient/example JSON BASE:name.where(use='usual') %}{% endraw %} will result in the following:
Sometimes you want to perform more filtering than only selecting an element within your instance. You want to only show a portion of that element, hiding (ellipsing) the content you don't care about. There are two ways to do this: you can either define the specific elements you want to ellipse; or you can define the elements you don't want to ellipse.
The 'ELLIPSE:' filter can only be specified once, but with FHIRPath '|', you can express as many elements as you like. For example, {% raw %}{% fragment Patient/example XML BASE:name.where(use='official').first() ELLIPSE:use|given[1]|period %}{% endraw %} will look like this:
'EXCEPT:' works slightly differently. With Except you identify the elements to retain (be unellipsed) but you can also specify a descendant 'BASE:' element those expressions are evaluated within. For example, the following expression will return the patient showing only id an names, and within name, will ellipse everything except the family name: {% raw %}{% fragment Patient/example XML EXCEPT:id|name EXCEPT:family BASE:name %}{% endraw %}
The overall syntax for fragments is as follows:
{% raw %}{% fragment [resource]/[id] [XML|JSON] (BASE:[base FHIRPath])? (ELLIPSE:[ellipse elements path])? (EXCEPT:[except elements FHIRPath] (BASE:[except base FHIRPath])?)* %}{% endraw %}