Person
Overview
A Person object in OpenMRS represents either a Patient or a User. A Person can have multiple PersonNames and multiple PersonAddresses. There is some general metadata defined on a Person object (birthdate, deathdate, gender, etc.), but most attributes of a Person are custom to a certain install location. This is where PersonAttributes come in; they are additional "columns" on a Person that are defined by the implementation. Two or more Person objects can be linked by a Relationship.
Person
A Person object is the basis for all humans in the OpenMRS system.
Properties on a Person:
personId: the database's integer used to identify the object
gender: the Person's gender
birthdate: the Person's birth date
birthDateEstimated: only needed if the birth date is uncertain. It is not required
dead: a Boolean denoting whether or not a Person has died. It is not required
deathDate: the date on which the Person died. It is not required
causeOfDeath: the cause of the Person's death. It is not required
causeOfDeathNonCoded: a String representation of the cause of death. Used when the cause of death does not exist as a Concept
isPatient: a Boolean denoting whether or not a Person is also a Patient
1 to n PersonNames
0 to n PersonAddresses
0 to n PersonAttributes
0 to n Relationships
Inherited from BaseOpenMRSData:
creator
PersonService
// Gets Person objects with the given criteria.
public List<Person> getPeople(String searchPhrase, Boolean dead);
// Saves the given Person object to the database. Saves will cascade down onto the Person's fields (PersonName, PersonAddress, etc.)
public Person savePerson(Person person);
// Marks the given Person as invalid. All associated data will be left as-is.
public Person voidPerson(Person person, String reason);
// Gets all PersonAttributeTypes in the system.
public List<PersonAttributeType> getAllPersonAttributeTypes();
// Gets all Relationships in the system.
public List<Relationship> getAllRelationships();
// Gets all RelationshipTypes in the system.
public List<RelationshipType> getAllRelationshipTypes();
// Gets all PersonAttributeTypes in the system.
public List<PersonAttributeType> getAllPersonAttributeTypes();
Example:
Person person = Context.getPersonService().getPersonByUuid("1234-56789-123");
person.setGender("M");
person.addName(new PersonName("Jim", "Bob", "Smith"));
Context.getPersonService().savePerson(person);
The Person class source code can be seen here.
The PersonService class source code can be seen here.
A module demonstrating how to use this class can be seen here.
Person Name
A PersonName object represents a person's name. A Person can have multiple PersonName objects. A PersonName's primary information is contained in the givenName, middleName, and familyName fields.
Properties on a PersonName:
personNameId: same as personId but tied to the PersonName
person: the Person the PersonName is attached to
preferred: a Boolean denoting whether or not the current PersonName is the person's preferred name
givenName: the person's given name
middleName: the person's middle name
familyName: the person's family name
familyNamePrefix: the person's family name's prefix
familyName2: the person's second family name
degree: the person's medical degree (Ph.D., etc.)
The PersonName class source code can be seen here.
Person Address
A PersonAddress object represents a person's address. A PersonAddress's primary information is contained in the address1, address2, cityVillage, countryDistrict, stateProvince, country, and postalCode fields.
PersonAddress implements the Address interface.
Properties on a PersonAddress:
personAddressId: same as personId but tied to the PersonAddress
person: the Person the PersonAddress is attached to
preferred: a Boolean denoting whether or not the current PersonAddress is the person's preferred address
address1 to address15: address lines 1 through 15
cityVillage: the city or village the address is in
countryDistrict: the country or district the address is in
stateProvince: the state or province the address is in
country: the country the address is in
postalCode: the postal code of the address
latitude: the latitude of the address
longitude: the longitude of the address
startDate: the date describing when the Person began living at that address
endDate: the date describing when the Person began living at that address
The PersonAddress class source code can be seen here.
Person Attribute
A PersonAttribute object represents arbitrary information about a Person. A PersonAttribute is essentially a key-value pair tied to a Person object. The value can have anything in it, including a foreign key reference to another table.
Properties on a PersonAttribute:
personAttributeId: same as personId but tied to the PersonAttribute
person: the Person the PersonAttribute is attached to
attributeType: the PersonAttributeType of the PersonAttribute
value: the value of the PersonAttribute
The PersonAttribute class source code can be seen here.
Person Attribute Type
A PersonAttributeType exists to group PersonAttribute objects together.
Properties on a PersonAttributeType:
personAttributeTypeId: same as personId but tied to the PersonAttributeType
format: the Java class the PersonAttributeType uses
java.lang.String, org.openmrs.Concept, etc.
foreignKey: the foreign key in the database that this PersonAttributeType references
sortWeight: the order this PersonAttributeType will appear in when searched
searchable: a Boolean denoting whether or not this PersonAttributeType can be searched for
editPrivilege: the privileges required to make changes to this type
The PersonAttributeType class source code can be seen here.
See also Managing Person Attribute Types
Relationship
A relationship pairs two Person objects together.
Properties on a Relationship:
relationshipId: same as personId but tied to the Relationship
personA: the first person in the relationship
relationshipType: a RelationshipType describing how personA and personB are related
personB: the second person in the relationship
startDate: the date that the relationship began
endDate: the date that the relationship ended
The Relationship class source code can be seen here.
Relationship Type
A RelationshipType defines a type of relationship between two Person objects.
Properties on a RelationshipType:
relationshipTypeId: same as personId but tied to the Relationship
aIsToB: the relationship of personA relative to personB
If personB is a Parent, aIsToB would be "Child"
bIsToA: the relationship of personB relative to personA
If personA is a Parent, bIsToA would be "Child"
weight: the order this RelationshipType will appear in when searched
preferred: a Boolean denoting if this RelationshipType should be a default one when updating a Person's RelationshipTypes
The RelationshipType class source code can be seen here.
Visualization
This is a class diagram for the Person class and the classes it uses in its properties. This provides an at-a-glance summary of the classes, their fields, and their methods.
The XML file can be edited in case of future changes.