I want to auto generate a code in which I have to use the initials of the user, not the client’s. For example, if the person logged in the system his surname is John and first name Paul, my code should be JP…
In addition to that, how do I use the V(event_count) so that I generate a sequential code for the number of events a user is creating in a day? For example if John Paul is adding 2 new clients in March/2022, the clients’ code should be as JP1032022(where 1 is the event number, 03 is the month and 2022 is the year) for the first client, and second client JP2032022 respectfully.
It’d be interesting to know the use case to understand the situation better and help the core team to evaluate. I’m not sure we can get the username of the person logged in using program rules or in the autogenerated values; however, with a detailed description of the use case and a feature request, it could get the interest of the community and the team. If you’d like please create a feature request in jira.dhis2.org and share it here so other can vote/watch/ and comment. Feature had been created before: https://jira.dhis2.org/browse/DHIS2-5883@WaluQ thanks for sharing!
Please add to the description how important this is in your use case and probably why it’d be important for other implementations. Maybe there is a different approach to the solution as well so it’s great to have this discussion.
The shortest way I put it is that, I need the users’ details, who are social workers, to create reference codes/unique IDs for clients by which the unique codes are generated with the initials of the social workers who have registered the clients and and case number and date following. And as for importance, it is quite important because it is being used as clients’ unique code.
Thank you for your patience! I know there is currently no direct way to get the ‘current user’s username’ in a program rule; however, if it works with you that the social worker will select their username each time they register a new client then the suggestion by @plinnegan in another similar post might help with creating a program rule for your use case:
If not then perhaps you or @elmoujarrade could create a feature request and add your votes, share it with the community so that others will be able to watch/vote too! Please let me know if you need assistance creating the feature request on jira.dhis2.org
@Terence_Scott made a feature request some time back but the support has not been fast, could all vote the request up since this is a use case that will be very helpful. The link is here: [DHIS2-5883] - Jira