Generating unique ID with identical TEA

Hi everyone,

I created my unique Id using the first 2 letters of the name, surname, last 2 digits of the year of birth and the org unit code. In a case were I have 2 or more people that have same names, same date of birth and from the same region, how do I create a sequence to help add maybe an extra character to the code in this instance?

Thank you

2 Likes

Maybe add to the text pattern SEQUENTIAL(###):
first 2 letters of the name, surname, last 2 digits of the year of birth and the org unit code + SEQUENTIAL(##)

source - dhis2 docs

2 Likes

4 posts were split to a new topic: Generating ID with OU hierarchy program details and date

Dear @Tangy,

Have you tried @Gassim solution? It should solve the issue that you are experiencing.

It would be great if you could provide us with the result of the solution suggested, otherwise please let me know how I can be of assistance at this point.

BR,
Ayman

Hi @ayman.tuffaha

I’ll let the community know on the results I get when I try that.

2 Likes

Hey @Tangy , if you are planning to use the Android App with the specific configuration please read the following: Android implementation - DHIS2 Documentation as the system might not behave as you initially expected.

1 Like

Hi @ayman.tuffaha , I have tried the text pattern SEQUENTIAL and it seems to be giving me any error. Maybe I am doing the placement wrongly in my expression, See image below please and advice

image

Hello @Tangy,

Thanks for reaching out, please try the below code instead:
ORG_UNIT_CODE(^…) + “-” + SEQUENTIAL(#####)

This code should work fine, otherwise please let me know if you received any errors at your end.

Best regards,
Ayman

Hi @ayman.tuffaha thank you for your response. I already have the org unit code in my expression and the correct pattern from my end for org unit code is: ORGUNIT_CODE. What I am failing to understand however is why I should include it in my sequence pattern, if you could please enlighten me. Also, every other thing is giving an error, if I am to remove the ORG_UNIT_CODE from your example. See image below:

image

If you look at my code you will see d2:substring(V{orgunit_code}, 0,2), for org unit code, which is working perfectly fine.

[quote=“Ayman Tuffaha, post:8, topic:50498, username:ayman.tuffaha”]
SEQUENTIAL
[/quote] seems to not be recognized from my end

Dear @Tangy,

Let me explain in a little more detail:

  1. ORG_UNIT_CODE(format): is a segment that represents the organization unit code associated with the generation.

  2. SEQUENTIAL(format): Sequential segments will be replaced by a number, based on a counting value on the server. Sequential segments will start at the value 1, and for each generated value count up until no more values are available, based on the format. Like Random segments, uniqueness is based on the rest of the pattern, so each possible version of the pattern will have it’s own sequential counter starting from 1.

  3. “^…” and “…” will use “^” Used when you want to enforce the length of the input value. For example, “^…$” will accept AAAA, since it’s 4 characters between the start and end, but PARIS will be rejected since it has 5 characters.

I hope this will answer your question, if you need further details I encourage you to go over the below URL link which has plenty of details about the text pattern syntax in DHIS2:

Best regards,
Ayman

@ayman.tuffaha thank you for the link and for your assistance. I have a better understanding now.
I kinda just have an issue with “SEQUENTIAL” giving an error in my code.

I do not want it attached to the org unit so we can exclude the ORG_UNIT_CODE for now, I want the sequence to come after an attribute.

If the last variable in my unique code is A{IM.RE_code}, then adding a sequence right after that should be A{IM.RE_code} +SEQUENTIAL(####) right?

1 Like

Yes, that’s right @Tangy, but make sure that A{IM.RE_code} is working with no issues
I prefer to add separation between two codes to be more readable to the user by adding concatenation A{IM.RE_code}+ “-” +SEQUENTIAL(####)

Best regards,
Ayman

@ayman.tuffaha the A{IM.RE_code} is working perfectly, it is what I am using as a placeholder for now while waiting for the sequence to work. And it is still not working

This specific line of code is not recognized from my end… Is there perhaps any other way to look into this. Maybe it the version of DHIS2 I am using, which is 2.37.8; perhaps the code is different for that version upward.

image
I am still getting that

I still need help with this team.

1 Like

It’d help a lot if you can share the steps to reproduce this issue in any of the play.dhis2.org instances please! :slight_smile:

Hi @Gassim, I’ll do that now

@Gassim I created a new program under https://play.dhis2.org/2.37nightly/dhis-web-dashboard/ called “Sequential Unique Code Testing” I then created 3 attributes; Sequential unique code Name, Sequential unique code last name and Sequential unique code(which will be assigned a value from name and last name plus the sequence).

Below is my program rule, without the +SEQUENTIAL and it is working perfectly.
d2:concatenate(d2:substring( A{Sequential.01}, 0, 2 ), d2:substring(A{Sequential.02}, 0, 2 )

However, when I added the sequential suggested by @ayman.tuffaha it gives an error, see image below:
image

And that is where I need assistance.

Hi @Tangy,


It’s not clear how the expression above would work because it’s not formulated properly as a condition and thus I’m not able to reproduce the issue you posted. Could you take a screenshot of the one that’s working please?

Thanks!

@Gassim, thank you for your response.

The new program is called Sequential Code, still under the same instance.

The code below is the one which is working.

image

What I need added here is just the code which will allow for sequence.

The program rule is Seq_code

Thank you.