This page is part of the FHIR Specification (v0.0.82: DSTU 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 R3 R2

6.8 Resource Bundle - Content

This resource maintained by the FHIR Management Group Work Group

A container for a collection of resources.

6.8.1 Scope and Usage

One common operation performed with resources is to gather a collection of resources into a single instance with containing context. In FHIR this is referred to as "bundling" the resources together. These resource bundles are useful for a variety of different reasons, including:

6.8.2 Boundaries and Relationships

There are two ways to collect resources together - contained resources , and bundles. There is an important difference between the two:

6.8.3 Resource Content

Structure

Name Flags Card. Type Description & Constraints doco
. . Bundle I Resource Contains a collection of resources
entry.search only when a search
total only when a search or history
entry.transaction when (and only when) a transaction
entry.transactionResponse when (and only when) a transaction-response
. . . type 1..1 code document | message | transaction | transaction-response | history | searchset | collection
BundleType ( Required )
. . . base 0..1 uri Stated Base URL
. . . total I 0..1 integer If search, the total number of matches
. . . link 0..* Element Links related to this Bundle
. . . . relation 1..1 string http://www.iana.org/assignments/link-relations/link-relations.xhtml
. . . . url 1..1 uri Reference details for the link
. . . entry I 0..* Element Entry in the bundle - will have a resource, or information
must be a resource unless there's a transaction or transaction response
. . . . base 0..1 uri Base URL, if different to bundle base
. . . . link 0..* see link Links related to this entry
. . . . resource 0..1 Resource Resources in this bundle
. . . . search I 0..1 Element Search related information
. . . . . mode 0..1 code match | include - why this is in the result set
SearchEntryMode ( Required )
. . . . . score 0..1 decimal Search ranking (between 0 and 1)
. . . . transaction I 0..1 Element Transaction Related Information
. . . . . method 1..1 code GET | POST | PUT | DELETE
HTTPVerb ( Required )
. . . . . url 1..1 uri The URL for the transaction
. . . . . ifNoneMatch 0..1 string For managing cache currency
. . . . . ifMatch 0..1 string For managing update contention
. . . . . ifModifiedSince 0..1 instant For managing update contention
. . . . . ifNoneExist 0..1 string For conditional creates
. . . . transactionResponse I 0..1 Element Transaction Related Information
. . . . . status 1..1 string Status return code for entry
. . . . . location 0..1 uri The location, if the operation returns a location
. . . . . etag 0..1 string The etag for the resource (if relevant)
. . . . . lastModified 0..1 instant Server's date time modified
. . . signature 0..1 base64Binary XML Digital Signature (base64 encoded)

UML Diagram

Bundle ( Resource ) Indicates the purpose of this bundle- how it was intended to be used type : code 1..1 « Indicates the purpose of a bundle- how it was intended to be used BundleType » The base URL for the service that provided these resources. All relative URLs are relative to this one (equivalent to xml:base) base : uri 0..1 If a set of search matches, this is the total number of matches for the search (as opposed to the number of results in this bundle) total : integer 0..1 XML Digital Signature - base64 encoded signature : base64Binary 0..1 Link A name which details the functional use for this link - see [[http://www.iana.org/assignments/link-relations/link-relations.xhtml]] relation : string 1..1 The reference details for the link url : uri 1..1 Entry The Base URL for the resource, if different to the base URL specified for the bundle as a whole base : uri 0..1 The Resources for the entry resource : Resource 0..1 Search Why this entry is in the result set - whether it's included as a match or because of an _include requirement mode : code 0..1 « Why an entry is in the result set - whether it's included as a match or because of an _include requirement SearchEntryMode » When searching, the server's search ranking score for the entry score : decimal 0..1 Transaction The HTTP verb for this entry in either a update history, or a transaction/ transaction response method : code 1..1 « HTTP verbs (in the HTTP command line) HTTPVerb » A search URL for this resource that specifies how the resource is matched to an existing resource when processing a transaction (see transaction documentation) url : uri 1..1 If the ETag values match, return a 304 Not modified status. See the read/vread interaction documentation ifNoneMatch : string 0..1 Only perform the operation if the Etag value matches. For more information, see the API section "Managing Resource Contention" ifMatch : string 0..1 Only perform the operation if the last updated date matches. For more information, see the API section "Managing Resource Contention" ifModifiedSince : instant 0..1 Instruct the server not to perform the create if a specified resource already exists. For further information, see "Conditional Create" ifNoneExist : string 0..1 TransactionResponse The status code returned by processing this entry status : string 1..1 The location header created by processing this operation location : uri 0..1 The etag for the resource, it the operation for the entry produced a versioned resource etag : string 0..1 The date/time that the resource was modified on the server lastModified : instant 0..1 A series of links that provide context to this bundle link 0..* A series of links that provide context to this entry link 0..* Information about the search process that lead to the creation of this entry search 0..1 Additional information about how this entry should be processed as part of a transaction transaction 0..1 Additional information about how this entry should be processed as part of a transaction transactionResponse 0..1 An entry in a bundle resource - will either contain a resource, or information about a resource (transactions and history only) entry 0..*

XML Template

<Bundle xmlns="http://hl7.org/fhir"> doco
 <!-- from Resource: id, meta, implicitRules, and language -->
 <type value="[code]"/><!-- 1..1 document | message | transaction | transaction-response | history | searchset | collection -->
 <base value="[uri]"/><!-- 0..1 Stated Base URL -->
 <total value="[integer]"/><!-- ?? 0..1 If search, the total number of matches -->
 <link>  <!-- 0..* Links related to this Bundle -->
  <relation value="[string]"/><!-- 1..1 http://www.iana.org/assignments/link-relations/link-relations.xhtml -->
  <url value="[uri]"/><!-- 1..1 Reference details for the link -->
 </link>
 <entry>  <!-- 0..* Entry in the bundle - will have a resource, or information -->
  <base value="[uri]"/><!-- 0..1 Base URL, if different to bundle base -->
  <link><!-- 0..* Content as for Bundle.link Links related to this entry --></link>
  <resource><!-- 0..1 Resource Resources in this bundle --></resource>
  <search>  <!-- ?? 0..1 Search related information -->
   <mode value="[code]"/><!-- 0..1 match | include - why this is in the result set -->
   <score value="[decimal]"/><!-- 0..1 Search ranking (between 0 and 1) -->
  </search>
  <transaction>  <!-- ?? 0..1 Transaction Related Information -->
   <method value="[code]"/><!-- 1..1 GET | POST | PUT | DELETE -->
   <url value="[uri]"/><!-- 1..1 The URL for the transaction -->
   <ifNoneMatch value="[string]"/><!-- 0..1 For managing cache currency -->
   <ifMatch value="[string]"/><!-- 0..1 For managing update contention -->
   <ifModifiedSince value="[instant]"/><!-- 0..1 For managing update contention -->
   <ifNoneExist value="[string]"/><!-- 0..1 For conditional creates -->
  </transaction>
  <transactionResponse>  <!-- ?? 0..1 Transaction Related Information -->
   <status value="[string]"/><!-- 1..1 Status return code for entry -->
   <location value="[uri]"/><!-- 0..1 The location, if the operation returns a location -->
   <etag value="[string]"/><!-- 0..1 The etag for the resource (if relevant) -->
   <lastModified value="[instant]"/><!-- 0..1 Server's date time modified -->
  </transactionResponse>
 </entry>
 <signature value="[base64Binary]"/><!-- 0..1 XML Digital Signature (base64 encoded) -->
</Bundle>

JSON Template

{doco
  "resourceType" : "Bundle",
  // from Resource: id, meta, implicitRules, and language
  "type" : "<code>", // R!  document | message | transaction | transaction-response | history | searchset | collection
  "base" : "<uri>", // Stated Base URL
  "total" : <integer>, // C? If search, the total number of matches
  "link" : [{ // Links related to this Bundle
    "relation" : "<string>", // R!  http://www.iana.org/assignments/link-relations/link-relations.xhtml
    "url" : "<uri>" // R!  Reference details for the link
  }],
  "entry" : [{ // Entry in the bundle - will have a resource, or information
    "base" : "<uri>", // Base URL, if different to bundle base
    "link" : [{ Content as for Bundle.link }], // Links related to this entry
    "resource" : { Resource }, // Resources in this bundle
    "search" : { // C? Search related information
      "mode" : "<code>", // match | include - why this is in the result set
      "score" : <decimal> // Search ranking (between 0 and 1)
    },
    "transaction" : { // C? Transaction Related Information
      "method" : "<code>", // R!  GET | POST | PUT | DELETE
      "url" : "<uri>", // R!  The URL for the transaction
      "ifNoneMatch" : "<string>", // For managing cache currency
      "ifMatch" : "<string>", // For managing update contention
      "ifModifiedSince" : "<instant>", // For managing update contention
      "ifNoneExist" : "<string>" // For conditional creates
    },
    "transactionResponse" : { // C? Transaction Related Information
      "status" : "<string>", // R!  Status return code for entry
      "location" : "<uri>", // The location, if the operation returns a location
      "etag" : "<string>", // The etag for the resource (if relevant)
      "lastModified" : "<instant>" // Server's date time modified
    }
  }],
  "signature" : "<base64Binary>" // XML Digital Signature (base64 encoded)
}

Structure

Name Flags Card. Type Description & Constraints doco
. . Bundle I Resource Contains a collection of resources
entry.search only when a search
total only when a search or history
entry.transaction when (and only when) a transaction
entry.transactionResponse when (and only when) a transaction-response
. . . type 1..1 code document | message | transaction | transaction-response | history | searchset | collection
BundleType ( Required )
. . . base 0..1 uri Stated Base URL
. . . total I 0..1 integer If search, the total number of matches
. . . link 0..* Element Links related to this Bundle
. . . . relation 1..1 string http://www.iana.org/assignments/link-relations/link-relations.xhtml
. . . . url 1..1 uri Reference details for the link
. . . entry I 0..* Element Entry in the bundle - will have a resource, or information
must be a resource unless there's a transaction or transaction response
. . . . base 0..1 uri Base URL, if different to bundle base
. . . . link 0..* see link Links related to this entry
. . . . resource 0..1 Resource Resources in this bundle
. . . . search I 0..1 Element Search related information
. . . . . mode 0..1 code match | include - why this is in the result set
SearchEntryMode ( Required )
. . . . . score 0..1 decimal Search ranking (between 0 and 1)
. . . . transaction I 0..1 Element Transaction Related Information
. . . . . method 1..1 code GET | POST | PUT | DELETE
HTTPVerb ( Required )
. . . . . url 1..1 uri The URL for the transaction
. . . . . ifNoneMatch 0..1 string For managing cache currency
. . . . . ifMatch 0..1 string For managing update contention
. . . . . ifModifiedSince 0..1 instant For managing update contention
. . . . . ifNoneExist 0..1 string For conditional creates
. . . . transactionResponse I 0..1 Element Transaction Related Information
. . . . . status 1..1 string Status return code for entry
. . . . . location 0..1 uri The location, if the operation returns a location
. . . . . etag 0..1 string The etag for the resource (if relevant)
. . . . . lastModified 0..1 instant Server's date time modified
. . . signature 0..1 base64Binary XML Digital Signature (base64 encoded)

UML Diagram

Bundle ( Resource ) Indicates the purpose of this bundle- how it was intended to be used type : code 1..1 « Indicates the purpose of a bundle- how it was intended to be used BundleType » The base URL for the service that provided these resources. All relative URLs are relative to this one (equivalent to xml:base) base : uri 0..1 If a set of search matches, this is the total number of matches for the search (as opposed to the number of results in this bundle) total : integer 0..1 XML Digital Signature - base64 encoded signature : base64Binary 0..1 Link A name which details the functional use for this link - see [[http://www.iana.org/assignments/link-relations/link-relations.xhtml]] relation : string 1..1 The reference details for the link url : uri 1..1 Entry The Base URL for the resource, if different to the base URL specified for the bundle as a whole base : uri 0..1 The Resources for the entry resource : Resource 0..1 Search Why this entry is in the result set - whether it's included as a match or because of an _include requirement mode : code 0..1 « Why an entry is in the result set - whether it's included as a match or because of an _include requirement SearchEntryMode » When searching, the server's search ranking score for the entry score : decimal 0..1 Transaction The HTTP verb for this entry in either a update history, or a transaction/ transaction response method : code 1..1 « HTTP verbs (in the HTTP command line) HTTPVerb » A search URL for this resource that specifies how the resource is matched to an existing resource when processing a transaction (see transaction documentation) url : uri 1..1 If the ETag values match, return a 304 Not modified status. See the read/vread interaction documentation ifNoneMatch : string 0..1 Only perform the operation if the Etag value matches. For more information, see the API section "Managing Resource Contention" ifMatch : string 0..1 Only perform the operation if the last updated date matches. For more information, see the API section "Managing Resource Contention" ifModifiedSince : instant 0..1 Instruct the server not to perform the create if a specified resource already exists. For further information, see "Conditional Create" ifNoneExist : string 0..1 TransactionResponse The status code returned by processing this entry status : string 1..1 The location header created by processing this operation location : uri 0..1 The etag for the resource, it the operation for the entry produced a versioned resource etag : string 0..1 The date/time that the resource was modified on the server lastModified : instant 0..1 A series of links that provide context to this bundle link 0..* A series of links that provide context to this entry link 0..* Information about the search process that lead to the creation of this entry search 0..1 Additional information about how this entry should be processed as part of a transaction transaction 0..1 Additional information about how this entry should be processed as part of a transaction transactionResponse 0..1 An entry in a bundle resource - will either contain a resource, or information about a resource (transactions and history only) entry 0..*

XML Template

<Bundle xmlns="http://hl7.org/fhir"> doco
 <!-- from Resource: id, meta, implicitRules, and language -->
 <type value="[code]"/><!-- 1..1 document | message | transaction | transaction-response | history | searchset | collection -->
 <base value="[uri]"/><!-- 0..1 Stated Base URL -->
 <total value="[integer]"/><!-- ?? 0..1 If search, the total number of matches -->
 <link>  <!-- 0..* Links related to this Bundle -->
  <relation value="[string]"/><!-- 1..1 http://www.iana.org/assignments/link-relations/link-relations.xhtml -->
  <url value="[uri]"/><!-- 1..1 Reference details for the link -->
 </link>
 <entry>  <!-- 0..* Entry in the bundle - will have a resource, or information -->
  <base value="[uri]"/><!-- 0..1 Base URL, if different to bundle base -->
  <link><!-- 0..* Content as for Bundle.link Links related to this entry --></link>
  <resource><!-- 0..1 Resource Resources in this bundle --></resource>
  <search>  <!-- ?? 0..1 Search related information -->
   <mode value="[code]"/><!-- 0..1 match | include - why this is in the result set -->
   <score value="[decimal]"/><!-- 0..1 Search ranking (between 0 and 1) -->
  </search>
  <transaction>  <!-- ?? 0..1 Transaction Related Information -->
   <method value="[code]"/><!-- 1..1 GET | POST | PUT | DELETE -->
   <url value="[uri]"/><!-- 1..1 The URL for the transaction -->
   <ifNoneMatch value="[string]"/><!-- 0..1 For managing cache currency -->
   <ifMatch value="[string]"/><!-- 0..1 For managing update contention -->
   <ifModifiedSince value="[instant]"/><!-- 0..1 For managing update contention -->
   <ifNoneExist value="[string]"/><!-- 0..1 For conditional creates -->
  </transaction>
  <transactionResponse>  <!-- ?? 0..1 Transaction Related Information -->
   <status value="[string]"/><!-- 1..1 Status return code for entry -->
   <location value="[uri]"/><!-- 0..1 The location, if the operation returns a location -->
   <etag value="[string]"/><!-- 0..1 The etag for the resource (if relevant) -->
   <lastModified value="[instant]"/><!-- 0..1 Server's date time modified -->
  </transactionResponse>
 </entry>
 <signature value="[base64Binary]"/><!-- 0..1 XML Digital Signature (base64 encoded) -->
</Bundle>

JSON Template

{doco
  "resourceType" : "Bundle",
  // from Resource: id, meta, implicitRules, and language
  "type" : "<code>", // R!  document | message | transaction | transaction-response | history | searchset | collection
  "base" : "<uri>", // Stated Base URL
  "total" : <integer>, // C? If search, the total number of matches
  "link" : [{ // Links related to this Bundle
    "relation" : "<string>", // R!  http://www.iana.org/assignments/link-relations/link-relations.xhtml
    "url" : "<uri>" // R!  Reference details for the link
  }],
  "entry" : [{ // Entry in the bundle - will have a resource, or information
    "base" : "<uri>", // Base URL, if different to bundle base
    "link" : [{ Content as for Bundle.link }], // Links related to this entry
    "resource" : { Resource }, // Resources in this bundle
    "search" : { // C? Search related information
      "mode" : "<code>", // match | include - why this is in the result set
      "score" : <decimal> // Search ranking (between 0 and 1)
    },
    "transaction" : { // C? Transaction Related Information
      "method" : "<code>", // R!  GET | POST | PUT | DELETE
      "url" : "<uri>", // R!  The URL for the transaction
      "ifNoneMatch" : "<string>", // For managing cache currency
      "ifMatch" : "<string>", // For managing update contention
      "ifModifiedSince" : "<instant>", // For managing update contention
      "ifNoneExist" : "<string>" // For conditional creates
    },
    "transactionResponse" : { // C? Transaction Related Information
      "status" : "<string>", // R!  Status return code for entry
      "location" : "<uri>", // The location, if the operation returns a location
      "etag" : "<string>", // The etag for the resource (if relevant)
      "lastModified" : "<instant>" // Server's date time modified
    }
  }],
  "signature" : "<base64Binary>" // XML Digital Signature (base64 encoded)
}

 

Alternate definitions: Schema / Schematron , Resource Profile ( XML , JSON ), Questionnaire

6.8.3.1 Terminology Bindings

Path Definition Type Reference
Bundle.type Indicates the purpose of a bundle- how it was intended to be used Required http://hl7.org/fhir/bundle-type
Bundle.entry.search.mode Why an entry is in the result set - whether it's included as a match or because of an _include requirement Required http://hl7.org/fhir/search-entry-mode
Bundle.entry.transaction.method HTTP verbs (in the HTTP command line) Required http://hl7.org/fhir/http-verb

6.8.3.2 Constraints

6.8.3.3 Notes

6.8.3.4 Using Bundles

The content and rules for using a Bundle depend on the type of the bundle. Note that all bundle types use Bundle.base and Bundle.entry.base for identity resolution as described below.

6.8.3.4.1 Document

A document bundle (type = "document") consists of a series of entries, the first of which is a Composition . Each entry element SHALL contain a resource. See Documents for further information.

Example

6.8.3.4.2 Message

A message bundle (type = "message") consists of a series of entries, the first of which is a MessageHeader . Each entry element SHALL contain a resource. See Messaging for further information.

Example: todo

6.8.3.4.3 Search Results

A set of search results (type = "searchset") consists of a series of 0 or more entries. Each entry element SHALL contain a resource. See Search for further information.

In addition, Bundle.total may be used to return the total number of resources that match the search, and that may be returned by following the "next" link .

For each entry, a search set can also contain two specific pieces of search related information:

Example

6.8.3.4.4 History

An update history (type = "history") consists of a series of 0 or more entries. Each entry element SHALL contain a transaction element that describes the change that was made, and, if the method is a POST or PUT, a resource that represents the state of the resource at the conclusion of the operation. See History for further information.

In addition, Bundle.total may be used to return the total number of resources that are included in the update history, and that may be returned by following the "next" link .

4

Example to do

6.8.3.4.5 Transaction

A transaction (type = "transaction") consists of a series of 0 or more entries. Each entry element MAY contain a transaction element, and MAY contain either a resource element. See Transactions for further information. Each entry in a transaction has the details of an HTTP operation that informs the system processing the transaction what to do with the entry. If the entry method is a 'PUT' or 'POST', then the entry SHALL contain a resource that becomes the body of the HTTP operation.

If there is no transaction element, then there SHALL be a resource and the server must infer whether this is a create or an update from from the resource identity supplied.

Example

6.8.3.4.6 Transaction Response

A transaction response (type = "transaction-response") consists of a series of 0 or more entries, 1 for each entry in the transaction it is in response to. Each entry element SHALL contain a transactionResponse element which indicates the outcome of the HTTP operation that the server performed for the entry.

Example

6.8.3.4.7 Collection

A collection (type = "collection") consists of a series of 0 or more entries. No particular use with respect to the FHIR specification is associated with this bundle. Each entry element SHALL contain a resource.

Example

6.8.3.5 Resolving references in Bundles

Bundle has a 'base' element, which is used to resolve relative references present in the bundled resources. In the case that the bundle includes resources with different bases, each entry can also assert its applicable base if this is different to the overall base. A base SHOULD always be specified, either in the bundle itself, or on each entry.

Applications reading a bundle should always look for a resource by its identity in the bundle first before trying to access it by its URL.

The id property of a resource is a relative URI. In the case of the RESTful API, the id is relative to the system base URL such that the absolute URI of the resource is:

[base]/[Type]/[id]

When resolving references with in a bundle, the resolution is against the absolute URI. For instance, if a resource with a stated base of http://example.org/fhir has a reference with a value of Patient/2341, then it will resolve to a Patient resource with an id of 2341 and a base of http://example.org/fhir, which is an absolute URI of http://example.org/fhir/Patient/2341.

There is one special case: for a base URI of urn:uuid: or urn:oid:, the absolute URI does not include the type of the resource:

[base][id]

OIDs and UUIDs are intended for use where the resource the entry is for has no established identity on an existing RESTful interface.

6.8.4 Search Parameters

Search parameters for this resource. The common parameters also apply. See Searching for more information about searching in REST, messaging, and services.

Name Type Description Paths
composition reference The first resource in the bundle, if the bundle type is "document" - this is a composition, and this parameter provides access to searches its contents
( Composition )
message reference The first resource in the bundle, if the bundle type is "message" - this is a message header, and this parameter provides access to search its contents
( MessageHeader )
type token document | message | transaction | transaction-response | history | searchset | collection Bundle.type