FHIR Application Feature Framework Implementation Guide, published by HL7 International / FHIR Infrastructure. This guide is not an authorized publication; it is the continuous build for version 1.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/capstmt/ and changes regularly. See the Directory of published versions
Page standards status: Informative |
Welcome to the FHIR Application Feature Framework.
A Feature is a software behavior that applications may choose to implement, or be required to implement, where the existence (or not) of the behavior it describes changes the behavior of other actors in the ecosystem. Features may be software behaviors that are directly related to FHIR based interoperability, such as "forces version-aware updates on resources", or they may be more general - such as "passes a testing protocol" (potentially defined using a TestScript - or they may relate to the user interface/experience, such as "the interface complies to [some named national specification]".
There is no scope limitation to the kinds of features that might be described, but the intent of this features framework is to describe software behaviors that affect participants in the ecosystem of FHIR exchange.
Features are defined using FeatureDefinitions. This is a logical structure that looks a lot like a FHIR resource (and may become one in a future version of the FHIR specification). The important parts of the FeatureDefintion are:
{
"resourceType" : "FeatureDefinition",
"id" : "FeatureSupport",
"url" : "http://hl7.org/fhir/uv/application-feature/FeatureDefinition/FeatureSupport",
"name" : "ApplicationFeatureSupport",
"status" : "active",
"description" : "This feature is used to report conformance/support of a particular version of the Feature Framework. The value is a code which is the most recent version of the framework supported",
"valueType" : "code",
"context" : [
🔗 "http://hl7.org/fhir/StructureDefinition/CapabilityStatement#CapabilityStatement"
]
}
and in xml
<FeatureDefinition xmlns="http://hl7.org/fhir">
<id value="FeatureSupport"/>
<url
value="http://hl7.org/fhir/uv/application-feature/FeatureDefinition/FeatureSupport"/>
<name value="ApplicationFeatureSupport"/>
<status value="active"/>
<description
value="This feature is used to report conformance/support of a particular version of the Feature Framework. The value is a code which is the most recent version of the framework supported"/>
<valueType value="code"/>
<context
value="http://hl7.org/fhir/StructureDefinition/CapabilityStatement#CapabilityStatement"/>
</FeatureDefinition>
The Application Feature Framework only defines one actual feature: FeatureSupport, which declares the most recent version of the feature framework that the application supports. This feature is used by applications to declare that they support the application feature framework at the root of their capability statement.
Applications can implement some of all of this specification without declaring that they support the application feature framework, but if they do declare that it is supported, they SHALL support the following functionality:
Note: clients can query for features without first checking for FeatureSupport, understanding that if the target server or application does not support this framework, the response(s) will not conform to those detailed in this specification.
Features are declared in an extension. Each Feature is a pair: a code that identifies of which features is being described, and a value for that feature.
"extension" : [{
"url" : "http://hl7.org/fhir/uv/application-feature/StructureDefinition/feature",
"extension" : [{
"url" : "definition",
"valueCanonical" : "http://hl7.org/fhir/uv/application-feature/FeatureDefinition/FeatureSupport"
},{
"url" : "value",
"valueCode" : "1.0.0"
}]
}]
or in xml:
<extension url="http://hl7.org/fhir/uv/application-feature/StructureDefinition/feature">
<extension url="definition">
<valueCanonical value="http://hl7.org/fhir/uv/application-feature/FeatureDefinition/FeatureSupport"/>
</extension>
<extension url="value">
<valueCode value="1.0.0"/>
</extension>
</extension>
The feature extension can appear in any resource, on any element, but in practice, it's only allowed
to appear on the element contexts allowed in the Feature Definition. For example, the feature definition
for Feature says that it appears
on the root element of the CapabilityStatement resource (http://hl7.org/fhir/StructureDefinition/CapabilityStatement#CapabilityStatement
):
{
"resourceType" : "CapabilityStatement",
"id" : "something",
"extension" : [{
"url" : "http://hl7.org/fhir/uv/application-feature/StructureDefinition/feature",
"extension" : [{
"url" : "definition",
"valueCanonical" : "http://hl7.org/fhir/uv/application-feature/FeatureDefinition/FeatureSupport"
},{
"url" : "value",
"valueCode" : "1.0.0"
}]
}]
or in xml:
<CapabilityStatement xmlns="http://hl7.org/fhir">
<id value="something"/>
<extension url="http://hl7.org/fhir/uv/application-feature/StructureDefinition/feature">
<extension url="definition">
<valueCanonical value="http://hl7.org/fhir/uv/application-feature/FeatureDefinition/FeatureSupport"/>
</extension>
<extension url="value">
<valueCode value="1.0.0"/>
</extension>
</extension>
</CapabilityStatement>
Features defined inside the capability statement automatically have an implied scope, but are otherwise the same statement.
Here is an example of a feature defined for all resources available via REST:
<CapabilityStatement xmlns="http://hl7.org/fhir">
<rest>
<extension url="http://hl7.org/fhir/uv/application-feature/StructureDefinition/feature">
<extension url="code">
<valueCanonical value="http://hl7.org/fhir/uv/application-feature/CodeSystem/feature-versioning"/>
</extension>
<extension url="value">
<valueCode value="versioned-update"/>
</extension>
</extension>
</rest>
</CapabilityStatement>
Here is the same feature only defined on CodeSystem:
<CapabilityStatement xmlns="http://hl7.org/fhir">
<rest>
<resource>
<type value="CodeSystem"/>
<extension url="http://hl7.org/fhir/uv/application-feature/StructureDefinition/feature">
<extension url="code">
<valueCanonical value="http://hl7.org/fhir/uv/application-feature/CodeSystem/feature-versioning"/>
</extension>
<extension url="value">
<valueCode value="versioned-update"/>
</extension>
</extension>
</resource>
</rest>
</CapabilityStatement>
Note, however, that the feature scopes are not restricted to the contexts implied by the structure of the FeatureCapabilityStatement profile. Feature contexts are defined for features that are deeper into the system than those defined by the FeatureCapabilityStatement profile.
In general, default CapabilityStatements returned from the /metadata
endpoint do not include
Feature assertions (other then possibly the FeatureFramework Feature itself), though specific features or
other implementation guides may require that features are populated in the CapabilityStatement by default.
For other CapabilityStatements - e.g. those produced to store in registries as static copies, it is at the
discretion of the application to decide how much to populate the CapabilityStatement with the applicable
features.
When an application fetches
up to here….
General Patterns
Responses
By default, when a client asks a server for it's capability statement using /metadata, which features to report on is at the discretion of the server. Typically, servers will not report any features by default. Features can be queried by search parameter or via an operation.
Features are identified by an expression that includes the scope in which the feature is being asserted. Here's some examples:
The full details of the expression format are described below.
Clients interacting with a FHIR server that supports this implementation guide SHOULD NOT download entire CapabilityStatement resources, since they may be many megabytes in size. Clients should instead use the FeatureQuery operation or the Required-Features HTTP header to determine if the server supports needed features.
Clients can query servers about the features they support using the FeatureQuery operation.
General Patterns
Responses
By default, when a client asks a server for it's capability statement using /metadata, which features to report on is at the discretion of the server. Typically, servers will not report any features by default. Features can be queried via the FeatureQuery operation using an HTTP GET or POST, or via an HTTP header.
Clients can request that a server by using GET as follows:
GET [base]/$feature-query?feature[@context](value)
For example, here is how you would ask if the Patient resource has read access:
GET [base]/$feature-query?param=read@Patient(true)
Requesting multiple features:
GET [base]/$feature-query?param=read@Patient(true)¶m=update@Patient(true)
TBD: add example in/out params and explain invoking them in a POST
Clients can use HTTP POST with a Parameters resource to query for features. The following example shows how to use POST to check if a server supports this feature framework:
POST [base]/$feature-query
An instance of Feature Query Input Parameters would be the body of this POST.
JSON example:
{
"resourceType" : "Parameters",
"id" : "FeatureQueryInputParametersExample",
"meta" : {
"profile" : [
🔗 "http://hl7.org/fhir/uv/application-feature/StructureDefinition/FeatureQueryInputParameters"
]
},
"parameter" : [
{
"name" : "feature",
"part" : [
{
"name" : "definition",
"valueCanonical" : "http://hl7.org/fhir/uv/application-feature/StructureDefinition/FeatureSupport"
},
{
"name" : "value",
"valueCode" : "1.0.0"
}
]
}
]
}
XML example:
<Parameters xmlns="http://hl7.org/fhir">
<id value="FeatureQueryInputParametersExample"/>
<meta>
<profile value="http://hl7.org/fhir/uv/application-feature/StructureDefinition/FeatureQueryInputParameters"/>
</meta>
<parameter>
<name value="feature"/>
<part>
<name value="definition"/>
<valueCanonical value="http://hl7.org/fhir/uv/application-feature/StructureDefinition/FeatureSupport"/>
</part>
<part>
<name value="value"/>
<valueCode value="1.0.0"/>
</part>
</parameter>
</Parameters>
The resulting output paramater is an instance of Feature Query Output Parameters.
JSON example
{
"resourceType" : "Parameters",
"id" : "FeatureQueryOutputParametersExample",
"meta" : {
"profile" : [
🔗 "http://hl7.org/fhir/uv/application-feature/StructureDefinition/FeatureQueryOutputParameters"
]
},
"parameter" : [
{
"name" : "feature",
"part" : [
{
"name" : "definition",
"valueCanonical" : "http://hl7.org/fhir/uv/application-feature/StructureDefinition/FeatureSupport"
},
{
"name" : "value",
"valueCode" : "1.0.0"
},
{
"name" : "answer",
"valueBoolean" : true
},
{
"name" : "processing-status",
"valueCode" : "all-ok"
}
]
}
]
}
XML example
<Parameters xmlns="http://hl7.org/fhir">
<id value="FeatureQueryOutputParametersExample"/>
<meta>
<profile
value="http://hl7.org/fhir/uv/application-feature/StructureDefinition/FeatureQueryOutputParameters"/>
</meta>
<parameter>
<name value="feature"/>
<part>
<name value="definition"/>
<valueCanonical
value="http://hl7.org/fhir/uv/application-feature/StructureDefinition/FeatureSupport"/>
</part>
<part>
<name value="value"/>
<valueCode value="1.0.0"/>
</part>
<part>
<name value="answer"/>
<valueBoolean value="true"/>
</part>
<part>
<name value="processing-status"/>
<valueCode value="all-ok"/>
</part>
</parameter>
</Parameters>
Alternatively, a client can include a feature assertion on an HTTP header:
GET [base]/Patient/23/_history/45
Required-Features: param=read@Patient(true)
The server checks the header, and returns a 501 Not implemented if it does not support reading historical entries for Patient.
Clients can only expect a server to check these headers if the server declares that it does using the feature rest:server.feature-header = true.
While there are two mechanisms to check for feature support (HTTP header and the $feature-query operation), these mechanisms have different purposes. The HTTP header approach will limit whether the requested HTTP action will be performed based on whether the specified feature(s) are supported, while the $feature-query operation acts as a query that returns what features the system supports.
It is important to note that the characters @, *, and () are not allowed in the code, context, or value in a GET or while using the Required-Features header, since this would lead to ambiguous parsing. If an implementer's use case requires those characters, then only POST with a Parameters resource is allowed.
The $feature-query operation and Required-Features header MAY take into account authorization. For example, if querying for features when unauthorized, a server may choose to only expose those features available to unauthorized clients, while if querying when authenticated, those features that are available to the authenticated client are returned. If no access is allowed for an unauthorized user, the $feature-query operation SHALL return a processing status of unauthorized in the return parameter.