This page is part of the FHIR Specification (v4.2.0: R5 Preview #1). The current version which supercedes this version is 5.0.0. For a full list of available versions, see the Directory of published versions . Page versions: R5 R4B R4
Vocabulary Work Group | Maturity Level: N | Normative (from v4.0.0) | Compartments: N/A |
This page has been approved as part of an ANSI standard. See the Conformance Package for further details. |
The definition of a value set is used to create a simple collection of codes suitable for use for data entry or validation.
If the operation is not called at the instance level, one of the in parameters url, context or valueSet must be provided. An expanded value set will be returned, or an OperationOutcome with an error message.
The official URL for this operation definition is
http://hl7.org/fhir/OperationDefinition/ValueSet-expand
Formal Definition (as a OperationDefinition).
URL: [base]/ValueSet/$expand
URL: [base]/ValueSet/[id]/$expand
This is an idempotent operation
In Parameters: | |||||
Name | Cardinality | Type | Binding | Profile | Documentation |
url | 0..1 | uri | A canonical reference to a value set. The server must know the value set (e.g. it is defined explicitly in the server's value sets, or it is defined implicitly by some code system known to the server | ||
valueSet | 0..1 | ValueSet | The value set is provided directly as part of the request. Servers may choose not to accept value sets in this fashion | ||
valueSetVersion | 0..1 | string | The identifier that is used to identify a specific version of the value set to be used when generating the expansion. This is an arbitrary value managed by the value set author and is not expected to be globally unique. For example, it might be a timestamp (e.g. yyyymmdd) if a managed version is not available. | ||
context | 0..1 | uri | The context of the value set, so that the server can resolve this to a value set to expand. The recommended format for this URI is [Structure Definition URL]#[name or path into structure definition] e.g. http://hl7.org/fhir/StructureDefinition/observation-hspc-height-hspcheight#Observation.interpretation. Other forms may be used but are not defined. This form is only usable if the terminology server also has access to the conformance registry that the server is using, but can be used to delegate the mapping from an application context to a binding at run-time | ||
contextDirection | 0..1 | code | If a context is provided, a context direction may also be provided. Valid values are:
The purpose is to inform the server whether to use the value set associated with the context for reading or writing purposes (note: for most elements, this is the same value set, but there are a few elements where the reading and writing value sets are different) | ||
filter | 0..1 | string | A text filter that is applied to restrict the codes that are returned (this is useful in a UI context). The interpretation of this is delegated to the server in order to allow to determine the most optimal search approach for the context. The server can document the way this parameter works in TerminologyCapabilities..expansion.textFilter. Typical usage of this parameter includes functionality like:
Text Search engines such as Lucene or Solr, long with their considerable functionality, might also be used. The optional text search might also be code system specific, and servers might have different implementations for different code systems | ||
date | 0..1 | dateTime | The date for which the expansion should be generated. if a date is provided, it means that the server should use the value set / code system definitions as they were on the given date, or return an error if this is not possible. Normally, the date is the current conditions (which is the default value) but under some circumstances, systems need to generate an expansion as it would have been in the past. A typical example of this would be where code selection is constrained to the set of codes that were available when the patient was treated, not when the record is being edited. Note that which date is appropriate is a matter for implementation policy. | ||
offset | 0..1 | integer | Paging support - where to start if a subset is desired (default = 0). Offset is number of records (not number of pages) | ||
count | 0..1 | integer | Paging support - how many codes should be provided in a partial page view. Paging only applies to flat expansions - servers ignore paging if the expansion is not flat. If count = 0, the client is asking how large the expansion is. Servers SHOULD honor this request for hierarchical expansions as well, and simply return the overall count | ||
includeDesignations | 0..1 | boolean | Controls whether concept designations are to be included or excluded in value set expansions | ||
designation | 0..* | string | A token that specifies a system+code that is either a use or a language. Designations that match by language or use are included in the expansion. If no designation is specified, it is at the server discretion which designations to return | ||
includeDefinition | 0..1 | boolean | Controls whether the value set definition is included or excluded in value set expansions | ||
activeOnly | 0..1 | boolean | Controls whether inactive concepts are included or excluded in value set expansions. Note that if the value set explicitly specifies that inactive codes are included, this parameter can still remove them from a specific expansion, but this parameter cannot include them if the value set excludes them | ||
excludeNested | 0..1 | boolean | Controls whether or not the value set expansion nests codes or not (i.e. ValueSet.expansion.contains.contains) | ||
excludeNotForUI | 0..1 | boolean | Controls whether or not the value set expansion is assembled for a user interface use or not. Value sets intended for User Interface might include 'abstract' codes or have nested contains with items with no code or abstract = true, with the sole purpose of helping a user navigate through the list efficiently, where as a value set not generated for UI use might be flat, and only contain the selectable codes in the value set. The exact implications of 'for UI' depend on the code system, and what properties it exposes for a terminology server to use. In the FHIR Specification itself, the value set expansions are generated with excludeNotForUI = false, and the expansions used when generated schema / code etc, or performing validation, are all excludeNotForUI = true. | ||
excludePostCoordinated | 0..1 | boolean | Controls whether or not the value set expansion includes post coordinated codes | ||
displayLanguage | 0..1 | code | Specifies the language to be used for description in the expansions i.e. the language to be used for ValueSet.expansion.contains.display | ||
property | 0..* | string | A request to return a particular property in the expansion. May be either a code from the code system definition (convenient) or a the formal URI that refers to the property. Note that property names can clash, so using a URI is recommended. The special value '*' means all properties known to the server | ||
exclude-system | 0..* | canonical | Code system, or a particular version of a code system to be excluded from the value set expansion. The format is the same as a canonical URL: [system]|[version] - e.g. http://loinc.org|2.56 | ||
system-version | 0..* | canonical | Specifies a version to use for a system, if the value set does not specify which one to use. The format is the same as a canonical URL: [system]|[version] - e.g. http://loinc.org|2.56 | ||
check-system-version | 0..* | canonical | Edge Case: Specifies a version to use for a system. If a value set specifies a different version, an error is returned instead of the expansion. The format is the same as a canonical URL: [system]|[version] - e.g. http://loinc.org|2.56 | ||
force-system-version | 0..* | canonical | Edge Case: Specifies a version to use for a system. This parameter overrides any specified version in the value set (and any it depends on). The format is the same as a canonical URL: [system]|[version] - e.g. http://loinc.org|2.56. Note that this has obvious safety issues, in that it may result in a value set expansion giving a different list of codes that is both wrong and unsafe, and implementers should only use this capability reluctantly. It primarily exists to deal with situations where specifications have fallen into decay as time passes. If the value is override, the version used SHALL explicitly be represented in the expansion parameters | ||
Out Parameters: | |||||
Name | Cardinality | Type | Binding | Profile | Documentation |
return | 1..1 | ValueSet | The result of the expansion. Servers generating expansions SHOULD ensure that all the parameters that affect the contents of the expansion are recorded in the ValueSet.expansion.parameter list Note: as this is the only out parameter, it is a resource, and it has the name 'return', the result of this operation is returned directly as a resource |
The value set expansion returned by this query should be treated as a transient result that will change over time (whether it does or not depends on how the value set is specified), so applications should repeat the operation each time the value set is used.
If the expansion is too large (at the discretion of the server), the server MAY return an error (OperationOutcome with code too-costly). Clients can work through large flat expansions in a set of pages (partial views of the full expansion) instead of just getting the full expansion in a single exchange by using offset and count parameters, or use the count parameter to request a subset of the expansion for limited purposes. Servers are not obliged to support paging, but if they do, SHALL support both the offset and count parameters. Hierarchical expansions are not subject to paging and servers simply return the entire expansion.
Different servers may return different results from expanding a value set for the following reasons:
When a server cannot correctly expand a value set because it does not fully understand the code systems (e.g. it has the wrong version, or incomplete definitions) then it SHALL return an error. If the value set itself is unbounded due to the inclusion of post-coordinated value sets (e.g. SNOMED CT, UCUM), then the extension http://hl7.org/fhir/StructureDefinition/valueset-unclosed can be used to indicate that the expansion is incomplete
Request: Expanding a value set that is already registered on the server as "23", with a text filter of "abdo"
GET [base]/ValueSet/23/$expand?filter=abdo
Request: Expanding a value set by it's canonical URL (version 1.1), with a text filter of "abdo"
GET [base]/ValueSet/$expand?url=http://acme.com/fhir/ValueSet/23&valueSetVerson=1.1&filter=abdo
Request: Expanding a value set that is specified by the client (using JSON)
POST [base]/ValueSet/23/$expand [other headers] { "resourceType" : "Parameters", "parameter" : [ { "name" : "valueSet", "resource" : { "resourceType" : "ValueSet", [value set details] } } ] }
Request: Expanding a value set for a particular element, for what a client is allowed to PUT/POST. The server determines the appropriate value set to use
GET [base]/ValueSet/$expand?context=DiagnosticReport.category&contextDirection=incoming
Request: Like the last example, but profile specific. Note the need to encode the #. When no contextDirection is specified, server discretion applies
GET [base]/ValueSet/$expand?context=http://fhir.org/guides/argonaut-clinicalnotes/StructureDefinition/argo-diagnosticreport%23DiagnosticReport.category
Request: Expanding a value set for a particular date (for an old record), for a german user
GET [base]/ValueSet/23/$expand?date=2014-02-23&displayLanguage=de
Request: Expanding a value set, in the 3rd page
GET [base]/ValueSet/23/$expand?offset=200&count=100
Request: Expanding a value set. Asking not to get any SNOMED CT codes, and requiring that any LOINC codes come from 2.62 (if any other version of LOINC is in use, it's an error)
GET [base]/ValueSet/23/$expand?exclude-system=http://snomed.info/sct&check-system-version=http://loinc.org|2.62
Response: General pattern of response. Note: This specification also provides a file with 100s of expansions for code generators in both JSON and XML
HTTP/1.1 200 OK [other headers] <ValueSet xmlns="http://hl7.org/fhir"> <!-- the server SHOULD populate the id with a newly created UUID so clients can easily track a particular expansion --> <id value="43770626-f685-4ba8-8d66-fb63e674c467"/> <!-- no need for meta, though it is allowed for security labels, profiles --> <!-- other value set details --> <expansion> <!-- when expanded --> <timestamp value="20141203T08:50:00+11:00"/> <contains> <!-- expansion contents --> </contains> </expansion> </ValueSet>
For more information about operations, including how they are invoked, see Operations.