Random ID Generator

Forwarding along a response from Drew about the BHOMA CommCare random ID

··· ---------- Forwarded message ---------- From: Drew Roos Date: Thu, Mar 10, 2011 at 1:22 AM Subject: Re: Random ID Generator To: Nick Amland

Comments in line (in blue text)

On Mon, Mar 7, 2011 at 3:25 AM, Nick Amland namland@dimagi.com wrote:

Hey Drew,

After talking with the rest team in Boston, they think that they can re-use
the random ID generator that you built for BHOMA to satisfy our requirement
down here. I don’t really know much beyond that is randomly generates an
ID. So, I wondering if I can ask you some more specifics about the

  1. How is the generator accessed on the phone?

the ID itself is set into a hidden field. then, when you want to show the ID
to the user, you add it to an info message.

in instance:
<verification_code />
<info_verif_code />

in binds:

(this will produce a random number between 1 and 999; change 998 to 9998 to
add another digit)
(don’t get fancy with this calculate w/o talking to me first, or else the
number may change unpredictably from what you expect (such as using inside a

in the controls:

The code for this visit is . Write this down and give it to the head of

  1. What does it look like to the user?

They’ll see the message above when they get to that part of the form

  1. How many digits is the random ID? Always the same number of digits?

the above calculation produces numbers with up to 3 digits, but numbers like
7 and 45 will show as written, not like ‘007’ and ‘045’.

  1. Does the ID generator save a log of IDs generated or capable of
    doing that?

there is no log per se, but the generated number will be present in the
submitted xform.

I wrote a quick specification for our proposed verification process. Here
is the technical requirements section for the process.
Technical: We need CC to generate a temporary, random household visit ID.
This ID doesn’t need to be unique, even it would be okay to have the same
household with the same ID at one time. The ID just needs to be random
enough that the CHV can’t guess a pattern.Technical Requirements:

· CommCare to generate a temporary, random ID.

o Must be relatively random

§ Must pass easy to guess pattern

§ Must minimize (but not required to eliminate) the probability of
generating the same ID on consecutive visits

§ There is no big clustering around individual numbers

o Must be an integer

o Must be positive

o Should be 3 or 4 digits long

  • · In terms of when specifically (or how) CC will generate the
    ID, our first priority is to have the ID generated within the household
  • · The household ID data entry field is added to the household
    follow-up form:

o It needs to be a REQUIRED field

  • CommCare must log the IDs generated (for our reporting purposes).

Any comments on that? Does it seem realistic for the BHOMA generator to
satisfy these requirements without significant technical effort?

Thanks for any response/input.


Nick P. Amland

CommCare Field Fellow
Dimagi, Inc.
Dodoma, Tanzania
Google Voice: 253.642.7790
Email: namland@dimagi.com namland08@gmail.com

Nick P. Amland

CommCare Field Fellow
Dimagi, Inc.
Dodoma, Tanzania
Google Voice: 253.642.7790
TZ Mobile: +255 762 740 996
Email: namland@dimagi.com namland08@gmail.com