public interface PersonService extends OpenmrsService
List<Person> personObjects = Context.getPersonService().getAllPersons();
Modifier and Type | Interface and Description |
---|---|
static class |
PersonService.ATTR_VIEW_TYPE
These enumerations are used when determining which person attr types to display.
|
Modifier and Type | Method and Description |
---|---|
void |
checkIfPersonAttributeTypesAreLocked()
Check if the person attribute types are locked, and if they are throws an exception during manipulation of a person attribute type
|
List<PersonAttributeType> |
getAllPersonAttributeTypes()
Get all PersonAttributeTypes in the database
|
List<PersonAttributeType> |
getAllPersonAttributeTypes(boolean includeRetired)
Get all PersonAttributeTypes in the database with the option of including the retired types
|
List<PersonMergeLog> |
getAllPersonMergeLogs(boolean deserialize)
Gets all the
PersonMergeLog objects from the model |
List<Relationship> |
getAllRelationships()
Get list of relationships that are not voided
|
List<Relationship> |
getAllRelationships(boolean includeVoided)
Get list of relationships optionally including the voided ones or not
|
List<RelationshipType> |
getAllRelationshipTypes()
Get all relationshipTypes Includes retired relationship types
|
List<RelationshipType> |
getAllRelationshipTypes(boolean includeRetired)
Get all relationshipTypes with the option of including the retired types
|
PersonMergeLog |
getLosingPersonMergeLog(Person person,
boolean deserialize)
Gets the
PersonMergeLog where person p is the loser. |
List<Person> |
getPeople(String searchPhrase,
Boolean dead)
Find a person matching the searchPhrase search string
|
List<Person> |
getPeople(String searchPhrase,
Boolean dead,
Boolean voided) |
Person |
getPerson(Integer personId)
Gets a person by internal id
|
PersonAddress |
getPersonAddressByUuid(String uuid)
Get PersonAddress by its UUID
|
PersonAttribute |
getPersonAttribute(Integer id)
Get a PersonAttribute from the database with the given PersonAttributeid
|
PersonAttribute |
getPersonAttributeByUuid(String uuid)
Get PersonAttribute by its UUID
|
PersonAttributeType |
getPersonAttributeType(Integer typeId)
Get the PersonAttributeType given the type's PersonAttributeTypeId
|
PersonAttributeType |
getPersonAttributeTypeByName(String typeName)
Get the PersonAttributeType given the type's name
|
PersonAttributeType |
getPersonAttributeTypeByUuid(String uuid)
Gets a person attribute type with the given uuid.
|
List<PersonAttributeType> |
getPersonAttributeTypes(OpenmrsConstants.PERSON_TYPE personType,
PersonService.ATTR_VIEW_TYPE viewType)
Gets the types defined for the given person type (person, user, patient) and the given type
of view (one person vs many person objects)
|
List<PersonAttributeType> |
getPersonAttributeTypes(String exactName,
String format,
Integer foreignKey,
Boolean searchable)
Find person attribute types matching the given parameters.
|
Person |
getPersonByUuid(String uuid)
Get Person by its UUID
|
PersonMergeLog |
getPersonMergeLogByUuid(String uuid,
boolean deserialize)
Gets a PersonMergeLog object from the model using the UUID identifier.
|
PersonName |
getPersonName(Integer personNameId)
Get PersonName by its personNameId
|
PersonName |
getPersonNameByUuid(String uuid)
Get PersonName by its UUID
|
Relationship |
getRelationship(Integer relationshipId)
Get relationship by internal relationship identifier
|
Relationship |
getRelationshipByUuid(String uuid)
Get Relationship by its UUID
|
Map<Person,List<Person>> |
getRelationshipMap(RelationshipType relationshipType)
Get all relationships for a given type of relationship mapped from the personA to all of the
personB's
|
List<Relationship> |
getRelationships(Person fromPerson,
Person toPerson,
RelationshipType relType)
Get relationships stored in the database that
|
List<Relationship> |
getRelationships(Person fromPerson,
Person toPerson,
RelationshipType relType,
Date effectiveDate)
Get relationships stored in the database that are active on the passed date
|
List<Relationship> |
getRelationships(Person fromPerson,
Person toPerson,
RelationshipType relType,
Date startEffectiveDate,
Date endEffectiveDate)
Get relationships stored in the database that were active during the specified date range
|
List<Relationship> |
getRelationshipsByPerson(Person p)
Get list of relationships that include Person in person_id or relative_id Does not include
voided relationships
|
List<Relationship> |
getRelationshipsByPerson(Person p,
Date effectiveDate)
Get list of relationships that include Person in person_id or relative_id.
|
RelationshipType |
getRelationshipType(Integer relationshipTypeId)
Get relationshipType by internal identifier
|
RelationshipType |
getRelationshipTypeByName(String relationshipTypeName)
Find relationshipType by exact name match
|
RelationshipType |
getRelationshipTypeByUuid(String uuid)
Gets the relationship type with the given uuid.
|
List<RelationshipType> |
getRelationshipTypes(String searchString)
Get relationshipTypes by searching through the names and loosely matching to the given
searchString
|
List<RelationshipType> |
getRelationshipTypes(String relationshipTypeName,
Boolean preferred)
Find relationshipTypes by exact name match and/or preferred status
|
Set<Person> |
getSimilarPeople(String nameSearch,
Integer birthyear,
String gender)
Find a similar person given the attributes.
|
List<PersonMergeLog> |
getWinningPersonMergeLogs(Person person,
boolean deserialize)
Gets
PersonMergeLog objects by winning person p. |
PersonName |
parsePersonName(String name)
Parses a name into a PersonName (separate Given, Middle, and Family names)
|
void |
purgePerson(Person person)
Purges a person from the database (cannot be undone)
|
void |
purgePersonAttributeType(PersonAttributeType type)
Purges a PersonAttribute type from the database (cannot be undone)
|
void |
purgeRelationship(Relationship relationship)
Purges a relationship from the database (cannot be undone)
|
void |
purgeRelationshipType(RelationshipType relationshipType)
Purge relationship type from the database (cannot be undone)
|
PersonAttributeType |
retirePersonAttributeType(PersonAttributeType type,
String retiredReason)
Retire a Person Attribute Type
|
RelationshipType |
retireRelationshipType(RelationshipType type,
String retiredReason)
Retire a Person Relationship Type
|
Person |
savePerson(Person person)
Creates or updates a Person in the database
|
PersonAddress |
savePersonAddress(PersonAddress personAddress)
Inserts or updates the given personAddress object in the database
|
PersonAttributeType |
savePersonAttributeType(PersonAttributeType type)
Save the given person attribute type in the database.
|
PersonMergeLog |
savePersonMergeLog(PersonMergeLog personMergeLog)
Builds the serialized data from
PersonMergeLog.getPersonMergeLogData() , sets the mergedData String,
and the creator and date if null. |
PersonName |
savePersonName(PersonName personName)
Inserts or updates the given personName object in the database
|
Relationship |
saveRelationship(Relationship relationship)
Create or update a relationship between people.
|
RelationshipType |
saveRelationshipType(RelationshipType relationshipType)
Inserts or updates the given relationship type object in the database
|
void |
setPersonDAO(PersonDAO dao)
Sets the DAO for this service.
|
void |
unretirePersonAttributeType(PersonAttributeType type)
Unretires a PersonAttribute type from the database (can be undone)
|
RelationshipType |
unretireRelationshipType(RelationshipType relationshipType)
Unretire a Person Relationship Type
|
Person |
unvoidPerson(Person person)
Effectively resurrects this person in the db.
|
PersonAddress |
unvoidPersonAddress(PersonAddress personAddress)
Unvoid PersonAddress in the database, effectively marking this as a valid PersonAddress again
|
PersonName |
unvoidPersonName(PersonName personName)
Unvoid PersonName in the database, effectively marking this as a valid personName again
|
Relationship |
unvoidRelationship(Relationship relationship)
Unvoid Relationship in the database, effectively marking this as a valid relationship again
|
Person |
voidPerson(Person person,
String reason)
Effectively removes this person from the system.
|
PersonAddress |
voidPersonAddress(PersonAddress personAddress,
String voidReason)
Voids the given PersonAddress, effectively deleting the personAddress, from the end-user's
point of view.
|
PersonName |
voidPersonName(PersonName personName,
String voidReason)
Voids the given PersonName, effectively deleting the name, from the end-user's point of view.
|
Relationship |
voidRelationship(Relationship relationship,
String voidReason)
Voids the given Relationship, effectively removing it from openmrs.
|
onShutdown, onStartup
void setPersonDAO(PersonDAO dao)
dao
- DAO for this service@Authorized(value="Get People") Set<Person> getSimilarPeople(String nameSearch, Integer birthyear, String gender) throws APIException
nameSearch
parameter. This does a very loose lookup on birthyear
as
well. Any person with a null/missing birthdate is included and anyone with a birthyear
plus/minus one year from the given birthyear
is also includednameSearch
- string to search the person's name forbirthyear
- the year of birth to restrictgender
- The gender field to search on (Typically just "M" or "F")APIException
- Should accept greater than three names
Should match single search to any name part
Should match two word search to any name part
Should match three word search to any name part
Should match search to familyName2@Authorized(value="Get People") List<Person> getPeople(String searchPhrase, Boolean dead) throws APIException
searchPhrase
- person name to match ondead
- if true will return only dead patients, if false will return only alive patients,
if null will return bothAPIException
@Authorized(value="Get People") List<Person> getPeople(String searchPhrase, Boolean dead, Boolean voided) throws APIException
APIException
@Authorized(value="Manage Person Attribute Types") PersonAttributeType savePersonAttributeType(PersonAttributeType type) throws APIException
OpenmrsConstants.GLOBAL_PROPERTIES_OF_PERSON_ATTRIBUTES
and reference this given
type, prior to saving this given type. type
- APIException
- Should set the date created and creator on new
Should set the date changed and changed by on update
Should update any global property which reference this type
Should throw an error when trying to save person attribute type while person attribute types are locked@Authorized(value="Manage Person Attribute Types") PersonAttributeType retirePersonAttributeType(PersonAttributeType type, String retiredReason) throws APIException
type
- retiredReason
- Should throw an error when trying to retire person attribute type while person attribute types are lockedAPIException
@Authorized(value="Manage Relationship Types") RelationshipType retireRelationshipType(RelationshipType type, String retiredReason) throws APIException
type
- retiredReason
- APIException
@Authorized(value="Manage Relationship Types") RelationshipType unretireRelationshipType(RelationshipType relationshipType)
relationshipType
- retiredReason@Authorized(value="Purge Person Attribute Types") void purgePersonAttributeType(PersonAttributeType type) throws APIException
type
- type to be purged from the databaseAPIException
- Should delete person attribute type from database
Should throw an error when trying to delete person attribute type while person attribute types are locked@Authorized(value="Manage Person Attribute Types") void unretirePersonAttributeType(PersonAttributeType type) throws APIException
type
- type to be restored from the databaseAPIException
- Should restore person attribute type from database
Should throw an error when trying to unretire person attribute type while person attribute types are locked@Authorized(value="Edit People") Person voidPerson(Person person, String reason) throws APIException
person
- person to be voidedreason
- reason for voiding personAPIException
@Authorized(value="Edit People") Person unvoidPerson(Person person) throws APIException
person
- person to be revivedAPIException
@Authorized(value="Get Person Attribute Types") List<PersonAttributeType> getAllPersonAttributeTypes() throws APIException
APIException
getAllPersonAttributeTypes(boolean)
@Authorized(value="Get Person Attribute Types") List<PersonAttributeType> getAllPersonAttributeTypes(boolean includeRetired) throws APIException
includeRetired
- boolean - include retired attribute types as well?APIException
@Authorized(value="Get Person Attribute Types") List<PersonAttributeType> getPersonAttributeTypes(String exactName, String format, Integer foreignKey, Boolean searchable) throws APIException
exactName
- (optional) The name of typeformat
- (optional) The format for this typeforeignKey
- (optional) The foreign keysearchable
- (optional) if true only returns searchable types, if false returns only
nonsearchable and if null returns allAPIException
- Should return person attribute types matching given parameters
Should return empty list when no person attribute types match given parameters@Authorized(value="Get Person Attribute Types") PersonAttributeType getPersonAttributeType(Integer typeId) throws APIException
typeId
- PersonAttributeType.personAttributeTypeId to match onAPIException
@Authorized(value="Get Person Attribute Types") PersonAttributeType getPersonAttributeTypeByUuid(String uuid)
uuid
- the universally unique identifier to lookup@Authorized(value="Get Person Attribute Types") PersonAttribute getPersonAttribute(Integer id) throws APIException
id
- the PersonAttribute.personAttributeId to match onAPIException
- Should return null when PersonAttribute with given id does not exist
Should return person attribute when PersonAttribute with given id does exist@Authorized(value="Get Person Attribute Types") PersonAttributeType getPersonAttributeTypeByName(String typeName) throws APIException
typeName
- APIException
@Authorized(value="Get Relationships") Relationship getRelationship(Integer relationshipId) throws APIException
relationshipId
- APIException
- Should return relationship with given id
Should return null when relationship with given id does not exist@Authorized(value="Get Relationships") Relationship getRelationshipByUuid(String uuid) throws APIException
uuid
- APIException
@Authorized(value="Get Relationships") List<Relationship> getAllRelationships() throws APIException
APIException
@Authorized(value="Get Relationships") List<Relationship> getAllRelationships(boolean includeVoided) throws APIException
includeVoided
- true/false whether to include the voided relationshipsAPIException
- Should return all relationship including voided when include voided equals true
Should return all relationship excluding voided when include voided equals false@Authorized(value="Get Relationships") List<Relationship> getRelationshipsByPerson(Person p) throws APIException
p
- person object listed on either side of the relationshipAPIException
- Should only get unvoided relationships
Should fetch relationships associated with the given person
Should fetch unvoided relationships only@Authorized(value="Get Relationships") List<Relationship> getRelationshipsByPerson(Person p, Date effectiveDate) throws APIException
p
- person object listed on either side of the relationshipeffectiveDate
- effective date of relationshipAPIException
- Should only get unvoided relationships
Should only get unvoided relationships regardless of effective date
Should fetch relationships associated with the given person
Should fetch relationships that were active during effectiveDate@Authorized(value="Get Relationships") List<Relationship> getRelationships(Person fromPerson, Person toPerson, RelationshipType relType) throws APIException
fromPerson
- (optional) Person to in the person_id columntoPerson
- (optional) Person in the relative_id columnrelType
- (optional) The RelationshipType to matchAPIException
- Should fetch relationships matching the given from person
Should fetch relationships matching the given to person
Should fetch relationships matching the given rel type
Should return empty list when no relationship matching given parameters exist@Authorized(value="Get Relationships") List<Relationship> getRelationships(Person fromPerson, Person toPerson, RelationshipType relType, Date effectiveDate) throws APIException
fromPerson
- (optional) Person to in the person_id columntoPerson
- (optional) Person in the relative_id columnrelType
- (optional) The RelationshipType to matcheffectiveDate
- (optional) The date during which the relationship was effectiveAPIException
- Should fetch relationships matching the given from person
Should fetch relationships matching the given to person
Should fetch relationships matching the given rel type
Should return empty list when no relationship matching given parameters exist
Should fetch relationships that were active during effectiveDate@Authorized(value="Get Relationships") List<Relationship> getRelationships(Person fromPerson, Person toPerson, RelationshipType relType, Date startEffectiveDate, Date endEffectiveDate) throws APIException
fromPerson
- (optional) Person to in the person_id columntoPerson
- (optional) Person in the relative_id columnrelType
- (optional) The RelationshipType to matchstartEffectiveDate
- (optional) The date during which the relationship was effective
(lower bound)endEffectiveDate
- (optional) The date during which the relationship was effective
(upper bound)APIException
- Should fetch relationships matching the given from person
Should fetch relationships matching the given to person
Should fetch relationships matching the given rel type
Should return empty list when no relationship matching given parameters exist
Should fetch relationships that were active during the specified date range@Authorized(value="Get Relationship Types") List<RelationshipType> getAllRelationshipTypes() throws APIException
APIException
- Should return all relationship types@Authorized(value="Get Relationship Types") List<RelationshipType> getAllRelationshipTypes(boolean includeRetired) throws APIException
includeRetired
- boolean - include retired relationshipTypes as well?APIException
@Authorized(value="Get Relationship Types") RelationshipType getRelationshipType(Integer relationshipTypeId) throws APIException
relationshipTypeId
- APIException
- Should return relationship type with the given relationship type id
Should return null when no relationship type matches given relationship type id@Authorized(value="Get Relationship Types") RelationshipType getRelationshipTypeByUuid(String uuid) throws APIException
uuid
- APIException
- Should find object given valid uuid
Should return null if no object found with given uuid@Authorized(value="Get Relationship Types") RelationshipType getRelationshipTypeByName(String relationshipTypeName) throws APIException
relationshipTypeName
- name to match onAPIException
- Should return null when no relationship type match the given name@Authorized(value="Get Relationship Types") List<RelationshipType> getRelationshipTypes(String relationshipTypeName, Boolean preferred) throws APIException
relationshipTypeName
- name to match onpreferred
- if true, returns on preferred types, if false returns only the nonpreferred
types. if null returns bothAPIException
- Should return list of preferred relationship type matching given name
Should return empty list when no preferred relationship type match the given name@Authorized(value="Get Relationship Types") List<RelationshipType> getRelationshipTypes(String searchString) throws APIException
searchString
- string to match to a relationship type nameAPIException
- Should return empty list when no relationship type match the search string@Authorized(value={"Add Relationships","Edit Relationships"}) Relationship saveRelationship(Relationship relationship) throws APIException
relationship
to
the databaserelationship
- relationship to be created or updatedAPIException
- Should create new object when relationship id is null
Should update existing object when relationship id is not null@Authorized(value="Purge Relationships") void purgeRelationship(Relationship relationship) throws APIException
relationship
- relationship to be purged from the databaseAPIException
- Should delete relationship from the database@Authorized(value="Delete Relationships") Relationship voidRelationship(Relationship relationship, String voidReason) throws APIException
relationship
- Relationship to voidvoidReason
- String reason the relationship is being voided.APIException
- Should void relationship with the given reason@Authorized(value="Edit Relationships") Relationship unvoidRelationship(Relationship relationship) throws APIException
relationship
- Relationship to unvoidAPIException
- Should unvoid voided relationship@Authorized(value={"Add People","Edit People"}) Person savePerson(Person person) throws APIException
person
- person to be created or updatedAPIException
- Should create new object when person id is null
Should update existing object when person id is not null
Should set the preferred name and address if none is specified
Should not set the preferred name and address if they already exist
Should not set a voided name or address as preferred@Authorized(value="Purge People") void purgePerson(Person person) throws APIException
person
- person to be purged from the databaseAPIException
- Should delete person from the database@Authorized(value="Get People") Person getPersonByUuid(String uuid) throws APIException
uuid
- APIException
@Authorized(value="Get People") PersonAddress getPersonAddressByUuid(String uuid) throws APIException
uuid
- APIException
@Authorized(value="Get People") PersonAttribute getPersonAttributeByUuid(String uuid) throws APIException
uuid
- APIException
@Authorized(value="Get People") PersonName getPersonName(Integer personNameId)
personNameId
- @Authorized(value="Get People") PersonName getPersonNameByUuid(String uuid) throws APIException
uuid
- APIException
@Authorized(value="Get People") Person getPerson(Integer personId) throws APIException
personId
- internal identifier of person to getAPIException
- Should return null when no person has the given id@Authorized(value="Manage Relationship Types") RelationshipType saveRelationshipType(RelationshipType relationshipType) throws APIException
relationshipType
- type to be created or updatedAPIException
- Should create new object when relationship type id is null
Should update existing object when relationship type id is not null
Should fail if the description is not specified@Authorized(value="Purge Relationship Types") void purgeRelationshipType(RelationshipType relationshipType) throws APIException
relationshipType
- relationship type to be purgedAPIException
- Should delete relationship type from the databaseList<PersonAttributeType> getPersonAttributeTypes(OpenmrsConstants.PERSON_TYPE personType, PersonService.ATTR_VIEW_TYPE viewType) throws APIException
personType
- PERSON, USER, PATIENT, or null. Both PERSON and null mean to return attr
types for both patients and usersviewType
- whether this is a listing or viewing or null for both listing and viewingAPIException
@Authorized(value="Edit People") PersonName voidPersonName(PersonName personName, String voidReason)
personName
- PersonName to voidvoidReason
- String reason the personName is being voided.APIException
- Should void personName with the given reason@Authorized(value="Edit People") PersonName unvoidPersonName(PersonName personName) throws APIException
personName
- PersonName to unvoidAPIException
- Should unvoid voided personName@Authorized(value="Edit People") PersonName savePersonName(PersonName personName)
personName
- to be created or updatedAPIException
- Should fail if you try to void the last non voided namePersonName parsePersonName(String name) throws APIException
name
- person name to be parsedAPIException
@Authorized(value="Get Relationships") Map<Person,List<Person>> getRelationshipMap(RelationshipType relationshipType) throws APIException
relationshipType
- type of relationship for which to retrieve all relationshipsAPIException
- Should return empty map when no relationship has the matching relationship typePersonMergeLog savePersonMergeLog(PersonMergeLog personMergeLog) throws SerializationException, APIException
PersonMergeLog.getPersonMergeLogData()
, sets the mergedData String,
and the creator and date if null. It then saves the PersonMergeLog
object to the
model.personMergeLog
- the PersonMergeLog
object to save.PersonMergeLog
objectSerializationException
APIException
PersonMergeLog
,
Should require PersonMergeLogData
Should require winner
Should require loser
Should set date created if null
Should set creator if null
Should serialize PersonMergeLogData
Should save PersonMergeLog
PersonMergeLog getPersonMergeLogByUuid(String uuid, boolean deserialize) throws SerializationException, APIException
uuid
- deserialize
- SerializationException
APIException
- Should require uuid
Should retrieve personMergeLog without deserializing data
Should retrieve personMergeLog and deserialize dataList<PersonMergeLog> getAllPersonMergeLogs(boolean deserialize) throws SerializationException
PersonMergeLog
objects from the modelSerializationException
- Should retrieve all PersonMergeLogs from the model
Should retrieve all PersonMergeLogs and deserialize themList<PersonMergeLog> getWinningPersonMergeLogs(Person person, boolean deserialize) throws SerializationException
PersonMergeLog
objects by winning person p. Useful for to getting all persons merged into p.person
- the winning personPersonMergeLog
objectsSerializationException
- Should retrieve PersonMergeLogs by winnerPersonMergeLog getLosingPersonMergeLog(Person person, boolean deserialize) throws SerializationException
PersonMergeLog
where person p is the loser. Useful for getting the person that p was merged into.person
- the losing personPersonMergeLog
objectSerializationException
- Should find PersonMergeLog by loser@Authorized(value="Edit People") PersonAddress voidPersonAddress(PersonAddress personAddress, String voidReason)
personAddress
- PersonAddress to voidvoidReason
- String reason the personAddress is being voided.APIException
- Should void personAddress with the given reason@Authorized(value="Edit People") PersonAddress unvoidPersonAddress(PersonAddress personAddress) throws APIException
personAddress
- PersonAddress to unvoidAPIException
- Should unvoid voided personAddress@Authorized(value="Edit People") PersonAddress savePersonAddress(PersonAddress personAddress)
personAddress
- PersonAddress to be created or updatedvoid checkIfPersonAttributeTypesAreLocked() throws PersonAttributeTypeLockedException
Copyright © 2024 OpenMRS Inc.. All rights reserved.