use of org.openmrs.module.pihcore.RuntimeProperties in project openmrs-module-pihcore by PIH.
the class ConfigurationSetup method configureNonConceptDependencies.
// Anything in here depends on configuration settings and needs to be refreshed in a specific order,
// as some configurations depend on settings or metadata setup in previous configurations.
// Ideally we will get rid of this non-concept vs concept dependencies. Just need to speed up the concept loading component.
public void configureNonConceptDependencies() throws Exception {
setStatus("Configuration Setup Initiated");
// Load in PIH Config
setStatus("Loading pih.config descriptor");
config.reload(ConfigLoader.loadFromRuntimeProperties());
// Configure the Name Template based on the config (TODO: Move this to config / configure outside of Java code)
// hack: configure both name support beans, since two actually exist (?)
setStatus("Configuring name template");
NameTemplateSetup.configureNameTemplate(nameSupport, config);
NameTemplateSetup.configureNameTemplate(NameSupport.getInstance(), config);
// Execute any liquibase changesets defined in the pih/liquibase domain
setStatus("Executing liquibase scripts in configuration");
LiquibaseSetup.setup();
// Setup all metadata that are before Concepts in Iniz loading order
setStatus("Loading initializer pre-concept domains");
InitializerSetup.loadPreConceptDomains(config);
// Setup any global properties defined in pih config (TODO: Move this to gp iniz domain)
// TODO: We need to consider the setting component GPs here
setStatus("Setting additional global properties");
setGlobalProperties(config);
// TODO: Confirm that moving this here makes sense - these refer to concepts, but in the same way that GPs refer to concepts
if (config != null && config.getDispositionConfig() != null) {
setStatus("Configuring disposition config");
dispositionService.setDispositionConfig(config.getDispositionConfig());
}
// Setup Metadata Mappings for Extra Identifier Types, as specified in PIH Config (TODO: Move this to metadatamapping iniz domain)
if (config != null && config.getExtraIdentifierTypes() != null && config.getExtraIdentifierTypes().size() > 0) {
setStatus("Configuring extra identifier types metadata mappings");
List<PatientIdentifierType> extraIdentifierTypes = new ArrayList<PatientIdentifierType>();
for (String uuid : config.getExtraIdentifierTypes()) {
extraIdentifierTypes.add(patientService.getPatientIdentifierTypeByUuid(uuid));
}
metadataMappingService.mapMetadataItems(extraIdentifierTypes, EmrApiConstants.EMR_METADATA_SOURCE_NAME, EmrApiConstants.GP_EXTRA_PATIENT_IDENTIFIER_TYPES);
}
// Setup Location Tags from PIH Config (TODO: Move this to use locations or locationtagmaps domains in Iniz)
setStatus("Configuring location tags from pih config");
LocationTagSetup.setupLocationTags(locationService, config);
// Setup primary identifier type metadata mappings (TODO: Move this to metadatamapping iniz domain with site-based exclusion filters)
setStatus("Configuring primary identifier type");
MetadataMappingsSetup.setupPrimaryIdentifierTypeBasedOnCountry(metadataMappingService, patientService, config);
// Setup identifier generators (TODO: This is a remaining configuration initiative piece. Move to iniz and/or pih config)
setStatus("Configuring identifier generators");
PatientIdentifierSetup.setupIdentifierGeneratorsIfNecessary(identifierSourceService, locationService, config);
// TODO: Move the below to config. All this is ultimately doing is ensuring the setting of a single global property:
// registrationcore.identifierSourceId = <uuid of identifier source configured as autogeneration option for the emrapi primary identifier type>
setStatus("Configuring global properties for registration modules");
ModuleFactory.getStartedModuleById("registrationapp").getModuleActivator().started();
// Initialize PACS HL7 listener, if the PACS_INTEGRATION component is enabled in pih config
// TODO: 1. Determine if we can just enable this all the time, and if that will cause any adverse effects
// TODO: 2. Or determine if we can enable it all the time, but switch inside the listener on the component, to determine whether to act or not
// TODO: 3. If we leave this like this, determine if we can call this setup method over and over in a running server, or if we need to code around that
// In testing, when running configure, I get this: java.lang.RuntimeException: java.net.BindException: Address already in use (Bind failed)
setStatus("Configuring PACS HL7 Listener");
PacIntegrationSetup.setup(config);
// TODO: This seems harmless here for refreshing, but we should determine if
// TODO: 1. Has this run everywhere it needs to, and can we remove this code altogether now
// TODO: 2. If not, can we move this to a liquibase changeset instead
setStatus("Migrating attachment concepts if necessary");
AttachmentsSetup.migrateAttachmentsConceptsIfNecessary(conceptService);
// Configure global scripts and css files defined in the configuration directory
setStatus("Configuring global resources");
GlobalResourceSetup.includeGlobalResources();
// Rebuild search index (TODO: Confirm this is intended to run here, prior to metadata loading, rather than at the end of the process(
if (config.shouldRebuildSearchIndex()) {
setStatus("Rebuilding search index");
Context.updateSearchIndex();
}
// c) if it's used, we could likely try to make it more entirely configurable from config
if (config.isComponentEnabled(Components.LEGACY_MPI)) {
setStatus("Setting up connection to Legacy MPI");
LegacyMasterPatientIndexSetup.setupConnectionToMasterPatientIndex(new RuntimeProperties());
}
if (config.isComponentEnabled(Components.APPOINTMENT_SCHEDULING)) {
if (config.getCountry().equals(ConfigDescriptor.Country.HAITI)) {
// TODO: This seems like something that should be moved to configuration. We should add a GP to the appointment scheduling module
// or wherever this is created to control which identifier type to use in the report, and then set this GP in Iniz config
AppointmentSchedulingSetup.customizeDailyAppointmentsDataSet();
}
}
setStatus("Reloading all apps and extensions");
reloadAppsAndExtensions();
setStatus("Configuration Setup Completed Successfully");
}
Aggregations