<StructureDefinition xmlns="http://hl7.org/fhir" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hl7.org/fhir ../../input-cache/schemas/R5/fhir-single.xsd">
  <id value="profile-Group" />
  <url value="https://bpcs.exchange/fhir/StructureDefinition/profile-Group" />
  <name value="GroupFamily" />
  <title value="GroupFamily" />
  <status value="active" />
  <experimental value="false" />
  <description value="A record reflecting a family that is associated with an insurance application" />
  <fhirVersion value="5.0.0" />
  <mapping>
    <identity value="BPCS" />
    <name value="Internal BPCS API" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Group" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Group" />
  <derivation value="constraint" />
  <differential>
    <element id="Group.id">
      <path value="Group.id" />
      <comment value="This will be the same as the associated coverage id" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <!--    <element id="Group.meta">
      <path value="Group.meta" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Group.meta.profile">
      <path value="Group.meta.profile" />
      <min value="1" />
      <max value="1" />
      <fixedCanonical value="https://bpcs.exchange/fhir/StructureDefinition/profile-Group" />
    </element>-->
    <element id="Group.extension:contact">
      <path value="Group.extension" />
      <sliceName value="contact" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Group-Contact" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Group.extension:useDelegate">
      <path value="Group.extension" />
      <sliceName value="useDelegate" />
      <type>
        <code value="Extension" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/ext-Group-UseDelegate" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="ApplicationDTO.useDelegate, FamilyHistoryDTO.useDelegateInd" />
      </mapping>
    </element>
    <element id="Group.type">
      <path value="Group.type" />
      <patternCode value="person" />
    </element>
    <element id="Group.membership">
      <path value="Group.membership" />
      <patternCode value="enumerated" />
    </element>
    <element id="Group.quantity">
      <path value="Group.quantity" />
      <definition value="This is the number of family members on application" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="ApplicationDTO.familyMembersCount, FamilyHistoryDTO.hsldMbrCnt" />
      </mapping>
    </element>
    <element id="Group.managingEntity">
      <path value="Group.managingEntity" />
      <mustSupport value="true" />
    </element>
    <element id="Group.member">
      <path value="Group.member" />
      <mustSupport value="true" />
    </element>
    <element id="Group.member.entity">
      <path value="Group.member.entity" />
      <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="FamilyDTO.familyMembers" />
      </mapping>
    </element>
    <element id="Group.member.inactive">
      <path value="Group.member.inactive" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="FamilyMemberDTO.inactiveFlag" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>