Autogenerated uic's

I am trying to come up with a program rule that will generate an automatic UIC based on the variables captured.Here is what i want to the system to generate the UIC from: A.CLIENT DEMOGRAPHICS

First name Stanley
Last name Kalyati
Mothers Firstname Jeniffer
Mothers Surname Kalyati
DoB YearsMonthsDays
Gender F
Are you a Twin No Twin, First_Twin,Second_Twin
District of Birth Lilongwe

Last 2 letters of mothers first name

Last 2 letters of AGYW surname

Last letters of district of birth name

Birthday 120500 (12 for day, 05 for month and 00 for year of birth)

Gender (F)

0 if she has No Twin

1 if she is the First_Twin

2 if she the Second_Twin

I.e ERTIWE120500F0

And now this is the code that i have come up with.Anyone to analyse and help me here: d2:concatenate(
d2:substring(#{DL_Mothers Firstname}, d2:length(#{DL_Mothers Firstname}) - 2, 2),
d2:substring(#{DL_Mothers Surname}, d2:length(#{DL_Mothers Surname}) - 2, 2),
d2:substring(#{DL_District of Birth}, d2:length(#{DL_District of Birth}) - 1, 1),
d2:substring(#{DL_DoB}, 8, 2), // Day
d2:substring(#{DL_DoB}, 5, 2), // Month
d2:substring(#{DL_DoB}, 2, 2), // Year
#{DL_Gender},
#{DL_Are you a Twin}
)

Anyone to help me,i will certainly appreciate.

Hi @Stanley

Thank you for the detailed post. It appears that you have done all the work and prepared a working formula, and it’s good that you are willing to ask the community and share.

I’m curious to know if there is a third twin or fourth? Are they going to be classified as second twin? Additionally, what if this data is missing, are you going to make all those fields required because the rule you put together requires that all the data is available.

The other question, still about the twins field which seems to be options (No Twin, First_Twin,Second_Twin), but the expected value in the rule is a number (0,1,2).

Did you test the formula? It will not be used in the program rule’s condition, it will be in the program rule’s action to assign the value to a data element.

Alright! Please share your insights and updates.

Thanks!