Search in sources :

Example 46 with GlobalProperty

use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.

the class LocationServiceTest method getDefaultLocation_shouldReturnDefaultLocationForTheImplementation.

/**
 * @see LocationService#getDefaultLocation()
 */
@Test
public void getDefaultLocation_shouldReturnDefaultLocationForTheImplementation() {
    // set the global property for default location to something other than Unknown Location
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCATION_NAME, "Test Parent Location", "Testing default Location");
    Context.getAdministrationService().saveGlobalProperty(gp);
    Assert.assertEquals("Test Parent Location", Context.getLocationService().getDefaultLocation().getName());
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 47 with GlobalProperty

use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.

the class PatientServiceTest method createPatientIdentifierTypeLockedGPAndSetValue.

/**
 * Creates a new Global Property to lock patient identifier types by setting its value
 *
 * @param propertyValue value for patient identifier types locked GP
 */
public void createPatientIdentifierTypeLockedGPAndSetValue(String propertyValue) {
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_IDENTIFIER_TYPES_LOCKED);
    gp.setPropertyValue(propertyValue);
    Context.getAdministrationService().saveGlobalProperty(gp);
}
Also used : GlobalProperty(org.openmrs.GlobalProperty)

Example 48 with GlobalProperty

use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.

the class ExistingOrNewVisitAssignmentHandlerTest method beforeCreateEncounter_shouldResolveEncounterAndVisitTypeUuidsAsGlobalPropertyValues.

/**
 * @see ExistingOrNewVisitAssignmentHandler#beforeCreateEncounter(Encounter)
 */
@Test
public void beforeCreateEncounter_shouldResolveEncounterAndVisitTypeUuidsAsGlobalPropertyValues() {
    final String encounterTypeUuid = "759799ab-c9a5-435e-b671-77773ada74e4";
    final String visitTypeUuid = "c0c579b0-8e59-401d-8a4a-976a0b183519";
    Encounter encounter = Context.getEncounterService().getEncounter(1);
    Assert.assertNull(encounter.getVisit());
    Assert.assertEquals(encounterTypeUuid, encounter.getEncounterType().getUuid());
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(encounter.getEncounterDatetime());
    calendar.set(Calendar.YEAR, 1900);
    encounter.setEncounterDatetime(calendar.getTime());
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GP_ENCOUNTER_TYPE_TO_VISIT_TYPE_MAPPING, encounterTypeUuid + ":" + visitTypeUuid);
    Context.getAdministrationService().saveGlobalProperty(gp);
    new ExistingOrNewVisitAssignmentHandler().beforeCreateEncounter(encounter);
    Assert.assertNotNull(encounter.getVisit());
    // should be set according toencounterTypeUuid:visitTypeUuid
    Assert.assertEquals(1, encounter.getEncounterType().getEncounterTypeId().intValue());
    Assert.assertEquals(Context.getVisitService().getVisitTypeByUuid(visitTypeUuid), encounter.getVisit().getVisitType());
}
Also used : Calendar(java.util.Calendar) Encounter(org.openmrs.Encounter) GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 49 with GlobalProperty

use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.

the class GlobalLocaleListTest method globalPropertyChanged_shouldSetAllowedLocalesIfGlobalPropertyIsAnEmptyString.

@Test
public void globalPropertyChanged_shouldSetAllowedLocalesIfGlobalPropertyIsAnEmptyString() {
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, "");
    globalLocaleList.globalPropertyChanged(gp);
    assertThat(globalLocaleList.getAllowedLocales(), contains(Locale.ROOT));
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test)

Example 50 with GlobalProperty

use of org.openmrs.GlobalProperty in project openmrs-module-coreapps by openmrs.

the class CoreAppsActivator method started.

/**
 * @see ModuleActivator#started()
 */
public void started() {
    // purge old global property no longer used
    GlobalProperty defaultDashboard = Context.getAdministrationService().getGlobalPropertyObject(CoreAppsConstants.GP_DEFAULT_DASHBOARD);
    if (defaultDashboard != null) {
        Context.getAdministrationService().purgeGlobalProperty(defaultDashboard);
    }
    log.info("Core Apps Module started");
}
Also used : GlobalProperty(org.openmrs.GlobalProperty)

Aggregations

GlobalProperty (org.openmrs.GlobalProperty)110 Test (org.junit.Test)80 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)77 Locale (java.util.Locale)14 OrderUtilTest (org.openmrs.order.OrderUtilTest)14 Encounter (org.openmrs.Encounter)12 ArrayList (java.util.ArrayList)11 User (org.openmrs.User)11 Patient (org.openmrs.Patient)10 AdministrationService (org.openmrs.api.AdministrationService)10 BindException (org.springframework.validation.BindException)10 DrugOrder (org.openmrs.DrugOrder)9 Errors (org.springframework.validation.Errors)9 CareSetting (org.openmrs.CareSetting)7 OrderType (org.openmrs.OrderType)7 Date (java.util.Date)6 EncounterType (org.openmrs.EncounterType)5 APIException (org.openmrs.api.APIException)5 MutableMessageSource (org.openmrs.messagesource.MutableMessageSource)4 MutableResourceBundleMessageSource (org.openmrs.messagesource.impl.MutableResourceBundleMessageSource)4