Search in sources :

Example 6 with GlobalProperty

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

the class HibernateAdministrationDAO method saveGlobalProperty.

/**
 * @see org.openmrs.api.db.AdministrationDAO#saveGlobalProperty(org.openmrs.GlobalProperty)
 */
@Override
public GlobalProperty saveGlobalProperty(GlobalProperty gp) throws DAOException {
    GlobalProperty gpObject = getGlobalPropertyObject(gp.getProperty());
    if (gpObject != null) {
        gpObject.setPropertyValue(gp.getPropertyValue());
        gpObject.setDescription(gp.getDescription());
        sessionFactory.getCurrentSession().update(gpObject);
        return gpObject;
    } else {
        sessionFactory.getCurrentSession().save(gp);
        return gp;
    }
}
Also used : GlobalProperty(org.openmrs.GlobalProperty)

Example 7 with GlobalProperty

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

the class OrderServiceTest method saveOrder_shouldSetTheOrderNumberReturnedByTheConfiguredGenerator.

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldSetTheOrderNumberReturnedByTheConfiguredGenerator() {
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GP_ORDER_NUMBER_GENERATOR_BEAN_ID, "orderEntry.OrderNumberGenerator");
    Context.getAdministrationService().saveGlobalProperty(gp);
    Order order = new TestOrder();
    order.setPatient(patientService.getPatient(7));
    order.setConcept(conceptService.getConcept(5497));
    order.setOrderer(providerService.getProvider(1));
    order.setCareSetting(orderService.getCareSetting(1));
    order.setOrderType(orderService.getOrderType(2));
    order.setEncounter(encounterService.getEncounter(3));
    order.setDateActivated(new Date());
    order = orderService.saveOrder(order, null);
    assertTrue(order.getOrderNumber().startsWith(TimestampOrderNumberGenerator.ORDER_NUMBER_PREFIX));
}
Also used : DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Order(org.openmrs.Order) TestOrder(org.openmrs.TestOrder) Date(java.util.Date) GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 8 with GlobalProperty

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

the class OrderServiceTest method getDrugDispensingUnits_shouldReturnAnEmptyListIfNothingIsConfigured.

/**
 * @see OrderService#getDrugDispensingUnits()
 */
@Test
public void getDrugDispensingUnits_shouldReturnAnEmptyListIfNothingIsConfigured() {
    adminService.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GP_DRUG_DISPENSING_UNITS_CONCEPT_UUID, ""));
    adminService.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GP_DRUG_DOSING_UNITS_CONCEPT_UUID, ""));
    assertThat(orderService.getDrugDispensingUnits(), is(empty()));
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 9 with GlobalProperty

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

the class OrderServiceTest method getDurationUnits_shouldReturnAnEmptyListIfNothingIsConfigured.

/**
 * @see OrderService#getDurationUnits()
 */
@Test
public void getDurationUnits_shouldReturnAnEmptyListIfNothingIsConfigured() {
    adminService.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GP_DURATION_UNITS_CONCEPT_UUID, ""));
    assertThat(orderService.getDurationUnits(), is(empty()));
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 10 with GlobalProperty

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

the class FormServiceTest method createFormsLockedGPAndSetValue.

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

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