org.openmrs
Class Person

java.lang.Object
  extended by org.openmrs.BaseOpenmrsObject
      extended by org.openmrs.BaseOpenmrsData
          extended by org.openmrs.Person
All Implemented Interfaces:
java.io.Serializable, Auditable, OpenmrsData, OpenmrsObject, Voidable
Direct Known Subclasses:
Patient

public class Person
extends BaseOpenmrsData
implements java.io.Serializable

A Person in the system. This can be either a small person stub, or indicative of an actual Patient in the system. This class holds the generic person things that both the stubs and patients share. Things like birthdate, names, addresses, and attributes are all generified into the person table (and hence this super class)

See Also:
Patient, Serialized Form

Field Summary
protected  java.lang.Integer personId
           
static long serialVersionUID
           
 
Fields inherited from class org.openmrs.BaseOpenmrsData
creator
 
Constructor Summary
Person()
          default empty constructor
Person(java.lang.Integer personId)
          Default constructor taking in the primary key personId value
Person(Person person)
          This constructor is used to build a new Person object copy from another person object (usually a patient or a user subobject).
 
Method Summary
 void addAddress(PersonAddress address)
          Convenience method to add the address to this person's address list if the address doesn't exist already.
 void addAttribute(PersonAttribute newAttribute)
          Convenience method to add the attribute to this person's attribute list if the attribute doesn't exist already.

Voids any current attribute with type = newAttribute.getAttributeType()

NOTE: This effectively limits persons to only one attribute of any given type **
 void addName(PersonName name)
          Convenience method to add the name to this person's name list if the name doesn't exist already.
 boolean equals(java.lang.Object obj)
           
 java.util.List<PersonAttribute> getActiveAttributes()
          Returns only the non-voided attributes for this person
 java.util.Set<PersonAddress> getAddresses()
           
 java.lang.Integer getAge()
          Convenience method to calculate this person's age based on the birthdate For a person who lived 1990 to 2000, age would be -5 in 1985, 5 in 1995, 10 in 2000, and 10 2010.
 java.lang.Integer getAge(java.util.Date onDate)
          Convenience method: calculates the person's age on a given date based on the birthdate
 PersonAttribute getAttribute(java.lang.Integer attributeTypeId)
          Convenience method to get this person's first attribute that has a PersonAttributeTypeId equal to attributeTypeId.
 PersonAttribute getAttribute(PersonAttributeType pat)
          Convenience Method to return the first non-voided person attribute matching a person attribute type
 PersonAttribute getAttribute(java.lang.String attributeName)
          Convenience method to get this person's first attribute that has a PersonAttributeType.name equal to attributeName.
 java.util.Map<java.lang.String,PersonAttribute> getAttributeMap()
          Convenience method to get all of this person's attributes in map form: .
 java.util.Set<PersonAttribute> getAttributes()
           
 java.util.List<PersonAttribute> getAttributes(java.lang.Integer attributeTypeId)
          Convenience method to get all of this person's attributes that have a PersonAttributeType.id equal to attributeTypeId.
 java.util.List<PersonAttribute> getAttributes(PersonAttributeType personAttributeType)
          Convenience method to get all of this person's attributes that have a PersonAttributeType equal to personAttributeType.
 java.util.List<PersonAttribute> getAttributes(java.lang.String attributeName)
          Convenience method< to get all of this person's attributes that have a PersonAttributeType.name equal to attributeName.
 java.util.Date getBirthdate()
           
 java.lang.Boolean getBirthdateEstimated()
           
 Concept getCauseOfDeath()
           
 java.lang.Boolean getDead()
           
 java.util.Date getDeathDate()
           
 java.lang.String getFamilyName()
          Convenience method to get the family name attribute on this person's preferred PersonName
 java.lang.String getGender()
           
 java.lang.String getGivenName()
          Convenience method to get the given name attribute on this person's preferred PersonName
 java.lang.Integer getId()
           
 java.lang.String getMiddleName()
          Convenience method to get the middle name attribute on this person's preferred PersonName
 java.util.Set<PersonName> getNames()
           
 PersonAddress getPersonAddress()
          Convenience Method to get the "preferred" address for person.
 User getPersonChangedBy()
           
 User getPersonCreator()
           
 java.util.Date getPersonDateChanged()
           
 java.util.Date getPersonDateCreated()
           
 java.util.Date getPersonDateVoided()
           
 java.lang.Integer getPersonId()
           
 PersonName getPersonName()
          Convenience method to get the "preferred" name for the person.
 java.lang.Boolean getPersonVoided()
           
 User getPersonVoidedBy()
           
 java.lang.String getPersonVoidReason()
           
 int hashCode()
           
 java.lang.Boolean isBirthdateEstimated()
           
 java.lang.Boolean isDead()
           
 boolean isPatient()
           
 java.lang.Boolean isPersonVoided()
           
 boolean isUser()
          Deprecated. use UserService.getUsersByPerson(Person, boolean)
 java.lang.String printAttributes()
          Convenience method for viewing all of the person's current attributes
 void removeAddress(PersonAddress address)
          Convenience method to remove the address from this person's address list if the address exists already.
 void removeAttribute(PersonAttribute attribute)
          Convenience method to get the attribute from this person's attribute list if the attribute exists already.
 void removeName(PersonName name)
          Convenience method remove the name from this person's name list if the name exists already.
 Person replaceSerialization(java.util.Map<?,?> sessionMap)
          If the serializer wishes, don't serialize this entire object, just the important parts
 void setAddresses(java.util.Set<PersonAddress> addresses)
           
 void setAttributes(java.util.Set<PersonAttribute> attributes)
           
 void setBirthdate(java.util.Date birthdate)
           
 void setBirthdateEstimated(java.lang.Boolean birthdateEstimated)
           
 void setBirthdateFromAge(int age, java.util.Date ageOnDate)
          Convenience method: sets a person's birth date from an age as of the given date Also sets flag indicating that the birth date is inexact.
 void setCauseOfDeath(Concept causeOfDeath)
           
 void setDead(java.lang.Boolean dead)
           
 void setDeathDate(java.util.Date deathDate)
           
 void setGender(java.lang.String gender)
           
 void setId(java.lang.Integer id)
           
 void setNames(java.util.Set<PersonName> names)
           
 void setPersonChangedBy(User changedBy)
           
 void setPersonCreator(User creator)
           
 void setPersonDateChanged(java.util.Date dateChanged)
           
 void setPersonDateCreated(java.util.Date dateCreated)
           
 void setPersonDateVoided(java.util.Date dateVoided)
           
 void setPersonId(java.lang.Integer personId)
           
 void setPersonVoided(java.lang.Boolean voided)
           
 void setPersonVoidedBy(User voidedBy)
           
 void setPersonVoidReason(java.lang.String voidReason)
           
 java.lang.String toString()
           
 
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

personId

protected java.lang.Integer personId
Constructor Detail

Person

public Person()
default empty constructor


Person

public Person(Person person)
This constructor is used to build a new Person object copy from another person object (usually a patient or a user subobject). All attributes are copied over to the new object. NOTE! All child collection objects are copied as pointers, each individual element is not copied.

Parameters:
person - Person to create this person object from

Person

public Person(java.lang.Integer personId)
Default constructor taking in the primary key personId value

Parameters:
personId - Integer internal id for this person
Expected behavior:
set person id
Method Detail

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)
Expected behavior:
equal person with same person id, not equal person with different person id, not equal on null, equal person objects with no person id, not equal person objects when one has null person id

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()
Expected behavior:
have same hashcode when equal, have different hash code when not equal, get hash code with null attributes

getPersonId

public java.lang.Integer getPersonId()
Returns:
Returns the personId.

setPersonId

public void setPersonId(java.lang.Integer personId)
Parameters:
personId - The personId to set.

getGender

public java.lang.String getGender()
Returns:
person's gender

setGender

public void setGender(java.lang.String gender)
Parameters:
gender - person's gender

getBirthdate

public java.util.Date getBirthdate()
Returns:
person's date of birth

setBirthdate

public void setBirthdate(java.util.Date birthdate)
Parameters:
birthdate - person's date of birth

isBirthdateEstimated

public java.lang.Boolean isBirthdateEstimated()
Returns:
true if person's birthdate is estimated

getBirthdateEstimated

public java.lang.Boolean getBirthdateEstimated()

setBirthdateEstimated

public void setBirthdateEstimated(java.lang.Boolean birthdateEstimated)
Parameters:
birthdateEstimated - true if person's birthdate is estimated

isDead

public java.lang.Boolean isDead()
Returns:
Returns the death status.

getDead

public java.lang.Boolean getDead()
Returns:
Returns the death status.

setDead

public void setDead(java.lang.Boolean dead)
Parameters:
dead - The dead to set.

getDeathDate

public java.util.Date getDeathDate()
Returns:
date of person's death

setDeathDate

public void setDeathDate(java.util.Date deathDate)
Parameters:
deathDate - date of person's death

getCauseOfDeath

public Concept getCauseOfDeath()
Returns:
cause of person's death

setCauseOfDeath

public void setCauseOfDeath(Concept causeOfDeath)
Parameters:
causeOfDeath - cause of person's death

getAddresses

public java.util.Set<PersonAddress> getAddresses()
Returns:
list of known addresses for person
See Also:
PersonAddress
Expected behavior:
not get voided addresses, not fail with null addresses

setAddresses

public void setAddresses(java.util.Set<PersonAddress> addresses)
Parameters:
addresses - Set list of known addresses for person
See Also:
PersonAddress

getNames

public java.util.Set<PersonName> getNames()
Returns:
all known names for person
See Also:
PersonName
Expected behavior:
not get voided names, not fail with null names

setNames

public void setNames(java.util.Set<PersonName> names)
Parameters:
names - update all known names for person
See Also:
PersonName

getAttributes

public java.util.Set<PersonAttribute> getAttributes()
Returns:
all known attributes for person
See Also:
PersonAttribute
Expected behavior:
not get voided attributes, not fail with null attributes

getActiveAttributes

public java.util.List<PersonAttribute> getActiveAttributes()
Returns only the non-voided attributes for this person

Returns:
list attributes
Expected behavior:
not get voided attributes, not fail with null attributes

setAttributes

public void setAttributes(java.util.Set<PersonAttribute> attributes)
Parameters:
attributes - update all known attributes for person
See Also:
PersonAttribute

addAttribute

public void addAttribute(PersonAttribute newAttribute)
Convenience method to add the attribute to this person's attribute list if the attribute doesn't exist already.

Voids any current attribute with type = newAttribute.getAttributeType()

NOTE: This effectively limits persons to only one attribute of any given type **

Parameters:
newAttribute - PersonAttribute to add to the Person
Expected behavior:
fail when new attribute exist, fail when new atribute are the same type with same value, void old attribute when new attribute are the same type with different value, remove attribute when old attribute are temporary, not save an attribute with a null value, not save an attribute with a blank string value, void old attribute when a null or blank string value is added

removeAttribute

public void removeAttribute(PersonAttribute attribute)
Convenience method to get the attribute from this person's attribute list if the attribute exists already.

Parameters:
attribute -
Expected behavior:
not fail when person attribute is null, not fail when person attribute is not exist, remove attribute when exist

getAttribute

public PersonAttribute getAttribute(PersonAttributeType pat)
Convenience Method to return the first non-voided person attribute matching a person attribute type

Parameters:
pat -
Returns:
PersonAttribute
Expected behavior:
not fail when attribute type is null, not return voided attribute, return null when given attribute type is not exist

getAttribute

public PersonAttribute getAttribute(java.lang.String attributeName)
Convenience method to get this person's first attribute that has a PersonAttributeType.name equal to attributeName.

Parameters:
attributeName -

getAttribute

public PersonAttribute getAttribute(java.lang.Integer attributeTypeId)
Convenience method to get this person's first attribute that has a PersonAttributeTypeId equal to attributeTypeId.

Parameters:
attributeTypeId -

getAttributes

public java.util.List<PersonAttribute> getAttributes(java.lang.String attributeName)
Convenience method< to get all of this person's attributes that have a PersonAttributeType.name equal to attributeName.

Parameters:
attributeName -

getAttributes

public java.util.List<PersonAttribute> getAttributes(java.lang.Integer attributeTypeId)
Convenience method to get all of this person's attributes that have a PersonAttributeType.id equal to attributeTypeId.

Parameters:
attributeTypeId -

getAttributes

public java.util.List<PersonAttribute> getAttributes(PersonAttributeType personAttributeType)
Convenience method to get all of this person's attributes that have a PersonAttributeType equal to personAttributeType.

Parameters:
personAttributeType -

getAttributeMap

public java.util.Map<java.lang.String,PersonAttribute> getAttributeMap()
Convenience method to get all of this person's attributes in map form: .


printAttributes

public java.lang.String printAttributes()
Convenience method for viewing all of the person's current attributes

Returns:
Returns a string with all the attributes

addName

public void addName(PersonName name)
Convenience method to add the name to this person's name list if the name doesn't exist already.

Parameters:
name -

removeName

public void removeName(PersonName name)
Convenience method remove the name from this person's name list if the name exists already.

Parameters:
name -

addAddress

public void addAddress(PersonAddress address)
Convenience method to add the address to this person's address list if the address doesn't exist already.

Parameters:
address -

removeAddress

public void removeAddress(PersonAddress address)
Convenience method to remove the address from this person's address list if the address exists already.

Parameters:
address -

getPersonName

public PersonName getPersonName()
Convenience method to get the "preferred" name for the person. Returns a blank PersonName object if no names are given.

Returns:
Returns the "preferred" person name.

getGivenName

public java.lang.String getGivenName()
Convenience method to get the given name attribute on this person's preferred PersonName

Returns:
String given name of the person

getMiddleName

public java.lang.String getMiddleName()
Convenience method to get the middle name attribute on this person's preferred PersonName

Returns:
String middle name of the person

getFamilyName

public java.lang.String getFamilyName()
Convenience method to get the family name attribute on this person's preferred PersonName

Returns:
String family name of the person

getPersonAddress

public PersonAddress getPersonAddress()
Convenience Method to get the "preferred" address for person.

Returns:
Returns the "preferred" person address.

getAge

public java.lang.Integer getAge()
Convenience method to calculate this person's age based on the birthdate For a person who lived 1990 to 2000, age would be -5 in 1985, 5 in 1995, 10 in 2000, and 10 2010.

Returns:
Returns age as an Integer.
Expected behavior:
get correct age after death

getAge

public java.lang.Integer getAge(java.util.Date onDate)
Convenience method: calculates the person's age on a given date based on the birthdate

Parameters:
onDate - (null defaults to today)
Returns:
int value of the person's age
Expected behavior:
get age before birthday, get age on birthday with no minutes defined, get age on birthday with minutes defined, get age after birthday, get age after death, get age with given date after death, get age with given date before death, get age with given date before birth

setBirthdateFromAge

public void setBirthdateFromAge(int age,
                                java.util.Date ageOnDate)
Convenience method: sets a person's birth date from an age as of the given date Also sets flag indicating that the birth date is inexact. This sets the person's birth date to January 1 of the year that matches this age and date

Parameters:
age - (the age to set)
ageOnDate - (null defaults to today)

getPersonChangedBy

public User getPersonChangedBy()

setPersonChangedBy

public void setPersonChangedBy(User changedBy)

getPersonDateChanged

public java.util.Date getPersonDateChanged()

setPersonDateChanged

public void setPersonDateChanged(java.util.Date dateChanged)

getPersonCreator

public User getPersonCreator()

setPersonCreator

public void setPersonCreator(User creator)

getPersonDateCreated

public java.util.Date getPersonDateCreated()

setPersonDateCreated

public void setPersonDateCreated(java.util.Date dateCreated)

getPersonDateVoided

public java.util.Date getPersonDateVoided()

setPersonDateVoided

public void setPersonDateVoided(java.util.Date dateVoided)

setPersonVoided

public void setPersonVoided(java.lang.Boolean voided)

getPersonVoided

public java.lang.Boolean getPersonVoided()

isPersonVoided

public java.lang.Boolean isPersonVoided()

getPersonVoidedBy

public User getPersonVoidedBy()

setPersonVoidedBy

public void setPersonVoidedBy(User voidedBy)

getPersonVoidReason

public java.lang.String getPersonVoidReason()

setPersonVoidReason

public void setPersonVoidReason(java.lang.String voidReason)

isPatient

public boolean isPatient()
Returns:
true/false whether this person is a patient or not

isUser

public boolean isUser()
Deprecated. use UserService.getUsersByPerson(Person, boolean)

Returns:
true/false whether this person is a user or not

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

replaceSerialization

public Person replaceSerialization(java.util.Map<?,?> sessionMap)
If the serializer wishes, don't serialize this entire object, just the important parts

Parameters:
sessionMap - serialization session information
Returns:
Person object to serialize
See Also:
OpenmrsUtil.isShortSerialization(Map)

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