Slicing


Introduction


In this module you will learn more about Slicing. We will use Forge, the official HL7®FHIR® profile editor, to edit our profiles. You can download Forge for free.

The topics covered in this module are:

  • When to use slicing
  • Defining a discrimator
  • Slicing in Forge

Reading material


Once you have finished the Start Profiling module, you are well versed in how to apply constraints to your profile's elements. These changes are overall constraints that, once made, pertain to an element in its entirety. Slicing allows you to assign specific constraints to each individual slice of an element.

1. When to use slicing

Slicing is useful when constraints need to be made that do not necessarily apply to the whole element. In this case it would be best to slice the element first and then apply constraints to the slices individually. This allows you to define different constraints to each slice of a single element, thereby further customizing your profile.

Example
Suppose you want to be really specific about what types of phone numbers you are sending or receiving for your Patient resources. In some situations, you may want to specify that your Patient resource must have a mobile number and can have a home phone and work phone. To make the mobile number obligatory without also making the home phone and work phone necessary it would be best to first slice the telecom element and then to assign the cardinality and use to each slice individually.

2. Defining a discriminator

A system will need some type of indicator to determine what differentiates the slices. In other words it needs to know which element to choose to be able to tell the elements apart. The discriminator is used to distinguish the sliced elements from one another. The discriminators in their sum should allow systems to easily determine which slice belongs to each section.

When you first slice an element you will need to assign a discriminator. To do this you will need to assign a Path and Type when creating slices. The Path indicates in which element the discriminator can be found. The Type defines how the discriminator should be evaluated. There are five types defined in the FHIR specification:

  • value - The slices have different values in the nominated element
  • exists - The slices are differentiated by the presence or absence of the nominated element
  • pattern - The slices have different values in the nominated element, as determined by testing them against the applicable ElementDefinition.pattern[x]
  • type - The slices are differentiated by type of the nominated element to a specified profile
  • profile - The slices are differentiated by conformance of the nominated element to a specified profile

Example
Suppose you want to slice the element Patient.identifier and add a slice for both the national identifier and the hospital identifier for a Patient. The discriminator will be the value of the naming system used to register the identifier (e.g. in the Netherlands the BSN number is used as the national identifier, while the hospital will use a local patient number as the hospital identifier). In this case the Type of the discriminator is value and its Path is system.

3. Cardinality of slices and slice entry

When you have defined one or more slices on an element, you can define different cardinalities for each slice and the sliced element. In the example of the previous section, you could say for example that a patient should at least have a BSN number and an optional local patient number. The cardinality of the identifier element would be for example be 0..* or you could restrict it to 0..2 if you don't want to allow more than two identifiers. The cardinality of the slice for BSN number would be 1..1 to make it mandatory and the cardinality of the local patient number would be 0..1 to make it optional.

Another possibility is that you add a couple of optional slices (0..1) and specify that exactly one of them should be defined by restricting the cardinality of the slice entry to 1..1. For example, suppose you want to slice the element MedicationStatement.subject and add the following slices: a slice named SubjectPatient and a slice named SubjectGroup. Both slices are optional, but the slice entry cardinality requires you to specify at least one subject.

<element id="MedicationStatement.subject">
    <path value="MedicationStatement.subject"/>
    <slicing>
        <discriminator>
            <type value="type"/>
            <path value="$this"/>
        </discriminator>
        <rules value="open"/>
    </slicing>
    <min value="1"/>
    <max value="1"/>
</element>
<element id="MedicationStatement.subject:SubjectPatient">
    <path value="MedicationStatement.subject"/>
    <sliceName value="SubjectPatient"/>
    <min value="0"/>
    <max value="1"/>
    <type>
        <code value="Reference"/>
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient"/>
    </type>
</element>
<element id="MedicationStatement.subject:SubjectGroup">
    <path value="MedicationStatement.subject"/>
    <sliceName value="SubjectGroup"/>
    <min value="0"/>
    <max value="1"/>
    <type>
        <code value="Reference"/>
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Group"/>
    </type>
</element>

4. Slicing rules

Slicing rules define how slices are interpreted when evaluating an instance of the resource. When slicing an element you can use these rules to define whether or not you want to allow additional content. In the rules element of the sliced element you can choose one of the following options.

Code Definition
closed No additional content is allowed other than that described by the slices in this profile.
open Additional content is allowed anywhere in the list.
openAtEnd Additional content is allowed, but only at the end of the list. Note that using this requires that the slices be ordered, which makes it hard to share uses. This should only be done where absolutely required.

For example, let's say you have sliced Practitioner.identifier. In the Netherlands, we have different ways of identifying practitioners: UZI number, AGB code and BIG code. Let's say you added a slice for UZI number as well as a slice for AGB code. When the slicing is open, you are allowed to add additional identifiers, such as the a BIG code. When the slicing is closed, however, you are not allowed to add a BIG code. When the slicing is open at end, you are allowed to add a BIG code, but only at the end of the list of identifiers.

5. Slicing in Forge

Select the element that you want to slice and click on the scissor icon. The element is now ‘Sliced’ and it is possible to add slices by clicking the scissor icon with a little plus. You can create as many slices as necessary by selecting the sliced element and clicking the ‘Add Slice’ icon again. The added slices can be defined and constrained as any other element.

After adding slices, Forge shows a warning message containing the message that there is no discriminator defined for the sliced elements. The discriminator information can be provided in the ‘Element Properties’ of the sliced element under ‘Slicing Details’. Assign a Path and Type to assign a discriminator. Note that Forge automatically initializes the discriminator for type slices when you slice a "name[x]" element.

By default the Rules element is set to Open. You can change this in the sliced element (the one with the scissor icon next to it) by selecting the desired value from the drop down menu.

Keep in mind that slicing is also used to express extensions definitions and extension elements. The Forge UI tries to hide this complexity from the user, however it is clearly visible in the XML viewer.


Real-life examples


Here below are examples of customers that we helped building profiles.

HL7 Norway

HL7 Norway promotes standardized exchange of clinical and administrative information between various health-related information systems in Norway, using international standards from HL7 (www.hl7.org).

The example below shows the HL7 Norway profile for a Practitioner. In Norway, practitioners have a HPR number (a health employee number, issued by the National Agency for Healthcare), a F-number (a birth number, issued by the Tax Administration) and a HERID (a unique identifier for a given health unit, which can be either a person, organization or service). To distinguish between these types of identifiers, the identifier element is sliced and for each of type of identifier a slice is added. The discriminator in this case is the value of the system (i.e. type=value, path=system). A practitioner should have exactly one HPR-number and one F-number (cardinality in these slices is 1..1). In addition, a practitioner should have at least one HERID (cardinality in this slice is 1..*).

NameFlagsCard.TypeDescription & Constraintsdoco
.. Practitioner 0..*PractitionerA person with a formal responsibility in the provisioning of healthcare or related services
... id Σ0..1idLogical id of this artifact
... meta Σ0..1MetaMetadata about the resource
... implicitRules ?! Σ0..1uriA set of rules under which this content was created
... language 0..1codeLanguage of the resource content
Binding: http://tools.ietf.org/html/bcp47 (required)
... text I0..1NarrativeText summary of the resource, for human interpretation
... contained 0..*ResourceContained, inline Resources
... extension 0..*ExtensionAdditional Content defined by implementations
... modifierExtension ?!0..*ExtensionExtensions that cannot be ignored
... identifier ΣIdentifierA identifier for the person as this agent
Slice: Unordered, Open At End, by system
... identifier (HPR-number) Σ1..1IdentifierHPR-number
.... id 0..1idxml:id (or equivalent in JSON)
.... extension 0..*ExtensionAdditional Content defined by implementations
.... use ?! Σ0..0code
.... type Σ0..0CodeableConcept
.... system Σ1..1uriThe namespace for the identifier
Fixed Value: urn:oid:2.16.578.1.12.4.1.4.4
.... value Σ1..1stringThe value that is unique
Example: 123456
.... period Σ0..0Period
.... assigner Σ0..0Reference(Organization)
... identifier (F-number) Σ1..1IdentifierF-number
.... id 0..1idxml:id (or equivalent in JSON)
.... extension 0..*ExtensionAdditional Content defined by implementations
.... use ?! Σ0..0code
.... type Σ0..0CodeableConcept
.... system Σ1..1uriThe namespace for the identifier
Fixed Value: urn:oid:2.16.578.1.12.4.1.4.1
.... value Σ1..1stringThe value that is unique
Example: 123456
.... period Σ0..0Period
.... assigner Σ0..0Reference(Organization)
... identifier (HERID) Σ1..*IdentifierA identifier for the person as this agent
.... id 0..1idxml:id (or equivalent in JSON)
.... extension 0..*ExtensionAdditional Content defined by implementations
.... use ?! Σ0..1codeusual | official | temp | secondary (If known)
Binding: IdentifierUse (required)
.... type Σ0..0CodeableConcept
.... system Σ1..1uriThe namespace for the identifier
Fixed Value: urn:oid:2.16.578.1.12.4.1.2
.... value Σ1..1stringThe value that is unique
Example: 123456
.... period Σ0..0Period
.... assigner Σ0..0Reference(Organization)
... active Σ0..1booleanWhether this practitioner's record is in active use
... name Σ0..1HumanNameA name associated with the person
.... id 0..1idxml:id (or equivalent in JSON)
.... extension 0..*ExtensionAdditional Content defined by implementations
.... use ?! Σ0..0code
.... text Σ0..1stringText representation of the full name
.... family Σ0..*stringFamily name (often called 'Surname')
.... given Σ0..*stringGiven names (not always 'first'). Includes middle names
.... prefix Σ0..0string
.... suffix Σ0..0string
.... period Σ0..0Period
... telecom Σ0..0ContactPoint
... address Σ0..1AddressWhere practitioner can be found/visited
.... id 0..1idxml:id (or equivalent in JSON)
.... extension 0..*ExtensionAdditional Content defined by implementations
.... use ?! Σ0..1codehome | work | temp | old - purpose of this address
Binding: AddressUse (required)
Fixed Value: work
.... type Σ0..1codepostal | physical | both
Binding: AddressType (required)
Example: both
.... text Σ0..1stringText representation of the address
Example: 137 Nowhere Street, Erewhon 9132
.... line Σ0..*stringStreet name, number, direction & P.O. Box etc.
Example: 137 Nowhere Street
.... city Σ0..1stringName of city, town etc.
Example: Erewhon
.... district Σ0..1stringDistrict name (aka county)
Example: Madison
.... state Σ0..0string
.... postalCode Σ0..1stringPostal code for area
Example: 9132
.... country Σ0..1stringCountry (can be ISO 3166 3 letter code)
.... period Σ0..0Period
... gender Σ0..1codemale | female | other | unknown
Binding: AdministrativeGender (required)
... birthDate Σ0..1dateThe date on which the practitioner was born
... photo 0..0Attachment
... practitionerRole 0..*BackboneElementRoles/organizations the practitioner is associated with
.... id 0..1idxml:id (or equivalent in JSON)
.... extension 0..*ExtensionAdditional Content defined by implementations
.... modifierExtension ?!0..*ExtensionExtensions that cannot be ignored
.... managingOrganization 0..1Reference(noAuditOrganization)Organization where the roles are performed
.... role Σ0..1CodeableConceptRoles which this practitioner may perform
Binding: PractitionerRole (example)
..... id 0..1idxml:id (or equivalent in JSON)
..... extension 0..*ExtensionAdditional Content defined by implementations
..... coding Σ0..*CodingCode defined by a terminology system
...... id 0..1idxml:id (or equivalent in JSON)
...... extension 0..*ExtensionAdditional Content defined by implementations
...... system Σ1..1uriIdentity of the terminology system
...... version Σ0..0string
...... code Σ1..1codeSymbol in syntax defined by the system
...... display Σ0..1stringRepresentation defined by the system
...... userSelected Σ0..0boolean
..... text Σ0..1stringPlain text representation of the concept
.... specialty Σ0..0CodeableConcept
.... period Σ0..1PeriodThe period during which the practitioner is authorized to perform in these role(s)
.... location 0..0Reference(Location)
.... healthcareService 0..0Reference(HealthcareService)
... qualification 0..0BackboneElement
... communication 0..0CodeableConcept

doco Documentation for this format

Nictiz

Nictiz is the centre of expertise for standardization and eHealth in The Netherlands. HL7 Netherlands core and MedMij profiles are published on Simplifier. MedMij is a national project that aims to give Dutch citizens integrated access to all their health data in one personal health environment. FHIR is used as a standard to exchange health information between the involved parties. The profiles are based on standardized clinical building blocks called Health and Care Information Models (HCIM).

The example below shows the Dutch profile for the HCIM InstructionsForUse (e.g. dose and route of medication administration), which is based on the core Dosage data type. The element dose[x] is sliced on data type and two slices are added: DoseQuantity (a slice for data type SimpleQuantity) and DoseRange (a slice for data type Range).

sequence
text
additionalInstruction
timingHCIM AdministrationSchedule
asNeededCodeableConceptCodeableConceptBinding
routeBinding
DoseQuantitySimpleQuantityBinding
lowBinding
highBinding
numeratorBinding
rate[x]

In the discriminator the type element is set to 'type' and the path is set to '$this'. See the XML code below.

    <slicing>
      <discriminator>
        <type value="type" />
        <path value="$this" />
      </discriminator>
      <rules value="open" />
    </slicing>


Exercise


In this exercise you will continue with the Patient profile that you created in the Start Profiling module. If you did not follow this module, please create a new profile on Patient and complete the required fields in the Properties tab. Start by reading the case description. Here below are a couple of links that you may find useful during this exercise:

    Case description
    Hospital X wants to receive patient data from general practitioners. The hospital has decided to build conform the FHIR standard, starting with administrative data of patients and their general practitioner. The following (additional) requirements are specified:
  • Patients are identified by their BSN number, a specific HIS ID is optional
  • Email address is mandatory
  • Phone number is optional

Steps to follow

  1. Start Forge and open your Patient profile.
  2. Slice the element ‘identifier’.
  3. Add two slices.
  4. Give both slices a logical name.
  5. Choose the right value for ‘system’ to ensure that the BSN number is unique and according to the given system. See the link above.
  6. Ensure that the elements ‘system’ and ‘value’ in 'identification' are mandatory.
  7. Add a discriminator on system for the two slices. Select the right constraints in this element. Note that path already contains the value system.
  8. Now you know how to slice, change the profile to meet the remaining two requirements.

Feedback


We are always looking for ways to improve our products. The Profiling Academy was built using our own IG-editor in Simplifier. If you have any feedback on this module or on our Profiling Academy in general, please leave a comment in the Issue Tracker of the project.


Get in touch


Start profiling

Most modules end with an exercise. Use Forge to start profiling yourself. Just contact us at simplifier@fire.ly if you need any help.

Learn more

Follow one of our predefined or tailor-made courses. We will make sure you know FHIR inside-out.

Need help or advice?

Let us assist you with your FHIR use case. Visit our company website to know more about our services or get into contact with Rien Wertheim right away.