Repository navigation
Example Simple Extension
chrisgrenz edited this page Apr 26, 2016
·
1 revision
Adding a single extension to a resource.
Standard disclaimer: These extensions are contrived for the purpose of illustrating syntax. DO NOT assume that the content exists or is useful in any particular context!
<Patient xmlns="http://hl7.org/fhir">
...snip...
<!-- Add a "Do Not Call" flag to a Patient record. -->
<extension url="http://example.com/fhir/StructureDefinition/patient-do-not-call">
<valueBoolean value="false"/>
</extension>
...snip...An extension profile
- Extends the HL7 Extension type
- Fixes all url elements (Element.url and any sub-element element.url paths)
- Constrains as appropriate the value[x] element
The differential (what's different from Extension):
<differential>
<element>
<path value="Element.url" />
<fixedUri value="http://example.com/fhir/StructureDefinition/patient-do-not-call" />
</element>
<element>
<path value="Element.value[x]" />
<!-- Require the value if desired. -->
<min value="1" />
<!-- Limit the value type to boolean -->
<type>
<code value="boolean" />
</type>
</element>
</differential>The extension can then be added to a profile as a known/expected extension. This is as simple as adding a slice of extension to the profile.
When adding an extension to the profile:
- Assign a name to the extension (as a named slice of extension).
- Constrain the type of the profile to the extension profile (using the extension profile's URI)
There is no need to add an additional information to the resource profile - the value[x] and/or any sub-extension will be pulled in from the extension profile.
<differential>
<element>
<path value="Patient.extension" />
<name value="doNotCall" />
<type>
<code value="Extension" />
<profile value="http://example.com/fhir/StructureDefinition/patient-do-not-call" />
</type>
</element>
</differential>