工作组:FHIR Infrastructure ![]() | 成熟度: 1 | Trial Use | Security Category: Anonymous | Compartments: Not linked to any defined compartments |
逻辑区块定义声明了如何在服务器上访问资源
每个资源可能属于一个或多个逻辑逻辑区块。逻辑区块是共享公共属性的资源的逻辑分组。逻辑区块主要扮演以下两个角色:
注意:
目前,逻辑区块定义只能由国际HL7组织定义。这是因为它们的存在会对服务器的行为产生重大影响。
逻辑区块定义描述了如何命名和标识特定逻辑区块实例,以及系统如何知道逻辑区块中有哪些资源。本规范规定了以下逻辑区块:
| 逻辑区块名称 | 描述 | 标识 | 成员 |
| Patient (患者区块) |
与特定患者相关的资源集 | 每个患者资源都有一个患者逻辑区块的实例,并且逻辑区块的标识与患者相同。 当患者链接到另一患者时,与链接患者相关联的所有记录都会在逻辑区块中,此逻辑区块与链接目标相关联。 | 患者逻辑区块包括资源主体是患者的任何资源,以及与患者逻辑区块中的资源直接相关的一些其他资源 |
| Encounter (医疗活动区块) | The set of resources associated with a particular encounter | There is an instance of the encounter compartment for each encounter resource, and the identity of the compartment is the same as the encounter | The encounter compartment includes any resources where the resource has an explicitly nominated encounter, and some other resources that themselves 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?) |
| RelatedPerson (相关人区块) | The 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 relatedPerson | The relatedPerson compartment includes any resources where the resource is explicitly linked to relatedPerson (usually as author) |
| Practitioner (参与人区块) | The set of resources associated with a particular practitioner | There is an instance of the practitioner compartment for each Practitioner resource, and the identity of the compartment is the same as the Practitioner | The practitioner compartment includes any resources where the resource is explicitly linked to a Practitioner (usually as author, but other kinds of linkage exist) |
| Device (设备区块) | The set of resources associated with a particular device | There is an instance of the device compartment for each Device resource, and the identity of the compartment is the same as the Device | The 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.
This resource is referenced by CapabilityStatement
Structure
| Name | Flags | Card. | Type | Description & Constraints![]() |
|---|---|---|---|---|
![]() | ITU | DomainResource | Compartment Definition for a resource + Warning: Name should be usable as an identifier for the module by machine processing applications such as code generation Elements defined in Ancestors: id, meta, implicitRules, language, text, contained, extension, modifierExtension | |
![]() ![]() | Σ | 1..1 | uri | Canonical identifier for this compartment definition, represented as a URI (globally unique) |
![]() ![]() | Σ | 0..1 | string | Business version of the compartment definition |
![]() ![]() | ΣI | 1..1 | string | Name for this compartment definition (computer friendly) |
![]() ![]() | ?!Σ | 1..1 | code | draft | active | retired | unknown PublicationStatus (Required) |
![]() ![]() | Σ | 0..1 | boolean | For testing purposes, not real usage |
![]() ![]() | Σ | 0..1 | dateTime | Date last changed |
![]() ![]() | Σ | 0..1 | string | Name of the publisher (organization or individual) |
![]() ![]() | Σ | 0..* | ContactDetail | Contact details for the publisher |
![]() ![]() | 0..1 | markdown | Natural language description of the compartment definition | |
![]() ![]() | Σ | 0..* | UsageContext | The context that the content is intended to support |
![]() ![]() | 0..1 | markdown | Why this compartment definition is defined | |
![]() ![]() | Σ | 1..1 | code | Patient | Encounter | RelatedPerson | Practitioner | Device CompartmentType (Required) |
![]() ![]() | Σ | 1..1 | boolean | Whether the search syntax is supported |
![]() ![]() | Σ | 0..* | BackboneElement | How a resource is related to the compartment |
![]() ![]() ![]() | Σ | 1..1 | code | Name of resource type ResourceType (Required) |
![]() ![]() ![]() | Σ | 0..* | string | Search Parameter Name, or chained parameters |
![]() ![]() ![]() | 0..1 | string | Additional documentation about the resource and compartment | |
Documentation for this format | ||||
UML Diagram (Legend)
XML Template
<CompartmentDefinition xmlns="http://hl7.org/fhir"><!-- from Resource: id, meta, implicitRules, and language --> <!-- from DomainResource: text, contained, extension, and modifierExtension --> <url value="[uri]"/><!-- 1..1 Canonical identifier for this compartment definition, represented as a URI (globally unique) --> <version value="[string]"/><!-- 0..1 Business version of the compartment definition --> <name value="[string]"/><!--
1..1 Name for this compartment definition (computer friendly) --> <status value="[code]"/><!-- 1..1 draft | active | retired | unknown --> <experimental value="[boolean]"/><!-- 0..1 For testing purposes, not real usage --> <date value="[dateTime]"/><!-- 0..1 Date last changed --> <publisher value="[string]"/><!-- 0..1 Name of the publisher (organization or individual) --> <contact><!-- 0..* ContactDetail Contact details for the publisher --></contact> <description value="[markdown]"/><!-- 0..1 Natural language description of the compartment definition --> <useContext><!-- 0..* UsageContext The context that the content is intended to support --></useContext> <purpose 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 a resource is related to the compartment --> <code value="[code]"/><!-- 1..1 Name of resource type --> <param value="[string]"/><!-- 0..* Search Parameter Name, or chained parameters --> <documentation value="[string]"/><!-- 0..1 Additional documentation about the resource and compartment --> </resource> </CompartmentDefinition>
JSON Template
{
"resourceType" : "CompartmentDefinition",
// from Resource: id, meta, implicitRules, and language
// from DomainResource: text, contained, extension, and modifierExtension
"url" : "<uri>", // R! Canonical identifier for this compartment definition, represented as a URI (globally unique)
"version" : "<string>", // Business version of the compartment definition
"name" : "<string>", // C? R! Name for this compartment definition (computer friendly)
"status" : "<code>", // R! draft | active | retired | unknown
"experimental" : <boolean>, // For testing purposes, not real usage
"date" : "<dateTime>", // Date last changed
"publisher" : "<string>", // Name of the publisher (organization or individual)
"contact" : [{ ContactDetail }], // Contact details for the publisher
"description" : "<markdown>", // Natural language description of the compartment definition
"useContext" : [{ UsageContext }], // The context that the content is intended to support
"purpose" : "<markdown>", // Why this compartment definition is defined
"code" : "<code>", // R! Patient | Encounter | RelatedPerson | Practitioner | Device
"search" : <boolean>, // R! Whether the search syntax is supported
"resource" : [{ // How a resource is related to the compartment
"code" : "<code>", // R! Name of resource type
"param" : ["<string>"], // Search Parameter Name, or chained parameters
"documentation" : "<string>" // Additional documentation about the resource and compartment
}]
}
Turtle Template
@prefix fhir: <http://hl7.org/fhir/> .[ 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 Canonical identifier for this compartment definition, represented as a URI (globally unique) fhir:CompartmentDefinition.version [ string ]; # 0..1 Business version of the compartment definition fhir:CompartmentDefinition.name [ string ]; # 1..1 Name for this compartment definition (computer friendly) fhir:CompartmentDefinition.status [ code ]; # 1..1 draft | active | retired | unknown fhir:CompartmentDefinition.experimental [ boolean ]; # 0..1 For testing purposes, not real usage fhir:CompartmentDefinition.date [ dateTime ]; # 0..1 Date last changed fhir:CompartmentDefinition.publisher [ string ]; # 0..1 Name of the publisher (organization or individual) fhir:CompartmentDefinition.contact [ ContactDetail ], ... ; # 0..* Contact details for the publisher fhir:CompartmentDefinition.description [ markdown ]; # 0..1 Natural language description of the compartment definition fhir:CompartmentDefinition.useContext [ UsageContext ], ... ; # 0..* The context that the content is intended to support fhir:CompartmentDefinition.purpose [ 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 a 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 parameters fhir:CompartmentDefinition.resource.documentation [ string ]; # 0..1 Additional documentation about the resource and compartment ], ...; ]
Changes since R3
| CompartmentDefinition | |
| CompartmentDefinition |
|
| CompartmentDefinition.version |
|
| CompartmentDefinition.status |
|
| CompartmentDefinition.experimental |
|
| CompartmentDefinition.code |
|
| CompartmentDefinition.resource.code |
|
| CompartmentDefinition.title |
|
| CompartmentDefinition.jurisdiction |
|
See the Full Difference for further information
This analysis is available as XML or JSON.
See R3 <--> R4 Conversion Maps (status = 6 tests that all execute ok. 1 fail round-trip testing and 5 r3 resources are invalid (0 errors).)
Structure
| Name | Flags | Card. | Type | Description & Constraints![]() |
|---|---|---|---|---|
![]() | ITU | DomainResource | Compartment Definition for a resource + Warning: Name should be usable as an identifier for the module by machine processing applications such as code generation Elements defined in Ancestors: id, meta, implicitRules, language, text, contained, extension, modifierExtension | |
![]() ![]() | Σ | 1..1 | uri | Canonical identifier for this compartment definition, represented as a URI (globally unique) |
![]() ![]() | Σ | 0..1 | string | Business version of the compartment definition |
![]() ![]() | ΣI | 1..1 | string | Name for this compartment definition (computer friendly) |
![]() ![]() | ?!Σ | 1..1 | code | draft | active | retired | unknown PublicationStatus (Required) |
![]() ![]() | Σ | 0..1 | boolean | For testing purposes, not real usage |
![]() ![]() | Σ | 0..1 | dateTime | Date last changed |
![]() ![]() | Σ | 0..1 | string | Name of the publisher (organization or individual) |
![]() ![]() | Σ | 0..* | ContactDetail | Contact details for the publisher |
![]() ![]() | 0..1 | markdown | Natural language description of the compartment definition | |
![]() ![]() | Σ | 0..* | UsageContext | The context that the content is intended to support |
![]() ![]() | 0..1 | markdown | Why this compartment definition is defined | |
![]() ![]() | Σ | 1..1 | code | Patient | Encounter | RelatedPerson | Practitioner | Device CompartmentType (Required) |
![]() ![]() | Σ | 1..1 | boolean | Whether the search syntax is supported |
![]() ![]() | Σ | 0..* | BackboneElement | How a resource is related to the compartment |
![]() ![]() ![]() | Σ | 1..1 | code | Name of resource type ResourceType (Required) |
![]() ![]() ![]() | Σ | 0..* | string | Search Parameter Name, or chained parameters |
![]() ![]() ![]() | 0..1 | string | Additional documentation about the resource and compartment | |
Documentation for this format | ||||
XML Template
<CompartmentDefinition xmlns="http://hl7.org/fhir"><!-- from Resource: id, meta, implicitRules, and language --> <!-- from DomainResource: text, contained, extension, and modifierExtension --> <url value="[uri]"/><!-- 1..1 Canonical identifier for this compartment definition, represented as a URI (globally unique) --> <version value="[string]"/><!-- 0..1 Business version of the compartment definition --> <name value="[string]"/><!--
1..1 Name for this compartment definition (computer friendly) --> <status value="[code]"/><!-- 1..1 draft | active | retired | unknown --> <experimental value="[boolean]"/><!-- 0..1 For testing purposes, not real usage --> <date value="[dateTime]"/><!-- 0..1 Date last changed --> <publisher value="[string]"/><!-- 0..1 Name of the publisher (organization or individual) --> <contact><!-- 0..* ContactDetail Contact details for the publisher --></contact> <description value="[markdown]"/><!-- 0..1 Natural language description of the compartment definition --> <useContext><!-- 0..* UsageContext The context that the content is intended to support --></useContext> <purpose 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 a resource is related to the compartment --> <code value="[code]"/><!-- 1..1 Name of resource type --> <param value="[string]"/><!-- 0..* Search Parameter Name, or chained parameters --> <documentation value="[string]"/><!-- 0..1 Additional documentation about the resource and compartment --> </resource> </CompartmentDefinition>
JSON Template
{
"resourceType" : "CompartmentDefinition",
// from Resource: id, meta, implicitRules, and language
// from DomainResource: text, contained, extension, and modifierExtension
"url" : "<uri>", // R! Canonical identifier for this compartment definition, represented as a URI (globally unique)
"version" : "<string>", // Business version of the compartment definition
"name" : "<string>", // C? R! Name for this compartment definition (computer friendly)
"status" : "<code>", // R! draft | active | retired | unknown
"experimental" : <boolean>, // For testing purposes, not real usage
"date" : "<dateTime>", // Date last changed
"publisher" : "<string>", // Name of the publisher (organization or individual)
"contact" : [{ ContactDetail }], // Contact details for the publisher
"description" : "<markdown>", // Natural language description of the compartment definition
"useContext" : [{ UsageContext }], // The context that the content is intended to support
"purpose" : "<markdown>", // Why this compartment definition is defined
"code" : "<code>", // R! Patient | Encounter | RelatedPerson | Practitioner | Device
"search" : <boolean>, // R! Whether the search syntax is supported
"resource" : [{ // How a resource is related to the compartment
"code" : "<code>", // R! Name of resource type
"param" : ["<string>"], // Search Parameter Name, or chained parameters
"documentation" : "<string>" // Additional documentation about the resource and compartment
}]
}
Turtle Template
@prefix fhir: <http://hl7.org/fhir/> .[ 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 Canonical identifier for this compartment definition, represented as a URI (globally unique) fhir:CompartmentDefinition.version [ string ]; # 0..1 Business version of the compartment definition fhir:CompartmentDefinition.name [ string ]; # 1..1 Name for this compartment definition (computer friendly) fhir:CompartmentDefinition.status [ code ]; # 1..1 draft | active | retired | unknown fhir:CompartmentDefinition.experimental [ boolean ]; # 0..1 For testing purposes, not real usage fhir:CompartmentDefinition.date [ dateTime ]; # 0..1 Date last changed fhir:CompartmentDefinition.publisher [ string ]; # 0..1 Name of the publisher (organization or individual) fhir:CompartmentDefinition.contact [ ContactDetail ], ... ; # 0..* Contact details for the publisher fhir:CompartmentDefinition.description [ markdown ]; # 0..1 Natural language description of the compartment definition fhir:CompartmentDefinition.useContext [ UsageContext ], ... ; # 0..* The context that the content is intended to support fhir:CompartmentDefinition.purpose [ 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 a 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 parameters fhir:CompartmentDefinition.resource.documentation [ string ]; # 0..1 Additional documentation about the resource and compartment ], ...; ]
Changes since Release 3
| CompartmentDefinition | |
| CompartmentDefinition |
|
| CompartmentDefinition.version |
|
| CompartmentDefinition.status |
|
| CompartmentDefinition.experimental |
|
| CompartmentDefinition.code |
|
| CompartmentDefinition.resource.code |
|
| CompartmentDefinition.title |
|
| CompartmentDefinition.jurisdiction |
|
See the Full Difference for further information
This analysis is available as XML or JSON.
See R3 <--> R4 Conversion Maps (status = 6 tests that all execute ok. 1 fail round-trip testing and 5 r3 resources are invalid (0 errors).)
See the Profiles & Extensions and the alternate definitions: Master Definition XML + JSON, XML Schema/Schematron + JSON Schema, ShEx (for Turtle) + see the extensions & the dependency analysis
| Path | Definition | Type | Reference |
|---|---|---|---|
| CompartmentDefinition.status | The lifecycle status of an artifact. | Required | PublicationStatus |
| CompartmentDefinition.code | Which type a compartment definition describes. | Required | CompartmentType |
| CompartmentDefinition.resource.code | One of the resource types defined as part of this version of FHIR. | Required | Resource Types |
| id | Level | Location | Description | Expression |
| cpd-0 | Warning | (base) | Name should be usable as an identifier for the module by machine processing applications such as code generation | name.matches('[A-Z]([A-Za-z0-9_]){0,254}') |
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
The outcome of a compartment search is the same as the equivalent normal search. For 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.
Note that while this specification describes how to use the compartment syntax to find resources that are logically associated with the compartment, the compartment is not part of the identity of the resource. E.g. the response to the following is not defined by this specification:
GET [base]/Patient/[patient-id]/Condition/[resource-id]
The response for write operations (PUT/DELETE/PATCH) are also not defined by this specification. Nor is the response to a POST defined:
POST [base]/Patient/[patient-id]/Condition
There is no expectation for servers to support either read or write to such URLs.
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:
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.
The graph definition resource provides a method by which rules about cross-linking may be made and enforced.
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 linked 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.
Compartments are defined and added to 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.
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 | Expression | In Common |
| code | token | Patient | Encounter | RelatedPerson | Practitioner | Device | CompartmentDefinition.code | |
| context | token | A use context assigned to the compartment definition | (CompartmentDefinition.useContext.value as CodeableConcept) | |
| context-quantity | quantity | A quantity- or range-valued use context assigned to the compartment definition | (CompartmentDefinition.useContext.value as Quantity) | (CompartmentDefinition.useContext.value as Range) | |
| context-type | token | A type of use context assigned to the compartment definition | CompartmentDefinition.useContext.code | |
| context-type-quantity | composite | A use context type and quantity- or range-based value assigned to the compartment definition | On CompartmentDefinition.useContext: context-type: code context-quantity: value.as(Quantity) | value.as(Range) | |
| context-type-value | composite | A use context type and value assigned to the compartment definition | On CompartmentDefinition.useContext: context-type: code context: value.as(CodeableConcept) | |
| date | date | The compartment definition publication date | CompartmentDefinition.date | |
| description | string | The description of the compartment definition | CompartmentDefinition.description | |
| name | string | Computationally friendly name of the compartment definition | CompartmentDefinition.name | |
| publisher | string | Name of the publisher of the compartment definition | CompartmentDefinition.publisher | |
| resource | token | Name of resource type | CompartmentDefinition.resource.code | |
| status | token | The current status of the compartment definition | CompartmentDefinition.status | |
| url | uri | The uri that identifies the compartment definition | CompartmentDefinition.url | |
| version | token | The business version of the compartment definition | CompartmentDefinition.version |