<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-DwCarePlan" />
  <url value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwCarePlan" />
  <version value="2.0.0" />
  <name value="DwCarePlan" />
  <status value="draft" />
  <date value="2026-05-29" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="CarePlan" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/CarePlan" />
  <derivation value="constraint" />
  <differential>
    <element id="CarePlan.id">
      <path value="CarePlan.id" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.meta.lastUpdated">
      <path value="CarePlan.meta.lastUpdated" />
      <min value="1" />
    </element>
    <element id="CarePlan.meta.source">
      <path value="CarePlan.meta.source" />
      <min value="1" />
    </element>
    <element id="CarePlan.meta.profile">
      <path value="CarePlan.meta.profile" />
      <max value="1" />
    </element>
    <element id="CarePlan.meta.security">
      <path value="CarePlan.meta.security" />
      <comment value="CHR: Populated when the patient record is restricted." />
    </element>
    <element id="CarePlan.text">
      <path value="CarePlan.text" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.identifier">
      <path value="CarePlan.identifier" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.identifier.system">
      <path value="CarePlan.identifier.system" />
      <comment value="CHR: urn:telus:emr:chr:{region}:{accountId}:carePlan" />
      <min value="1" />
    </element>
    <element id="CarePlan.identifier.value">
      <path value="CarePlan.identifier.value" />
      <min value="1" />
    </element>
    <element id="CarePlan.status">
      <path value="CarePlan.status" />
      <comment value="CHR: Status derived from encounter locked state — completed when locked, draft when unlocked. Deleted encounters are excluded upstream, so entered-in-error is not currently produced." />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.intent">
      <path value="CarePlan.intent" />
      <comment value="CHR: Hardcoded value &quot;plan&quot;." />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.description">
      <path value="CarePlan.description" />
      <comment value="Usage note: Reason for leaving it must support and not 1..1 cardinality as there might be visit notes where there is not plan documented.&#xD;&#xA;&#xD;&#xA;Note that FHIR strings SHALL NOT exceed 1MB in size" />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.subject">
      <path value="CarePlan.subject" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwPatient" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Group" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.encounter">
      <path value="CarePlan.encounter" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwEncounter" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.created">
      <path value="CarePlan.created" />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.contributor">
      <path value="CarePlan.contributor" />
      <comment value="CHR: Unique practitioners who contributed actions on the encounter." />
      <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" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwPractitionerRole" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Device" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/RelatedPerson" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwOrganization" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwCareTeam" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.supportingInfo">
      <path value="CarePlan.supportingInfo" />
      <comment value="CHR: References to DocumentReference resources built from attachments linked to the encounter.&#xA;MA: Reference to the linked clinical note or consult report DocumentReference for the visit.&#xA;&#xA;Usage note: Provide reference to the documentReferenceClinicalNote associated with this plan.&#xD;&#xA;Use &quot;concern&quot; to identify specific conditions addressed by the care plan." />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwDocumentReference" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwQuestionnaireResponse" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.activity">
      <path value="CarePlan.activity" />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.activity.outcomeCodeableConcept">
      <path value="CarePlan.activity.outcomeCodeableConcept" />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.activity.outcomeReference">
      <path value="CarePlan.activity.outcomeReference" />
      <comment value="CHR: MedicationRequest (prescriptions), MedicationAdministration (injections)&#xA;MA: MedicationRequest, ServiceRequest, Immunization, Observation" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwMedicationRequest" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwServiceRequest" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwImmunization" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwObservation" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwObservationVitals" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwObservationResults" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwMedicationAdministration" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.activity.outcomeReference.display">
      <path value="CarePlan.activity.outcomeReference.display" />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.activity.reference">
      <path value="CarePlan.activity.reference" />
      <comment value="CHR: Referral records created within the encounter (ServiceRequest).&#xA;MA: Referral tasks (category Investigation/Lab/Consult/Consultation) not yet complete (ServiceRequest).&#xA;&#xA;Usage note - Planned activities with  FHIR profile will be referenced here for example Immunization prescribed but not given during that visit use MedicationRequest, serviceRequest for referrals etc&#xD;&#xD;&#xA;Standard extension exists ([resource-pertainsToGoal](extension-resource-pertainstogoal.html)) that allows goals to be referenced from any of the referenced resources in CarePlan.activity.reference.  &#xD;The goal should be visible when the resource referenced by CarePlan.activity.reference is viewed independently from the CarePlan.  Requests that are pointed to by a CarePlan using this element should *not* point to this CarePlan using the &quot;basedOn&quot; element.  i.e. Requests that are part of a CarePlan are not &quot;based on&quot; the CarePlan." />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwAppointment" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwMedicationRequest" />
        <targetProfile value="https://www.telus.com/health/fhir/dwemrextract/StructureDefinition/DwServiceRequest" />
      </type>
    </element>
    <element id="CarePlan.activity.reference.display">
      <path value="CarePlan.activity.reference.display" />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.activity.detail.kind">
      <path value="CarePlan.activity.detail.kind" />
      <comment value="CHR: Hardcoded value &quot;Task&quot;.&#xA;MA: Hardcoded value &quot;Task&quot;.&#xA;&#xA;Usage note - Most of the time it will be 'Task'&#xD;&#xA;Note that FHIR strings SHALL NOT exceed 1MB in size" />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.activity.detail.code">
      <path value="CarePlan.activity.detail.code" />
      <comment value="CHR: Text-only value — no coded value populated.&#xA;MA: Text-only value (task category) — no coded value populated.&#xA;&#xA;Usage note - Provide the category of the planned activity/task under code.text eg immunization, Recall etc&#xD;&#xA;Tends to be less relevant for activities involving particular products.  Codes should not convey negation - use &quot;prohibited&quot; instead." />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.activity.detail.code.text">
      <path value="CarePlan.activity.detail.code.text" />
      <comment value="CHR: Form template name (Attachments → Add Form) or follow-up questionnaire name (Follow-up Qnaires → Add Follow-up Qnaire).&#xA;MA: Task category (e.g. Recall, Callback) for tasks that are not a completed/in-progress referral or completed immunization.&#xA;&#xA;Usage Note - Provide the category of the planned activity/task under code.text eg immunization, Recall etc&#xD;&#xA;Very often the text is the same as a displayName of one of the codings." />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.activity.detail.status">
      <path value="CarePlan.activity.detail.status" />
      <comment value="CHR: Hardcoded value &quot;unknown&quot; — the actual completion state of the activity is not tracked.&#xA;MA: Mapped from the underlying task's status.&#xA;&#xA;Usage Note - Identifies what progress is being made for the specific activity." />
      <mustSupport value="true" />
    </element>
    <element id="CarePlan.activity.detail.description">
      <path value="CarePlan.activity.detail.description" />
      <comment value="MA: Task description field.&#xA;&#xA;Usage Note - Name and details of the planned activity ex, immunization name flu shot etc&#xD;&#xA;Note that FHIR strings SHALL NOT exceed 1MB in size" />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>