Search in sources :

Example 1 with SequentialIdentifierGenerator

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

the class ConfigureHaitiIdGenerators method remoteZlIdentifierSource.

public RemoteIdentifierSource remoteZlIdentifierSource(PatientIdentifierType zlPatientIdentifierType) {
    RemoteIdentifierSource remoteZlIdentifierSource;
    SequentialIdentifierGenerator localGenerator = null;
    if (getLocalZlIdentifierGeneratorEnabled()) {
        localGenerator = localZlIdentifierGenerator(zlPatientIdentifierType);
    }
    try {
        remoteZlIdentifierSource = getRemoteZlIdentifierSource();
    } catch (IllegalStateException ex) {
        remoteZlIdentifierSource = new RemoteIdentifierSource();
        remoteZlIdentifierSource.setName("Remote Source for ZL Identifiers");
        remoteZlIdentifierSource.setUuid(PihCoreConstants.REMOTE_ZL_IDENTIFIER_SOURCE_UUID);
        remoteZlIdentifierSource.setIdentifierType(zlPatientIdentifierType);
    }
    String url = getRemoteZlIdentifierSourceUrl();
    if (url != null && localGenerator != null) {
        url = url.replace("{LOCAL_SOURCE_ID}", localGenerator.getId().toString());
    }
    remoteZlIdentifierSource.setUrl(url);
    remoteZlIdentifierSource.setUser(getRemoteZlIdentifierSourceUsername());
    remoteZlIdentifierSource.setPassword(getRemoteZlIdentifierSourcePassword());
    identifierSourceService.saveIdentifierSource(remoteZlIdentifierSource);
    return remoteZlIdentifierSource;
}
Also used : SequentialIdentifierGenerator(org.openmrs.module.idgen.SequentialIdentifierGenerator) RemoteIdentifierSource(org.openmrs.module.idgen.RemoteIdentifierSource)

Example 2 with SequentialIdentifierGenerator

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

the class ConfigureHaitiIdGenerators method createDossierNumberGenerator.

public static void createDossierNumberGenerator(LocationService locationService, ConfigureHaitiIdGenerators configureHaitiIdGenerators, Config config) {
    PatientIdentifierType dossierIdentifierType = getDossierIdentifierType();
    // special, legacy case for Mirebalais
    if (config.getSite().equals(ConfigDescriptor.Site.MIREBALAIS)) {
        SequentialIdentifierGenerator sequentialIdentifierGeneratorForUHM = configureHaitiIdGenerators.sequentialIdentifierGeneratorForDossier(dossierIdentifierType, PihCoreConstants.UHM_DOSSIER_NUMBER_PREFIX, PihCoreConstants.UHM_DOSSIER_NUMBER_IDENTIFIER_SOURCE_UUID);
        configureHaitiIdGenerators.setAutoGenerationOptionsForDossierNumberGenerator(sequentialIdentifierGeneratorForUHM, locationService.getLocationByUuid(MirebalaisLocations.MIREBALAIS_HOSPITAL.uuid()));
        SequentialIdentifierGenerator sequentialIdentifierGeneratorForCDI = configureHaitiIdGenerators.sequentialIdentifierGeneratorForDossier(dossierIdentifierType, PihCoreConstants.CDI_DOSSIER_NUMBER_PREFIX, PihCoreConstants.CDI_DOSSIER_NUMBER_IDENTIFIER_SOURCE_UUID);
        configureHaitiIdGenerators.setAutoGenerationOptionsForDossierNumberGenerator(sequentialIdentifierGeneratorForCDI, locationService.getLocationByUuid(MirebalaisLocations.CDI_KLINIK_EKSTEN_JENERAL.uuid()));
    } else if (config.getDossierIdentifierPrefix() != null) {
        SequentialIdentifierGenerator sequentialIdentifierGenerator = configureHaitiIdGenerators.sequentialIdentifierGeneratorForDossier(dossierIdentifierType, config.getDossierIdentifierPrefix().toString(), ZL_DOSSIER_NUMBER_IDENTIFIER_SOURCE_UUID);
        configureHaitiIdGenerators.setAutoGenerationOptionsForDossierNumberGenerator(sequentialIdentifierGenerator, null);
    }
}
Also used : SequentialIdentifierGenerator(org.openmrs.module.idgen.SequentialIdentifierGenerator) PatientIdentifierType(org.openmrs.PatientIdentifierType)

Example 3 with SequentialIdentifierGenerator

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

the class ConfigureLiberiaIdGenerators method configureGenerators.

public static void configureGenerators(IdentifierSourceService identifierSourceService, Config config) {
    Location identifierLocation = MetadataUtils.existing(Location.class, LiberiaLocations.PLEEBO.uuid());
    SequentialIdentifierGenerator pleeboPrimaryIdentifierSource = (SequentialIdentifierGenerator) identifierSourceService.getIdentifierSourceByUuid(PLEEBO_PRIMARY_IDENTIFIER_SOURCE_UUID);
    if (pleeboPrimaryIdentifierSource == null) {
        pleeboPrimaryIdentifierSource = new SequentialIdentifierGenerator();
    }
    pleeboPrimaryIdentifierSource.setName("Pleebo Primary Identifier Source");
    pleeboPrimaryIdentifierSource.setDescription("Primary Identifier Generator for Pleebo");
    pleeboPrimaryIdentifierSource.setIdentifierType(MetadataUtils.existing(PatientIdentifierType.class, LiberiaPatientIdentifierTypes.PLEEBO_EMR_ID.uuid()));
    pleeboPrimaryIdentifierSource.setPrefix(config.getPrimaryIdentifierPrefix());
    pleeboPrimaryIdentifierSource.setMinLength(7 + pleeboPrimaryIdentifierSource.getPrefix().length());
    pleeboPrimaryIdentifierSource.setMaxLength(8 + pleeboPrimaryIdentifierSource.getPrefix().length());
    pleeboPrimaryIdentifierSource.setBaseCharacterSet("0123456789");
    pleeboPrimaryIdentifierSource.setFirstIdentifierBase("0000001");
    pleeboPrimaryIdentifierSource.setUuid(PLEEBO_PRIMARY_IDENTIFIER_SOURCE_UUID);
    identifierSourceService.saveIdentifierSource(pleeboPrimaryIdentifierSource);
    AutoGenerationOption autoGenerationOption = identifierSourceService.getAutoGenerationOption(pleeboPrimaryIdentifierSource.getIdentifierType(), identifierLocation);
    if (autoGenerationOption == null) {
        autoGenerationOption = new AutoGenerationOption();
    }
    autoGenerationOption.setIdentifierType(MetadataUtils.existing(PatientIdentifierType.class, LiberiaPatientIdentifierTypes.PLEEBO_EMR_ID.uuid()));
    autoGenerationOption.setSource(pleeboPrimaryIdentifierSource);
    autoGenerationOption.setAutomaticGenerationEnabled(true);
    autoGenerationOption.setManualEntryEnabled(false);
    autoGenerationOption.setLocation(identifierLocation);
    identifierSourceService.saveAutoGenerationOption(autoGenerationOption);
}
Also used : AutoGenerationOption(org.openmrs.module.idgen.AutoGenerationOption) SequentialIdentifierGenerator(org.openmrs.module.idgen.SequentialIdentifierGenerator) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location)

Example 4 with SequentialIdentifierGenerator

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

the class ConfigureSierraLeoneIdGenerators method configureGenerators.

public static void configureGenerators(IdentifierSourceService identifierSourceService) {
    Location identifierLocation = MetadataUtils.existing(Location.class, SierraLeoneLocations.WELLBODY_HEALTH_CENTER.uuid());
    SequentialIdentifierGenerator wellbodyPrimaryIdentifierSource = (SequentialIdentifierGenerator) identifierSourceService.getIdentifierSourceByUuid(WELLBODY_PRIMARY_IDENTIFIER_SOURCE_UUID);
    if (wellbodyPrimaryIdentifierSource == null) {
        wellbodyPrimaryIdentifierSource = new SequentialIdentifierGenerator();
    }
    wellbodyPrimaryIdentifierSource.setName("Wellbody Primary Identifier Source");
    wellbodyPrimaryIdentifierSource.setDescription("Primary Identifier Generator for Wellbody");
    wellbodyPrimaryIdentifierSource.setIdentifierType(MetadataUtils.existing(PatientIdentifierType.class, SierraLeonePatientIdentifierTypes.WELLBODY_EMR_ID.uuid()));
    wellbodyPrimaryIdentifierSource.setPrefix("W");
    wellbodyPrimaryIdentifierSource.setMinLength(7 + wellbodyPrimaryIdentifierSource.getPrefix().length());
    wellbodyPrimaryIdentifierSource.setMaxLength(8 + wellbodyPrimaryIdentifierSource.getPrefix().length());
    wellbodyPrimaryIdentifierSource.setBaseCharacterSet("0123456789");
    wellbodyPrimaryIdentifierSource.setFirstIdentifierBase("0000001");
    wellbodyPrimaryIdentifierSource.setUuid(WELLBODY_PRIMARY_IDENTIFIER_SOURCE_UUID);
    identifierSourceService.saveIdentifierSource(wellbodyPrimaryIdentifierSource);
    AutoGenerationOption autoGenerationOption = identifierSourceService.getAutoGenerationOption(wellbodyPrimaryIdentifierSource.getIdentifierType(), identifierLocation);
    if (autoGenerationOption == null) {
        autoGenerationOption = new AutoGenerationOption();
    }
    autoGenerationOption.setIdentifierType(MetadataUtils.existing(PatientIdentifierType.class, SierraLeonePatientIdentifierTypes.WELLBODY_EMR_ID.uuid()));
    autoGenerationOption.setSource(wellbodyPrimaryIdentifierSource);
    autoGenerationOption.setAutomaticGenerationEnabled(true);
    autoGenerationOption.setManualEntryEnabled(false);
    autoGenerationOption.setLocation(identifierLocation);
    identifierSourceService.saveAutoGenerationOption(autoGenerationOption);
}
Also used : AutoGenerationOption(org.openmrs.module.idgen.AutoGenerationOption) SequentialIdentifierGenerator(org.openmrs.module.idgen.SequentialIdentifierGenerator) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location)

Example 5 with SequentialIdentifierGenerator

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

the class PihProviderIdentifierGenerator method generateIdentifier.

// this generates a 3digit base 30 identifier with an "M" prefix and a check-digit suffix
// the identifier is seeded on the primary key of the associated provider
// since 30^3 = 27000, this will start to fail if the primary key every goes above 27000
@Override
public String generateIdentifier(Provider provider) {
    if (provider.getId() == null) {
        throw new IllegalStateException("Cannot generate identifier for provider without primary key");
    }
    SequentialIdentifierGenerator generator = new SequentialIdentifierGenerator();
    generator.setBaseCharacterSet("ACDEFGHJKLMNPRTUVWXY1234567890");
    generator.setFirstIdentifierBase("100");
    generator.setPrefix(config.getProviderIdentifierPrefix());
    generator.setMaxLength(3 + config.getProviderIdentifierPrefix().length());
    generator.setMinLength(3 + config.getProviderIdentifierPrefix().length());
    String identifier = generator.getIdentifierForSeed(provider.getId().longValue());
    return new LuhnMod30IdentifierValidator().getValidIdentifier(identifier);
}
Also used : LuhnMod30IdentifierValidator(org.openmrs.module.idgen.validator.LuhnMod30IdentifierValidator) 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