Looping through People

By far, the most common type of entity to loop over in IEG scripts is the Person entity. IEG comes with some handy features to help you in this regard. The first feature is person tabs. When using person tabs, the user will be presented with a panel between the page title and the main contents of the page which shows all the people in the household and highlights the person for whom the user is currently entering information.

Each person is represented by his or her first name and an icon to depict whether the person is a man, woman, boy or girl. A generic person icon is also provided for persons whose gender and date-of-birth has not yet been provided. Configuring a page to use person tabs is as simple as setting the show-person-tabs attribute to true for that page. Note that the page must be within a loop whose entity attribute is set to 'Person' for this to work.

When used on a page within a for loop, the first time the user enters the loop, the only information known is the number of people to be captured. The system then builds up information about the people as the user goes through the loop. The only indication the person tab can give is how many people are left to enter and not their age or gender.

Note that the show-person-tabs attribute can also be set on pages within a nested loop, so long as the entity for the outer loop is set to 'Person'. In that way, the user can still see the person for whom they are collecting the information in the inner loop.

Another feature of IEG which can be used to help capture information about people in a household is the relationship-page element. This element provides a simple way of instructing the system to capture the relationships between the household members. Including a relationship-page element in a script looks something like this:

Figure 1. Relationship Page XML
<relationship-page id="RelationshipPage" show-person-tabs="true">
  <title id="RelationshipPage.Title">
    <![CDATA[Household Relationships]]>
  </title>
</relationship-page>

The system will automatically take the user through a loop of the people entered so far, and allow the user to enter details of the user's relationships with each of the other members of the household. The system will only ask the user to enter relationships which have not yet been entered, so for each person in the household, there will be one less relationship to enter. This means that no relationships will be captured for the last person as his or her reciprocal relationships would have already been entered.

By default, the relationships page will only ask for the type of each relationship. You also have the option of using an indicator to record whether a relationship is a non-parent caretaker relationship. This can be done using the following syntax:

Figure 2. Relationship Page XML with Caretaker Indicator
<relationship-page id="RelationshipPage" show-person-tabs="true">
  <title id="RelationshipPage.Title">
    <![CDATA[Household Relationships]]>
  </title>
  <question id="caretakerInd">
    <label id="CaretakerInd.Label">
      <![CDATA[Is this a non-parent caretaker relationship]]>
    </label>
  </question>
</relationship-page>

The caretaker indicator is the only question that can be added directly to the relationship page. Questions regarding other attributes of a Relationship entity must be added to clusters that have been added to the relationship page. For example:

Figure 3. Relationship Page XML with Relationship Attributes
<relationship-page id="RelationshipPage" show-person-tabs="true">
  <title id="RelationshipPage.Title">
    <![CDATA[Household Relationships]]>
  </title>
  <question id="caretakerInd">
    <label id="CaretakerInd.Label">
      <![CDATA[Is this a non-parent caretaker relationship?]]>
    </label>
  </question>
  <cluster>
    <question id="startDate" mandatory="true">
      <label id="StartDate.Label">
        <![CDATA[Relationship Start Date:]]>
      </label>
    </question>
  </cluster>
</relationship-page>

The clusters added to a relationship page will be repeated for each relationship to be captured.

Display Text can be added directly to a relationship page. This text will be displayed once on the page regardless of the number of relationship captured. The display text will be displayed at the top of page, above the relationships.

A summary of the relationships captured for the household can easily be included on a summary page by adding a relationship-summary-list element.

The relationships list will always contain at least three columns to display the two people involved in the relationship and the relationship type. If you have captured the caretaker indicator on your relationships page, or you have captured other information about relationships, columns may be added to the relation summary list to display this information. For example:

Figure 4. Relationship Summary List XML
<relationship-summary-list>
  <title id="RelationshipSummaryPage.Title">
    <![CDATA[Person Relationships Summary]]>
  </title>
  <description id="PersonRelationshipSummaryPage.Description">
    <![CDATA[Person Relationship Summary Details]]>
  </description>
  <column id="caretakerInd">
    <title id="CaretakerInd.Title">
      <![CDATA[Caretaker?]]>
    </title>
  </column>
  <column id="startDate">
    <title id="StartDate.Title">
      <![CDATA[Start Date]]>
    </title>
  </column>
  <edit-link start-page="RelationshipPage"/>
</relationship-summary-list>

The edit-link element can be used in a relationship-summary-list to edit relationships in the same way the edit-link element works in a list (Editing Records in Lists)