Search in sources :

Example 16 with Config

use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.

the class MirebalaisHospitalActivatorComponentTest method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    initializeInMemoryDatabase();
    executeDataSet("requiredDataTestDataset.xml");
    executeDataSet("globalPropertiesTestDataset.xml");
    executeDataSet("mirebalaisProviderIdentifierGeneratorComponentTestDataset.xml");
    executeDataSet("fromMirebalaisMetadataModule.xml");
    executeDataSet("serializedReportingDataset.xml");
    authenticate();
    deployService.installBundle(conceptsFromMetadataSharing);
    haitiPersonAttributeTypeBundle.install();
    // run the emrapi activator
    emrApiActivator = new EmrApiActivator();
    emrApiActivator.started();
    // run the appointmentschedulingui manager
    appointmentSchedulingUIActivator = new AppointmentSchedulingUIActivator();
    appointmentSchedulingUIActivator.started();
    // set up metadata from pih core first
    pihCoreActivator = new PihCoreActivator();
    Config config = mock(Config.class);
    when(config.getCountry()).thenReturn(ConfigDescriptor.Country.HAITI);
    when(config.getSite()).thenReturn(ConfigDescriptor.Site.MIREBALAIS);
    when(config.getBiometricsConfig()).thenReturn(new BiometricsConfigDescriptor());
    pihCoreActivator.setConfig(config);
    pihCoreActivator.started();
    mirebalaisHospitalActivator = new MirebalaisHospitalActivator();
    // TODO: get ReportSetup to work while testing so we no longer need this
    mirebalaisHospitalActivator.setTestMode(true);
    mirebalaisHospitalActivator.willRefreshContext();
    mirebalaisHospitalActivator.contextRefreshed();
    mirebalaisHospitalActivator.willStart();
    mirebalaisHospitalActivator.started();
}
Also used : EmrApiActivator(org.openmrs.module.emrapi.EmrApiActivator) BiometricsConfigDescriptor(org.openmrs.module.pihcore.config.registration.BiometricsConfigDescriptor) PihCoreActivator(org.openmrs.module.pihcore.PihCoreActivator) Config(org.openmrs.module.pihcore.config.Config) AppointmentSchedulingUIActivator(org.openmrs.module.appointmentschedulingui.AppointmentSchedulingUIActivator) MirebalaisHospitalActivator(org.openmrs.module.mirebalais.MirebalaisHospitalActivator) Before(org.junit.Before)

Example 17 with Config

use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.

the class CustomAppLoaderComponentTest method shouldSetUpAppsAndExtensions.

@Test
public void shouldSetUpAppsAndExtensions() throws Exception {
    deployService.installBundle(socioEconomicConcepts);
    factory.setConfig(new Config());
    factory.getExtensions();
    factory.getAppDescriptors();
}
Also used : Config(org.openmrs.module.pihcore.config.Config) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 18 with Config

use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.

the class PatientRegistrationAppTest method shouldCreateAppDescriptor.

@Test
public void shouldCreateAppDescriptor() throws Exception {
    executeDataSet("org/openmrs/module/pihcore/coreMetadata.xml");
    authenticate();
    deployService.installBundle(socioEconomicConcepts);
    AppDescriptor d = patientRegistrationApp.getAppDescriptor(new Config());
    assertThat(d.getId(), is(CustomAppLoaderConstants.Apps.PATIENT_REGISTRATION));
    assertThat(d.getDescription(), is("registrationapp.registerPatient"));
    assertThat(d.getLabel(), is("registrationapp.app.registerPatient.label"));
    assertThat(d.getIcon(), is("icon-user"));
    assertThat(d.getUrl(), is("registrationapp/findPatient.page?appId=" + CustomAppLoaderConstants.Apps.PATIENT_REGISTRATION));
    assertThat(d.getRequiredPrivilege(), is("App: registrationapp.registerPatient"));
    assertThat(d.getConfig().get("afterCreatedUrl").getTextValue(), is("mirebalais/patientRegistration/afterRegistration.page?patientId={{patientId}}&encounterId={{encounterId}}"));
    assertThat(d.getConfig().get("patientDashboardLink").getTextValue(), is("registrationapp/registrationSummary.page?appId=registrationapp.registerPatient"));
    assertThat(d.getConfig().get("registrationEncounter").get("encounterType").getTextValue(), is(EncounterTypes.PATIENT_REGISTRATION.uuid()));
    assertThat(d.getConfig().get("registrationEncounter").get("encounterRole").getTextValue(), is(EncounterRoleBundle.EncounterRoles.ADMINISTRATIVE_CLERK));
    assertTrue(d.getConfig().get("allowRetrospectiveEntry").getBooleanValue());
    assertTrue(d.getConfig().get("allowUnknownPatients").getBooleanValue());
    assertTrue(d.getConfig().get("allowManualIdentifier").getBooleanValue());
    JsonNode demographicsSection = assertSectionFound(d.getConfig(), 0, "demographics", "", 1);
    assertPersonAttributeQuestionFound(demographicsSection, 0, HaitiPersonAttributeTypes.MOTHERS_FIRST_NAME.uuid(), true);
    JsonNode contactInfoSection = assertSectionFound(d.getConfig(), 1, "contactInfo", "registrationapp.patient.contactInfo.label", 2);
    assertSingleFieldQuestion(contactInfoSection, 0, "personAddress");
    assertPersonAttributeQuestionFound(contactInfoSection, 1, HaitiPersonAttributeTypes.TELEPHONE_NUMBER.uuid(), false);
    JsonNode socialSection = assertSectionFound(d.getConfig(), 2, "social", "zl.registration.patient.social.label", 4);
    assertSingleFieldQuestion(socialSection, 0, "personAddress");
    assertObsQuestionFound(socialSection, 1, "obs.PIH:CIVIL STATUS");
    assertObsQuestionFound(socialSection, 2, "obs.PIH:Occupation");
    assertObsQuestionFound(socialSection, 3, "obs.PIH:Religion");
    assertSectionFound(d.getConfig(), 3, "contacts", "zl.registration.patient.contactPerson.label", 3);
}
Also used : AppDescriptor(org.openmrs.module.appframework.domain.AppDescriptor) Config(org.openmrs.module.pihcore.config.Config) JsonNode(org.codehaus.jackson.JsonNode) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 19 with Config

use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.

the class PatientRegistrationApp method getFingerprintWidget.

protected ObjectNode getFingerprintWidget(Config config, FeatureToggleProperties featureToggles) {
    BiometricsConfigDescriptor biometricsConfig = config.getBiometricsConfig();
    FingerprintWidget w = new FingerprintWidget();
    FingerprintWidget.Config c = new FingerprintWidget.Config();
    c.setFormat(biometricsConfig.getTemplateFormat());
    c.setScanUrl(biometricsConfig.getScanUrl());
    c.setDevicesUrl(biometricsConfig.getDevicesUrl());
    // TODO these two toggles can probably be removed, I just added them so we would have a quick way of turning off the collection of either finger if we change our minds again
    if (!featureToggles.isFeatureEnabled("hideLeftIndex")) {
        c.addFinger(new FingerprintWidget.FingerprintFormField("leftIndexTemplate", "zl.registration.patient.biometrics.fingerprints.leftIndexLabel", "LEFT_INDEX_FINGER"));
    }
    if (!featureToggles.isFeatureEnabled("hideRightIndex")) {
        c.addFinger(new FingerprintWidget.FingerprintFormField("rightIndexTemplate", "zl.registration.patient.biometrics.fingerprints.rightIndexLabel", "RIGHT_INDEX_FINGER"));
    }
    w.setConfig(c);
    return toObjectNode(w);
}
Also used : FingerprintWidget(org.openmrs.module.registrationapp.model.FingerprintWidget) BiometricsConfigDescriptor(org.openmrs.module.pihcore.config.registration.BiometricsConfigDescriptor) Config(org.openmrs.module.pihcore.config.Config) RegistrationAppConfig(org.openmrs.module.registrationapp.model.RegistrationAppConfig)

Example 20 with Config

use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.

the class MirebalaisHospitalActivator method started.

/**
 * @see ModuleActivator#started()
 */
public void started() {
    try {
        // currently only one of these
        Config config = Context.getRegisteredComponents(Config.class).get(0);
        AdministrationService administrationService = Context.getAdministrationService();
        ReportService reportService = Context.getService(ReportService.class);
        ReportDefinitionService reportDefinitionService = Context.getService(ReportDefinitionService.class);
        SerializedObjectDAO serializedObjectDAO = Context.getRegisteredComponents(SerializedObjectDAO.class).get(0);
        PrinterService printerService = Context.getService(PrinterService.class);
        DispositionService dispositionService = Context.getService(DispositionService.class);
        removeOldPrivileges();
        setDispositionConfig(config, dispositionService);
        // register our custom print handlers
        PrinterSetup.registerPrintHandlers(printerService);
        // set up html forms--this must happen *after* MDS packages are installed, so that forms defined in code/github
        // take precedent over any in MDS packages; therefore we still do this in the Mirebalais module, not PIH Core
        HtmlFormSetup.setupHtmlForms(config);
        // configure default dashboard in coreapps
        updateGlobalProperty(CoreAppsConstants.GP_DASHBOARD_URL, config.getDashboardUrl());
        // configure default visits page in coreapps
        updateGlobalProperty(CoreAppsConstants.GP_VISITS_PAGE_URL, config.getVisitPageUrl());
        // configure default specific visit detail page in coreapps
        updateGlobalProperty(CoreAppsConstants.GP_VISITS_PAGE_WITH_SPECIFIC_URL, config.getVisitsPageWithSpecificUrl());
        if (config.isComponentEnabled(Components.LEGACY_MPI)) {
            LegacyMasterPatientIndexSetup.setupConnectionToMasterPatientIndex(customProperties);
        }
        if (config.isComponentEnabled(Components.ARCHIVES)) {
            ArchivesSetup.setupCloseStaleCreateRequestsTask();
            ArchivesSetup.setupCloseStalePullRequestsTask();
        }
        if (config.isComponentEnabled(Components.APPOINTMENT_SCHEDULING)) {
            AppointmentSchedulingSetup.setupMarkAppointmentAsMissedOrCompletedTask();
            if (config.getCountry().equals(ConfigDescriptor.Country.HAITI)) {
                AppointmentSchedulingSetup.customizeDailyAppointmentsDataSet();
            }
        }
        if (config.isComponentEnabled(Components.RADIOLOGY) && config.getSite().equals(ConfigDescriptor.Site.MIREBALAIS)) {
            updateGlobalProperty(OpenmrsConstants.GP_ORDER_NUMBER_GENERATOR_BEAN_ID, MirebalaisConstants.RADIOLOGY_ORDER_NUMBER_GENERATOR_BEAN_ID);
        }
        if (!testMode) {
            if (config.isComponentEnabled(Components.OVERVIEW_REPORTS) || config.isComponentEnabled(Components.DATA_EXPORTS)) {
                // must happen after location tags have been configured
                ReportSetup.setupReports(reportService, reportDefinitionService, administrationService, serializedObjectDAO, config);
            }
            // do app and extension configuration
            Context.getRegisteredComponent("customAppLoaderFactory", CustomAppLoaderFactory.class).setReadyForRefresh(true);
            ModuleFactory.getStartedModuleById("appframework").getModuleActivator().contextRefreshed();
            // on first startup, these modules may not have been able to configure their global propertes correctly because
            // all metadata was not loaded; we call the started method here to complete setup
            ModuleFactory.getStartedModuleById("registrationapp").getModuleActivator().started();
        }
    } catch (Exception e) {
        Module mod = ModuleFactory.getModuleById(MirebalaisConstants.MIREBALAIS_MODULE_ID);
        ModuleFactory.stopModule(mod);
        throw new RuntimeException("failed to setup the required modules", e);
    }
    log.info("Mirebalais Hospital Module started");
}
Also used : DispositionService(org.openmrs.module.emrapi.disposition.DispositionService) ReportService(org.openmrs.module.reporting.report.service.ReportService) AdministrationService(org.openmrs.api.AdministrationService) ReportDefinitionService(org.openmrs.module.reporting.report.definition.service.ReportDefinitionService) CustomAppLoaderFactory(org.openmrs.module.mirebalais.apploader.CustomAppLoaderFactory) Config(org.openmrs.module.pihcore.config.Config) PrinterService(org.openmrs.module.printer.PrinterService) Module(org.openmrs.module.Module) SerializedObjectDAO(org.openmrs.api.db.SerializedObjectDAO)

Aggregations

Config (org.openmrs.module.pihcore.config.Config)26 Test (org.junit.Test)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)8 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)8 Location (org.openmrs.Location)6 SimpleObject (org.openmrs.ui.framework.SimpleObject)6 Before (org.junit.Before)5 DateTime (org.joda.time.DateTime)4 EmrApiActivator (org.openmrs.module.emrapi.EmrApiActivator)4 BiometricsConfigDescriptor (org.openmrs.module.pihcore.config.registration.BiometricsConfigDescriptor)4 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)4 File (java.io.File)3 ResourceFactory (org.openmrs.ui.framework.resource.ResourceFactory)3 Encounter (org.openmrs.Encounter)2 Order (org.openmrs.Order)2 Patient (org.openmrs.Patient)2 Module (org.openmrs.module.Module)2 MirebalaisHospitalActivator (org.openmrs.module.mirebalais.MirebalaisHospitalActivator)2 PihCoreActivator (org.openmrs.module.pihcore.PihCoreActivator)2