<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="ext-subscriptionManagingEntity" />
  <url value="http://ontariohealth.ca/fhir/pubsub/StructureDefinition/ext-subscriptionManagingEntity" />
  <version value="1.0.0" />
  <name value="SubscriptionManagingEntityExtension" />
  <title value="OH Subscription Managing Entity (R4 Backport)" />
  <status value="draft" />
  <description value="Backport of the R5 Subscription.managingEntity element. This extension identifies the entity responsible for managing the subscription, constrained to be a Device referenced by its identifier." />
  <fhirVersion value="4.0.1" />
  <kind value="complex-type" />
  <abstract value="false" />
  <context>
    <type value="element" />
    <expression value="Subscription" />
  </context>
  <type value="Extension" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Extension" />
  <derivation value="constraint" />
  <differential>
    <element id="Extension">
      <path value="Extension" />
      <short value="Entity managing the subscription" />
      <definition value="The entity responsible for managing the subscription. Backported from R5 Subscription.managingEntity and constrained to be a Device referenced by identifier." />
    </element>
    <element id="Extension.extension">
      <path value="Extension.extension" />
      <max value="0" />
    </element>
    <element id="Extension.url">
      <path value="Extension.url" />
      <fixedUri value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/ext-subscriptionManagingEntity" />
    </element>
    <element id="Extension.value[x]">
      <path value="Extension.value[x]" />
      <short value="Managing entity (Must be Device by identifier)" />
      <definition value="A reference to the managing Device. This reference SHALL be a logical reference (using Reference.identifier) and SHALL NOT use a literal resource URL (Reference.reference)." />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Device" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Extension.value[x].reference">
      <path value="Extension.valueReference.reference" />
      <short value="NOT USED - Use .identifier instead" />
      <definition value="Literal path references (e.g., 'Device/123') are not permitted for this extension. The Device MUST be referenced by its logical identifier." />
      <min value="0" />
      <max value="0" />
    </element>
    <element id="Extension.value[x].type">
      <path value="Extension.valueReference.type" />
      <short value="Fixed to 'Device'" />
      <definition value="The type of the referenced resource, fixed to 'Device'." />
      <min value="1" />
      <fixedUri value="Device" />
    </element>
    <element id="Extension.value[x].identifier">
      <path value="Extension.valueReference.identifier" />
      <short value="Logical identifier for the managing Device" />
      <definition value="The logical identifier for the managing Device. This is the required method for referencing." />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Extension.value[x].identifier.system">
      <path value="Extension.valueReference.identifier.system" />
      <short value="Identifier namespace" />
      <definition value="Namespace for the Device's identifier (e.g., an OID or URI)." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Extension.value[x].identifier.value">
      <path value="Extension.valueReference.identifier.value" />
      <short value="Identifier value" />
      <definition value="The value of the Device's identifier." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>