...
First, upload the following z-score table using 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.
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.
...
Then add a hidden value (zscore) to calculate the approximate z-score from the table. Assuming the name of your lookup table is "zscoreszscore" the calculation for this hidden value should be:
if(/data/weight < instance('zscoreszscore')/zscoreszscore_list/zscoreszscore[gender = /data/gender][month = /data/age]/sd3neg, -3, if(/data/weight < instance('zscoreszscore')/zscoreszscore_list/zscoreszscore[gender = /data/gender][month = /data/age]/sd2neg, -2, if(/data/weight < instance('zscoreszscore')/zscoreszscore_list/zscoreszscore[gender = /data/gender][month = /data/age]/sd1neg, -1,0))) |
...
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.