Configure random allocation using predefined random tables


Are there people who can share how they use CommCare in RCTs?

In our study, our statistician developed random tables with sequentially numbered participant IDs with an arm allocated to each ID. When a participant is enrolled, the subsequent PID will be allocated to them. We have 30 sites, each site has a different number of PIDs (based on enrolment projections for each site). Example:

Site 1
11 A
12 B
13 A
14 B

Site 2
21 A
22 B
23 B
24 A

Site 3

31 B
32 A
33 B
34 A

I have to ensure that the data capturers do not skip numbers, use them in the correct order (according to enrolment), and selects the correct arm.

I’m currently using concealed paper envelopes. CommCare prompts them to enter the envelope details after participant enrolment. I’ve configured the app menus to make it easy to spot mistakes that have already been made, however, I would like to know if I can prevent mistakes.

Any suggestions?

Best regards,


Perhaps someone else has a better idea, but i do believe you’ll need to do case sharing in here where each site shares the cases across the users in that location. you could either run an xpath expression to give you the list of cases under that location/other parameters and then add “1” to that total. theoretically, this should guarantee that numbers are following sequence, unless, two users on two separate phones enroll cases at the same period before synchronizing and getting the case the other person enrolled before the calculation ran. so depending on how many users you have using the app at the same time in the same location, you may not be able to use this approach.

A different approach which also needs to leverage case sharing, is if you had a special parent case for each site, that the enrollments you do create child cases for and updates a value “last ID given” or something in the parent case. this way, you can pass that information to the child case when you’re creating it, provided it was synced before performing this operation.

This is an issue that comes across many platforms if not all, the reason behind is the way records are communicated to the servers and are stored. it’s actually impossible to guarantee a sequence across location/connections/cases in my opinion, but one could try some creative workarounds to get similar results.



Hi Mazz,

Thank you for the suggestions!



Hi Andre,

I’ll offer another suggestion here, which would be to use a case upload to issue each user in an area a case with a predefined distribution of values.


Case: 11

User 1

Location 1

Distribution: ABAABBAA

Case 12

User 1

Location 2

Distribution: BABABBBAA

which you can then index into.

This will let you control the distribution, and avoid any conflicts between users sharing access to a central case.


1 Like

Hi Clayton,

Thank you for the reply.

I will give that a try.