<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="ext-Coverage-DeductibleCalculation" />
  <url value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-DeductibleCalculation" />
  <name value="CoverageDeductibleCalculation" />
  <title value="Coverage Deductible Calculation" />
  <status value="active" />
  <experimental value="false" />
  <description value="Information related to the calculation of the deductible for this particular coverage for this recipient for this coverage period" />
  <fhirVersion value="5.0.0" />
  <mapping>
    <identity value="BPCS" />
    <name value="Internal BPCS API" />
  </mapping>
  <kind value="complex-type" />
  <abstract value="false" />
  <context>
    <type value="element" />
    <expression value="Coverage.costToBeneficiary" />
  </context>
  <contextInvariant value="type.coding.exists(system='http://terminology.hl7.org/CodeSystem/coverage-copay-type' and code='deductible')" />
  <type value="Extension" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Extension" />
  <derivation value="constraint" />
  <differential>
    <element id="Extension">
      <path value="Extension" />
      <short value="Deductible calculation information" />
      <definition value="Information related to the calculation of the deductible for this particular coverage for this recipient for this coverage period" />
      <max value="1" />
    </element>
    <element id="Extension.extension">
      <path value="Extension.extension" />
      <min value="3" />
      <mustSupport value="true" />
    </element>
    <element id="Extension.extension:createdDate">
      <path value="Extension.extension" />
      <sliceName value="createdDate" />
      <short value="When deductible available to system" />
      <definition value="The date on which this current version of the deductible information became available to the system" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Extension.extension:createdDate.url">
      <path value="Extension.extension.url" />
      <fixedUri value="createdDate" />
    </element>
    <element id="Extension.extension:createdDate.value[x]">
      <path value="Extension.extension.value[x]" />
      <min value="1" />
      <type>
        <code value="instant" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientDeductibleDTO.recCreateCustomTimestamp" />
      </mapping>
    </element>
    <element id="Extension.extension:createdBy">
      <path value="Extension.extension" />
      <sliceName value="createdBy" />
      <short value="Deductible createdBy timestamp" />
      <definition value="The user responsible for setting the dedictible information" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Extension.extension:createdBy.url">
      <path value="Extension.extension.url" />
      <fixedUri value="createdBy" />
    </element>
    <element id="Extension.extension:createdBy.value[x]">
      <path value="Extension.extension.value[x]" />
      <min value="1" />
      <type>
        <code value="string" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientDeductibleDTO.recCreateUserId" />
      </mapping>
    </element>
    <element id="Extension.extension:established">
      <path value="Extension.extension" />
      <sliceName value="established" />
      <short value="Deductible established timestamp" />
      <definition value="The specific time that the dedictible information was last captured" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Extension.extension:established.url">
      <path value="Extension.extension.url" />
      <fixedUri value="established" />
    </element>
    <element id="Extension.extension:established.value[x]">
      <path value="Extension.extension.value[x]" />
      <min value="1" />
      <type>
        <code value="instant" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientDeductibleDTO.deductibleEstablishedTimestamp" />
      </mapping>
    </element>
    <element id="Extension.extension:base">
      <path value="Extension.extension" />
      <sliceName value="base" />
      <short value="Base deductible value" />
      <definition value="The default deductible value for this type of coverage for the specified period, before any adjustments" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Extension.extension:base.url">
      <path value="Extension.extension.url" />
      <fixedUri value="base" />
    </element>
    <element id="Extension.extension:base.value[x]">
      <path value="Extension.extension.value[x]" />
      <min value="1" />
      <type>
        <code value="Money" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Money-CAD" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientDeductibleDTO.annualDeductibleAmount" />
      </mapping>
    </element>
    <element id="Extension.extension:proratedAdjustment">
      <path value="Extension.extension" />
      <sliceName value="proratedAdjustment" />
      <short value="Adjustment to prorate for partial year coverage" />
      <definition value="For coverages that do not cover the full coverage period (e.g. started part-way through the year), represents an amount to reduce the base deductible by to account for the fact the patient is only covered for part of the year." />
      <comment value="This will always be either 0 or a negative value." />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Extension.extension:proratedAdjustment.url">
      <path value="Extension.extension.url" />
      <fixedUri value="proratedAdjustment" />
    </element>
    <element id="Extension.extension:proratedAdjustment.value[x]">
      <path value="Extension.extension.value[x]" />
      <min value="1" />
      <type>
        <code value="Money" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Money-CAD" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientDeductibleDTO.proratedDedectibleAdjustmentAmount" />
      </mapping>
    </element>
    <element id="Extension.extension:proratedAdjustment.value[x].value">
      <path value="Extension.extension.value[x].value" />
      <maxValueDecimal value="0" />
    </element>
    <element id="Extension.extension:otherAdjustment">
      <path value="Extension.extension" />
      <sliceName value="otherAdjustment" />
      <short value="Other deductible adjustments" />
      <definition value="Additional adjustments to the base deductible (could be positive or negative)." />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Extension.extension:otherAdjustment.url">
      <path value="Extension.extension.url" />
      <fixedUri value="otherAdjustment" />
    </element>
    <element id="Extension.extension:otherAdjustment.value[x]">
      <path value="Extension.extension.value[x]" />
      <min value="1" />
      <type>
        <code value="Money" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Money-CAD" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientDeductibleDTO.deductibleAdjustmentAmount" />
      </mapping>
    </element>
    <element id="Extension.url">
      <path value="Extension.url" />
      <fixedUri value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-DeductibleCalculation" />
    </element>
    <element id="Extension.value[x]">
      <path value="Extension.value[x]" />
      <max value="0" />
    </element>
  </differential>
</StructureDefinition>