<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="au-device" />
  <url value="http://hl7.org.au/fhir/StructureDefinition/au-device" />
  <version value="1.1.0" />
  <name value="AUBaseDevice" />
  <title value="AU Base Device" />
  <status value="draft" />
  <date value="2017-09-26T15:50:09.867+10:00" />
  <publisher value="Health Level Seven Australia (Patient Administration WG)" />
  <contact>
    <telecom>
      <system value="url" />
      <value value="http://hl7.org.au/fhir" />
      <use value="work" />
    </telecom>
  </contact>
  <description value="This profile defines a device administration details structure that includes core localisation concepts for use in an Australian context." />
  <fhirVersion value="3.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Device" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Device" />
  <derivation value="constraint" />
  <differential>
    <element id="Device">
      <path value="Device" />
      <short value="A device in an Australian healthcare context" />
    </element>
    <element id="Device.identifier">
      <path value="Device.identifier" />
      <slicing>
        <discriminator>
          <type value="pattern" />
          <path value="type" />
        </discriminator>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Device.identifier:paid">
      <path value="Device.identifier" />
      <sliceName value="paid" />
      <short value="My Health Record Assigned Identity for Devices (PAI-D)" />
      <definition value="My Health Record (PCEHR) Assigned Identity for Devices (PAI-D) numbers. An identifier for devices which may author documents on behalf of organisations." />
      <max value="1" />
      <constraint>
        <key value="inv-paid-value-0" />
        <requirements value="The value shall be a 16 digit number." />
        <severity value="error" />
        <human value="PAI-D shall be an exactly 16 digit number" />
        <expression value="value.matches('^([0-9]{16})$')" />
      </constraint>
      <constraint>
        <key value="inv-paid-value-1" />
        <severity value="error" />
        <human value="PAI-D prefix is 8003640003" />
        <expression value="value.startsWith('8003640003')" />
      </constraint>
      <constraint>
        <key value="inv-paid-value-2" />
        <requirements value="PAI-D shall pass the Luhn algorithm check" />
        <severity value="error" />
        <human value="The identifier shall pass the Luhn algorithm check" />
        <expression value="(((select(value.substring(0,1).toInteger()).select(iif($this&lt;5, $this*2, (($this*2)-9))))+(value.substring(1,1).toInteger())+(select(value.substring(2,1).toInteger()).select(iif($this&lt;5, $this*2, (($this*2)-9))))+(value.substring(3,1).toInteger())+(select(value.substring(4,1).toInteger()).select(iif($this&lt;5, $this*2, (($this*2)-9))))+(value.substring(5,1).toInteger())+(select(value.substring(6,1).toInteger()).select(iif($this&lt;5, $this*2, (($this*2)-9))))+(value.substring(7,1).toInteger())+(select(value.substring(8,1).toInteger()).select(iif($this&lt;5, $this*2, (($this*2)-9))))+(value.substring(9,1).toInteger())+(select(value.substring(10,1).toInteger()).select(iif($this&lt;5, $this*2, (($this*2)-9))))+(value.substring(11,1).toInteger())+(select(value.substring(12,1).toInteger()).select(iif($this&lt;5, $this*2, (($this*2)-9))))+(value.substring(13,1).toInteger())+(select(value.substring(14,1).toInteger()).select(iif($this&lt;5, $this*2, (($this*2)-9))))+(value.substring(15,1).toInteger()))mod 10=0)" />
      </constraint>
    </element>
    <element id="Device.identifier:paid.type">
      <path value="Device.identifier.type" />
      <short value="Coded identifier type for PAI-D" />
      <definition value="Element describing the type of identifier." />
      <patternCodeableConcept>
        <coding>
          <system value="http://hl7.org.au/fhir/v2/0203" />
          <code value="NDI" />
        </coding>
      </patternCodeableConcept>
      <binding>
        <extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName">
          <valueString value="IdentifierType" />
        </extension>
        <extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding">
          <valueBoolean value="true" />
        </extension>
        <strength value="required" />
        <description value="Local Identifier Type" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ValueSet/au-hl7v2-0203" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Device.identifier:paid.type.text">
      <extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable">
        <valueBoolean value="true" />
      </extension>
      <path value="Device.identifier.type.text" />
      <fixedString value="PAI-D" />
    </element>
    <element id="Device.identifier:paid.system">
      <path value="Device.identifier.system" />
      <short value="Namespace for PAI-D" />
      <definition value="This namespace is used for qualified identifiers to represent My Health Record Assigned Identity for Devices (PAI-D) numbers." />
      <min value="1" />
      <fixedUri value="http://ns.electronichealth.net.au/id/pcehr/paid/1.0" />
    </element>
    <element id="Device.identifier:paid.value">
      <path value="Device.identifier.value" />
      <short value="PAI-D number" />
      <min value="1" />
      <example>
        <label value="PAI-D number" />
        <valueString value="8003640003999998" />
      </example>
      <maxLength value="16" />
    </element>
    <element id="Device.udi">
      <path value="Device.udi" />
      <definition value="Unique device identifier (UDI) assigned to device label or package." />
    </element>
  </differential>
</StructureDefinition>