Search in sources :

Example 1 with RemoteIdentifierSource

use of org.openmrs.module.idgen.RemoteIdentifierSource 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 RemoteIdentifierSource

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

the class ConfigureHaitiIdGenerators method createPatientIdGenerator.

// TODO refactor all this to make more sense
public static void createPatientIdGenerator(ConfigureHaitiIdGenerators configureHaitiIdGenerators) {
    PatientIdentifierType zlIdentifierType = getZlIdentifierType();
    RemoteIdentifierSource remoteZlIdentifierSource = configureHaitiIdGenerators.remoteZlIdentifierSource(zlIdentifierType);
    IdentifierPool localZlIdentifierPool = configureHaitiIdGenerators.localZlIdentifierSource(remoteZlIdentifierSource);
    configureHaitiIdGenerators.setAutoGenerationOptionsForZlIdentifier(localZlIdentifierPool);
}
Also used : IdentifierPool(org.openmrs.module.idgen.IdentifierPool) PatientIdentifierType(org.openmrs.PatientIdentifierType) RemoteIdentifierSource(org.openmrs.module.idgen.RemoteIdentifierSource)

Aggregations

RemoteIdentifierSource (org.openmrs.module.idgen.RemoteIdentifierSource)2 PatientIdentifierType (org.openmrs.PatientIdentifierType)1 IdentifierPool (org.openmrs.module.idgen.IdentifierPool)1 SequentialIdentifierGenerator (org.openmrs.module.idgen.SequentialIdentifierGenerator)1