<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-Coverage-family" />
  <url value="https://bpcs.exchange/fhir/StructureDefinition/profile-Coverage-family" />
  <name value="CoverageFamily" />
  <title value="Coverage - Family" />
  <status value="active" />
  <experimental value="false" />
  <description value="Coverage that is enrolled in on a family rather than individual basis" />
  <fhirVersion value="5.0.0" />
  <mapping>
    <identity value="BPCS" />
    <name value="Internal BPCS API" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Coverage" />
  <baseDefinition value="https://bpcs.exchange/fhir/StructureDefinition/profile-Coverage-family-base" />
  <derivation value="constraint" />
  <differential>
    <element id="Coverage.contained">
      <path value="Coverage.contained" />
      <slicing>
        <discriminator>
          <type value="profile" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
    </element>
    <element id="Coverage.contained:provenance">
      <path value="Coverage.contained" />
      <sliceName value="provenance" />
      <short value="Creation/Update/etc. Metadata" />
      <definition value="Nested Provenance information referring to this resource that describes the creation, and sometimes the most recent update and/or inactivation of the record, specifically who was responsible and when it occurred" />
      <min value="1" />
      <type>
        <code value="Provenance" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Provenance" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.extension:overpaidDeductible">
      <path value="Coverage.extension" />
      <sliceName value="overpaidDeductible" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-OverpaidDeductibleStatus" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.extension:privateInsuranceContribution">
      <path value="Coverage.extension" />
      <sliceName value="privateInsuranceContribution" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-PrivateInsuranceContribution" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.extension:basePrivateInsuranceCredit">
      <path value="Coverage.extension" />
      <sliceName value="basePrivateInsuranceCredit" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-BasePrivateInsuranceCredit" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.extension:baseDeductible">
      <path value="Coverage.extension" />
      <sliceName value="baseDeductible" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-BaseDeductible" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.extension:problemCode">
      <path value="Coverage.extension" />
      <sliceName value="problemCode" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Resource-ProblemCode" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="FamilyDTO.problemCodes" />
      </mapping>
    </element>
    <element id="Coverage.extension:problemCode.value[x]">
      <path value="Coverage.extension.value[x]" />
      <binding>
        <strength value="required" />
        <valueSet value="https://bpcs.exchange/fhir/ValueSet/vs-Problem-family" />
      </binding>
    </element>
    <element id="Coverage.costToBeneficiary">
      <path value="Coverage.costToBeneficiary" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="type" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <comment value="This is the application number" />
      <min value="4" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.costToBeneficiary:deductible">
      <path value="Coverage.costToBeneficiary" />
      <sliceName value="deductible" />
      <min value="4" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.costToBeneficiary:deductible.extension">
      <path value="Coverage.costToBeneficiary.extension" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.costToBeneficiary:deductible.extension:insuranceCredit">
      <path value="Coverage.costToBeneficiary.extension" />
      <sliceName value="insuranceCredit" />
      <min value="1" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-InsuranceCredit" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.costToBeneficiary:deductible.extension:reachedDate">
      <path value="Coverage.costToBeneficiary.extension" />
      <sliceName value="reachedDate" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-DeductibleDateReached" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.costToBeneficiary:deductible.extension:deductiblePct">
      <path value="Coverage.costToBeneficiary.extension" />
      <sliceName value="deductiblePct" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-DeductiblePct" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.costToBeneficiary:deductible.type">
      <path value="Coverage.costToBeneficiary.type" />
      <min value="1" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/coverage-copay-type" />
          <code value="deductible" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Coverage.costToBeneficiary:deductible.unit">
      <path value="Coverage.costToBeneficiary.unit" />
      <min value="1" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/benefit-unit" />
          <code value="family" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Coverage.costToBeneficiary:deductible.term">
      <path value="Coverage.costToBeneficiary.term" />
      <min value="1" />
      <type>
        <code value="CodeableConcept" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-CodeableConcept-simple" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="https://bpcs.exchange/fhir/ValueSet/vs-Term" />
      </binding>
    </element>
    <element id="Coverage.costToBeneficiary:deductible.value[x]">
      <path value="Coverage.costToBeneficiary.value[x]" />
      <min value="1" />
      <type>
        <code value="Money" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Money-CAD" />
      </type>
      <type>
        <code value="Quantity" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Quantity-percentage" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="FamilyExpensesDTO.deductLvl1, deductLvl2, deductLvl3, deductLvl4 (based on quarter), FamilyHistoryDTO.dedLvl1Period1Ytd, dedLvl1Period2Ytd, dedLvl1Period3Ytd, dedLvl1Period4Ytd" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>