<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-Observation-income" />
  <url value="https://bpcs.exchange/fhir/StructureDefinition/profile-Observation-income" />
  <name value="ObservationIncome" />
  <title value="Observation Income Profile" />
  <status value="active" />
  <experimental value="false" />
  <description value="An observation that reports the income for a specified subject" />
  <fhirVersion value="5.0.0" />
  <mapping>
    <identity value="BPCS" />
    <name value="Internal BPCS API" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Observation" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Observation" />
  <derivation value="constraint" />
  <differential>
    <element id="Observation.meta">
      <path value="Observation.meta" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.meta.tag">
      <path value="Observation.meta.tag" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Observation.meta.tag:readOnly">
      <path value="Observation.meta.tag" />
      <sliceName value="readOnly" />
      <comment value="This tag will be present if the income is not allowed to be overridden.  It will be absent if the income is overrideable." />
      <max value="1" />
      <patternCoding>
        <system value="https://bpcs.exchange/fhir/CodeSystem/cs-MetaTags" />
        <code value="readOnly" />
      </patternCoding>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="FamilyMemberDTO.incomeOverride (if true, then incomeOverride is false)" />
      </mapping>
    </element>
    <element id="Observation.meta.extension">
      <path value="Observation.meta.extension" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.meta.extension:effectiveDate">
      <path value="Observation.meta.extension" />
      <sliceName value="effectiveDate" />
      <comment value="This associates the income information to the verson of the Trillium insurance application the income information is associated with." />
      <min value="1" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Meta-effectiveDate" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO.recEffDate, FamilyMemberHistoryDTO.recEffDate" />
      </mapping>
    </element>
    <element id="Observation.status">
      <path value="Observation.status" />
      <patternCode value="final" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.code">
      <path value="Observation.code" />
      <patternCodeableConcept>
        <coding>
          <system value="https://bpcs.exchange/fhir/CodeSystem/cs-ObservationTypes" />
          <code value="income" />
          <display value="Annual Income" />
        </coding>
      </patternCodeableConcept>
      <mustSupport value="true" />
    </element>
    <element id="Observation.subject">
      <path value="Observation.subject" />
      <type>
        <code value="Reference" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Reference-rest" />
        <targetProfile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Group" />
        <targetProfile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Patient-search" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO.odbNum, FamilyMemberDTO.odbNum, FamilyMemberHistory.odbNum" />
      </mapping>
    </element>
    <element id="Observation.subject.identifier">
      <path value="Observation.subject.identifier" />
      <short value="Social Insurance Number" />
      <comment value="The SIN is sent alongside the RESTful reference to the patient because SIN is only maintained as part of the income observation, not as part of the general recipient demographics" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.subject.identifier.type">
      <path value="Observation.subject.identifier.type" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/v2-0203" />
          <code value="SB" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.subject.identifier.system">
      <path value="Observation.subject.identifier.system" />
      <short value="This is the Canada Social Insurance Number URI" />
      <patternUri value="https://fhir.infoway-inforoute.ca/NamingSystem/ca-social-insurance-number" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.subject.identifier.value">
      <path value="Observation.subject.identifier.value" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO.sin, FamilyMemberDTO.sin, FamilyMemberHistory.sin" />
      </mapping>
    </element>
    <element id="Observation.effective[x]">
      <path value="Observation.effective[x]" />
      <definition value="The income tax year (i.e. calendar year) associated with net income of package size as recorded against an individual." />
      <type>
        <code value="dateTime" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-dateTime-year" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO.taxYear, FamilyMemberDTO.taxYear, FamilyMemberHistory.taxYear" />
      </mapping>
    </element>
    <element id="Observation.issued">
      <path value="Observation.issued" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO.recCreateCustomTimestamp, FamilyMemberHistory.recCreateCustomTimestamp" />
      </mapping>
    </element>
    <element id="Observation.performer">
      <path value="Observation.performer" />
      <min value="1" />
      <max value="1" />
      <patternReference>
        <display value="CRA" />
      </patternReference>
    </element>
    <element id="Observation.value[x]">
      <path value="Observation.value[x]" />
      <short value="incomeAmt/netIncome" />
      <definition value="RM - Income of recipient.&#xD;&#xA;AM - For families, the total net family income calculated by summing the net income of all family members. For individuals, the net personal income of an individual as obtained through income testing or as determined by special review." />
      <comment value="Income of recipient." />
      <min value="1" />
      <type>
        <code value="Quantity" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.value[x].value">
      <path value="Observation.value[x].value" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO.incomeAmount, FamilyMemberDTO.netIncome, FamilyMemberDTO.zeroIncomeFlag, FamilyMemberHistoryDTO.netIncome, FamilyMemberHistoryDTO.zeroIncomeFlag (If incomeAmount is 0 and zeroIncomeFlag is false, we'll suppress the whole Observation)" />
      </mapping>
    </element>
    <element id="Observation.value[x].system">
      <path value="Observation.value[x].system" />
      <min value="1" />
      <patternUri value="urn:iso:std:iso:4217" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.value[x].code">
      <path value="Observation.value[x].code" />
      <min value="1" />
      <patternCode value="CAD" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component">
      <path value="Observation.component" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="code" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Observation.component:noa">
      <path value="Observation.component" />
      <sliceName value="noa" />
      <definition value="Information about whether there is a notice of assessment on file" />
      <comment value="This is only relevant (and will only be retained) for members enrolled in the Seniors Drug Program" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:noa.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="https://bpcs.exchange/fhir/CodeSystem/cs-ObservationTypes" />
          <code value="noa" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:noa.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="1" />
      <type>
        <code value="boolean" />
      </type>
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>