Generate case Unique ID within case sharing group

Hi all,

I found some great documentation for a way to great a unique, sequential ID for each case registered using a mobile worker custom field (prefix).

I am wondering if it is possible to generate unique, sequential ID ID for each case registered among a case-sharing groups?

Our use case is that two people will be registering cases at the same location, and ideally there would be a way to generate a unique, sequential ID for each patient, irrespective of which person "registers" the case. ie if worker1 registers case1, and immediately after worker2 registers a case, then ideally counting that as case2, etc.

At the moment I have only been able to make it so that there are 2 prefixes that share the same "root" prefix, and then an identifier for the mobile worker (ex: 123.1 and 123.2), followed by the order of the case registered. But doing so means we'd have two "lists" of sequential cases (ex: 123.1.0001, 123.2.0001), rather than a single sequential list shared between the two (ex: 123.0001, 123.0002, etc)

Ideally trying to avoid using location-based case sharing...

Thanks for your help!
Stephen

That's a great explanation of the issue. I'm guessing you're talking about this documentation? In theory you could do something like you described by storing the counter on a case that both users have access to rather than on the user case. However in practice this is not recommended, as it is highly susceptible to concurrency problems. For example:

  • worker1 registers case1, updating the counter to 2
  • worker2 syncs, now they see the counter at 2
  • worker2 begins filling out a form to register a new case
  • worker1 registers case2, updating the counter to 3
  • worker2 finishes that form, registering another case as case2, because the counter doesn't update live

If users sync infrequently, this is even more likely. The mobile worker identifier provides a namespace which prevents any conflicts from multiple people working at the same time.