One way to accomplish this is by loading the label text in a hidden variable's Calculate Condition and then reference that variable later.
Create a hidden variable with your label text
Add the label text to the Calculate Condition of a hidden variable question type. For example, my_label_text
Reference that variable in a question's label text box
You can drag and drop that hidden variable, my_label_text
, into the label portion of the question:
![enter image description here](https://i.stack.imgur.com/UzUha.png)
Save the hidden variable to a case property
You can then add logic to save my_label_text
as a case property in the Case Management tab. In your scenario you may also want to add logic to save whether or not the question was answered properly.
![enter image description here](https://i.stack.imgur.com/XfmIi.png)
I'm assuming in this case that you've loaded a the member
case into your form, and that you can load the member case ID id into
/data/member_id
What you want to get is:
The count of all member
cases which are children of this case's parent, for which the member case has the property mm_is_in_tb_treatment = 'yes'
For now we can create a new hidden value to store the parent household's case ID, since it'll make understanding the full query below easier.
New hidden value: /data/parent_id
:
instance('casedb')/casedb/case[@case_id = /data/member_id]/index/parent
All cases which are children of that parent would be referenced as:
instance('casedb')/casedb/case[index/parent = /data/parent_id]
You can now add your new filter directly to the end of that statement and introduce the count
count(instance('casedb')/casedb/case[index/parent = /data/parent_id][mm_is_in_tb_treatment = 'yes']
If you wanted, you could further specify that you (for safety) only want to include children that are member
cases and which are open. You can also collapse back the parent ID reference if you want a one-line expression:
count(instance('casedb')/casedb/case[@case_type='member'][@status='open'][index/parent = instance('casedb')/casedb/case[@case_id = /data/member_id]/index/parent][mm_is_in_tb_treatment = 'yes']
Best Answer
Yes, you can save the particular question from a child case form that you wish to save as the property to the parent case by typing "parent/[property name]" in the case management settings page of the child case form.
See the "Accessing Parent Case Properties" on the CommCare help wiki (link here: https://wiki.commcarehq.org/display/commcarepublic/Child+Cases).