org.openmrs
Class PersonAttribute

java.lang.Object
  extended by org.openmrs.BaseOpenmrsObject
      extended by org.openmrs.BaseOpenmrsData
          extended by org.openmrs.PersonAttribute
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<PersonAttribute>, Auditable, OpenmrsData, OpenmrsObject, Voidable

public class PersonAttribute
extends BaseOpenmrsData
implements java.io.Serializable, java.lang.Comparable<PersonAttribute>

A PersonAttribute is meant as way for implementations to add arbitrary information about a user/patient to their database. PersonAttributes are essentially just key-value pairs. However, the PersonAttributeType can be defined in such a way that the value portion of this PersonAttribute is a foreign key to another database table (like to the location table, or concept table). This gives a PersonAttribute the ability to link to any other part of the database A Person can have zero to n PersonAttribute(s).

See Also:
PersonAttributeType, Attributable, Serialized Form

Field Summary
static long serialVersionUID
           
 
Fields inherited from class org.openmrs.BaseOpenmrsData
creator
 
Constructor Summary
PersonAttribute()
          default constructor
PersonAttribute(java.lang.Integer personAttributeId)
           
PersonAttribute(PersonAttributeType type, java.lang.String value)
          Constructor for creating a basic attribute
 
Method Summary
 int compareTo(PersonAttribute other)
           
 PersonAttribute copy()
          Shallow copy of this PersonAttribute.
protected  PersonAttribute copyHelper(PersonAttribute target)
          The purpose of this method is to allow subclasses of PersonAttribute to delegate a portion of their copy() method back to the superclass, in case the base class implementation changes.
 boolean equals(java.lang.Object obj)
          Compares two objects for similarity
 boolean equalsContent(PersonAttribute otherAttribute)
          Compares this PersonAttribute object to the given otherAttribute.
 PersonAttributeType getAttributeType()
           
 java.lang.Object getHydratedObject()
          Will try to create an object of class 'PersonAttributeType.format'.
 java.lang.Integer getId()
           
 Person getPerson()
           
 java.lang.Integer getPersonAttributeId()
           
 java.lang.String getValue()
           
 int hashCode()
           
 void setAttributeType(PersonAttributeType attributeType)
           
 void setId(java.lang.Integer id)
           
 void setPerson(Person person)
           
 void setPersonAttributeId(java.lang.Integer personAttributeId)
           
 void setValue(java.lang.String value)
           
 java.lang.String toString()
           
 void voidAttribute(java.lang.String reason)
          Convenience method for voiding this attribute
 
Methods inherited from class org.openmrs.BaseOpenmrsData
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateVoided, getVoided, getVoidedBy, getVoidReason, isVoided, setChangedBy, setCreator, setDateChanged, setDateCreated, setDateVoided, setVoided, setVoidedBy, setVoidReason
 
Methods inherited from class org.openmrs.BaseOpenmrsObject
getUuid, setUuid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openmrs.OpenmrsObject
getUuid, setUuid
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

PersonAttribute

public PersonAttribute()
default constructor


PersonAttribute

public PersonAttribute(java.lang.Integer personAttributeId)

PersonAttribute

public PersonAttribute(PersonAttributeType type,
                       java.lang.String value)
Constructor for creating a basic attribute

Parameters:
type - PersonAttributeType
value - String
Method Detail

copy

public PersonAttribute copy()
Shallow copy of this PersonAttribute. Does NOT copy personAttributeId

Returns:
a shallows copy of this

copyHelper

protected PersonAttribute copyHelper(PersonAttribute target)
The purpose of this method is to allow subclasses of PersonAttribute to delegate a portion of their copy() method back to the superclass, in case the base class implementation changes.

Parameters:
target - a PersonAttribute that will have the state of this copied into it
Returns:
Returns the PersonAttribute that was passed in, with state copied into it

equals

public boolean equals(java.lang.Object obj)
Compares two objects for similarity

Overrides:
equals in class java.lang.Object
Parameters:
obj -
Returns:
boolean true/false whether or not they are the same objects
Expected behavior:
return true if personAttributeIds match, return false if personAttributeIds do not match, match on object equality if a personAttributeId is null

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

equalsContent

public boolean equalsContent(PersonAttribute otherAttribute)
Compares this PersonAttribute object to the given otherAttribute. This method differs from equals(Object) in that this method compares the inner fields of each attribute for equality. Note: Null/empty fields on otherAttribute /will not/ cause a false value to be returned

Parameters:
otherAttribute - PersonAttribute with which to compare
Returns:
boolean true/false whether or not they are the same attributes
Expected behavior:
return true if attributeType value and void status are the same

getPerson

public Person getPerson()
Returns:
Returns the person.

setPerson

public void setPerson(Person person)
Parameters:
person - The person to set.

getAttributeType

public PersonAttributeType getAttributeType()
Returns:
the attributeType

setAttributeType

public void setAttributeType(PersonAttributeType attributeType)
Parameters:
attributeType - the attributeType to set

getValue

public java.lang.String getValue()
Returns:
the value

setValue

public void setValue(java.lang.String value)
Parameters:
value - the value to set

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()
Expected behavior:
return toString of hydrated value

getPersonAttributeId

public java.lang.Integer getPersonAttributeId()
Returns:
the personAttributeId

setPersonAttributeId

public void setPersonAttributeId(java.lang.Integer personAttributeId)
Parameters:
personAttributeId - the personAttributeId to set

getHydratedObject

public java.lang.Object getHydratedObject()
Will try to create an object of class 'PersonAttributeType.format'. If that implements Attributable, hydrate(value) is called. Defaults to just returning getValue()

Returns:
hydrated object or getValue()
Expected behavior:
load class in format property, still load class in format property if not Attributable

voidAttribute

public void voidAttribute(java.lang.String reason)
Convenience method for voiding this attribute

Parameters:
reason -
Expected behavior:
set voided bit to true

compareTo

public int compareTo(PersonAttribute other)
Specified by:
compareTo in interface java.lang.Comparable<PersonAttribute>
See Also:
Comparable.compareTo(java.lang.Object)
Expected behavior:
return negative if other attribute is voided, return negative if other attribute has earlier date created, return negative if this attribute has lower attribute type than argument, return negative if other attribute has lower value, return negative if this attribute has lower attribute id than argument

getId

public java.lang.Integer getId()
Specified by:
getId in interface OpenmrsObject
Returns:
id - The unique Identifier for the object
Since:
1.5
See Also:
OpenmrsObject.getId()

setId

public void setId(java.lang.Integer id)
Specified by:
setId in interface OpenmrsObject
Parameters:
id - - The unique Identifier for the object
Since:
1.5
See Also:
OpenmrsObject.setId(java.lang.Integer)

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change