<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="lra-notification-request-bundle" />
  <url value="http://phsa.ca/fhir/StructureDefinition/lra-notification-request-bundle" />
  <version value="1.0.0-draft" />
  <name value="LRANotificationRequestBundle" />
  <title value="LRA Notification Request Bundle" />
  <status value="draft" />
  <experimental value="false" />
  <date value="2026-05-14" />
  <publisher value="Longitudinal Record Access (LRA)" />
  <description value="Message Bundle used to submit a notification request from Health Gateway to LRA." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Bundle" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Bundle" />
  <derivation value="constraint" />
  <differential>
    <element id="Bundle">
      <path value="Bundle" />
      <constraint>
        <key value="lra-notif-bdl-1" />
        <severity value="error" />
        <human value="A notification request Bundle SHALL contain exactly one MessageHeader, one CommunicationRequest, one DocumentReference, and one Patient." />
        <expression value="entry.resource.ofType(MessageHeader).count() = 1 and entry.resource.ofType(CommunicationRequest).count() = 1 and entry.resource.ofType(DocumentReference).count() = 1 and entry.resource.ofType(Patient).count() = 1" />
      </constraint>
    </element>
    <element id="Bundle.identifier">
      <path value="Bundle.identifier" />
      <short value="Message-level unique identifier for correlation and tracking" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.identifier.system">
      <path value="Bundle.identifier.system" />
      <min value="1" />
      <max value="1" />
      <fixedUri value="https://healthgateway.gov.bc.ca/identifiers/message-bundle" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.identifier.value">
      <path value="Bundle.identifier.value" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.type">
      <path value="Bundle.type" />
      <min value="1" />
      <max value="1" />
      <fixedCode value="message" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.timestamp">
      <path value="Bundle.timestamp" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry">
      <path value="Bundle.entry" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="resource" />
        </discriminator>
        <ordered value="false" />
        <rules value="open" />
      </slicing>
      <min value="4" />
      <max value="*" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:messageHeader">
      <path value="Bundle.entry" />
      <sliceName value="messageHeader" />
      <short value="Notification MessageHeader" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:messageHeader.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:messageHeader.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="MessageHeader" />
        <profile value="http://phsa.ca/fhir/StructureDefinition/lra-notification-messageheader" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:communicationRequest">
      <path value="Bundle.entry" />
      <sliceName value="communicationRequest" />
      <short value="Notification CommunicationRequest" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:communicationRequest.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:communicationRequest.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="CommunicationRequest" />
        <profile value="http://phsa.ca/fhir/StructureDefinition/lra-notification-communicationrequest" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:documentReference">
      <path value="Bundle.entry" />
      <sliceName value="documentReference" />
      <short value="Notification DocumentReference" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:documentReference.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:documentReference.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="DocumentReference" />
        <profile value="http://phsa.ca/fhir/StructureDefinition/lra-notification-documentreference" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:patient">
      <path value="Bundle.entry" />
      <sliceName value="patient" />
      <short value="Notification Patient" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:patient.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:patient.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="Patient" />
        <profile value="http://phsa.ca/fhir/StructureDefinition/lra-notification-patient" />
      </type>
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>