Search in sources :

Example 31 with GlobalProperty

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

the class AdministrationServiceImpl method updateGlobalProperty.

/**
 * @see org.openmrs.api.AdministrationService#updateGlobalProperty(java.lang.String,
 *      java.lang.String)
 */
@Override
public void updateGlobalProperty(String propertyName, String propertyValue) throws IllegalStateException {
    GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject(propertyName);
    if (gp == null) {
        throw new IllegalStateException("Global property with the given propertyName does not exist" + propertyName);
    }
    gp.setPropertyValue(propertyValue);
    dao.saveGlobalProperty(gp);
}
Also used : GlobalProperty(org.openmrs.GlobalProperty)

Example 32 with GlobalProperty

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

the class LocationUtilityTest method getDefaultLocation_shouldReturnTheUpdatedDefaultLocationWhenTheValueOfTheGlobalPropertyIsChanged.

/**
 * @see LocationUtility#getDefaultLocation()
 */
@Test
public void getDefaultLocation_shouldReturnTheUpdatedDefaultLocationWhenTheValueOfTheGlobalPropertyIsChanged() {
    // sanity check
    Assert.assertEquals("Unknown Location", LocationUtility.getDefaultLocation().getName());
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCATION_NAME, "Xanadu", "Testing");
    Context.getAdministrationService().saveGlobalProperty(gp);
    Assert.assertEquals("Xanadu", LocationUtility.getDefaultLocation().getName());
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 33 with GlobalProperty

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

the class EncounterServiceTest method saveEncounter_shouldAssignEncounterToVisitIfTheAssignToExistingHandlerIsRegistered.

/**
 * @see EncounterService#saveEncounter(Encounter)
 */
@Test
public void saveEncounter_shouldAssignEncounterToVisitIfTheAssignToExistingHandlerIsRegistered() {
    Encounter encounter = buildEncounter();
    // We should have no visit
    assertNull(encounter.getVisit());
    GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER);
    gp.setPropertyValue("org.openmrs.api.handler.ExistingVisitAssignmentHandler");
    Context.getAdministrationService().saveGlobalProperty(gp);
    Context.getEncounterService().saveEncounter(encounter);
    // We should have a visit.
    assertNotNull(encounter.getVisit());
    assertNotNull(encounter.getVisit().getVisitId());
}
Also used : Encounter(org.openmrs.Encounter) GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 34 with GlobalProperty

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

the class EncounterServiceTest method getActiveEncounterVisitHandler_shouldReturnBeanHaveBeenRegisteredWithGivenName.

@Test
public void getActiveEncounterVisitHandler_shouldReturnBeanHaveBeenRegisteredWithGivenName() {
    String correctBeanName = OpenmrsConstants.REGISTERED_COMPONENT_NAME_PREFIX + "existingOrNewVisitAssignmentHandler";
    GlobalProperty visitHandlerProperty = new GlobalProperty(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER, correctBeanName);
    Context.getAdministrationService().saveGlobalProperty(visitHandlerProperty);
    EncounterVisitHandler activeEncounterVisitHandler = Context.getEncounterService().getActiveEncounterVisitHandler();
    Assert.assertNotNull(activeEncounterVisitHandler);
}
Also used : EncounterVisitHandler(org.openmrs.api.handler.EncounterVisitHandler) GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 35 with GlobalProperty

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

the class EncounterServiceTest method unretireEncounterType_shouldThrowErrorWhenTryingToUnretireEncounterTypeWhenEncounterTypesAreLocked.

/**
 * @see EncounterService#unretireEncounterType(EncounterType)
 */
@Test(expected = EncounterTypeLockedException.class)
public void unretireEncounterType_shouldThrowErrorWhenTryingToUnretireEncounterTypeWhenEncounterTypesAreLocked() {
    EncounterService encounterService = Context.getEncounterService();
    EncounterType encounterType = Context.getEncounterService().getEncounterType(2);
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_ENCOUNTER_TYPES_LOCKED);
    gp.setPropertyValue("true");
    Context.getAdministrationService().saveGlobalProperty(gp);
    encounterService.unretireEncounterType(encounterType);
}
Also used : EncounterType(org.openmrs.EncounterType) GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

GlobalProperty (org.openmrs.GlobalProperty)107 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 BindException (org.springframework.validation.BindException)10 DrugOrder (org.openmrs.DrugOrder)9 Errors (org.springframework.validation.Errors)9 AdministrationService (org.openmrs.api.AdministrationService)8 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)4 MutableMessageSource (org.openmrs.messagesource.MutableMessageSource)4 MutableResourceBundleMessageSource (org.openmrs.messagesource.impl.MutableResourceBundleMessageSource)4