/** * @see PersonService#getRelationshipsByPerson(Person) */ @Test public void getRelationshipsByPerson2_shouldFetchRelationshipsAssociatedWithTheGivenPerson() throws Exception { PersonService personService = Context.getPersonService(); Person person = personService.getPerson(2); List<Relationship> relationships = personService.getRelationshipsByPerson(person, new Date()); Assert.assertNotNull(relationships); assertTrue("There should be relationship found given the person", relationships.size() > 0); }
/** * @see PersonService#getRelationshipsByPerson(Person) */ @Test public void getRelationshipsByPerson2_shouldFetchUnvoidedRelationshipsOnly() throws Exception { executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredRelationship.xml"); PersonService personService = Context.getPersonService(); Person person = personService.getPerson(6); List<Relationship> relationships = personService.getRelationshipsByPerson(person, new Date()); Assert.assertNotNull(relationships); assertTrue("There should be no relationship found given the person", relationships.isEmpty()); }
/** * @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); }
/** * @see PatientService#mergePatients(Patient,Patient) */ @Test public void mergePatients_shouldVoidAllRelationshipsForNonPreferredPatient() throws Exception { executeDataSet(PATIENT_RELATIONSHIPS_XML); Patient preferred = patientService.getPatient(999); Patient notPreferred = patientService.getPatient(2); voidOrders(Collections.singleton(notPreferred)); patientService.mergePatients(preferred, notPreferred); List<Relationship> rels = personService.getRelationshipsByPerson(notPreferred); assertTrue("there should not be any relationships for non preferred", rels.isEmpty()); }
/** * @see PersonService#getRelationshipsByPerson(Person) */ @Test public void getRelationshipsByPerson_shouldFetchUnvoidedRelationshipsOnly() throws Exception { executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredRelationship.xml"); PersonService personService = Context.getPersonService(); Person person = personService.getPerson(6); List<Relationship> relationships = personService.getRelationshipsByPerson(person); Assert.assertNotNull(relationships); assertTrue("There should be no relationship found given the person", relationships.isEmpty()); }
Set<String> existingRelationships = new HashSet<>(); for (Relationship rel : personService.getRelationshipsByPerson(preferred)) { existingRelationships.add(relationshipHash(rel, preferred)); for (Relationship rel : personService.getRelationshipsByPerson(notPreferred)) { if (!rel.getVoided()) { boolean personAisPreferred = rel.getPersonA().equals(preferred);
List<Relationship> res = personService.getRelationshipsByPerson(patient, df.parse("1988-01-01"));
/** * @see PatientService#mergePatients(Patient,Patient) */ @Test public void mergePatients_shouldAuditCreatedRelationships() throws Exception { //create relationships and retrieve preferred and notPreferredPatient patient executeDataSet(PATIENT_RELATIONSHIPS_XML); Patient preferred = patientService.getPatient(7); Patient notPreferred = patientService.getPatient(2); voidOrders(Collections.singleton(notPreferred)); //merge the two patients and retrieve the audit object PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); //find the UUID of the created relationship as a result of the merge //note: since patient 2 is related to patient 1. patient 7 should now be related to patient 1 String createdRelationshipUuid = null; List<Relationship> relationships = personService.getRelationshipsByPerson(preferred); for (Relationship r : relationships) { if (r.getPersonB().getId().equals(1) || r.getPersonA().getId().equals(1)) { createdRelationshipUuid = r.getUuid(); } } Assert.assertNotNull("expected relationship was not found for the preferred patient after the merge", createdRelationshipUuid); Assert.assertTrue("relationship creation not audited", isValueInList(createdRelationshipUuid, audit.getPersonMergeLogData().getCreatedRelationships())); }
List<Relationship> updatedARels = personService.getRelationshipsByPerson(p1, new Date()); List<Relationship> updatedBRels = personService.getRelationshipsByPerson(p2, new Date());
List<Relationship> updatedARels = personService.getRelationshipsByPerson(p1); List<Relationship> updatedBRels = personService.getRelationshipsByPerson(p2);
sb.append("</th></tr>"); List<Relationship> existingRelationships = Context.getPersonService().getRelationshipsByPerson(context.getExistingPatient()); for(int i=0; i < relationshipsToCreate.size(); i++)
List<Relationship> rels = Context.getPersonService().getRelationshipsByPerson(patient);
List<Relationship> existingRelationships = Context.getPersonService().getRelationshipsByPerson(session.getSubmissionActions().getCurrentPerson());
relationshipList = tempList; } else if (personOb != null) { relationshipList = personService.getRelationshipsByPerson(personOb); } else if (personAOb != null && personBOb != null && relationshipType != null) { relationshipList = personService.getRelationships(personAOb, personBOb, relationshipType);