Search in sources :

Example 1 with RelationshipType

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

the class PersonServiceTest method saveRelationshipType_shouldFailIfTheDescriptionIsNotSpecified.

/**
 * @see PersonService#saveRelationshipType(RelationshipType)
 */
@Test(expected = APIException.class)
public void saveRelationshipType_shouldFailIfTheDescriptionIsNotSpecified() throws Exception {
    RelationshipType relationshipType = new RelationshipType();
    relationshipType.setaIsToB("Sister");
    relationshipType.setbIsToA("Brother");
    personService.saveRelationshipType(relationshipType);
}
Also used : RelationshipType(org.openmrs.RelationshipType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 2 with RelationshipType

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

the class PersonServiceTest method getRelationshipMap_shouldReturnEmptyMapWhenNoRelationshipHasTheMatchingRelationshipType.

/**
 * @see PersonService#getRelationshipMap(RelationshipType)
 */
@Test
public void getRelationshipMap_shouldReturnEmptyMapWhenNoRelationshipHasTheMatchingRelationshipType() throws Exception {
    executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredRelationship.xml");
    PersonService personService = Context.getPersonService();
    RelationshipType relationshipType = personService.getRelationshipType(15);
    Map<Person, List<Person>> relationshipMap = personService.getRelationshipMap(relationshipType);
    Assert.assertNotNull(relationshipMap);
    assertTrue("There should be no element in the map", relationshipMap.isEmpty());
}
Also used : RelationshipType(org.openmrs.RelationshipType) ArrayList(java.util.ArrayList) List(java.util.List) Person(org.openmrs.Person) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 3 with RelationshipType

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

the class PersonServiceTest method getRelationships3_shouldFetchRelationshipsMatchingTheGivenRelType.

/**
 * @see PersonService#getRelationships(Person,Person,RelationshipType,Date,Date)
 */
@Test
public void getRelationships3_shouldFetchRelationshipsMatchingTheGivenRelType() throws Exception {
    PersonService personService = Context.getPersonService();
    RelationshipType relationshipType = personService.getRelationshipType(1);
    List<Relationship> relationships = personService.getRelationships(null, null, relationshipType, new Date(), new Date());
    Assert.assertNotNull(relationships);
    assertTrue("There should be relationship found given the relationship type", relationships.size() > 0);
}
Also used : Relationship(org.openmrs.Relationship) RelationshipType(org.openmrs.RelationshipType) Date(java.util.Date) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 4 with RelationshipType

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

the class PersonServiceTest method getRelationshipType_shouldReturnRelationshipTypeWithTheGivenRelationshipTypeId.

/**
 * @see PersonService#getRelationshipType(Integer)
 */
@Test
public void getRelationshipType_shouldReturnRelationshipTypeWithTheGivenRelationshipTypeId() throws Exception {
    RelationshipType relationshipType = Context.getPersonService().getRelationshipType(1);
    Assert.assertNotNull(relationshipType);
    assertTrue("Expecting the return is of a relationship type", relationshipType.getClass().equals(RelationshipType.class));
}
Also used : RelationshipType(org.openmrs.RelationshipType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 5 with RelationshipType

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

the class PersonServiceTest method getRelationshipTypeByName_shouldReturnNullWhenNoRelationshipTypeMatchTheGivenName.

/**
 * @see PersonService#getRelationshipTypeByName(String)
 */
@Test
public void getRelationshipTypeByName_shouldReturnNullWhenNoRelationshipTypeMatchTheGivenName() throws Exception {
    RelationshipType relationshipType = Context.getPersonService().getRelationshipTypeByName("Supervisor");
    Assert.assertNull(relationshipType);
}
Also used : RelationshipType(org.openmrs.RelationshipType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

RelationshipType (org.openmrs.RelationshipType)35 Test (org.junit.Test)29 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)29 Relationship (org.openmrs.Relationship)13 Person (org.openmrs.Person)8 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)7 Patient (org.openmrs.Patient)6 PersonService (org.openmrs.api.PersonService)5 Message (ca.uhn.hl7v2.model.Message)4 Date (java.util.Date)4 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)3 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 List (java.util.List)3 ProviderAttributeType (org.openmrs.ProviderAttributeType)2 Role (org.openmrs.Role)2 User (org.openmrs.User)2 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)2