ID Generation (IDGen)
Overview
DIGIT's IDGen service is used to generate unique IDs (like registration numbers or application numbers) for your application. Each application (like Birth Registration, Property, Trade License, etc.) needs unique IDs. IDGen helps generate those IDs in a specific format using configurations from the Master Data Management Service.
Configure IDGen
Configure ID format in MDMS
Add your ID format in the IdFormat master data (usually inside your MDMS repo):
Refer to the link here for details.
{
"format": "PB-BTR-[cy:yyyy-MM-dd]-[SEQ_EG_BTR_ID]",
"idname": "btr.registrationid"
}
Here -
format: Controls the structure of the generated ID.
idname: Unique identifier used to reference this format in your application. After adding, restart both the IDGen and MDMS services.
Port forward the IDGen Service
To access IDGen locally, forward its port:
kubectl port-forward <IDGEN_SERVICE_POD_NAME> 8285:8080
Now IDGen is available at: http://localhost:8285/
You can also run the IDGen service locally and set the format in application.properties if the DIGIT environment is unavailable.
Test the IDGen Format
Run this curl to test that your format is set up correctly:
curl --location --request POST 'http://localhost:8285/egov-idgen/id/_generate' \
--header 'Content-Type: application/json' \
--data-raw '{
"RequestInfo": {
"authToken": "REPLACE_WITH_TOKEN",
"userInfo": {
"id": 23299,
"uuid": "e721639b-c095-40b3-86e2-acecb2cb6efb",
"userName": "9337682030",
"name": "Abhilash Seth",
"type": "EMPLOYEE",
"mobileNumber": "9337682030",
"emailId": "[email protected]",
"roles": [{
"id": 281,
"name": "Employee"
}]
}
},
"idRequests": [{
"tenantId": "pg.citya",
"idName": "pgr.servicerequestid"
}]
}
Integrate IDGen into your application
In your service (e.g., BirthApplicationEnrichment
), call IDGen like this:
public void enrichBirthApplication(BirthRegistrationRequest request) {
List<String> idList = idgenUtil.getIdList(
request.getRequestInfo(),
request.getBirthRegistrationApplications().get(0).getTenantId(),
"btr.registrationid", "",
request.getBirthRegistrationApplications().size());
int index = 0;
for (BirthRegistrationApplication application : request.getBirthRegistrationApplications()) {
// Set audit details
AuditDetails auditDetails = AuditDetails.builder()
.createdBy(request.getRequestInfo().getUserInfo().getUuid())
.createdTime(System.currentTimeMillis())
.lastModifiedBy(request.getRequestInfo().getUserInfo().getUuid())
.lastModifiedTime(System.currentTimeMillis())
.build();
application.setAuditDetails(auditDetails);
// Set UUID for application
application.setId(UUID.randomUUID().toString());
// Set generated application number
application.setApplicationNumber(idList.get(index++));
// Set registration ID in address
application.getAddress().setApplicationNumber(application.getId());
// Set UUID for address
application.getAddress().setId(UUID.randomUUID().toString());
}
}
The IDGen service automatically generates unique application numbers.
Last updated
Was this helpful?