/** * @since 1.5 * @see org.openmrs.OpenmrsObject#getId() */ @Override public Integer getId() { return getPersonAttributeTypeId(); }
@Override public int compare(PersonAttributeType pat1, PersonAttributeType pat2) { return OpenmrsUtil.compareWithNullAsGreatest(pat1.getPersonAttributeTypeId(), pat2.getPersonAttributeTypeId()); } }
/** * Convenience method to get all of this person's attributes that have a PersonAttributeType.id * equal to <code>attributeTypeId</code>. * * @param attributeTypeId * @should return empty list when matching personAttribute by id is voided * @should return list of person attributes based on AttributeTypeId */ public List<PersonAttribute> getAttributes(Integer attributeTypeId) { List<PersonAttribute> ret = new ArrayList<>(); for (PersonAttribute attribute : getActiveAttributes()) { if (attributeTypeId.equals(attribute.getAttributeType().getPersonAttributeTypeId())) { ret.add(attribute); } } return ret; }
/** * Convenience method to get this person's first attribute that has a PersonAttributeTypeId * equal to <code>attributeTypeId</code>.<br> * <br> * Returns null if this person has no non-voided {@link PersonAttribute} with the given type id * or this person has no attributes.<br> * <br> * The given id cannot be null. * * @param attributeTypeId the id of the {@link PersonAttributeType} to look for * @return PersonAttribute whose {@link PersonAttributeType#getId()} equals the given Integer id * @should return PersonAttribute based on attributeTypeId * @should return null when existing personAttribute with matching attribute type id is voided */ public PersonAttribute getAttribute(Integer attributeTypeId) { for (PersonAttribute attribute : getActiveAttributes()) { if (attributeTypeId.equals(attribute.getAttributeType().getPersonAttributeTypeId())) { return attribute; } } return null; }
/** * @see PersonService#getPersonAttributeTypeByUuid(String) */ @Test public void getPersonAttributeTypeByUuid_shouldFindObjectGivenValidUuid() throws Exception { String uuid = "b3b6d540-a32e-44c7-91b3-292d97667518"; PersonAttributeType personAttributeType = Context.getPersonService().getPersonAttributeTypeByUuid(uuid); Assert.assertEquals(1, (int) personAttributeType.getPersonAttributeTypeId()); }