<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-Coverage-individual-private-create" />
  <url value="https://bpcs.exchange/fhir/StructureDefinition/profile-Coverage-individual-private-create" />
  <name value="CoverageIndividualPrivateCreate" />
  <title value="Coverage Individual Private Creation Profile" />
  <status value="active" />
  <experimental value="false" />
  <description value="The set of coverage elements used when creating or updating an individual private 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="RecipientInsuranceDTO, FamilyMemberHistoryDTO - separate repetitions for insurance...1 and insurance...2 fields, InsuranceDTO" />
      </mapping>
    </element>
    <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="RecipientInsuranceDTO.insuranceId '.' policyNum '.' id '.' coverageBegin (for insurance 1 or 2)" />
      </mapping>
    </element>
    <element id="Coverage.extension">
      <path value="Coverage.extension" />
      <min value="1" />
    </element>
    <element id="Coverage.extension:application">
      <path value="Coverage.extension" />
      <sliceName value="application" />
      <min value="1" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-Application" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.extension:premiumPaid">
      <path value="Coverage.extension" />
      <sliceName value="premiumPaid" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-PremiumPaid" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Coverage.status">
      <path value="Coverage.status" />
      <short value="active" />
      <patternCode value="active" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.kind">
      <path value="Coverage.kind" />
      <patternCode value="insurance" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.subscriber">
      <path value="Coverage.subscriber" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Reference-rest" />
        <targetProfile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Patient-create" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="FamilyMemberHistoryDTO.policyHolderOdbNum1 or policyHolderOdbNum2, InsuranceDTO.policyHolderOdbNum" />
      </mapping>
    </element>
    <element id="Coverage.subscriberId">
      <path value="Coverage.subscriberId" />
      <definition value="A unique identifier for a recipient within a policy offered by a private insurer." />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.subscriberId.value">
      <path value="Coverage.subscriberId.value" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO.id1 or id2, FamilyMemberHistoryDTO.identification1 or identification2, InsuranceDTO.identification" />
      </mapping>
    </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="RecipientInsuranceDTO.odbNum, InsuranceDTO.policyHolderOdbNum (when coverage is for policy holder)" />
      </mapping>
    </element>
    <element id="Coverage.period">
      <path value="Coverage.period" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.period.extension:notPayingPeriod">
      <path value="Coverage.period.extension" />
      <sliceName value="notPayingPeriod" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Coverage-NotPayingPeriod" />
      </type>
      <mustSupport value="true" />
      <isModifier value="false" />
    </element>
    <element id="Coverage.period.start">
      <path value="Coverage.period.start" />
      <definition value="The earliest date on which benefits under this policy were available" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO.coverageBegin1 or coverageBegin2, FamilyMemberHistoryDTO.coverageStartDate1 or coverageStartDate2, FamilyMemberInsuranceDTO.coverageStartDate, InsuranceDTO.coverageStartDate" />
      </mapping>
    </element>
    <element id="Coverage.period.end">
      <path value="Coverage.period.end" />
      <short value="coverageEnd/enrollmentEndDate/mbrshpEndDate/mbrshpEndDate" />
      <definition value="The last date on which benefits under this policy were/will be available" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO.coverageEnd1 or coverageEnd2, FamilyMemberHistoryDTO.coverageEndDate1 or coverageEndDate2, FamilyMemberInsuranceDTO.coverageEndDate, InsuranceDTO.coverageEndDate" />
      </mapping>
    </element>
    <element id="Coverage.insurer">
      <path value="Coverage.insurer" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.insurer.reference">
      <path value="Coverage.insurer.reference" />
      <max value="0" />
    </element>
    <element id="Coverage.insurer.identifier">
      <path value="Coverage.insurer.identifier" />
      <definition value="A unique identifier assigned to a private insurer." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.insurer.identifier.system">
      <path value="Coverage.insurer.identifier.system" />
      <min value="1" />
      <patternUri value="https://bpcs.exchange/fhir/NamingSystem/insurer-id" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.insurer.identifier.value">
      <path value="Coverage.insurer.identifier.value" />
      <short value="BPCS id for private insurer" />
      <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="required" />
        <valueSet value="https://bpcs.exchange/fhir/ValueSet/vs-PrivateInsurer" />
      </binding>
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO.insuranceId1 or insuranceid2, FamilyMemberHistoryDTO.companyId1 or companyId2, InsuranceDTO.companyId" />
      </mapping>
    </element>
    <element id="Coverage.class">
      <path value="Coverage.class" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="type" />
        </discriminator>
        <rules value="closed" />
      </slicing>
      <min value="1" />
      <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" />
      <short value="Plan id" />
      <mustSupport value="true" />
    </element>
    <element id="Coverage.class:program.value.value">
      <path value="Coverage.class.value.value" />
      <short value="Plan id" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="RecipientInsuranceDTO/FamilyMemberHistoryDTO.policyNum1 or policyNum2, InsuranceDTO.policyNum, FamilyMemberInsuranceDTO.policyNum" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>