Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Corrected a mistake in the example of how zcore was references, from either 'zscores' or 'zscores_list' to 'zscore' or 'zscore_list'

This page will walk through an example of setting up a form to calculate a z-score based on a age in months, gender, and weight.  

First, upload the following z-score table using the the Manage Lookup Tables page.  This table covers children between 0 and 60 months of age, but you can modify the table as needed for your project. 

zscoreszscore.xlsx

Including Lookup Table Information in the Form

Once we've defined a zscore lookup table, we need to reference it in our form.  Edit the form XML and add an "instance" line that references the name of the table.  You can place this above any existing instance tags in your form.  

<instance id="zscoreszscore" src="jr://fixture/item-list:zscore"></instance>

...

In your form, first add three questions, one for the gender, age in months and measured weight.  (You can also load these from a case if you've previously captured them elsewhere).  Image Removed Note-- your answer options for the gender question MUST be "female" and "male" (not "m", "f" or "1", "2") to align with what is written in the z score look up table. 

Image Added

Then add a hidden value (zscore) to calculate the approximate z-score from the table.  The   Assuming the name of your lookup table is "zscore" the calculation for this hidden value should be:

if(/data/weight < instance('zscoreszscore')/zscore_list/zscore[gender = /data/gender][month = /data/age]/sd3neg, -3, if(/data/weight < instance('zscoreszscore')/zscore_list/zscore[gender = /data/gender][month = /data/age]/sd2neg, -2, if(/data/weight < instance('zscoreszscore')/zscore_list/zscore[gender = /data/gender][month = /data/age]/sd1neg, -1,0)))

Note: this calculation uses case properties named "gender", "weight", and "age." If you have named your case properties something else, you will need to change the reference above to the same name as your case properties. 

 


This hidden value will be -3, -2, -1, or 0 which corresponds to the child being more than -3, -2, and -1 standard deviations from the mean.  You can then use this hidden value for further calculations or display it back to the user.