Create unique ids from a repeat group + lookup table data

Hello Everyone,

I am trying to create unique ids for a set of farmers registered within a cluster(parent/child case scenario). To create the unique id, i need to pull certain data from a group lookup table and concat that with a visit_count field.

I have set up my repeat group to pull up certain fields for the farmers(child cases) based on the number of farmers to be registered in the cluster.

The issue is that my unique farmer id being generated is the same for all the farmers in a single cluster.

image

What’s the expression you’re using to generate the ID?

Have you seen this wiki page on ID generation?
https://confluence.dimagi.com/display/commcarepublic/Generating+a+Unique+ID+for+beneficiaries

Hi Ethan,

Yes i have gone through that wiki page on ID generation. Somehow it seems to be working now when i substituted my visit_count parameter with the position parameter. The visit_count would still count as one regardless of how many times my repeat group loops so hence the ID would still be the same. I will test my present setup robustly and revert if i still have issues.

in a similar structure, i have this calculation inside the position hidden calc (i call it cur_pos just in case using the name position confuses the app as it’s also a function name)
position(…) + 1

this returns a different number for each instance of the repeat