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;
}
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);
}
Aggregations