use of org.openmrs.Relationship in project openmrs-core by openmrs.
the class PersonServiceTest method getRelationships_shouldFetchRelationshipsMatchingTheGivenToPerson.
/**
* @see PersonService#getRelationships(Person,Person,RelationshipType)
*/
@Test
public void getRelationships_shouldFetchRelationshipsMatchingTheGivenToPerson() throws Exception {
PersonService personService = Context.getPersonService();
Person secondPerson = personService.getPerson(7);
List<Relationship> relationships = personService.getRelationships(null, secondPerson, null);
Assert.assertNotNull(relationships);
assertTrue("There should be relationship found given the to person", relationships.size() > 0);
}
use of org.openmrs.Relationship in project openmrs-core by openmrs.
the class PersonServiceTest method getRelationships_shouldFetchRelationshipsMatchingTheGivenRelType.
/**
* @see PersonService#getRelationships(Person,Person,RelationshipType)
*/
@Test
public void getRelationships_shouldFetchRelationshipsMatchingTheGivenRelType() throws Exception {
PersonService personService = Context.getPersonService();
RelationshipType relationshipType = personService.getRelationshipType(1);
List<Relationship> relationships = personService.getRelationships(null, null, relationshipType);
Assert.assertNotNull(relationships);
assertTrue("There should be relationship found given the relationship type", relationships.size() > 0);
}
use of org.openmrs.Relationship in project openmrs-core by openmrs.
the class PersonServiceTest method getRelationshipByUuid_shouldFindObjectGivenValidUuid.
/**
* @see PersonService#getRelationshipByUuid(String)
*/
@Test
public void getRelationshipByUuid_shouldFindObjectGivenValidUuid() throws Exception {
String uuid = "c18717dd-5d78-4a0e-84fc-ee62c5f0676a";
Relationship relationship = Context.getPersonService().getRelationshipByUuid(uuid);
Assert.assertEquals(1, (int) relationship.getRelationshipId());
}
use of org.openmrs.Relationship in project openmrs-core by openmrs.
the class PersonServiceTest method getRelationshipsByPerson_shouldOnlyGetUnvoidedRelationshipsRegardlessOfEffectiveDate.
/**
* Tests a voided relationship between personA and Person B to see if it is still listed when
* retrieving unvoided relationships for personA and if it is still listed when retrieving
* unvoided relationships for personB.
*
* @see PersonService#getRelationshipsByPerson(Person,Date)
*/
@Test
public void getRelationshipsByPerson_shouldOnlyGetUnvoidedRelationshipsRegardlessOfEffectiveDate() throws Exception {
executeDataSet(CREATE_PATIENT_XML);
executeDataSet(CREATE_RELATIONSHIP_XML);
Patient p1 = ps.getPatient(6);
Patient p2 = ps.getPatient(8);
// Create a sibling relationship between o1 and p2
Relationship sibling = new Relationship();
sibling.setPersonA(p1);
sibling.setPersonB(p2);
sibling.setRelationshipType(personService.getRelationshipType(4));
personService.saveRelationship(sibling);
// Make p2 the Doctor of p1.
Relationship doctor = new Relationship();
doctor.setPersonB(p1);
doctor.setPersonA(p2);
doctor.setRelationshipType(personService.getRelationshipType(3));
personService.saveRelationship(doctor);
// Void all relationships.
List<Relationship> allRels = personService.getAllRelationships();
for (Relationship r : allRels) {
personService.voidRelationship(r, "Because of a JUnit test.");
}
// Get unvoided relationships after voiding all of them.
// (specified date should not matter as no relationships have date specified)
List<Relationship> updatedARels = personService.getRelationshipsByPerson(p1, new Date());
List<Relationship> updatedBRels = personService.getRelationshipsByPerson(p2, new Date());
// Neither p1 or p2 should have any relationships now.
assertEquals(0, updatedARels.size());
assertEquals(updatedARels, updatedBRels);
}
use of org.openmrs.Relationship in project openmrs-core by openmrs.
the class PersonServiceTest method getRelationshipsByPerson_shouldFetchRelationshipsAssociatedWithTheGivenPerson.
/**
* @see PersonService#getRelationshipsByPerson(Person)
*/
@Test
public void getRelationshipsByPerson_shouldFetchRelationshipsAssociatedWithTheGivenPerson() throws Exception {
PersonService personService = Context.getPersonService();
Person person = personService.getPerson(2);
List<Relationship> relationships = personService.getRelationshipsByPerson(person);
Assert.assertNotNull(relationships);
assertTrue("There should be relationship found given the person", relationships.size() > 0);
}
Aggregations