Search in sources :

Example 46 with Location

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

the class LocationServiceTest method saveLocationTag_shouldThrowAPIExceptionIfTagHasNoName.

/**
 * @see LocationService#saveLocationTag(LocationTag)
 */
@Test(expected = APIException.class)
public void saveLocationTag_shouldThrowAPIExceptionIfTagHasNoName() {
    LocationTag tagWithoutName = new LocationTag();
    Location location = new Location();
    location.setName("Some name");
    location.setDescription("Some description");
    location.addTag(tagWithoutName);
    Context.getLocationService().saveLocation(location);
}
Also used : LocationTag(org.openmrs.LocationTag) Location(org.openmrs.Location) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 47 with Location

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

the class PatientServiceTest method savePatient_shouldNotThrowANonUniqueObjectExceptionWhenCalledWithAHandConstructedPatient.

/**
 * Regression test for http://dev.openmrs.org/ticket/1375
 *
 * @see PatientService#savePatient(Patient)
 */
@Test
public void savePatient_shouldNotThrowANonUniqueObjectExceptionWhenCalledWithAHandConstructedPatient() throws Exception {
    Patient patient = new Patient();
    patient.setGender("M");
    patient.setPatientId(2);
    // patient.setCreator(new User(1));
    // patient.setDateCreated date_created="2005-09-22 00:00:00.0"
    // changed_by="1" date_changed="2008-08-18 12:29:59.0"
    patient.addName(new PersonName("This", "Isa", "Test"));
    PatientIdentifier patientIdentifier = new PatientIdentifier("101-6", new PatientIdentifierType(1), new Location(1));
    patientIdentifier.setPreferred(true);
    patient.addIdentifier(patientIdentifier);
    Context.getPatientService().savePatient(patient);
}
Also used : PersonName(org.openmrs.PersonName) Patient(org.openmrs.Patient) PatientIdentifier(org.openmrs.PatientIdentifier) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 48 with Location

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

the class PatientServiceTest method savePatient_shouldNotThrowNonUniqueObjectExceptionWhenCalledWithPersonPromotedToPatient.

/**
 * https://tickets.openmrs.org/browse/TRUNK-3728
 *
 * @see PatientService#savePatient(Patient)
 */
@Test
public void savePatient_shouldNotThrowNonUniqueObjectExceptionWhenCalledWithPersonPromotedToPatient() throws Exception {
    Person person = personService.getPerson(1);
    Patient patient = patientService.getPatientOrPromotePerson(person.getPersonId());
    PatientIdentifier patientIdentifier = new PatientIdentifier("some identifier", new PatientIdentifierType(2), new Location(1));
    patientIdentifier.setPreferred(true);
    patient.addIdentifier(patientIdentifier);
    patientService.savePatient(patient);
}
Also used : Patient(org.openmrs.Patient) Person(org.openmrs.Person) PatientIdentifier(org.openmrs.PatientIdentifier) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 49 with Location

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

the class PatientDAOTest method getPatientIdentifiers_shouldLimitByResultsByLocation.

@Test
public void getPatientIdentifiers_shouldLimitByResultsByLocation() {
    // there is only one identifier in the test database for location 3
    Location location = Context.getLocationService().getLocation(3);
    List<PatientIdentifier> patientIdentifiers = dao.getPatientIdentifiers(null, new ArrayList<>(), Collections.singletonList(location), new ArrayList<>(), null);
    Assert.assertEquals(1, patientIdentifiers.size());
    Assert.assertEquals("12345K", patientIdentifiers.get(0).getIdentifier());
}
Also used : PatientIdentifier(org.openmrs.PatientIdentifier) Location(org.openmrs.Location) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 50 with Location

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

the class BaseUnretireHandlerTest method handle_shouldUnsetTheDateRetired.

/**
 * @see BaseUnretireHandler#handle(Retireable,User,Date,String)
 */
@Test
public void handle_shouldUnsetTheDateRetired() {
    UnretireHandler<Retireable> handler = new BaseUnretireHandler();
    Retireable retireable = new Location();
    retireable.setRetired(true);
    retireable.setDateRetired(new Date());
    handler.handle(retireable, null, null, null);
    Assert.assertNull(retireable.getDateRetired());
}
Also used : Retireable(org.openmrs.Retireable) Date(java.util.Date) Location(org.openmrs.Location) Test(org.junit.Test)

Aggregations

Location (org.openmrs.Location)235 Test (org.junit.Test)161 Date (java.util.Date)80 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)74 Patient (org.openmrs.Patient)66 Encounter (org.openmrs.Encounter)38 SimpleObject (org.openmrs.ui.framework.SimpleObject)32 PatientIdentifierType (org.openmrs.PatientIdentifierType)31 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)31 Visit (org.openmrs.Visit)28 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)28 Obs (org.openmrs.Obs)27 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)27 PatientIdentifier (org.openmrs.PatientIdentifier)26 Concept (org.openmrs.Concept)19 EncounterType (org.openmrs.EncounterType)18 DateTime (org.joda.time.DateTime)17 ArrayList (java.util.ArrayList)15 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)15 BindException (org.springframework.validation.BindException)15