<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-device" />
  <url value="http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-device" />
  <version value="0.2.1" />
  <name value="DeviceProfile" />
  <title value="Device Profile (Implantable)" />
  <status value="draft" />
  <date value="2026-01-09" />
  <publisher value="HL7 Canada - FHIR Implementation Work Group" />
  <contact>
    <telecom>
      <system value="url" />
      <value value="https://infocentral.infoway-inforoute.ca/en/collaboration/wg/fhir-implementations" />
    </telecom>
  </contact>
  <description value="Proposed constraints on the Device resource for the minimal set of data to query and retrieve a patient's implantable device." />
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166" />
      <code value="CA" />
    </coding>
  </jurisdiction>
  <fhirVersion value="4.0.1" />
  <mapping>
    <identity value="rim" />
    <uri value="http://hl7.org/v3" />
    <name value="RIM Mapping" />
  </mapping>
  <mapping>
    <identity value="w5" />
    <uri value="http://hl7.org/fhir/fivews" />
    <name value="FiveWs Pattern Mapping" />
  </mapping>
  <mapping>
    <identity value="udi" />
    <uri value="http://fda.gov/UDI" />
    <name value="UDI Mapping" />
  </mapping>
  <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="Device Profile" />
      <definition value="The Device Profile is based upon the core FHIR Device Resource" />
      <constraint>
        <key value="ca-device-1" />
        <severity value="warning" />
        <human value="Implantable medical devices that have UDI information MAY represent this information in either carrierAIDC or carrierHRF." />
        <expression value="udiCarrier.empty() or (udiCarrier.carrierAIDC.exists() or udiCarrier.carrierHRF.exists())" />
        <xpath value="not(f:udiCarrier) or (f:carrierHRF or f:carrierAIDC)" />
      </constraint>
      <constraint>
        <key value="ca-device-2" />
        <severity value="warning" />
        <human value="For implantable medical devices that have UDI information, at least one of the Production Identifiers (UDI-PI) MAY be present." />
        <expression value="udiCarrier.empty() or (manufactureDate.exists() or expirationDate.exists() or lotNumber.exists() or serialNumber.exists() or distinctIdentifier.exists())" />
        <xpath value="not(f:udiCarrier) or (f:manufactureDate or f:expirationDate or f:lotNumber or f:serialNumber or f:distinctIdentifier)" />
      </constraint>
    </element>
    <element id="Device.udiCarrier">
      <path value="Device.udiCarrier" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="Device.udiCarrier.deviceIdentifier">
      <path value="Device.udiCarrier.deviceIdentifier" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="Device.distinctIdentifier">
      <path value="Device.distinctIdentifier" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Device.expirationDate">
      <path value="Device.expirationDate" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Device.lotNumber">
      <path value="Device.lotNumber" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Device.serialNumber">
      <path value="Device.serialNumber" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Device.type">
      <path value="Device.type" />
      <comment value="The device-kind and device-type valueSets used in HL7 are identical. This profile currently mainatins the binding on device-kind because it is currently hosted in THO and is therefor expected to be updated more frequently" />
      <min value="1" />
      <binding>
        <strength value="extensible" />
        <description value="Codes to identify medical devices" />
        <valueSet value="http://terminology.hl7.org/ValueSet/device-kind" />
      </binding>
    </element>
    <element id="Device.patient">
      <path value="Device.patient" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-patient" />
      </type>
    </element>
    <element id="Device.parent">
      <path value="Device.parent" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-device" />
      </type>
    </element>
  </differential>
</StructureDefinition>