Search in sources :

Example 61 with GlobalProperty

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

the class EncounterServiceTest method saveEncounter_shouldNotAssignEncounterToVisitIfTheNoAssignHandlerIsRegistered.

/**
 * @see EncounterService#saveEncounter(Encounter)
 */
@Test
public void saveEncounter_shouldNotAssignEncounterToVisitIfTheNoAssignHandlerIsRegistered() {
    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.NoVisitAssignmentHandler");
    Context.getAdministrationService().saveGlobalProperty(gp);
    Context.getEncounterService().saveEncounter(encounter);
    // We should have no visit.
    assertNull(encounter.getVisit());
}
Also used : Encounter(org.openmrs.Encounter) GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 62 with GlobalProperty

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

the class EncounterServiceTest method retireEncounterType_shouldThrowErrorWhenTryingToRetireEncounterTypeWhenEncounterTypesAreLocked.

/**
 * @see EncounterService#retireEncounterType(EncounterType, String)
 */
@Test(expected = EncounterTypeLockedException.class)
public void retireEncounterType_shouldThrowErrorWhenTryingToRetireEncounterTypeWhenEncounterTypesAreLocked() {
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_ENCOUNTER_TYPES_LOCKED);
    gp.setPropertyValue("true");
    Context.getAdministrationService().saveGlobalProperty(gp);
    EncounterService encounterService = Context.getEncounterService();
    EncounterType encounterType = Context.getEncounterService().getEncounterType(1);
    Assert.assertNotNull(encounterType);
    encounterService.retireEncounterType(encounterType, "reason");
}
Also used : EncounterType(org.openmrs.EncounterType) GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 63 with GlobalProperty

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

the class EncounterServiceTest method saveEncounterType_shouldThrowErrorWhenTryingToSaveEncounterTypeWhenEncounterTypesAreLocked.

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

Example 64 with GlobalProperty

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

the class LocationServiceTest method getDefaultLocation_shouldReturnUnknownLocationIfTheGlobalPropertyIsSomethingElseThatDoesnotExist.

/**
 * @see LocationService#getDefaultLocation()
 */
@Test
public void getDefaultLocation_shouldReturnUnknownLocationIfTheGlobalPropertyIsSomethingElseThatDoesnotExist() {
    // set the global property to something that has no match in the location table
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCATION_NAME, "None existent Location", "Testing");
    Context.getAdministrationService().saveGlobalProperty(gp);
    Assert.assertEquals("Unknown Location", Context.getLocationService().getDefaultLocation().getName());
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 65 with GlobalProperty

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

the class PatientServiceTest method getPatients_shouldSupportPatternUsingLastDigitAsCheckDigit.

/**
 * @see PatientService#getPatients(String, String, java.util.List, boolean)
 */
@Test
public void getPatients_shouldSupportPatternUsingLastDigitAsCheckDigit() throws Exception {
    Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_IDENTIFIER_SEARCH_PATTERN, "@SEARCH@,0@SEARCH@,@SEARCH-1@-@CHECKDIGIT@,0@SEARCH-1@-@CHECKDIGIT@"));
    // "^(0*@SEARCH-1@-@CHECKDIGIT@)$"));
    PatientIdentifier identifier = new PatientIdentifier("1234-4", new PatientIdentifierType(1), new Location(1));
    identifier.setCreator(new User(1));
    identifier.setDateCreated(new Date());
    Patient patient = Context.getPatientService().getPatient(2);
    patient.addIdentifier(identifier);
    Context.getPatientService().savePatient(patient);
    updateSearchIndex();
    assertEquals(1, Context.getPatientService().getPatients("12344").size());
    assertEquals(1, Context.getPatientService().getPatients("1234-4").size());
}
Also used : User(org.openmrs.User) Patient(org.openmrs.Patient) PatientIdentifier(org.openmrs.PatientIdentifier) PatientIdentifierType(org.openmrs.PatientIdentifierType) Date(java.util.Date) GlobalProperty(org.openmrs.GlobalProperty) Location(org.openmrs.Location) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

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