STU 3 Ballot

This page is part of the FHIR Specification (v1.6.0: STU 3 Ballot 4). 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

5.8 Resource CompartmentDefinition - Content

FHIR Infrastructure Work GroupMaturity Level: 0Compartments: Not linked to any defined compartments

A compartment definition that defines how resources are accessed on a server.

5.8.1 Scope and Usage

Each resource may belong to one or more logical compartments. A compartment is a logical grouping of resources which share a common property. Compartments have two principal roles:

  • Function as an access mechanism for finding a set of related resources quickly
  • Provide a definitional basis for applying access control to resources quickly

5.8.2 Boundaries and Relationships

Compartment definitions describe how particular compartment instances are named and identified, and how systems know which resources are in the compartment. The following compartments are defined by this specification:

TitleDescriptionIdentityMembership
PatientThe set of resources associated with a particular patientThere is an instance of the patient compartment for each patient resource, and the identity of the compartment is the same as the patient. When a patient is linked to another patient, all the records associated with the linked patient are in the compartment associated with the target of the link.The patient compartment includes any resources where the subject of the resource is the patient, and some other resources that are directly linked to resources in the patient compartment
EncounterThe set of resources associated with a particular encounterThere is an instance of the encounter compartment for each encounter resource, and the identity of the compartment is the same as the encounterThe encounter compartment includes any resources where the resource has an explicitly nominated encounter, and some other resources that them selves link to resources in the encounter compartment. Note that for many resources, the exact nature of the link to encounter can be ambiguous (e.g. for a DiagnosticReport, is it the encounter when it was initiated, or when it was reported?)
RelatedPersonThe set of resources associated with a particular 'related person'There is an instance of the relatedPerson compartment for each relatedPerson resource, and the identity of the compartment is the same as the relatedPersonThe relatedPerson compartment includes any resources where the resource is explicitly linked to relatedPerson (usually as author)
PractitionerThe set of resources associated with a particular practitionerThere is an instance of the practitioner compartment for each Practitioner resource, and the identity of the compartment is the same as the PractitionerThe practitioner compartment includes any resources where the resource is explicitly linked to a Practitioner (usually as author, but other kinds of linkage exist)
DeviceThe set of resources associated with a particular deviceThere is an instance of the practitioner compartment for each Device resource, and the identity of the compartment is the same as the DeviceThe device compartment includes any resources where the resource is explicitly linked to a Device (mostly subject or performer)

The full definitions of these compartments are published as CompartmentDefinition resources. Servers typically do not support the full definition of a compartment, and are not required to. Systems may publish CompartmentDefinition resources so that other systems may make use of compartments properly.

  • CompartmentDefinitions are used by Conformance instances for specifying how resources are accessed

5.8.3 Resource Content

Structure

NameFlagsCard.TypeDescription & Constraintsdoco
.. CompartmentDefinition DomainResourceCompartment Definition for a resource
... url Σ1..1uriAbsolute URL used to reference this compartment definition
... name Σ1..1stringInformal name for this compartment definition
... status ?!Σ0..1codedraft | active | retired
ConformanceResourceStatus (Required)
... experimental Σ0..1booleanIf for testing purposes, not real usage
... publisher Σ0..1stringName of the publisher (Organization or individual)
... contact Σ0..*BackboneElementContact details of the publisher
.... name Σ0..1stringName of an individual to contact
.... telecom Σ0..*ContactPointContact details for individual or publisher
... date Σ0..1dateTimePublication Date(/time)
... description Σ0..1markdownNatural language description of the CompartmentDefinition
... requirements 0..1markdownWhy this compartment definition is defined
... code Σ1..1codePatient | Encounter | RelatedPerson | Practitioner | Device
CompartmentType (Required)
... search Σ1..1booleanWhether the search syntax is supported
... resource Σ0..*BackboneElementHow resource is related to the compartment
.... code Σ1..1codeName of resource type
ResourceType (Required)
.... param Σ0..*stringSearch Parameter Name, or chained params
.... documentation 0..1stringAdditional doco about the resource and compartment

doco Documentation for this format

UML Diagram (Legend)

CompartmentDefinition (DomainResource)An absolute URL that is used to identify this compartment definition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this compartment definition is (or will be) publishedurl : uri [1..1]A free text natural language name identifying the compartment definitionname : string [1..1]The status of this compartment definition definition (this element modifies the meaning of other elements)status : code [0..1] « The lifecycle status of a Value Set or Concept Map. (Strength=Required)ConformanceResourceStatus! »A flag to indicate that this compartment definition definition is authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usageexperimental : boolean [0..1]The name of the individual or organization that published the compartment definitionpublisher : string [0..1]The date (and optionally time) when the compartment definition definition was published. The date must change when the business version changes, if it does, and it must change if the status code changes. In addition, it should change when the substantive content of the compartment definition changesdate : dateTime [0..1]A free text natural language description of the CompartmentDefinition and its usedescription : markdown [0..1]The Scope and Usage that this compartment definition was created to meetrequirements : markdown [0..1]Which compartment this definition describescode : code [1..1] « Which compartment a compartmnet definition describes (Strength=Required)CompartmentType! »Whether the search syntax is supportedsearch : boolean [1..1]ContactThe name of an individual to contact regarding the compartment definitionname : string [0..1]Contact details for individual (if a name was provided) or the publishertelecom : ContactPoint [0..*]ResourceThe name of a resource supported by the servercode : code [1..1] « One of the resource types defined as part of FHIR. (Strength=Required)ResourceType! »The name of a search parameter that represents the link to the compartment. More than one may be listed because a resource may be linked to a compartment more than one wayparam : string [0..*]Additional doco about the resource and compartmentdocumentation : string [0..1]Contacts to assist a user in finding and communicating with the publishercontact[0..*]Information about how a resource it related to the compartmentresource[0..*]

XML Template

<CompartmentDefinition xmlns="http://hl7.org/fhir"> doco
 <!-- from Resource: id, meta, implicitRules, and language -->
 <!-- from DomainResource: text, contained, extension, and modifierExtension -->
 <url value="[uri]"/><!-- 1..1 Absolute URL used to reference this compartment definition -->
 <name value="[string]"/><!-- 1..1 Informal name for this compartment definition -->
 <status value="[code]"/><!-- 0..1 draft | active | retired -->
 <experimental value="[boolean]"/><!-- 0..1 If for testing purposes, not real usage -->
 <publisher value="[string]"/><!-- 0..1 Name of the publisher (Organization or individual) -->
 <contact>  <!-- 0..* Contact details of the publisher -->
  <name value="[string]"/><!-- 0..1 Name of an individual to contact -->
  <telecom><!-- 0..* ContactPoint Contact details for individual or publisher --></telecom>
 </contact>
 <date value="[dateTime]"/><!-- 0..1 Publication Date(/time) -->
 <description value="[markdown]"/><!-- 0..1 Natural language description of the CompartmentDefinition -->
 <requirements value="[markdown]"/><!-- 0..1 Why this compartment definition is defined -->
 <code value="[code]"/><!-- 1..1 Patient | Encounter | RelatedPerson | Practitioner | Device -->
 <search value="[boolean]"/><!-- 1..1 Whether the search syntax is supported -->
 <resource>  <!-- 0..* How resource is related to the compartment -->
  <code value="[code]"/><!-- 1..1 Name of resource type -->
  <param value="[string]"/><!-- 0..* Search Parameter Name, or chained params -->
  <documentation value="[string]"/><!-- 0..1 Additional doco about the resource and compartment -->
 </resource>
</CompartmentDefinition>

Turtle Template

@prefix fhir: <http://hl7.org/fhir/> .doco


[ a fhir:CompartmentDefinition;
  fhir:nodeRole fhir:treeRoot; # if this is the parser root

  # from Resource: .id, .meta, .implicitRules, and .language
  # from DomainResource: .text, .contained, .extension, and .modifierExtension
  fhir:CompartmentDefinition.url [ uri ]; # 1..1 Absolute URL used to reference this compartment definition
  fhir:CompartmentDefinition.name [ string ]; # 1..1 Informal name for this compartment definition
  fhir:CompartmentDefinition.status [ code ]; # 0..1 draft | active | retired
  fhir:CompartmentDefinition.experimental [ boolean ]; # 0..1 If for testing purposes, not real usage
  fhir:CompartmentDefinition.publisher [ string ]; # 0..1 Name of the publisher (Organization or individual)
  fhir:CompartmentDefinition.contact [ # 0..* Contact details of the publisher
    fhir:CompartmentDefinition.contact.name [ string ]; # 0..1 Name of an individual to contact
    fhir:CompartmentDefinition.contact.telecom [ ContactPoint ], ... ; # 0..* Contact details for individual or publisher
  ], ...;
  fhir:CompartmentDefinition.date [ dateTime ]; # 0..1 Publication Date(/time)
  fhir:CompartmentDefinition.description [ markdown ]; # 0..1 Natural language description of the CompartmentDefinition
  fhir:CompartmentDefinition.requirements [ markdown ]; # 0..1 Why this compartment definition is defined
  fhir:CompartmentDefinition.code [ code ]; # 1..1 Patient | Encounter | RelatedPerson | Practitioner | Device
  fhir:CompartmentDefinition.search [ boolean ]; # 1..1 Whether the search syntax is supported
  fhir:CompartmentDefinition.resource [ # 0..* How resource is related to the compartment
    fhir:CompartmentDefinition.resource.code [ code ]; # 1..1 Name of resource type
    fhir:CompartmentDefinition.resource.param [ string ], ... ; # 0..* Search Parameter Name, or chained params
    fhir:CompartmentDefinition.resource.documentation [ string ]; # 0..1 Additional doco about the resource and compartment
  ], ...;
]

Changes since DSTU2

This resource did not exist in Release 2

Structure

NameFlagsCard.TypeDescription & Constraintsdoco
.. CompartmentDefinition DomainResourceCompartment Definition for a resource
... url Σ1..1uriAbsolute URL used to reference this compartment definition
... name Σ1..1stringInformal name for this compartment definition
... status ?!Σ0..1codedraft | active | retired
ConformanceResourceStatus (Required)
... experimental Σ0..1booleanIf for testing purposes, not real usage
... publisher Σ0..1stringName of the publisher (Organization or individual)
... contact Σ0..*BackboneElementContact details of the publisher
.... name Σ0..1stringName of an individual to contact
.... telecom Σ0..*ContactPointContact details for individual or publisher
... date Σ0..1dateTimePublication Date(/time)
... description Σ0..1markdownNatural language description of the CompartmentDefinition
... requirements 0..1markdownWhy this compartment definition is defined
... code Σ1..1codePatient | Encounter | RelatedPerson | Practitioner | Device
CompartmentType (Required)
... search Σ1..1booleanWhether the search syntax is supported
... resource Σ0..*BackboneElementHow resource is related to the compartment
.... code Σ1..1codeName of resource type
ResourceType (Required)
.... param Σ0..*stringSearch Parameter Name, or chained params
.... documentation 0..1stringAdditional doco about the resource and compartment

doco Documentation for this format

UML Diagram (Legend)

CompartmentDefinition (DomainResource)An absolute URL that is used to identify this compartment definition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this compartment definition is (or will be) publishedurl : uri [1..1]A free text natural language name identifying the compartment definitionname : string [1..1]The status of this compartment definition definition (this element modifies the meaning of other elements)status : code [0..1] « The lifecycle status of a Value Set or Concept Map. (Strength=Required)ConformanceResourceStatus! »A flag to indicate that this compartment definition definition is authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usageexperimental : boolean [0..1]The name of the individual or organization that published the compartment definitionpublisher : string [0..1]The date (and optionally time) when the compartment definition definition was published. The date must change when the business version changes, if it does, and it must change if the status code changes. In addition, it should change when the substantive content of the compartment definition changesdate : dateTime [0..1]A free text natural language description of the CompartmentDefinition and its usedescription : markdown [0..1]The Scope and Usage that this compartment definition was created to meetrequirements : markdown [0..1]Which compartment this definition describescode : code [1..1] « Which compartment a compartmnet definition describes (Strength=Required)CompartmentType! »Whether the search syntax is supportedsearch : boolean [1..1]ContactThe name of an individual to contact regarding the compartment definitionname : string [0..1]Contact details for individual (if a name was provided) or the publishertelecom : ContactPoint [0..*]ResourceThe name of a resource supported by the servercode : code [1..1] « One of the resource types defined as part of FHIR. (Strength=Required)ResourceType! »The name of a search parameter that represents the link to the compartment. More than one may be listed because a resource may be linked to a compartment more than one wayparam : string [0..*]Additional doco about the resource and compartmentdocumentation : string [0..1]Contacts to assist a user in finding and communicating with the publishercontact[0..*]Information about how a resource it related to the compartmentresource[0..*]

XML Template

<CompartmentDefinition xmlns="http://hl7.org/fhir"> doco
 <!-- from Resource: id, meta, implicitRules, and language -->
 <!-- from DomainResource: text, contained, extension, and modifierExtension -->
 <url value="[uri]"/><!-- 1..1 Absolute URL used to reference this compartment definition -->
 <name value="[string]"/><!-- 1..1 Informal name for this compartment definition -->
 <status value="[code]"/><!-- 0..1 draft | active | retired -->
 <experimental value="[boolean]"/><!-- 0..1 If for testing purposes, not real usage -->
 <publisher value="[string]"/><!-- 0..1 Name of the publisher (Organization or individual) -->
 <contact>  <!-- 0..* Contact details of the publisher -->
  <name value="[string]"/><!-- 0..1 Name of an individual to contact -->
  <telecom><!-- 0..* ContactPoint Contact details for individual or publisher --></telecom>
 </contact>
 <date value="[dateTime]"/><!-- 0..1 Publication Date(/time) -->
 <description value="[markdown]"/><!-- 0..1 Natural language description of the CompartmentDefinition -->
 <requirements value="[markdown]"/><!-- 0..1 Why this compartment definition is defined -->
 <code value="[code]"/><!-- 1..1 Patient | Encounter | RelatedPerson | Practitioner | Device -->
 <search value="[boolean]"/><!-- 1..1 Whether the search syntax is supported -->
 <resource>  <!-- 0..* How resource is related to the compartment -->
  <code value="[code]"/><!-- 1..1 Name of resource type -->
  <param value="[string]"/><!-- 0..* Search Parameter Name, or chained params -->
  <documentation value="[string]"/><!-- 0..1 Additional doco about the resource and compartment -->
 </resource>
</CompartmentDefinition>

Turtle Template

@prefix fhir: <http://hl7.org/fhir/> .doco


[ a fhir:CompartmentDefinition;
  fhir:nodeRole fhir:treeRoot; # if this is the parser root

  # from Resource: .id, .meta, .implicitRules, and .language
  # from DomainResource: .text, .contained, .extension, and .modifierExtension
  fhir:CompartmentDefinition.url [ uri ]; # 1..1 Absolute URL used to reference this compartment definition
  fhir:CompartmentDefinition.name [ string ]; # 1..1 Informal name for this compartment definition
  fhir:CompartmentDefinition.status [ code ]; # 0..1 draft | active | retired
  fhir:CompartmentDefinition.experimental [ boolean ]; # 0..1 If for testing purposes, not real usage
  fhir:CompartmentDefinition.publisher [ string ]; # 0..1 Name of the publisher (Organization or individual)
  fhir:CompartmentDefinition.contact [ # 0..* Contact details of the publisher
    fhir:CompartmentDefinition.contact.name [ string ]; # 0..1 Name of an individual to contact
    fhir:CompartmentDefinition.contact.telecom [ ContactPoint ], ... ; # 0..* Contact details for individual or publisher
  ], ...;
  fhir:CompartmentDefinition.date [ dateTime ]; # 0..1 Publication Date(/time)
  fhir:CompartmentDefinition.description [ markdown ]; # 0..1 Natural language description of the CompartmentDefinition
  fhir:CompartmentDefinition.requirements [ markdown ]; # 0..1 Why this compartment definition is defined
  fhir:CompartmentDefinition.code [ code ]; # 1..1 Patient | Encounter | RelatedPerson | Practitioner | Device
  fhir:CompartmentDefinition.search [ boolean ]; # 1..1 Whether the search syntax is supported
  fhir:CompartmentDefinition.resource [ # 0..* How resource is related to the compartment
    fhir:CompartmentDefinition.resource.code [ code ]; # 1..1 Name of resource type
    fhir:CompartmentDefinition.resource.param [ string ], ... ; # 0..* Search Parameter Name, or chained params
    fhir:CompartmentDefinition.resource.documentation [ string ]; # 0..1 Additional doco about the resource and compartment
  ], ...;
]

Changes since DSTU2

This resource did not exist in Release 2

 

Alternate definitions: Master Definition (XML, JSON), XML Schema/Schematron (for ) + JSON Schema, ShEx (for Turtle)

5.8.3.1 Terminology Bindings

PathDefinitionTypeReference
CompartmentDefinition.status The lifecycle status of a Value Set or Concept Map.RequiredConformanceResourceStatus
CompartmentDefinition.code Which compartment a compartmnet definition describesRequiredCompartmentType
CompartmentDefinition.resource.code One of the resource types defined as part of FHIR.Requiredhttp://hl7.org/fhir/valueset/resource-typesResourceType

5.8.3.2 Using Compartments

As an example of compartment usage, to retrieve a list of a patient's conditions, use the URL:

  GET [base]/Patient/[id]/Condition

Additional search parameters can be defined, such as this hypothetical search for acute conditions:

  GET [base]/Patient/[id]/Condition?code:in=http://hspc.org/ValueSet/acute-concerns

Note that as searches, these are syntactic variations on these two search URLs respectively:

  GET [base]/Condition?patient=[id]
  GET [base]/Condition?patient=[id]&code:in=http://hspc.org/ValueSet/acute-concerns

Note that the outcome of a compartment search is the same as the equivalent normal search. As an example, both these searches return the same outcome if there is no patient 333:

  GET [base]/Patient/333/Condition
  GET [base]/Condition?patient=333

Whether the patient doesn't exist, or the user has no access to the patient, both these searches return an empty bundle with no matches. Some systems will include an operation outcome warning that there is no matching patient.

However, there is a key difference in functionality between compartment based searches and direct searches with parameters. Consider this search:

  GET [base]/Patient/[id]/Communication

Because the definition of the patient compartment for Communication says that a Communication resource is in the patient compartment if the subject, sender, or recipient is the patient, the compartment search is actually the same as the union of these 3 searches:

  GET [base]/Communication?subject=[id]
  GET [base]/Communication?sender=[id]
  GET [base]/Communication?recipient=[id]

There is no way to do this as a single search, except by using the _filter:

  GET [base]/Communication?_filter=subject re [id] or sender re [id] or recipient re [id]

Further details of searching by compartment are described under the search operation. As a search related operation, the assignment of resources to compartments is only based on the current version of any of the resources involved. Note that contained patient resources cannot create a patient compartment of their own.

Compartments may be used explicitly, like this, but can also be used implicitly. For instance, if a FHIR server is providing a patient view of a record, the authorized user associated with use of the FHIR RESTful API may be limited to accessing records from the compartment instance(s) logically associated with their identity. Irrespective of whether compartments are being used explicitly or implicitly, servers will need to make arrangements to make some resources with no direct link to a patient available to the client (medications, substances, etc.).

Note that resources may cross between compartments, or interlink them. Examples of this would be where a Diagnostic Report identifies a subject, but an Observation it references identifies a different subject, or where a List resource references items that identify different subjects. Such cross-linking may arise for many valid reasons, including:

  • Cases where subject records are inter-linked - Transplants, Perinatal care, family therapy etc.
  • Workflow management where action lists link multiple patients and/or practitioners

Given the wide variety of use cases and contexts in which FHIR is used, compartments do not define how cross-linking is handled. Systems may reject resources, remove them from both compartments, or place them in both, or act in some other fashion.

It is at the discretion of the server whether to include resources in a compartment when the reference to the resource that establishes the compartment is in an extension.

Some resources are not in any compartment, e.g. Medication, Substance, Location. These resources are not directly to a patient or authored record, and are sometimes called 'master files'. Servers will need to make arrangements to make these resources available to the clients that are limited to particular compartments. For example, a Medication resource describes a medication itself and does not link to a patient; however, a resource such as MedicationAdministration connects the Medication (details of what was administered) to the patient (for whom was it administered), and so is required to interpret the administration.

5.8.4 Defining New Compartments

Compartments are defined and added the list above when implementer communities identify them as common access points for data. As described below, compartments have both syntactical and logical consequences, and both these aspects of their functionality are evaluated when deciding whether to define compartments.

5.8.5 Search Parameters

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

NameTypeDescriptionPaths
codetokenPatient | Encounter | RelatedPerson | Practitioner | DeviceCompartmentDefinition.code
datedatePublication Date(/time)CompartmentDefinition.date
namestringInformal name for this compartment definitionCompartmentDefinition.name
resourcetokenName of resource typeCompartmentDefinition.resource.code
statustokendraft | active | retiredCompartmentDefinition.status
urluriAbsolute URL used to reference this compartment definitionCompartmentDefinition.url