View raw Markdown
type: docsource: source/profiling-examples.html

[%settitle Profiling FHIR%] [%file newheader%] [%file newnavbar%] [%profilesheader examples%]

Slicing and Discriminator Examples

Responsible Owner: [[%wgt fhir%]]([%wg fhir%]) Work GroupStandards Status:Informative

Slicing Patient Telecom element

One common use of slicing is to describe different constraints on different kinds of patient contact details. In this example, Patient.telecom is defined as: ContactPoint [0..*] where the ContactPoint has system, value and use.

Consider the case where the profile should say:

An example of a patient resource that meets these rules:

<Patient>
... snip ... <telecom>
<system value="phone" />
<use value="home" />
<value value="5551234567" />
</telecom> <telecom>
<system value="email" />
<value value="someone@acme.org" />
</telecom> ... snip ... </Patient>

To do this, the profile that implements these rules needs to do the following:

In a StructureDefinition, this will look like:

<element id="Patient.telecom"> <path value="Patient.telecom"/> <slicing> <discriminator> <type value="value"/> <path value="system"/> </discriminator/> <discriminator> <type value="value"/> <path value="use"/> </discriminator/> <rules value="closed"/> </slicing>

&lt;min value="1"/&gt;
&lt;max value="3"/&gt;

</element>

<element id="Patient.telecom:HomePhone"> <path value="Patient.telecom"/> <sliceName value="HomePhone"/> <min value="1"/> <max value="1"/> </element> <element id="Patient.telecom:HomePhone.system"> <path value="Patient.telecom.system"/> <min value="1"/> <fixedCode value="phone"/> </element> <element id="Patient.telecom:HomePhone.value"> <path value="Patient.telecom.value"/> <min value="1"/> </element> <element id="Patient.telecom:HomePhone.use"> <path value="Patient.telecom.use"/> <min value="1"/> <fixedCode value="home"/> </element>

<element id="Patient.telecom:WorkPhone"> <path value="Patient.telecom"/> <sliceName value="WorkPhone"/> <min value="0"/> <max value="1"/> </element> <element id="Patient.telecom:WorkPhone"> <path value="Patient.telecom.system"/> <min value="1"/> <fixedCode value="phone"/> </element> <element id="Patient.telecom:WorkPhone"> <path value="Patient.telecom.value"/> <min value="1"/> </element> <element id="Patient.telecom:WorkPhone"> <path value="Patient.telecom.use"/> <min value="1"/> <fixedCode value="work"/> </element>

<element id="Patient.telecom:Email"> <path value="Patient.telecom"/> <sliceName value="Email"/> <min value="0"/> <max value="1"/> </element> <element id="Patient.telecom:Email"> <path value="Patient.telecom.system"/> <min value="1"/> <fixedCode value="email"/> </element> <element id="Patient.telecom:Email"> <path value="Patient.telecom.value"/> <min value="1"/> </element> <element id="Patient.telecom:Email"> <path value="Patient.telecom.use"/> <max value="0"/> </element>

Note: much of the definition detail has been left out, and only the parts relevant to the pattern are shown. Also, providing a fixed value makes the minimum cardinality irrelevant, but it is shown here for completeness.

This table illustrates the relationship between the instance and the ElementDefinitions:

PathNameMinMaxFixed
<Patient>Patient
Patient.telecom13
<telecom>Patient.telecomHomePhone11
 <system value="phone" />Patient.telecom.system11phone
 <value value="5551234567" />Patient.telecom.value11
 <use value="home" />Patient.telecom.use11home
</telecom>
Patient.telecomWorkPhone01
<telecom>Patient.telecomEmail01
 <system value="email" />Patient.telecom.system11email
 <value value="someone@acme.org" />Patient.telecom.value11
 </telecom>Patient.telecom.use

Fixed Order Slicing

A variant to this that looks simpler but turns out to be deceptively complicated is to fix the order and make all slices mandatory. In this case the profile says:

An example of a patient resource that meets these rules:

{ "resourceType" : "Patient", "telecom" : [ { "system" : "phone", "value" : "5551234567", "use" : "home" }, { "system" : "phone", "value" : "5551234567", "use" : "work" }, { "system" : "email", "value" : "someone@acme.org" } ] }

In a StructureDefinition, this will look like:

<element id="Patient.telecom:"> <path value="Patient.telecom"/> <slicing>

  &lt;description value="No discriminator needed since offsets are fixed"/&gt;
  &lt;rules value="closed"/&gt;
  &lt;ordered value="true"/&gt;
&lt;/slicing&gt;
<!-- cardinality rules -->
&lt;min value="3"/&gt;
&lt;max value="3"/&gt;

</element>

<element id="Patient.telecom:HomePhone"> <path value="Patient.telecom"/> <sliceName value="HomePhone"/> <min value="1"/> <max value="1"/> </element> <element id="Patient.telecom:HomePhone.system"> <path value="Patient.telecom.system"/> <min value="1"/> <fixedCode value="phone"/> </element> <element id="Patient.telecom:HomePhone.value"> <path value="Patient.telecom.value"/> <min value="1"/> </element> <element id="Patient.telecom:HomePhone.use"> <path value="Patient.telecom.use"/> <min value="1"/> <fixedCode value="home"/> </element>

<element id="Patient.telecom:WorkPhone"> <path value="Patient.telecom"/> <sliceName value="WorkPhone"/> <min value="0"/> <max value="1"/> </element> <element id="Patient.telecom:WorkPhone.system"> <path value="Patient.telecom.system"/> <min value="1"/> <fixedCode value="phone"/> </element> <element id="Patient.telecom:WorkPhone.value"> <path value="Patient.telecom.value"/> <min value="1"/> </element> <element id="Patient.telecom:WorkPhone.use"> <path value="Patient.telecom.use"/> <min value="1"/> <fixedCode value="work"/> </element>

<element id="Patient.telecom:Email"> <path value="Patient.telecom"/> <sliceName value="Email"/> <min value="0"/> <max value="1"/> </element> <element id="Patient.telecom:Email.system> <path value="Patient.telecom.system"/> <min value="1"/> <fixedCode value="email"/> </element> <element id="Patient.telecom:Email.value"> <path value="Patient.telecom.value"/> <min value="1"/> </element> <element id="Patient.telecom:Email.use"> <path value="Patient.telecom.use"/> <max value="0"/> </element>

A simple content model like this is attractive because it's both easier to specify and to work with. There's no need to think about the values of system and use - implementers can just grab first telecom value etc.

The problem with this approach is that such simple requirements are rarely valid in production healthcare systems, and even if they are valid during implementation, they rarely stay that way. Implementing multiple applications based on simple offsets will make the overall eco-system fragile against change, either internally, or as the scope of the eco-system grows.

Since the discriminator could be system+use in this case, it's best for future compatibility to specify it anyway.

Blood Pressure Example

Another use of Slicing is for Blood Pressure Measurements, where the profile says:

An example of an observation resource that conforms such constrained StructureDefinitions looks like this:

<Observation>
... <component>
<code>
<coding>
<system value="http://loinc.org" />
<code value="8480-6" />
<display value="Systolic blood pressure" />
</coding>
</code>
<valueQuantity ... />
</component> <component>
<code>
<coding>
<system value="http://loinc.org" />
<code value="8462-4" />
<display value="Diastolic blood pressure" />
</coding>
</code>
<valueQuantity .../>
</component> </Patient>

To do this, the profile that implements these rules needs to do the following:

In a StructureDefinition, this will look like:

<element id="Observation.component"> <path value="Observation.component"/> <slicing> <discriminator> <type value="value"/> <path value="code"/> </discriminator/> </slicing>

&lt;min value="2"/&gt;
&lt;max value="\*"/&gt;

</element>

<element id="Observation.component:systolic"> <path value="Observation.component"/> <sliceName value="systolic"/> <min value="1"/> <max value="1"/> </element> <element id="Observation.component:systolic.code"> <path value="Observation.component.code"/> <min value="1"/> <fixedCodeableConcept> <coding>
<system value="http://loinc.org" />
<code value="8480-6" />
<display value="Systolic blood pressure" />
</coding>
</fixedCodeableConcept> </element> <element id="Observation.component:systolic.valueQuantity"> <path value="Observation.component.valueQuantity"/> <min value="1"/> </element>

<element id="Observation.component:diastolic"> <path value="Observation.component"/> <slicename value="diastolic"/> <min value="1"/> <max value="1"/> </element> <element id="Observation.component:diastolic.code"> <path value="Observation.component.code"/> <min value="1"/> <fixedCodeableConcept> <coding>
<system value="http://loinc.org" />
<code value="8462-4" />
<display value="Diastolic blood pressure" />
</coding>
</fixedCodeableConcept> </element> <element id="Observation.component:diastolic.valueQuantity"> <path value="Observation.component.valueQuantity"/> <min value="1"/> </element>

Note: much of the definition detail has been left out, and only the parts relevant to the pattern are shown. e.g., A real blood pressure profile would fix unit, an overall Observation code etc.

Extensions

For another example, consider slicing extensions. The base extension on every element is defined as a list (0..*) of extensions, and each extension has a url that identifies it, and a value. Consider an example where a profile defines that for a particular element (named Patient), there are two extensions, with URLs http://acme.com/a and http://acme.com/b. In addition, the profile allows other extensions to be used.

Technically, the profile achieves this by "slicing" the extension list, into two slices, and saying that the slicing is "open" - that there can be other slices introduced. Here are the relevant parts of the Profile on patient:

<StructureDefinition xmlns="http://hl7.org/fhir">

&lt;baseType value="Patient" /&gt;
&lt;baseDefinition value="http://hl7.org/fhir/StructureDefinition/Patient" /&gt;
&lt;derivation value="constraint" /&gt;
&lt;snapshot&gt;
  &lt;element id="Patient"&gt;
    &lt;path value="Patient"/&gt;
    <!-- snip -->
  &lt;/element&gt;
  &lt;element id="Patient.extension"&gt;
    &lt;path value="Patient.extension"/&gt;
    <!-- this first element defines the slicing, and carries the base definition forward -->
    &lt;slicing&gt;
      <!-- Extensions are always discriminated by URL -->
      &lt;discriminator&gt;
        &lt;type value="value"/&gt;
        &lt;path value="url"/&gt;
      &lt;/discriminator/&gt;
      &lt;ordered value="false"/&gt;     <!-- we don't care what order they appear in -->
      &lt;rules value="open"/&gt;        <!-- other extensions can be used -->
    &lt;/slicing&gt;
    <!-- -- snip definition -->
  &lt;/element&gt;
  <!-- first extension -->
  &lt;element id="Patient.extension:name-a"&gt;
    &lt;path value="Patient.extension"/&gt;
    &lt;slicename value="name-a"/&gt; <!-- mandatory - gives the slice a name -->
    <!-- snip most of definition -->
    &lt;type&gt;
     &lt;code value="Extension"/&gt;
     <!-- the profile for an extension is a reference to the extension definition itself -
       this implies a profile, and happens to fix the @url value to the desired URL -->
     &lt;profile value="http://acme.com/a"/&gt;
    &lt;/type&gt;
  &lt;/element&gt;
  <!-- second extension -->
  &lt;element id="Patient.extension:name-b"&gt;
    &lt;path value="Patient.extension"/&gt;
    &lt;slicename value="name-b"/&gt; <!-- mandatory - gives the slice a name -->
    <!-- snip most of definition -->
    &lt;type&gt;
     &lt;code value="Extension"/&gt;
     <!-- the profile for an extension is a reference to the extension definition itself -
       this implies a profile, and happens to fix the @url value to the desired URL -->
     &lt;profile value="http://acme.com/b"/&gt;
    &lt;/type&gt;
  &lt;/element&gt;
  <!-- snip rest of profile -->
&lt;/snapshot&gt;

</StructureDefinition>

Here is a patient example that conforms to this profile:

<Patient xmlns="http://hl7.org/fhir">

<extension url="http://acme.com/b">

<!-- snip whatever value extension would have -->

</extension> <extension url="http://acme.com/a">

<!-- snip whatever value extension would have -->

</extension>

</Patient>

Diagnostic Report & Observation

In this example, a profile on a diagnostic report says that it must have four observations, each with a different LOINC code (e.g., a classic lab panel). In this case (taken from the Example Lipid Profile), the structure that applies to DiagnosticReport will say that there are four slices on DiagnosticReport.result, each conforming to a different structure, which are also contained in the same profile. Each of those structures will constrain the LOINC code in the observation.

<StructureDefinition xmlns="http://hl7.org/fhir">

<url value="http://acme.org/fhir/StructureDefinition/lipid-report"/> <name value="LipidProfile"/> <baseType value="DiagnosticReport"/> <baseDefinition value="http://hl7.org/fhir/StructureDefinition/DiagnosticReport"/> <derivation value="constraint" />

<snapshot>

&lt;element id="DiagnosticReport.result"&gt;
  <!-- first definition for result -->
  &lt;path value="DiagnosticReport.result"/&gt;
  &lt;slicing&gt;
    <!-- this is sliced by the code value of the target of the reference -->
    &lt;discriminator&gt;
      &lt;type value="value"/&gt;
      &lt;path value="resolve().code"/&gt;
    &lt;/discriminator/&gt;
    <!-- have to be in the specified order -->
    &lt;ordered value="true"/&gt;
    <!-- this profile says, no other observations allowed -->
    &lt;rules value="closed"/&gt;
  &lt;/slicing&gt;
  <!-- snip definition -->
&lt;/element&gt;
<!-- first slice: Cholesterol -->
&lt;element id="DiagnosticReport.result:Cholesterol"&gt;
  &lt;path value="DiagnosticReport.result"/&gt;
  &lt;sliceName value="Cholesterol"/&gt;
  <!-- snip definition parts -->
  &lt;type&gt;
    &lt;code value="Reference"/&gt;
    <!-- this target must conform to the "Cholesterol" structure -->
    &lt;targetProfile value="http://acme.org/fhir/StructureDefinition/Cholesterol"/&gt;
  &lt;/type&gt;
&lt;/element&gt;
<!-- next 3 slices all the same, but different names for profile -->
&lt;element id="DiagnosticReport.result"&gt;
  &lt;path value="DiagnosticReport.result:Triglyceride"/&gt;
  &lt;sliceName value="Triglyceride"/&gt;
  <!-- snip definition parts -->
  &lt;type&gt;
    &lt;code value="Reference"/&gt;
    <!-- this target must conform to the "Triglyceride" structure -->
    &lt;targetProfile value="http://acme.org/fhir/StructureDefinition/Triglyceride"/&gt;
  &lt;/type&gt;
&lt;/element&gt;
&lt;element id="DiagnosticReport.result:LDLCholesterol"&gt;
  &lt;path value="DiagnosticReport.result"/&gt;
  &lt;sliceName value="LDLCholesterol"/&gt;
  <!-- snip definition parts -->
  &lt;type&gt;
    &lt;code value="Reference"/&gt;
    <!-- this target must conform to the "LDLCholesterol" structure -->
    &lt;targetProfile value="http://acme.org/fhir/StructureDefinition/LDLCholesterol"/&gt;
  &lt;/type&gt;
&lt;/element&gt;
&lt;element id="DiagnosticReport.result:HDLCholesterol"&gt;
  &lt;path value="DiagnosticReport.result"/&gt;
  &lt;sliceName value="HDLCholesterol"/&gt;
  <!-- snip definition parts -->
  &lt;type&gt;
    &lt;code value="Reference"/&gt;
    <!-- this target must conform to the "HDLCholesterol" structure -->
    &lt;targetProfile value="http://acme.org/fhir/StructureDefinition/HDLCholesterol"/&gt;
  &lt;/type&gt;
&lt;/element&gt;
<!-- snip elements -->

</snapshot> </StructureDefinition>

<StructureDefinition> <url value="http://acme.org/fhir/StructureDefinition/Cholesterol"/> <name value="Cholesterol"/> <baseType value="Observation"/> <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Observation"/> <derivation value="constraint" /> <snapshot>

&lt;element id="Observation.code"&gt;
  <!-- this the element definition for name. Because of the
    slicing / discriminator rules in the LipidReport profile
    that references it, it is required to fix the value of
    the name element -->
  &lt;path value="Observation.code"/&gt;
  <!-- there are actually 3 ways to fix a CodeableConcept
  to a single fixed value. Here, we used the simplest one -->
  &lt;valueCodeableConcept&gt;
    <!-- just fix the value to the right code -->
    &lt;coding&gt;
      &lt;system value="http://loinc.org"/&gt;
      &lt;code value="35200-5"/&gt;
      &lt;display value="Cholesterol"/&gt;
    &lt;/coding&gt;
  &lt;/valueCodeableConcept&gt;
&lt;/element&gt;
<!-- snip elements -->

</snapshot> </StructureDefinition>

<StructureDefinition> <url value="http://acme.org/fhir/StructureDefinition/Triglyceride"/> <name value="Triglyceride"/> <baseType value="Observation"/> <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Observation"/> <derivation value="constraint" /> <snapshot>

&lt;element id="Observation.code"&gt;
  <!-- this the element definition for name. Because of the
    slicing / discriminator rules in the LipidReport profile
    that references it, it is required to fix the value of
    the name element -->
  &lt;path value="Observation.code"/&gt;
  <!-- there's actually 3 ways to fix a CodeableConcept
  to a single fixed value. Here, we used the simplest one -->
  &lt;valueCodeableConcept&gt;
    <!-- just fix the value to the right code -->
    &lt;coding&gt;
      &lt;system value="http://loinc.org"/&gt;
      &lt;code value="35217-9"/&gt;
      &lt;display value="Triglyceride"/&gt;
    &lt;/coding&gt;
  &lt;/valueCodeableConcept&gt;
&lt;/element&gt;
<!-- snip elements -->

</snapshot> </StructureDefinition>

<StructureDefinition> <url value="http://acme.org/fhir/StructureDefinition/LDLCholesterol"/> <name value="LDLCholesterol"/> <baseType value="Observation"/> <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Observation"/> <derivation value="constraint" /> <snapshot>

&lt;element id="Observation.code"&gt;
  <!-- this the element definition for name. Because of the
    slicing / discriminator rules in the LipidReport profile
    that references it, it is required to fix the value of
    the name element -->
  &lt;path value="Observation.code"/&gt;
  <!-- because of the way that LDL cholesterol measurements works
      (well, in this context- it varies), there's 2 different LOINC
      codes for either measured or calculated. So here, we bind to
      a value set -->
  &lt;binding&gt;
  &lt;conformance value="required"/&gt; <!-- must be required if this is a discriminator -->
  <!-- snip the actual value set reference, but it refers to a value
        set with two LOINC codes, one for each kind of LDL, which in
        this case are LOINC codes 18262-6 and 13457-7 -->
  &lt;/binding&gt;
&lt;/element&gt;
<!-- snip elements -->

</snapshot> </StructureDefinition>

<StructureDefinition> <url value="http://acme.org/fhir/StructureDefinition/HDLCholesterol"/> <name value="HDLCholesterol"/> <baseType value="Observation"/> <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Observation"/> <derivation value="constraint" /> <snapshot>

&lt;element id="Observation.code"&gt;
  <!-- this the element definition for name. Because of the
    slicing / discriminator rules in the LipidReport profile
    that references it, it is required to fix the value of
    the name element -->
  &lt;path value="Observation.code"/&gt;
  <!-- there's actually 3 ways to fix a CodeableConcept
  to a single fixed value. Here, we used the simplest one -->
  &lt;valueCodeableConcept&gt;
    <!-- just fix the value to the right code -->
    &lt;coding&gt;
      &lt;system value="http://loinc.org"/&gt;
      &lt;code value="2089-1"/&gt;
      &lt;display value="LDL Cholesterol"/&gt;
    &lt;/coding&gt;
  &lt;/valueCodeableConcept&gt;
&lt;/element&gt;
<!-- snip elements -->

</snapshot> </StructureDefinition>

Here is an instance that meets the rules for this profile:

<DiagnosticReport xmlns="http://hl7.org/fhir">

<result> <reference value="Observation/cholesterol"/> </result> <result> <reference value="Observation/triglyceride"/> </result> <result> <reference value="Observation/ldlcholesterol"/> </result> <result> <reference value="Observation/hdlcholesterol"/> </result>

</DiagnosticReport>

<Observation xmlns="http://hl7.org/fhir">

<code> <coding> <system value="http://loinc.org"/> <code value="35200-5"/> <display value="Cholesterol"/> </coding> </code>

</Observation>

<Observation xmlns="http://hl7.org/fhir"> <code> <coding> <system value="http://loinc.org"/> <code value="35217-9"/> <display value="Triglyceride"/> </coding> </code>

</Observation>

<Observation xmlns="http://hl7.org/fhir"> <code> <coding> <system value="http://loinc.org"/> <code value="2085-9"/> <display value="HDL Cholesterol"/> </coding> </code>

</Observation>

<Observation id="ldlcholesterol"> <code> <coding> <system value="http://loinc.org"/> <code value="13457-7"/> <display value="LDL Chol. (Calc)"/> </coding> </code>

</Observation>

Note that this version is not valid, because the slices are not in the correct order:

<DiagnosticReport xmlns="http://hl7.org/fhir">

<result> <reference value="Observation/cholesterol"/> </result> <result> <reference value="Observation/triglyceride"/> </result>

<result> <reference value="Observation/hdlcholesterol"/> </result> <result> <reference value="Observation/ldlcholesterol"/> </result>

</DiagnosticReport>

Composition Sections

Most uses of Composition involve conformance to a profile that specifies which sections will exist, and what their contents will be. This is yet another example of slicing. A typical document content profile might specify a section structure something like this:

Real profiles will contain lots of detail about the sections, but these are omitted here in the interests of clarity.

An example of a Composition that meets these rules:

<Composition>
... snip ... <section>
<code>
<coding>
<system value="http://loinc.org" />
<use value="29299-5" />
<value value="Reason for visit Narrative" />
</coding>
</code>
... snip ... </section> <section>
<code>
<coding>
<system value="http://loinc.org" />
<use value="46057-6" />
<value value="Medications section" />
</coding>
</code>
... snip ... <section>
<code>
<coding>
<system value="http://loinc.org" />
<use value="66149-6" />
<value value="Prescribed medications" />
</coding>
</code>
... snip ... </section> <section>
<code>
<coding>
<system value="http://loinc.org" />
<use value="66150-4" />
<value value="O medications" />
</coding>
</code>
... snip ... </section> </section> <section>
<code>
<coding>
<system value="http://loinc.org" />
<use value="8716-3" />
<value value="Vital signs" />
</coding>
</code>
... snip ... </section> </Composition>

To do this, the profile that implements these rules needs to do the following:

In a StructureDefinition, this will look like:

<element id="Composition.section"> <path value="Composition.section"/> <slicing> <discriminator> <type value="value"/> <path value="code"/> </discriminator/> <ordered value="true"/> <rules value="closed"/> </slicing>

&lt;min value="3"/&gt;
&lt;max value="3"/&gt;

</element>

<element id="Composition.section:reason-for-visit"> <path value="Composition.section"/> <sliceName value="reason-for-visit"/> <min value="1"/> <max value="1"/> </element> <element id="Composition.section:reason-for-visit.code"> <path value="Composition.section.code"/> <min value="1"/> <fixedCodeableConcept> <coding>
<system value="http://loinc.org" />
<use value="29299-5" />
<value value="Reason for visit Narrative" />
</coding>
</fixedCodeableConcept> </element>

<element id="Composition.section:medications"> <path value="Composition.section"/> <sliceName value="medications"/> <min value="1"/> <max value="1"/> </element> <element id="Composition.section:medications.code"> <path value="Composition.section.code"/> <min value="1"/> <fixedCodeableConcept> <coding>
<system value="http://loinc.org" />
<use value="46057-6" />
<value value="Medications section" />
</coding>
</fixedCodeableConcept> </element>

<element id="Composition.section.section"> <path value="Composition.section:medications.section"/> <slicing> <discriminator> <type value="value"/> <path value="code"/> </discriminator/> <ordered value="true"/> <rules value="closed"/> </slicing>

&lt;min value="1"/&gt;
&lt;max value="2"/&gt;

</element>

<element id="Composition.section:medications.section:prescribed"> <path value="Composition.section.section"/> <sliceName value="prescribed"/> <min value="1"/> <max value="1"/> </element> <element id="Composition.section:medications.section:prescribed.code"> <path value="Composition.section.section.code"/> <min value="1"/> <fixedCodeableConcept> <coding>
<system value="http://loinc.org" />
<use value="66149-6" />
<value value="Prescribed medications" />
</coding>
</fixedCodeableConcept> </element>

<element id="Composition.section:medications.section:otc"> <path value="Composition.section.section"/> <sliceName value="otc"/> <min value="0"/> <max value="1"/> </element> <element id="Composition.section:medications.section:otc.code"> <path value="Composition.section.section.code"/> <min value="1"/> <fixedCodeableConcept> <coding>
<system value="http://loinc.org" />
<use value="66150-4" />
<value value="Over the counter medications" />
</coding>
</fixedCodeableConcept> </element>

<element id="Composition.section:vital-signs"> <path value="Composition.section"/> <sliceName value="vital-signs"/> <min value="1"/> <max value="1"/> </element> <element id="Composition.section:vital-signs.code"> <path value="Composition.section.code"/> <min value="1"/> <fixedCodeableConcept> <coding>
<system value="http://loinc.org" />
<use value="8716-3" />
<value value="Vital signs" />
</coding>
</fixedCodeableConcept> </element>

Re-slicing

For some use cases, it is necessary to further re-slice in a derivative profile. This is when Profile A derives from Profile B, Profile A slices an element in Slice A and B, and Profile B further slices Slice A into A1 and A2.

As an example, assume that institution implementation guide specifies that a medication list is represented by a List resource, where the items into the list are split up into 3 slices, based on resource type:

These slices must come in order.

Now, a particular application creates an additional profile that specifies the following rules in addition to the base rules of the institution:

  1. the medicationRequests will be sliced into active and non-active, where all the active requests will come first, and then the inactive ones
  2. only active MedicationAdministrations will be encountered
  3. Medication statements are not supported

An example of a List resource that meets these rules:

<List>
... snip ... <entry>
<item>
<reference value="MedicationRequest/ex-active-1"/>
</item>
</entry> <entry>
<item>
<reference value="MedicationRequest/ex-active-2"/>
</item>
</entry> <entry>
<item>
<reference value="MedicationRequest/ex-inactive-1"/>
</item>
</entry> <entry>
<item>
<reference value="MedicationAdministration/ex-any-1"/>
</item>
</entry>

... snip ... </List>

The StructureDefinition differential for the first profile sets up the slicing, and then defines 3 slices:

<element id="List.entry"> <path value="List.entry"/> <slicing> <discriminator> <type value="profile"/> <path value="entry.item.resolve()"/> </discriminator> <ordered value="true"/> <rules value="closed"/> </slicing> </element>

<element id="List.entry:medrequest"> <path value="List.entry"/> <sliceName value="medrequest"/> </element> <element id="List.entry:medrequest.item"> <path value="List.entry.item"/> <type> <code value="Reference"/> <targetProfile value="http://example.org/StructureDefinition/medrequest"/> </type> </element>

<element id="List.entry:medadmin"> <path value="List.entry"/> <sliceName value="medadmin"/> </element> <element id="List.entry:medadmin.item"> <path value="List.entry.item"/> <type> <code value="Reference"/> <targetProfile value="http://example.org/StructureDefinition/medadmin"/> </type> </element>

<element id="List.entry:medstmt"> <path value="List.entry"/> <sliceName value="medstmt"/> </element> <element id="List.entry:medstmt.item"> <path value="List.entry.item"/> <type> <code value="Reference"/> <targetProfile value="http://example.org/StructureDefinition/medstmt"/> </type> </element>

The derived StructureDefinition differential re-slices the first slice into 2 slices, constrains the second slice, and prohibits the 3rd:

<element id="List.entry:med-request"> <path value="List.entry"/> <slicing> <discriminator> <type value="profile"/> <path value="entry.item.resolve()"/> </discriminator> <ordered value="true"/> <rules value="closed"/> </slicing> </element>

<element id="List.entry:med-request/active"> <path value="List.entry"/>

&lt;sliceName value="medrequest/active"/&gt; 

</element> <element id="List.entry:med-request/active.item"> <path value="List.entry.item"/> <type> <code value="Reference"/> <targetProfile value="http://example.org/StructureDefinition/medrequest-active"/> </type> </element>

<element id="List.entry:med-request/inactive"> <path value="List.entry"/> <sliceName value="medrequest/inactive"/> </element> <element id="List.entry:med-request/inactive.item"> <path value="List.entry.item"/> <type> <code value="Reference"/> <targetProfile value="http://example.org/StructureDefinition/medrequest-active"/> </type> </element>

<element id="List.entry:medadmin"> <path value="List.entry"/>

&lt;sliceName value="medadmin"/&gt; 

</element> <element id="List.entry:medadmin.item"> <path value="List.entry.item"/> <type> <code value="Reference"/> <targetProfile value="http://example.org/StructureDefinition/medadmin-active"/> </type> </element>

<element id="List.entry:medstmt"> <path value="List.entry"/>

&lt;sliceName value="medstmt"/&gt; 
&lt;max value="0"/&gt;

</element>

[%file newfooter%]