/** * @since 1.5 * @see org.openmrs.OpenmrsObject#getId() */ @Override public Integer getId() { return getRelationshipTypeId(); }
/** * generate a relationship hash for use in mergePatients; follows the convention: * [relationshipType][A|B][relativeId] * * @param rel relationship under consideration * @param primary the focus of the hash * @return hash depicting relevant information to avoid duplicates */ private String relationshipHash(Relationship rel, Person primary) { boolean isA = rel.getPersonA().equals(primary); return rel.getRelationshipType().getRelationshipTypeId().toString() + (isA ? "A" : "B") + (isA ? rel.getPersonB().getPersonId().toString() : rel.getPersonA().getPersonId().toString()); }
/** * @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()); }
/** * @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()); }
for (RelationshipType type : Context.getPersonService().getAllRelationshipTypes()) { String output = "<update tableName=\"relationship_type\"><column name=\"uuid\" value=\"" + type.getUuid() + "\"/><where> relationship_type_id = '" + type.getRelationshipTypeId() + "' and a_is_to_b = '" + type.getaIsToB().replace("'", "\\'") + "' and b_is_to_a = '" + type.getbIsToA().replace("'", "\\'") + "'</where></update>";
/** * @see PersonService#saveRelationshipType(RelationshipType) */ @Test public void saveRelationshipType_shouldUpdateExistingObjectWhenRelationshipTypeIdIsNotNull() throws Exception { RelationshipType savedRelationshipType = Context.getPersonService().getRelationshipType(1); Assert.assertNotNull(savedRelationshipType.getRelationshipTypeId()); savedRelationshipType.setPreferred(true); RelationshipType updatedRelationshipType = personService.saveRelationshipType(savedRelationshipType); Assert.assertEquals(true, updatedRelationshipType.getPreferred()); }