<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-Coverage-individual-public" />
  <url value="https://bpcs.exchange/fhir/StructureDefinition/profile-Coverage-individual-public" />
  <name value="CoverageIndividualPublic" />
  <title value="Coverage Individual Public Profile" />
  <status value="active" />
  <experimental value="false" />
  <description value="The set of coverage elements returned for individual private or bpcs coverage when returning a 'summary'" />
  <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-individual-public-create" />
  <derivation value="constraint" />
  <differential>
    <element id="Coverage.id">
      <path value="Coverage.id" />
      <short value="Unique identifier assigned to the coverage" />
      <comment value="This id is used when querying history" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.plan '.' program '.' odbNum '.' effDate" />
      </mapping>
    </element>
    <element id="Coverage.meta">
      <path value="Coverage.meta" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.meta.versionId">
      <path value="Coverage.meta.versionId" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.recUpdateCustomTimestamp (concatenate time and nanos)" />
      </mapping>
    </element>
    <element id="Coverage.meta.lastUpdated">
      <path value="Coverage.meta.lastUpdated" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.recUpdateCustomTimestamp (convert to valid FHIR format timestamp)" />
      </mapping>
    </element>
    <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:goodFaith">
      <path value="Coverage.extension" />
      <sliceName value="goodFaith" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-GoodFaith" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.goodFaith (boolean, or true if date), RecipientPlanDTO.faithConfirmed (date)" />
      </mapping>
    </element>
    <element id="Coverage.class">
      <path value="Coverage.class" />
      <slicing>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Coverage.class:program">
      <path value="Coverage.class" />
      <sliceName value="program" />
    </element>
    <element id="Coverage.class:program.name">
      <path value="Coverage.class.name" />
      <comment value="This will be omitted for private plans" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.planDescription" />
      </mapping>
    </element>
    <element id="Coverage.class:plan">
      <path value="Coverage.class" />
      <sliceName value="plan" />
    </element>
    <element id="Coverage.class:plan.name">
      <path value="Coverage.class.name" />
      <comment value="This will be omitted for private plans" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.planDescription" />
      </mapping>
    </element>
    <element id="Coverage.costToBeneficiary">
      <path value="Coverage.costToBeneficiary" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="type" />
        </discriminator>
        <discriminator>
          <type value="value" />
          <path value="unit" />
        </discriminator>
        <discriminator>
          <type value="value" />
          <path value="term" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Coverage.costToBeneficiary:deductible">
      <path value="Coverage.costToBeneficiary" />
      <sliceName value="deductible" />
      <comment value="Deductible information will only be available for BPCS-managed coverages" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.costToBeneficiary:deductible.extension:deductibleCalculation">
      <path value="Coverage.costToBeneficiary.extension" />
      <sliceName value="deductibleCalculation" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-DeductibleCalculation" />
      </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="individual" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Coverage.costToBeneficiary:deductible.term">
      <path value="Coverage.costToBeneficiary.term" />
      <min value="1" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/benefit-term" />
          <code value="annual" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Coverage.costToBeneficiary:deductible.value[x]">
      <path value="Coverage.costToBeneficiary.value[x]" />
      <comment value="This SHALL equal the base + adjustment amounts in the deductibleCalculation extension" />
      <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.netDeductibleAmount" />
      </mapping>
    </element>
    <element id="Coverage.costToBeneficiary:copay">
      <path value="Coverage.costToBeneficiary" />
      <sliceName value="copay" />
      <comment value="Copay information will only be available for BPCS-managed coverages" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.costToBeneficiary:copay.type">
      <path value="Coverage.costToBeneficiary.type" />
      <min value="1" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/coverage-copay-type" />
          <code value="copay" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Coverage.costToBeneficiary:copay.unit">
      <path value="Coverage.costToBeneficiary.unit" />
      <min value="1" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/benefit-unit" />
          <code value="individual" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Coverage.costToBeneficiary:copay.term">
      <path value="Coverage.costToBeneficiary.term" />
      <min value="1" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/benefit-term" />
          <code value="annual" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Coverage.costToBeneficiary:copay.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>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientDeductibleDTO.copayCeilingAmount" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>