How to generate a new ID for existing patients via SQL or Java?

I have made a change in the implementation from the Old OpenMRS ID without a check digit to the new OpenMRS ID with a check digit- my question is how to generate the new IDs via SQL or via Java code so that the patients have the new identifier

How do you generate the new IDs? Randomly?

@dkayiwa this is for the automatically generated ID with a check digit, how do I generate that?

I think the registrationcore module is using


Are you asking how to generate the ID numbers? Or if there’s an automatic way to generate these for all patients as a batch?

For generating, you should try to use the idgen module as @dkayiwa says. For bulk assignment, I think you’ll have to script this yourself.)

@darius I am looking at the latter, automatically generating the numbers for patients as a batch and adding them to the patients, as this will be common in our migrations.

Is there a best practice for doing such updates?