Slice

A slice of an array is a subarray of the original array to which you can apply constraints. It is a part of Slicing.

Syntax

Match property:

  • match (Match)

Cardinality properties:

  • min (integer)
  • max (integer)

Order property:

  • order (integer)

Reslice property:

  • reslice (string)

Constrain existing slice property:

  • sliceIsConstraining (boolean)

Schema property

  • schema (Element)

Slice matching

Syntax

Type property:

  • type (string: pattern|binding|profile|type)

Resolve ref (Obtain reference target and perform checks on it?) property:

  • resolve-ref (boolean)

Pattern / Binding / Profile / Type specification property:

  • value (Object)

A slice of an array is a subarray of the original array. This subarray is selected using match expressions. Let's overview existing match types:

Pattern

This matcher type enables the specification of a pattern to be compared against each element in the source array. The comparison relies on partial equality, meaning that for an element to match, it must contain all the properties and values specified in the pattern but may also have additional properties.

To define a slice utilizing this match type, the schema would look like this:

slicing:
  slices:
    <your-slice-name>:
      match:
        type: pattern
        value:
          system: http://hl7.org/fhir/sid/us-npi

Matched data element

The following data element will be matched into the slice defined earlier:

use: official
system: http://hl7.org/fhir/sid/us-npi
value: 1346336807

Unmatched data element

The following data element won't be matched into the slice defined earlier:

use: official
system: some-custom-system
value: some-value

resolve-ref

If you are slicing a reference array and want to check your pattern against the actual reference target, not the reference data element, add the resolve-ref: true declaration.

Consider FHIR R4 lipidprofile:

url: http://hl7.org/fhir/StructureDefinition/lipidprofile|4.0.1
package-meta:
  name: hl7.fhir.r4.core
  version: 4.0.1
  path: test/fixtures/hl7.fhir.r4.core#4.0.1
excluded:
- conclusionCode
id: lipidprofile
base: http://hl7.org/fhir/StructureDefinition/DiagnosticReport|4.0.1
kind: resource
required:
- code
type: http://hl7.org/fhir/StructureDefinition/DiagnosticReport|4.0.1
datatype: DiagnosticReport
 elements:
  code:
    fixed:
      coding:
      - system: http://loinc.org
        code: 57698-3
        display: Lipid panel with direct LDL - Serum or Plasma
    type: http://hl7.org/fhir/StructureDefinition/CodeableConcept|4.0.1
    datatype: CodeableConcept
   result:
     slicing:
      discriminator:
      - type: value
        path: resolve().code
      ordered: true
      rules: closed
       slices:
         Cholesterol:
          schema:
           refers:
           - http://hl7.org/fhir/StructureDefinition/cholesterol|4.0.1
            mustSupport: true
            type: http://hl7.org/fhir/StructureDefinition/Reference|4.0.1
            datatype: Reference
          min: 1
          max: 1
          order: 0
           match:
             type: pattern
             resolve-ref: true
             value:
               code:
                 coding:
                 - system: http://loinc.org
                   code: 35200-5
                   display: Cholesterol [Moles/​volume] in Serum or Plasma
        Triglyceride:
          schema:
            refers:
            - http://hl7.org/fhir/StructureDefinition/triglyceride|4.0.1
            mustSupport: true
            type: http://hl7.org/fhir/StructureDefinition/Reference|4.0.1
            datatype: Reference
          min: 1
          max: 1
          order: 1
          match:
            type: pattern
            resolve-ref: true
            value:
              code:
                coding:
                - system: http://loinc.org
                  code: 35217-9
                  display: Triglyceride [Moles/​volume] in Serum or Plasma
        HDLCholesterol:
          schema:
            refers:
            - http://hl7.org/fhir/StructureDefinition/hdlcholesterol|4.0.1
            mustSupport: true
            type: http://hl7.org/fhir/StructureDefinition/Reference|4.0.1
            datatype: Reference
          min: 1
          max: 1
          order: 2
          match:
            type: pattern
            resolve-ref: true
            value:
              code:
                coding:
                - system: http://loinc.org
                  code: 2085-9
                  display: HDL Cholesterol
        LDLCholesterol:
          schema:
            refers:
            - http://hl7.org/fhir/StructureDefinition/ldlcholesterol|4.0.1
            mustSupport: true
            type: http://hl7.org/fhir/StructureDefinition/Reference|4.0.1
            datatype: Reference
          min: 0
          max: 1
          order: 3
          match:
            type: binding
            resolve-ref: true
            value:
              code:
                valueSet: http://hl7.org/fhir/ValueSet/ldlcholesterol-codes
                strength: required
    array: true
  conclusion:
    min: 0
    max: 1
    mustSupport: true
    type: http://hl7.org/fhir/StructureDefinition/string|4.0.1
    datatype: string
  conclusionCode:
    type: http://hl7.org/fhir/StructureDefinition/CodeableConcept|4.0.1
    datatype: CodeableConcept

Human interpretation of the slice: The first reference should point to a cholesterol resource that contains the same code as used in the value property.

Binding

This matcher enables the specification of a terminology binding that will be checked against each element in the source array. An element will be matched in the slice if it passes the terminology binding check. The array in which this slicing is defined must be one of the following types: code, Coding, or CodeableConcept.

Consider folowing US Core 5.0.1 Condition Problems and Health Concerns schema:

url: http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition-problems-health-concerns
package-meta:
  name: hl7.fhir.us.core
  version: 5.0.1
  path: "/tmp/lw-fhir-schema-repository/hl7.fhir.us.core#5.0.1"
id: us-core-condition-problems-health-concerns
base: http://hl7.org/fhir/StructureDefinition/Condition
kind: resource
required:
- category
- code
type: Condition
elements:
  abatementDateTime:
    mustSupport: true
    type: dateTime
    choiceOf: abatement
  onsetPeriod:
    mustSupport: true
    type: Period
    choiceOf: onset
  onset:
    choices:
    - onsetDateTime
    - onsetAge
    - onsetPeriod
    - onsetRange
    - onsetString
  clinicalStatus:
    binding:
      valueSet: http://hl7.org/fhir/ValueSet/condition-clinical
      strength: required
    mustSupport: true
  abatementString:
    mustSupport: true
    type: string
    choiceOf: abatement
  onsetAge:
    mustSupport: true
    type: Age
    choiceOf: onset
  abatementRange:
    mustSupport: true
    type: Range
    choiceOf: abatement
  extension:
    slicing:
      slices:
        assertedDate:
          schema:
            mustSupport: true
            type: Extension
          max: 1
          match:
            type: pattern
            value:
              url: http://hl7.org/fhir/StructureDefinition/condition-assertedDate
      discriminator:
      - type: value
        path: url
      rules: open
  onsetRange:
    mustSupport: true
    type: Range
    choiceOf: onset
  subject:
    refers:
    - http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient
    mustSupport: true
    type: Reference
  abatementAge:
    mustSupport: true
    type: Age
    choiceOf: abatement
  recordedDate:
    mustSupport: true
  onsetDateTime:
    mustSupport: true
    type: dateTime
    choiceOf: onset
  abatement:
    choices:
    - abatementDateTime
    - abatementAge
    - abatementPeriod
    - abatementRange
    - abatementString
  abatementPeriod:
    mustSupport: true
    type: Period
    choiceOf: abatement
  verificationStatus:
    binding:
      valueSet: http://hl7.org/fhir/ValueSet/condition-ver-status
      strength: required
    mustSupport: true
  category:
    mustSupport: true
    slicing:
     discriminator:
     - type: pattern
       path: "$this"
      rules: open
      slices:
        us-core:
         schema:
           binding:
             valueSet: http://hl7.org/fhir/us/core/ValueSet/us-core-problem-or-health-concern
             strength: required
           mustSupport: true
          min: 1
          match:
            type: binding
            value:
              strength: required
              valueSet: http://hl7.org/fhir/us/core/ValueSet/us-core-problem-or-health-concern
        sdoh:
          schema:
            mustSupport: true
            pattern:
              coding:
              - system: http://hl7.org/fhir/us/core/CodeSystem/us-core-tags
                code: sdoh
          min: 0
          max: 1
          match:
            type: pattern
            value:
              coding:
              - system: http://hl7.org/fhir/us/core/CodeSystem/us-core-tags
                code: sdoh
  code:
    binding:
      valueSet: http://hl7.org/fhir/us/core/ValueSet/us-core-condition-code
      strength: extensible
    mustSupport: true
  onsetString:
    mustSupport: true
    type: string
    choiceOf: onset

Human interpretation of the slice: There should be at least one CodeableConcept in category that matches the provided terminology binding.

Matched data element

The following data element will be matched into the slice defined earlier:

coding:
- system: http://terminology.hl7.org/CodeSystem/condition-category
  code: problem-list-item

Unmatched data element

The following data element won't be matched into the slice defined earlier (terminology biding violation):

coding:
- system: http://terminology.hl7.org/CodeSystem/condition-category
  code: some-random-code

Profile

This matcher type enables the specification of a reference to a profile against which data elements will be validated. If the validation returns no errors, the array element will be matched in the slice.

Consider this two custom schemas for Patient and Bundle resources:

Patient
base: http://hl7.org/fhir/StructureDefinition/Patient
id: custom-pat
url: custom-pat
type: Patient
required:
- gender
Bundle
base: http://hl7.org/fhir/StructureDefinition/Bundle
id: custom-bundle
url: custom-bundle
type: Bundle
elements:
  entry:
    slicing:
      slices:
        pat:
          min: 1
          max: 1
          match:
            type: profile
            value:
              resource: custom-pat

Human interpretation of the slice: there should be only one resource entry that fully conforms to custom-pat profile

Matched data element

The following data element (entry.0.resource) will be matched into the slice defined earlier:

meta:
  profile:
  - custom-bundle
resourceType: Bundle
type: transaction
entry:
- request:
    method: POST
    url: "/Patient"
  resource:
    resourceType: Patient
    gender: male

Unmatched data element

The following data element (entry.0.resource) won't be matched (due to missed gender property) into the slice defined earlier:

meta:
  profile:
  - custom-bundle
resourceType: Bundle
type: transaction
entry:
- request:
    method: POST
    url: "/Patient"
  resource:
    resourceType: Patient

resolve-ref

If you are slicing a reference array and want to check your profile against the actual reference target, not the reference data element, add the resolve-ref: true declaration.

url: http://hl7.org/fhir/us/davinci-alerts/StructureDefinition/transfer-notification-messageheader
package-meta:
  name: hl7.fhir.us.davinci-alerts
  version: 1.0.0
  path: test/fixtures/hl7.fhir.us.davinci-alerts#1.0.0
id: transfer-notification-messageheader
base: http://hl7.org/fhir/us/davinci-alerts/StructureDefinition/notifications-messageheader
required:
- eventCoding
- focus
type: MessageHeader
elements:
  eventCoding:
    binding:
      valueSet: http://hl7.org/fhir/us/davinci-alerts/ValueSet/notification-transfer-event
      strength: extensible
    mustSupport: true
    type: Coding
  focus:
    mustSupport: true
    slicing:
      discriminator:
      - type: profile
        path: "$this.resolve()"
      rules: open
      slices:
        discharge-notification:
          schema:
            refers:
            - http://hl7.org/fhir/us/davinci-alerts/StructureDefinition/adt-notification-encounter
            mustSupport: true
            type: Reference
          min: 1
          match:
            type: profile
            resolve-ref: true
            value: http://hl7.org/fhir/us/davinci-alerts/StructureDefinition/adt-notification-encounter
    array: true

Human interpretation of the slice: at least one reference should point to Encounter resource that fully conforms to http://hl7.org/fhir/us/davinci-alerts/StructureDefinition/adt-notification-encounter profile

Type

This matcher type enables the specification of a type against which data elements will be checked.

Consider this Davinici 0.1.0 Alerts schema:

---
url: http://hl7.org/fhir/us/davinci-alerts/StructureDefinition/notifications-bundle|1.0.0
package-meta:
  name: hl7.fhir.us.davinci-alerts
  version: 1.0.0
  path: test/fixtures/hl7.fhir.us.davinci-alerts#1.0.0
excluded:
- total
id: notifications-bundle
base: http://hl7.org/fhir/StructureDefinition/Bundle|4.0.1
required:
- id
- timestamp
type: http://hl7.org/fhir/StructureDefinition/Bundle|4.0.1
elements:
  id:
    mustSupport: true
  type:
    fixed: message
    mustSupport: true
    type: http://hl7.org/fhir/StructureDefinition/code|4.0.1
  timestamp:
    mustSupport: true
  entry:
    excluded:
    - search
    - request
    - response
    mustSupport: true
    slicing:
      discriminator:
      - type: type
        path: resource
      rules: open
      slices:
        messageheader:
          schema:
            mustSupport: true
            required:
            - resource
            elements:
              resource:
                mustSupport: true
                type: http://hl7.org/fhir/StructureDefinition/MessageHeader|4.0.1
          min: 1
          max: 1
          match:
            type: type
            value:
              resource:
                resourceType: MessageHeader
    array: true

Human interpretation of the slice: there should be only one MessageHeader resource among the bundle entries

Matched data element

The following data element (entry.0.resource) will be matched into the slice defined earlier:

resourceType: Bundle
meta:
  profile:
  - http://hl7.org/fhir/us/davinci-alerts/StructureDefinition/notifications-bundle
type: message
entry:
- resource:
    resourceType: MessageHeader
    eventCoding:
      code: code
    source:
      endpoint: google.com

Unmatched data element

The following data element (entry.0.resource) won't be matched (due to wrong resource type) into the slice defined earlier:

resourceType: Bundle
meta:
  profile:
  - http://hl7.org/fhir/us/davinci-alerts/StructureDefinition/notifications-bundle
type: message
entry:
- resource:
    resourceType: Patient

resolve-ref

If you are slicing a reference array and want to check your reference type add the resolve-ref: true declaration.

Consider this IHE Interactive Multimedia Report (IMR) DiagnosticReport schema

url: https://profiles.ihe.net/RAD/imr/StructureDefinition/imr-diagnosticreport
package-meta:
  name: ihe.rad.imr
  version: 0.1.0
  path: "/tmp/lw-fhir-schema-repository/ihe.rad.imr#0.1.0"
id: imr-diagnosticreport
base: http://hl7.org/fhir/StructureDefinition/DiagnosticReport
kind: resource
required:
- basedOn
- category
- subject
- effective
- effectiveDateTime
- issued
- performer
- resultsInterpreter
- result
- imagingStudy
- presentedForm
type: DiagnosticReport
elements:
  effectiveDateTime:
    mustSupport: true
    type: dateTime
  resultsInterpreter:
    refers:
    - http://hl7.org/fhir/StructureDefinition/Practitioner
    - http://hl7.org/fhir/StructureDefinition/PractitionerRole
    type: Reference
  presentedForm:
    constraints:
      IMRAttachmentInvariant:
        human: Either data or url SHALL be present
        severity: error
        expression: data.exists() or url.exists()
    mustSupport: true
    required:
    - contentType
    - size
    - hash
    slicing:
      discriminator:
      - type: pattern
        path: contentType
      description: Slice based on the presentedForm content type
      ordered: false
      rules: open
      slices:
        html:
          schema:
            elements:
              contentType:
                pattern: text/html
          min: 1
          max: 2147483647
          match:
            type: pattern
            value:
              contentType: text/html
        pdf:
          schema:
            elements:
              contentType:
                pattern: applicatoin/pdf
          min: 0
          max: 2147483647
          match:
            type: pattern
            value:
              contentType: applicatoin/pdf
    elements:
      contentType:
        mustSupport: true
      size:
        mustSupport: true
      hash:
        mustSupport: true
  basedOn:
    mustSupport: true
    slicing:
      discriminator:
      - type: type
        path: resolve()
      description: Slice based on the basedOn reference type
      ordered: false
      rules: open
      slices:
        serviceRequest:
          schema:
            refers:
            - https://profiles.ihe.net/RAD/imr/StructureDefinition/imr-servicerequest
            type: Reference
          min: 1
          max: 2147483647
          match:
            resolve-ref: true
            type: type
            value: ServiceRequest
  imagingStudy:
    refers:
    - https://profiles.ihe.net/RAD/imr/StructureDefinition/imr-imagingstudy
    mustSupport: true
    type: Reference
  extension:
    slicing:
      discriminator:
      - type: value
        path: url
      ordered: false
      rules: open
      slices:
        comparisonStudy:
          schema:
            mustSupport: true
            type: Extension
          min: 0
          max: 2147483647
          match:
            type: pattern
            value:
              url: https://profiles.ihe.net/RAD/imr/StructureDefinition/comparisonStudy
        indication:
          schema:
            mustSupport: true
            type: Extension
          min: 0
          max: 2147483647
          match:
            type: pattern
            value:
              url: https://profiles.ihe.net/RAD/imr/StructureDefinition/indication
  status:
    binding:
      valueSet: https://profiles.ihe.net/RAD/imr/ValueSet/imr-diagnosticreport-status-vs
      strength: required
      codesystems:
      - http://hl7.org/fhir/diagnostic-report-status
  subject:
    refers:
    - http://hl7.org/fhir/StructureDefinition/Patient
    type: Reference
  result:
    refers:
    - https://profiles.ihe.net/RAD/imr/StructureDefinition/imr-observation
    mustSupport: true
    type: Reference
  performer:
    slicing:
      discriminator:
      - type: type
        path: resolve()
      description: Slice based on the performer reference type
      ordered: false
      rules: open
      slices:
        organization:
          schema:
            refers:
            - http://hl7.org/fhir/StructureDefinition/Organization
            type: Reference
          min: 1
          max: 1
          match:
            resolve-ref: true
            type: type
            value: Organization
derivation: constraint

Matched data element

The following data element (performer.0) will be matched into the slice defined earlier:

meta:
  profile:
  - https://profiles.ihe.net/RAD/IMR/StructureDefinition/imr-diagnosticreport
resourceType: DiagnosticReport
performer:
- reference: Organization/1

Unmatched data element

The following data element (performer.0) won't be matched (due to wrong reference type) into the slice defined earlier:

meta:
  profile:
  - https://profiles.ihe.net/RAD/IMR/StructureDefinition/imr-diagnosticreport
resourceType: DiagnosticReport
performer:
- reference: Practitioner/1

Human interpretation of the slice: there should be only one performer reference of type Organization

Cardinality

You can constrain the number of elements your slice will match by providing min and max properties. Omit the max property to match an unlimited number of elements. To make a slice required, provide a min value of 1 or greater.

Consider following US Core 5.0.1 race extension schema

url: http://hl7.org/fhir/us/core/StructureDefinition/us-core-race
package-meta:
  name: hl7.fhir.us.core
  version: 5.0.1
  path: "/tmp/lw-fhir-schema-repository/hl7.fhir.us.core#5.0.1"
excluded:
- value
id: us-core-race
base: http://hl7.org/fhir/StructureDefinition/Extension
kind: complex-type
required:
- url
type: Extension
elements:
  extension:
    slicing:
      slices:
        ombCategory:
          schema:
            mustSupport: true
            required:
            - url
            - value
            type: Extension
            elements:
              url:
                scalar: true
                fixed: ombCategory
                type: uri
              valueCoding:
                binding:
                  valueSet: http://hl7.org/fhir/us/core/ValueSet/omb-race-category
                  strength: required
                scalar: true
                required-element: true
                type: Coding
                choiceOf: value
              value:
                choices:
                - valueCoding
                scalar: true
          min: 0
          max: 5
          match:
            type: pattern
            value:
              url: ombCategory
        detailed:
          schema:
            required:
            - url
            - value
            type: Extension
            elements:
              url:
                scalar: true
                fixed: detailed
                type: uri
              valueCoding:
                binding:
                  valueSet: http://hl7.org/fhir/us/core/ValueSet/detailed-race
                  strength: required
                scalar: true
                required-element: true
                type: Coding
                choiceOf: value
              value:
                choices:
                - valueCoding
                scalar: true
          min: 0
          max: 2147483647
          match:
            type: pattern
            value:
              url: detailed
        text:
          schema:
            scalar: true
            mustSupport: true
            required:
            - url
            - value
            type: Extension
            elements:
              url:
                scalar: true
                fixed: text
                type: uri
              valueString:
                scalar: true
                required-element: true
                type: string
                choiceOf: value
              value:
                choices:
                - valueString
                scalar: true
          min: 1
          max: 1
          match:
            type: pattern
            value:
              url: text
      discriminator:
      - type: value
        path: url
      rules: open
  url:
    scalar: true
    fixed: http://hl7.org/fhir/us/core/StructureDefinition/us-core-race
derivation: constraint

Valid case

The following data elements will be matched into the slices defined earlier:

extension:
- url: ombCategory
  valueCoding:
    system: urn:oid:2.16.840.1.113883.6.238
    code: 2028-9
    display: Asian
- url: text
  valueString: Asian
url: http://hl7.org/fhir/us/core/StructureDefinition/us-core-race

Invalid case

Due to the absence of text, the text slice won't be matched, resulting in a validation error, since the text slice is required.

extension:
- url: ombCategory
  valueCoding:
    system: urn:oid:2.16.840.1.113883.6.238
    code: 2028-9
    display: Asian
url: http://hl7.org/fhir/us/core/StructureDefinition/us-core-race

Order

Defines the slice order in the case of ordered slicing. Please refer to ordered slicing specification page.

Reslice

It's sometimes necessary to slice data that has already been sliced in the base profile - that is, create new slices within the existing slices. This is called Re-slicing. Using reslice property you can refer to an existing slice and start re-slicing definition.

Consider this two custom schemas:

Schema foo
base: http://hl7.org/fhir/StructureDefinition/Patient
type: Patient
elements:
  address:
    type: Address
    array: true
    slicing:
      rules: closed
      slices:
        homeaddress:
          min: 1
          match:
            type: pattern
            value:
              use: home

Human interpretation of the slice: there should be at least one address with use: home

Schema bar
base: foo
type: Patient
elements:
  address:
    type: Address
    array: true
    slicing:
      slices:
        homeaddress/a:
          reslice: homeaddress
          max: 2
          match:
            type: pattern
            value:
              text: foo

Human interpretation of the slice: Within elements matched to the homeaddress slice, there should be a maximum of 2 elements with text: foo.

Valid case

The following addresses will be matched into the slices defined earlier:

resourceType: Patient
meta:
  profile:
  - bar
address:
- use: home
  text: foo
- use: home
  text: foo

Invalid case

The following addresses won't be matched into the homeaddress/a re-slice defined earlier due to max limit (2) exceed:

resourceType: Patient
meta:
  profile:
  - bar
address:
- use: home
  text: foo
- use: home
  text: foo
- use: home
  text: foo

Constraining existing slice

You can further constrain slice defined earlier in parent schemas by using same slice name and setting sliceIsConstraining property to true. Usually it's a good way to forbid an optional slice.

Consider following custom schemas:

Schema foo
base: http://hl7.org/fhir/StructureDefinition/Patient
type: Patient
elements:
  address:
    type: Address
    array: true
    slicing:
      slices:
        homeaddress:
          match:
            type: pattern
            value:
              use: home
Schema bar
base: foo
type: Patient
elements:
  address:
    type: Address
    array: true
    slicing:
      slices:
        homeaddress:
          sliceIsConstraining: true
          max: 0

Valid case

The following addresses won't be matched in any of slices defined earlier.

resourceType: Patient
meta:
  profile:
  - bar
address:
- use: office
  text: foo

Invalid case

The following addresses will be matched into the homeaddress slice, which violates our additional constraint in the profile bar.

resourceType: Patient
meta:
  profile:
  - bar
address:
- use: home
  text: foo

@default slice

Reserved slice ID, you can mention this slice only if you have closed slicing; all unmatched data elements will be checked against this slice.

Consider following custom schema:

base: http://hl7.org/fhir/StructureDefinition/Patient
type: Patient
elements:
  address:
    slicing:
      rules: closed
      ordered: true
      slices:
        homeaddress:
          min: 1
          match:
            type: pattern
            value:
              use: home
          order: 0
        "@default":
          schema:
            required:
            - type
            elements:
              use:
                fixed: billing
          order: 1

Human description of the slice: there shoud be at least one address with use: home, also it should preced addresses with use: billing

Valid case

The following addresses will be matched into the slices defined earlier.

resourceType: Patient
meta:
  profile:
  - bar
address:
- use: home
- use: billing

Invalid case

The following addresses won't be matched into the slices defined earlier due to incorrect order.

resourceType: Patient
meta:
  profile:
  - bar
address:
- use: billing
- use: home

Schema

After an element is matched by the match property, you can define additional constraints via the schema property. This property is essentially an Element, and the matched data element will be validated against the provided schema as usual. If the validator produces errors during the validation of this element, it will count as an unmatched slice element.

Consider following custom schema:

base: Patient
url: custom-pat
elements:
  name:
    slicing:
      slices:
        off-name:
          schema:
            constraints:
              off-nam-constr-1:
                expression: given.exists() or family.exists()
                severity: error
          match:
            type: pattern
            min: 1
            value:
              use: official

Human description of the slice: there should be at least one name with use: official, this name must contain given or family.

Valid case

The following name will be matched into slice defined earlier.

resourceType: Patient
name:
  - use: official
    given:
      - John

Invalid cases

No official name.

resourceType: Patient
name:
  - use: nickname
    given:
      - test

No given or family.

resourceType: Patient
name:
  - use: official
    text: test