public class Person extends BaseChangeableOpenmrsData
Patient
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected Integer |
personId |
static long |
serialVersionUID |
creator
Constructor and Description |
---|
Person()
default empty constructor
|
Person(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).
|
Modifier and Type | Method and Description |
---|---|
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. |
void |
addName(PersonName name)
Convenience method to add the
name to this person's name list if the name
doesn't exist already. |
List<PersonAttribute> |
getActiveAttributes()
Returns only the non-voided attributes for this person
|
Set<PersonAddress> |
getAddresses() |
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.
|
Integer |
getAge(Date onDate)
Convenience method: calculates the person's age on a given date based on the birthdate
|
Map<String,PersonAttribute> |
getAllAttributeMap()
Convenience method to get all of this person's attributes (including voided ones) in map
form: <String, PersonAttribute>.
|
PersonAttribute |
getAttribute(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(String attributeName)
Convenience method to get this person's first attribute that has a PersonAttributeType.name
equal to
attributeName . |
Map<String,PersonAttribute> |
getAttributeMap()
Convenience method to get this person's active attributes in map form: <String,
PersonAttribute>.
|
Set<PersonAttribute> |
getAttributes() |
List<PersonAttribute> |
getAttributes(Integer attributeTypeId)
Convenience method to get all of this person's attributes that have a PersonAttributeType.id
equal to
attributeTypeId . |
List<PersonAttribute> |
getAttributes(PersonAttributeType personAttributeType)
Convenience method to get all of this person's attributes that have a PersonAttributeType
equal to
personAttributeType . |
List<PersonAttribute> |
getAttributes(String attributeName)
Convenience method to get all of this person's attributes that have a
PersonAttributeType.name equal to
attributeName . |
Date |
getBirthdate() |
Boolean |
getBirthdateEstimated() |
Date |
getBirthDateTime() |
Date |
getBirthtime() |
Concept |
getCauseOfDeath() |
String |
getCauseOfDeathNonCoded()
This method returns the non coded cause of death
|
Boolean |
getDead() |
Date |
getDeathDate() |
Boolean |
getDeathdateEstimated() |
String |
getFamilyName()
Convenience method to get the family name attribute on this person's preferred PersonName
|
String |
getGender() |
String |
getGivenName()
Convenience method to get the given name attribute on this person's preferred PersonName
|
Integer |
getId() |
boolean |
getIsPatient() |
String |
getMiddleName()
Convenience method to get the middle name attribute on this person's preferred PersonName
|
Set<PersonName> |
getNames() |
PersonAddress |
getPersonAddress()
Convenience method to get the
PersonAddress object that is marked as "preferred". |
User |
getPersonChangedBy() |
User |
getPersonCreator() |
Date |
getPersonDateChanged() |
Date |
getPersonDateCreated() |
Date |
getPersonDateVoided() |
Integer |
getPersonId() |
PersonName |
getPersonName()
Convenience method to get the
PersonName object that is marked as "preferred". |
Boolean |
getPersonVoided() |
User |
getPersonVoidedBy() |
String |
getPersonVoidReason() |
Boolean |
isBirthdateEstimated()
Deprecated.
as of 2.0, use
getBirthdateEstimated() |
Boolean |
isDead()
Deprecated.
as of 2.0, use
getDead() |
boolean |
isPatient()
Deprecated.
as of 2.0, use
getIsPatient() |
Boolean |
isPersonVoided()
Deprecated.
as of 2.0, use
getPersonVoided() |
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. |
void |
setAddresses(Set<PersonAddress> addresses) |
void |
setAttributes(Set<PersonAttribute> attributes) |
void |
setBirthdate(Date birthdate) |
void |
setBirthdateEstimated(Boolean birthdateEstimated) |
void |
setBirthdateFromAge(int age,
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 |
setBirthtime(Date birthtime) |
void |
setCauseOfDeath(Concept causeOfDeath) |
void |
setCauseOfDeathNonCoded(String causeOfDeathNonCoded)
This method sets the non coded cause of death with the value given as parameter
|
void |
setDead(Boolean dead) |
void |
setDeathDate(Date deathDate) |
void |
setDeathdateEstimated(Boolean deathdateEstimated) |
void |
setGender(String gender) |
void |
setId(Integer id) |
void |
setNames(Set<PersonName> names) |
protected void |
setPatient(boolean isPatient)
This should only be set by the database layer by looking at whether a row exists in the
patient table
|
void |
setPersonChangedBy(User changedBy) |
void |
setPersonCreator(User creator) |
void |
setPersonDateChanged(Date dateChanged) |
void |
setPersonDateCreated(Date dateCreated) |
void |
setPersonDateVoided(Date dateVoided) |
void |
setPersonId(Integer personId) |
void |
setPersonVoided(Boolean voided) |
void |
setPersonVoidedBy(User voidedBy) |
void |
setPersonVoidReason(String voidReason) |
String |
toString()
Returns a string equal to the value of: ClassName{hashCode=...,
uuid=...}
|
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateVoided, getVoided, getVoidedBy, getVoidReason, isVoided, setChangedBy, setCreator, setDateChanged, setDateCreated, setDateVoided, setVoided, setVoidedBy, setVoidReason
equals, getUuid, hashCode, setUuid
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getUuid, setUuid
public static final long serialVersionUID
@DocumentId protected Integer personId
public Person()
public Person(Person person)
person
- Person to create this person object frompublic Person(Integer personId)
personId
- Integer internal id for this person
Should set person idpublic Integer getPersonId()
public void setPersonId(Integer personId)
personId
- The personId to set.public String getGender()
public void setGender(String gender)
gender
- person's genderpublic Date getBirthdate()
public void setBirthdate(Date birthdate)
birthdate
- person's date of birth@Deprecated public Boolean isBirthdateEstimated()
getBirthdateEstimated()
public Boolean getBirthdateEstimated()
public void setBirthdateEstimated(Boolean birthdateEstimated)
birthdateEstimated
- true if person's birthdate is estimatedpublic Boolean getDeathdateEstimated()
public void setDeathdateEstimated(Boolean deathdateEstimated)
deathdateEstimated
- true if person's deathdate is estimatedpublic void setBirthtime(Date birthtime)
birthtime
- person's time of birthpublic Date getBirthDateTime()
public Date getBirthtime()
@Deprecated public Boolean isDead()
getDead()
public Boolean getDead()
public void setDead(Boolean dead)
dead
- The dead to set.public Date getDeathDate()
public void setDeathDate(Date deathDate)
deathDate
- date of person's deathpublic Concept getCauseOfDeath()
public void setCauseOfDeath(Concept causeOfDeath)
causeOfDeath
- cause of person's deathpublic String getCauseOfDeathNonCoded()
public void setCauseOfDeathNonCoded(String causeOfDeathNonCoded)
causeOfDeathNonCoded
- is a String that describes as text the cause of deathpublic Set<PersonAddress> getAddresses()
Should not get voided addresses
Should not fail with null addresses
public void setAddresses(Set<PersonAddress> addresses)
addresses
- Set<PersonAddress> list of known addresses for personPersonAddress
public Set<PersonName> getNames()
Should not get voided names
Should not fail with null names
public void setNames(Set<PersonName> names)
names
- update all known names for personPersonName
public Set<PersonAttribute> getAttributes()
Should not get voided attributes
Should not fail with null attributes
public List<PersonAttribute> getActiveAttributes()
public void setAttributes(Set<PersonAttribute> attributes)
attributes
- update all known attributes for personPersonAttribute
public void addAttribute(PersonAttribute newAttribute)
attribute
to this person's attribute list if the
attribute doesn't exist already.newAttribute.getAttributeType()
newAttribute
- PersonAttribute to add to the Person
Should fail when new attribute exist
Should fail when new atribute are the same type with same value
Should void old attribute when new attribute are the same type with different value
Should remove attribute when old attribute are temporary
Should not save an attribute with a null value
Should not save an attribute with a blank string value
Should void old attribute when a null or blank string value is addedpublic void removeAttribute(PersonAttribute attribute)
attribute
from this person's attribute list if the
attribute exists already.attribute
- Should not fail when person attribute is null
Should not fail when person attribute is not exist
Should remove attribute when existpublic PersonAttribute getAttribute(PersonAttributeType pat)
PersonAttribute
with the given
PersonAttributeType
, the given PersonAttributeType
is null, or this person
has no attributes.pat
- the PersonAttributeType to look for (can be a stub, see
BaseOpenmrsObject.equals(Object)
for how its compared)public PersonAttribute getAttribute(String attributeName)
attributeName
.PersonAttribute
with the given type
name, the given name is null, or this person has no attributes.attributeName
- the name string to match onBaseOpenmrsMetadata.getName()
matchs the given name
string
Should return person attribute based on attributeName
Should return null if AttributeName is voidedpublic PersonAttribute getAttribute(Integer attributeTypeId)
attributeTypeId
.PersonAttribute
with the given type id
or this person has no attributes.attributeTypeId
- the id of the PersonAttributeType
to look forPersonAttributeType.getId()
equals the given Integer id
Should return PersonAttribute based on attributeTypeId
Should return null when existing personAttribute with matching attribute type id is voidedpublic List<PersonAttribute> getAttributes(String attributeName)
attributeName
.attributeName
- Should return all PersonAttributes with matching attributeType namespublic List<PersonAttribute> getAttributes(Integer attributeTypeId)
attributeTypeId
.attributeTypeId
- Should return empty list when matching personAttribute by id is voided
Should return list of person attributes based on AttributeTypeIdpublic List<PersonAttribute> getAttributes(PersonAttributeType personAttributeType)
personAttributeType
.personAttributeType
- public Map<String,PersonAttribute> getAttributeMap()
public Map<String,PersonAttribute> getAllAttributeMap()
public String printAttributes()
public void addName(PersonName name)
name
to this person's name list if the name
doesn't exist already.name
- public void removeName(PersonName name)
name
from this person's name list if the name
exists already.name
- public void addAddress(PersonAddress address)
address
to this person's address list if the
address doesn't exist already.address
- Should not add a person address with blank fieldspublic void removeAddress(PersonAddress address)
address
from this person's address list if the
address exists already.address
- public PersonName getPersonName()
PersonName
object that is marked as "preferred". getNames()
,
Should get preferred and not-voided person name if exist
Should get not-voided person name if preferred address does not exist
Should get voided person address if person is voided and not-voided address does not exist
Should return null if person is not-voided and have voided names
public String getGivenName()
public String getMiddleName()
public String getFamilyName()
public PersonAddress getPersonAddress()
PersonAddress
object that is marked as "preferred". getAddresses()
,
Should get preferred and not-voided person address if exist
Should get not-voided person address if preferred address does not exist
Should get voided person address if person is voided and not-voided address does not exist
Should return null if person is not-voided and have voided address
public Integer getAge()
public Integer getAge(Date onDate)
onDate
- (null defaults to today)public void setBirthdateFromAge(int age, Date ageOnDate)
age
- (the age to set)ageOnDate
- (null defaults to today)public User getPersonChangedBy()
public void setPersonChangedBy(User changedBy)
public Date getPersonDateChanged()
public void setPersonDateChanged(Date dateChanged)
public User getPersonCreator()
public void setPersonCreator(User creator)
public Date getPersonDateCreated()
public void setPersonDateCreated(Date dateCreated)
public Date getPersonDateVoided()
public void setPersonDateVoided(Date dateVoided)
public void setPersonVoided(Boolean voided)
public Boolean getPersonVoided()
@Deprecated public Boolean isPersonVoided()
getPersonVoided()
public User getPersonVoidedBy()
public void setPersonVoidedBy(User voidedBy)
public String getPersonVoidReason()
public void setPersonVoidReason(String voidReason)
@Deprecated public boolean isPatient()
getIsPatient()
public boolean getIsPatient()
protected void setPatient(boolean isPatient)
isPatient
- whether this person is a patient or notpublic String toString()
BaseOpenmrsObject
ClassName{hashCode=..., uuid=...}
If the uuid
field is null
, it returns:
ClassName{hashCode=...}Should include hashCode if uuid is null Should include uuid if not null
toString
in class BaseOpenmrsObject
Object.toString()
public Integer getId()
OpenmrsObject.getId()
public void setId(Integer id)
id
- - The unique Identifier for the objectOpenmrsObject.setId(java.lang.Integer)
Copyright © 2024 OpenMRS Inc.. All rights reserved.