Search in sources :

Example 6 with SequentialIdentifierGenerator

use of org.openmrs.module.idgen.SequentialIdentifierGenerator in project openmrs-module-pihcore by PIH.

the class ConfigureHaitiIdGenerators method localZlIdentifierGenerator.

public SequentialIdentifierGenerator localZlIdentifierGenerator(PatientIdentifierType zlPatientIdentifierType) {
    SequentialIdentifierGenerator localZlIdentifierGenerator;
    try {
        localZlIdentifierGenerator = getLocalZlIdentifierGenerator();
    } catch (IllegalStateException ex) {
        localZlIdentifierGenerator = new SequentialIdentifierGenerator();
        localZlIdentifierGenerator.setName("Local ZL Identifier Generator");
        localZlIdentifierGenerator.setUuid(PihCoreConstants.LOCAL_ZL_IDENTIFIER_GENERATOR_UUID);
        localZlIdentifierGenerator.setIdentifierType(zlPatientIdentifierType);
        localZlIdentifierGenerator.setBaseCharacterSet("ACDEFGHJKLMNPRTUVWXY1234567890");
        localZlIdentifierGenerator.setMaxLength(6);
        localZlIdentifierGenerator.setMinLength(6);
    }
    String prefix = getLocalZlIdentifierGeneratorPrefix();
    int firstIdentifierBase = (int) Math.pow(10, (4 - prefix.length()));
    localZlIdentifierGenerator.setPrefix(prefix);
    localZlIdentifierGenerator.setFirstIdentifierBase(Integer.toString(firstIdentifierBase));
    identifierSourceService.saveIdentifierSource(localZlIdentifierGenerator);
    return localZlIdentifierGenerator;
}
Also used : SequentialIdentifierGenerator(org.openmrs.module.idgen.SequentialIdentifierGenerator)

Aggregations

SequentialIdentifierGenerator (org.openmrs.module.idgen.SequentialIdentifierGenerator)6 PatientIdentifierType (org.openmrs.PatientIdentifierType)3 Location (org.openmrs.Location)2 AutoGenerationOption (org.openmrs.module.idgen.AutoGenerationOption)2 RemoteIdentifierSource (org.openmrs.module.idgen.RemoteIdentifierSource)1 LuhnMod30IdentifierValidator (org.openmrs.module.idgen.validator.LuhnMod30IdentifierValidator)1