I am currently facing a challenge while designing a XLSForm for a household survey that involves two repeat instances. The first repeat instance focuses on creating a household roster to collect information about all family members. The second repeat instance is specifically designed for eligible women (i.e., married women aged 15 to 49) from the household, aiming to gather their birth history.
In the second repeat instance, my objective is to fetch the line number of married females from the household roster and store it in the second repeat instance. For example, consider the following data entered in the first repeat instance:
|Column 1 | Column 2 | Column 3 | Column 4 | E|
line_no | name | sex | marri | age |
---|---|---|---|---|
1 | JH | 1 | 1 | 51 |
2 | SY | 2 | 1 | 47 |
3 | HR | 1 | 2 | 29 |
4 | HE | 2 | 2 | 20 |
5 | DV | 1 | 1 | 27 |
6 | EB | 2 | 1 | 25 |
From this data, I want to target married females aged 15 to 49 for the second repeat instance. In this example, only line_no 2 (SY) and 6 (EB) are eligible for the second repeat.
I have attempted to use the position()
function (please see XLSForm below), but unfortunately, I am not achieving the desired result. Specifically, when entering SY in “wname,” I expect it to fetch 2 in the “rostno,” and similarly, entering EB in “wname” should fetch 6 in “rostno.”
type | name | label | required | calculation | repeat_count | read_only | relevant |
---|---|---|---|---|---|---|---|
note | person_list | Please list the names of the people in your household. | |||||
begin_repeat | person | Member of household | |||||
calculate | id | yes | position(…) | ||||
integer | line_no | Person’s Line Number in the Hoousehold | yes | ${id} | yes | ||
text | name | Firs Name | yes | ||||
select_one sex | sex | Sex | yes | ||||
select_one marri | marri | Are you married or not? | yes | ||||
integer | age | Age | yes | ||||
calculate | eligible | yes | if((${sex}=‘2’ and ${age}>=15 and ${age}<=49 and ${marri}=‘1’), 1, 0) | ||||
end_repeat | |||||||
calculate | mwra | yes | sum(${eligible}) | ||||
note | eligible_note | Total number of eligible women from the household for birth history questions is ${mwra} | |||||
begin_repeat | womens | Woman’s Detail | yes | ${mwra} | |||
text | wname | Woman’s Name | yes | ||||
integer | rhid | Eligible woman’s ID | yes | position(…) | yes | ||
integer | rostno | Women’s Line Number in the Household Roster | yes | indexed-repeat(${id}, ${person}, position(…)) | yes | ||
select_one yesno | birth | Have you ever given birth to a baby? | yes | ||||
integer | no_birth | Number of total live birth. | yes | ${birth}=‘1’ | |||
end_repeat |
I would greatly appreciate your assistance in resolving this issue and welcome any insights or suggestions to effectively implement this functionality in my XLSForm. Thank you for your help!