<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-DwDocumentReference" />
  <url value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwDocumentReference" />
  <version value="2.0.0" />
  <name value="DwDocumentReference" />
  <status value="draft" />
  <date value="2026-05-29" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="DocumentReference" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/DocumentReference" />
  <derivation value="constraint" />
  <differential>
    <element id="DocumentReference.id">
      <path value="DocumentReference.id" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.meta.lastUpdated">
      <path value="DocumentReference.meta.lastUpdated" />
      <min value="1" />
    </element>
    <element id="DocumentReference.meta.source">
      <path value="DocumentReference.meta.source" />
      <min value="1" />
    </element>
    <element id="DocumentReference.meta.security">
      <path value="DocumentReference.meta.security" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.text">
      <path value="DocumentReference.text" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.extension">
      <path value="DocumentReference.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <ordered value="false" />
        <rules value="open" />
      </slicing>
    </element>
    <element id="DocumentReference.extension:ClinicianAnnotation">
      <path value="DocumentReference.extension" />
      <sliceName value="ClinicianAnnotation" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/ext-ClinicianAnnotation" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.identifier">
      <path value="DocumentReference.identifier" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.status">
      <path value="DocumentReference.status" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.docStatus">
      <path value="DocumentReference.docStatus" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.type">
      <path value="DocumentReference.type" />
      <comment value="Conformance Rule: This must be specified when known. Set type to the best, most precise LOINC code corresponding to the concept of the document in the source system." />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.category">
      <path value="DocumentReference.category" />
      <comment value="Usage note: A category will typically pertain to the specialty, eg Chemotherapy, Cardiology." />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.category.text">
      <path value="DocumentReference.category.text" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.subject">
      <path value="DocumentReference.subject" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwPatient" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwPractitioner" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.date">
      <path value="DocumentReference.date" />
      <comment value="Usage note: When the attachment was created into the documentReference." />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.author">
      <path value="DocumentReference.author" />
      <comment value="Conformance rule: If the consultation has been sent internally then provide practitioner as a reference for the specialist. For external providers provide the display only." />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwPractitioner" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwPractitionerRole" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwOrganization" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwPatient" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.author.reference">
      <path value="DocumentReference.author.reference" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.author.display">
      <path value="DocumentReference.author.display" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.content">
      <path value="DocumentReference.content" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.content.attachment.contentType">
      <path value="DocumentReference.content.attachment.contentType" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.content.attachment.data">
      <path value="DocumentReference.content.attachment.data" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.content.attachment.url">
      <path value="DocumentReference.content.attachment.url" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.content.attachment.size">
      <path value="DocumentReference.content.attachment.size" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.content.attachment.hash">
      <path value="DocumentReference.content.attachment.hash" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.content.attachment.title">
      <path value="DocumentReference.content.attachment.title" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.content.attachment.creation">
      <path value="DocumentReference.content.attachment.creation" />
      <comment value="Usage note: the date the document was created by the source EMR where there is an attachment. Not required for URLs" />
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.context.encounter">
      <path value="DocumentReference.context.encounter" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwEncounter" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="DocumentReference.context.period">
      <path value="DocumentReference.context.period" />
      <comment value="Usage note: Context around the attachment itself, used to capture received date of the document by the source EMR." />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>