<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-Coverage-individual-public-create" />
  <url value="https://bpcs.exchange/fhir/StructureDefinition/profile-Coverage-individual-public-create" />
  <name value="CoverageIndividualPublicCreate" />
  <title value="Coverage Individual Public Creation Profile" />
  <status value="active" />
  <experimental value="false" />
  <description value="The set of coverage elements available for population when recording a new bpcs individual coverage" />
  <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="http://hl7.org/fhir/StructureDefinition/Coverage" />
  <derivation value="constraint" />
  <differential>
    <element id="Coverage">
      <path value="Coverage" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO" />
      </mapping>
    </element>
    <element id="Coverage.extension:parent">
      <path value="Coverage.extension" />
      <sliceName value="parent" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-Parent" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="**NEW** This will be information from the Application associated with this coverage.  Specific syntax will be 'Coverage/' + [applicationNum] + '.' + [odbNum] + '.' + [start date] (no separators in date)" />
      </mapping>
    </element>
    <element id="Coverage.status">
      <path value="Coverage.status" />
      <comment value="This will be 'active' or 'cancelled', depending on whether the coverage has an end date, where the current date is less than the end date." />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.kind">
      <path value="Coverage.kind" />
      <patternCode value="insurance" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.beneficiary">
      <path value="Coverage.beneficiary" />
      <definition value="The patient for whom the insurance applies" />
      <type>
        <code value="Reference" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Reference-rest" />
        <targetProfile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Patient-search" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.odbNum, RecipientDeductibleDTO.odbNum" />
      </mapping>
    </element>
    <element id="Coverage.period">
      <path value="Coverage.period" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.period.start">
      <path value="Coverage.period.start" />
      <short value="coverageBegin/enrollmentEffectiveDate/registrationDate/mbrshpStartDate" />
      <definition value="The earliest date on which benefits under this policy were available" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.effDate, RecipientDeductibleDTO.benefitYear (matching), FamilyMemberDTO.startDate, FamilyMemberHistoryDTO.membershipStartDate" />
      </mapping>
    </element>
    <element id="Coverage.period.end">
      <path value="Coverage.period.end" />
      <definition value="The last date on which benefits under this policy were/will be available" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.endDate, RecipientDeductibleDTO.benefitYear (matching), FamilyMemberDTO.startDate, FamilyMemberHistoryDTO.membershipEndDate" />
      </mapping>
    </element>
    <element id="Coverage.insurer">
      <path value="Coverage.insurer" />
      <min value="1" />
      <patternReference>
        <reference value="Organization/bpcs" />
      </patternReference>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.class">
      <path value="Coverage.class" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="type" />
        </discriminator>
        <rules value="closed" />
      </slicing>
      <min value="2" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.class:program">
      <path value="Coverage.class" />
      <sliceName value="program" />
      <short value="Coverage plan info" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.class:program.type">
      <path value="Coverage.class.type" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/coverage-class" />
          <code value="plan" />
        </coding>
      </patternCodeableConcept>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.class:program.value">
      <path value="Coverage.class.value" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.class:program.value.system">
      <path value="Coverage.class.value.system" />
      <min value="1" />
      <patternUri value="https://bpcs.exchange/fhir/CodeSystem/cs-ProgramPlan" />
    </element>
    <element id="Coverage.class:program.value.value">
      <path value="Coverage.class.value.value" />
      <short value="BPCS Program id" />
      <comment value="The binding is extensible to allow for the addition of new codes.  Codes must be found in the current expansion of the value set." />
      <min value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="extensible" />
        <valueSet value="https://bpcs.exchange/fhir/ValueSet/vs-Program" />
      </binding>
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.program, RecipientDeductibleDTO.program (matching)" />
      </mapping>
    </element>
    <element id="Coverage.class:plan">
      <path value="Coverage.class" />
      <sliceName value="plan" />
      <short value="BPCS plan info" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.class:plan.type">
      <path value="Coverage.class.type" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/coverage-class" />
          <code value="subplan" />
        </coding>
      </patternCodeableConcept>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.class:plan.value">
      <path value="Coverage.class.value" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.class:plan.value.system">
      <path value="Coverage.class.value.system" />
      <min value="1" />
      <patternUri value="https://bpcs.exchange/fhir/CodeSystem/cs-ProgramPlan" />
    </element>
    <element id="Coverage.class:plan.value.value">
      <path value="Coverage.class.value.value" />
      <short value="BPCS plan id" />
      <comment value="The binding is extensible to allow for the addition of new codes.  Codes must be found in the current expansion of the value set." />
      <min value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="extensible" />
        <valueSet value="https://bpcs.exchange/fhir/ValueSet/vs-Plan" />
      </binding>
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientPlanDTO.plan" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>