Search in sources :

Example 26 with RelationshipType

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

the class PersonServiceTest method getRelationships3_shouldReturnEmptyListWhenNoRelationshipMatchingGivenParametersExist.

/**
 * @see PersonService#getRelationships(Person,Person,RelationshipType,Date,Date)
 */
@Test
public void getRelationships3_shouldReturnEmptyListWhenNoRelationshipMatchingGivenParametersExist() throws Exception {
    PersonService personService = Context.getPersonService();
    Person firstPerson = personService.getPerson(501);
    Person secondPerson = personService.getPerson(2);
    RelationshipType relationshipType = personService.getRelationshipType(1);
    List<Relationship> relationships = personService.getRelationships(firstPerson, secondPerson, relationshipType, new Date(), new Date());
    Assert.assertNotNull(relationships);
    assertTrue("There should be no relationship found given the from person", relationships.isEmpty());
}
Also used : Relationship(org.openmrs.Relationship) RelationshipType(org.openmrs.RelationshipType) Person(org.openmrs.Person) Date(java.util.Date) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 27 with RelationshipType

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

the class PersonServiceTest method getRelationshipTypeByUuid_shouldFindObjectGivenValidUuid.

/**
 * @see PersonService#getRelationshipTypeByUuid(String)
 */
@Test
public void getRelationshipTypeByUuid_shouldFindObjectGivenValidUuid() throws Exception {
    String uuid = "6d9002ea-a96b-4889-af78-82d48c57a110";
    RelationshipType relationshipType = Context.getPersonService().getRelationshipTypeByUuid(uuid);
    Assert.assertEquals(1, (int) relationshipType.getRelationshipTypeId());
}
Also used : RelationshipType(org.openmrs.RelationshipType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 28 with RelationshipType

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

the class PersonServiceTest method saveRelationshipType_shouldCreateNewObjectWhenRelationshipTypeIdIsNull.

/**
 * @see PersonService#saveRelationshipType(RelationshipType)
 */
@Test
public void saveRelationshipType_shouldCreateNewObjectWhenRelationshipTypeIdIsNull() throws Exception {
    RelationshipType relationshipType = new RelationshipType();
    relationshipType.setDescription("Test relationship");
    relationshipType.setaIsToB("Sister");
    relationshipType.setbIsToA("Brother");
    Assert.assertNull(relationshipType.getRelationshipTypeId());
    RelationshipType savedRelationshipType = personService.saveRelationshipType(relationshipType);
    Assert.assertNotNull(savedRelationshipType.getRelationshipTypeId());
}
Also used : RelationshipType(org.openmrs.RelationshipType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 29 with RelationshipType

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

the class PersonServiceTest method unretireRelationshipType_shouldRetireGivenRelationshipType.

@Test
public void unretireRelationshipType_shouldRetireGivenRelationshipType() {
    RelationshipType rt = personService.getRelationshipType(1);
    personService.retireRelationshipType(rt, "reason");
    assertTrue(rt.getRetired());
    personService.unretireRelationshipType(rt);
    assertFalse(rt.getRetired());
    assertNull(rt.getRetiredBy());
    assertNull(rt.getDateRetired());
    assertNull(rt.getRetireReason());
}
Also used : RelationshipType(org.openmrs.RelationshipType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 30 with RelationshipType

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

the class PersonServiceTest method getRelationships2_shouldFetchRelationshipsMatchingTheGivenRelType.

/**
 * @see PersonService#getRelationships(Person,Person,RelationshipType,Date)
 */
@Test
public void getRelationships2_shouldFetchRelationshipsMatchingTheGivenRelType() throws Exception {
    PersonService personService = Context.getPersonService();
    RelationshipType relationshipType = personService.getRelationshipType(1);
    List<Relationship> relationships = personService.getRelationships(null, null, relationshipType, 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)

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