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());
}
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");
}
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);
}
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());
}
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());
}
Aggregations