Search in sources :

Example 1 with IdentifierSourceService

use of org.openmrs.module.idgen.service.IdentifierSourceService in project openmrs-module-mirebalais by PIH.

the class MirebalaisHospitalActivatorIT method testThatActivatorDoesAllSetup.

@Test
@DirtiesContext
public void testThatActivatorDoesAllSetup() throws Exception {
    MirebalaisHospitalService service = Context.getService(MirebalaisHospitalService.class);
    IdentifierSourceService identifierSourceService = Context.getService(IdentifierSourceService.class);
    LocationService locationService = Context.getLocationService();
    /**
     *        ConfigureIdGenerators configureIdGenerators = new ConfigureIdGenerators(identifierSourceService, locationService);
     *
     *        IdentifierPool localZlIdentifierPool = service.getLocalZlIdentifierPool();
     *        RemoteIdentifierSource remoteZlIdentifierSource = service.getRemoteZlIdentifierSource();
     *        SequentialIdentifierGenerator dossierSequenceGenerator = service.getDossierSequenceGenerator(PihCoreConstants.UHM_DOSSIER_NUMBER_IDENTIFIER_SOURCE_UUID);
     *
     *        PatientIdentifierType zlIdentifierType = Context.getPatientService().getPatientIdentifierTypeByUuid(HaitiPatientIdentifierTypes.ZL_EMR_ID.uuid());
     *        PatientIdentifierType dossierNumberIdentifierType = Context.getPatientService().getPatientIdentifierTypeByUuid(HaitiPatientIdentifierTypes.DOSSIER_NUMBER.uuid());
     *
     *        AutoGenerationOption autoGenerationOption = Context.getService(IdentifierSourceService.class).getAutoGenerationOption(zlIdentifierType);
     *
     *        assertEquals(HaitiPatientIdentifierTypes.ZL_EMR_ID.uuid(), zlIdentifierType.getUuid());
     *        assertEquals(zlIdentifierType, autoGenerationOption.getIdentifierType());
     *        assertEquals(localZlIdentifierPool, autoGenerationOption.getSource());
     *
     *        assertEquals(PihCoreConstants.LOCAL_ZL_IDENTIFIER_POOL_UUID, localZlIdentifierPool.getUuid());
     *        assertEquals(PihCoreConstants.LOCAL_ZL_IDENTIFIER_POOL_BATCH_SIZE, localZlIdentifierPool.getBatchSize());
     *        assertEquals(PihCoreConstants.LOCAL_ZL_IDENTIFIER_POOL_MIN_POOL_SIZE, localZlIdentifierPool.getMinPoolSize());
     *
     *        assertEquals(PihCoreConstants.REMOTE_ZL_IDENTIFIER_SOURCE_UUID, remoteZlIdentifierSource.getUuid());
     *        assertEquals(configureIdGenerators.getRemoteZlIdentifierSourceUrl(), remoteZlIdentifierSource.getUrl());
     *        assertEquals(configureIdGenerators.getRemoteZlIdentifierSourceUsername(), remoteZlIdentifierSource.getUser());
     *        assertEquals(configureIdGenerators.getRemoteZlIdentifierSourcePassword(), remoteZlIdentifierSource.getPassword());
     *
     *        assertEquals("A", dossierSequenceGenerator.getPrefix());
     *        assertEquals(new Integer(7), dossierSequenceGenerator.getMaxLength());
     *        assertEquals(new Integer(7), dossierSequenceGenerator.getMinLength());
     *        assertEquals("0123456789", dossierSequenceGenerator.getBaseCharacterSet());
     *        assertEquals("000001", dossierSequenceGenerator.getFirstIdentifierBase());
     *        assertEquals(PihCoreConstants.UHM_DOSSIER_NUMBER_IDENTIFIER_SOURCE_UUID, dossierSequenceGenerator.getUuid());
     *        assertEquals(dossierNumberIdentifierType, dossierSequenceGenerator.getIdentifierType());
     *        assertEquals(2, Context.getService(IdentifierSourceService.class).getAutoGenerationOptions(dossierNumberIdentifierType).size());
     */
    assertNotNull(Context.getService(ImportPatientFromWebService.class).getRemoteServers().get("lacolline"));
}
Also used : LocationService(org.openmrs.api.LocationService) IdentifierSourceService(org.openmrs.module.idgen.service.IdentifierSourceService) MirebalaisHospitalService(org.openmrs.module.mirebalais.api.MirebalaisHospitalService) ImportPatientFromWebService(org.openmrs.module.importpatientfromws.api.ImportPatientFromWebService) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 2 with IdentifierSourceService

use of org.openmrs.module.idgen.service.IdentifierSourceService in project openmrs-module-mirebalais by PIH.

the class MirebalaisHospitalServiceImpl method getIdentifierSource.

private <T extends IdentifierSource> T getIdentifierSource(String uuid, Class<T> sourceType) {
    IdentifierSourceService iss = Context.getService(IdentifierSourceService.class);
    IdentifierSource source = iss.getIdentifierSourceByUuid(uuid);
    if (source == null) {
        throw new IllegalStateException(sourceType.getSimpleName() + " has not been configured");
    }
    return (T) source;
}
Also used : IdentifierSourceService(org.openmrs.module.idgen.service.IdentifierSourceService) IdentifierSource(org.openmrs.module.idgen.IdentifierSource) RemoteIdentifierSource(org.openmrs.module.idgen.RemoteIdentifierSource)

Example 3 with IdentifierSourceService

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

the class PihCoreActivator method started.

// TODO test
@Override
public void started() {
    try {
        MetadataMappingService metadataMappingService = Context.getService(MetadataMappingService.class);
        PatientService patientService = Context.getPatientService();
        FormService formService = Context.getFormService();
        LocationService locationService = Context.getLocationService();
        EncounterService encounterService = Context.getEncounterService();
        VisitService visitService = Context.getVisitService();
        IdentifierSourceService identifierSourceService = Context.getService(IdentifierSourceService.class);
        ConceptService conceptService = Context.getService(ConceptService.class);
        if (config == null) {
            // hack to allow injecting a mock config for testing
            // currently only one of these
            config = Context.getRegisteredComponents(Config.class).get(0);
        }
        setDispositionConfig(config);
        installMetadataBundles(config);
        setGlobalProperties(config);
        setExtraIdentifierTypes(metadataMappingService, patientService, config);
        MergeActionsSetup.registerMergeActions();
        LocationTagSetup.setupLocationTags(locationService, config);
        HtmlFormSetup.setupHtmlFormEntryTagHandlers();
        MetadataMappingsSetup.setupGlobalMetadataMappings(metadataMappingService, locationService, encounterService, visitService);
        MetadataMappingsSetup.setupPrimaryIdentifierTypeBasedOnCountry(metadataMappingService, patientService, config);
        MetadataMappingsSetup.setupFormMetadataMappings(metadataMappingService);
        PatientIdentifierSetup.setupIdentifierGeneratorsIfNecessary(identifierSourceService, locationService, config);
        PacIntegrationSetup.setup(config);
        AttachmentsSetup.migrateAttachmentsConceptsIfNecessary(conceptService);
    // RetireProvidersSetup.setupRetireProvidersTask();
    } catch (Exception e) {
        Module mod = ModuleFactory.getModuleById("pihcore");
        ModuleFactory.stopModule(mod);
        throw new RuntimeException("failed to setup the required modules", e);
    }
}
Also used : LocationService(org.openmrs.api.LocationService) VisitService(org.openmrs.api.VisitService) PatientService(org.openmrs.api.PatientService) FormService(org.openmrs.api.FormService) IdentifierSourceService(org.openmrs.module.idgen.service.IdentifierSourceService) Module(org.openmrs.module.Module) ConceptService(org.openmrs.api.ConceptService) EncounterService(org.openmrs.api.EncounterService) MetadataMappingService(org.openmrs.module.metadatamapping.api.MetadataMappingService)

Example 4 with IdentifierSourceService

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

the class ConfigureHaitiIdGenerators method getIdentifierSource.

private <T extends IdentifierSource> T getIdentifierSource(String uuid, Class<T> sourceType) {
    IdentifierSourceService iss = Context.getService(IdentifierSourceService.class);
    IdentifierSource source = iss.getIdentifierSourceByUuid(uuid);
    if (source == null) {
        throw new IllegalStateException(sourceType.getSimpleName() + " has not been configured");
    }
    return (T) source;
}
Also used : IdentifierSourceService(org.openmrs.module.idgen.service.IdentifierSourceService) IdentifierSource(org.openmrs.module.idgen.IdentifierSource) RemoteIdentifierSource(org.openmrs.module.idgen.RemoteIdentifierSource)

Aggregations

IdentifierSourceService (org.openmrs.module.idgen.service.IdentifierSourceService)4 LocationService (org.openmrs.api.LocationService)2 IdentifierSource (org.openmrs.module.idgen.IdentifierSource)2 RemoteIdentifierSource (org.openmrs.module.idgen.RemoteIdentifierSource)2 Test (org.junit.Test)1 ConceptService (org.openmrs.api.ConceptService)1 EncounterService (org.openmrs.api.EncounterService)1 FormService (org.openmrs.api.FormService)1 PatientService (org.openmrs.api.PatientService)1 VisitService (org.openmrs.api.VisitService)1 Module (org.openmrs.module.Module)1 ImportPatientFromWebService (org.openmrs.module.importpatientfromws.api.ImportPatientFromWebService)1 MetadataMappingService (org.openmrs.module.metadatamapping.api.MetadataMappingService)1 MirebalaisHospitalService (org.openmrs.module.mirebalais.api.MirebalaisHospitalService)1 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)1 DirtiesContext (org.springframework.test.annotation.DirtiesContext)1