org.openmrs.api
Interface PatientService

All Superinterfaces:
OpenmrsService
All Known Implementing Classes:
PatientServiceImpl

@Transactional
public interface PatientService
extends OpenmrsService

Contains methods pertaining to Patients in the system Use:

   List patients = Context.getPatientService().getAllPatients();
 

See Also:
Context, Patient

Method Summary
 void checkPatientIdentifier(PatientIdentifier patientIdentifier)
          Deprecated. use PatientIdentifierValidator.validateIdentifier(PatientIdentifier)
 void checkPatientIdentifiers(Patient patient)
          Convenience method to validate all identifiers for a given patient
 Patient createPatient(Patient patient)
          Deprecated. replaced by #savePatient(Patient)
 void deletePatient(Patient patient)
          Deprecated. replaced by purgePatient(Patient)
 void exitFromCare(Patient patient, java.util.Date dateExited, Concept reasonForExit)
          Convenience method to establish that a patient has left the care center.
 java.util.List<Patient> findDuplicatePatients(java.util.Set<java.lang.String> attributes)
          Deprecated. use getDuplicatePatientsByAttributes(List)
 Patient findPatient(Patient patientToMatch)
          Deprecated. use #getPatientByExample(Patient)
 java.util.List<Patient> findPatients(java.lang.String query, boolean includeVoided)
          Deprecated. use #getPatients(String)
 java.util.List<Allergy> getAllergies(Person p)
          Returns a sorted set of Allergies, sorted on sort_weight
 Allergy getAllergy(java.lang.Integer allergyListId)
          Returns the Allergy
 java.util.Collection<IdentifierValidator> getAllIdentifierValidators()
           
 java.util.List<PatientIdentifierType> getAllPatientIdentifierTypes()
          Get all patientIdentifier types
 java.util.List<PatientIdentifierType> getAllPatientIdentifierTypes(boolean includeRetired)
          Get all patientIdentifier types
 java.util.List<Patient> getAllPatients()
          Returns all non voided patients in the system
 java.util.List<Patient> getAllPatients(boolean includeVoided)
          Returns patients in the system
 IdentifierValidator getDefaultIdentifierValidator()
           
 java.util.List<Patient> getDuplicatePatientsByAttributes(java.util.List<java.lang.String> attributes)
          Search the database for patients that both share the given attributes.
 IdentifierValidator getIdentifierValidator(java.lang.Class<IdentifierValidator> clazz)
          Gets an identifier validator matching the given class.
 IdentifierValidator getIdentifierValidator(java.lang.String pivClassName)
           
 Patient getPatient(java.lang.Integer patientId)
          Get patient by internal identifier
 Patient getPatientByExample(Patient patientToMatch)
          This method tries to find a patient in the database given the attributes on the given patientToMatch object.
 Patient getPatientByUuid(java.lang.String uuid)
          Get patient by universally unique identifier.
 PatientIdentifier getPatientIdentifier(java.lang.Integer patientIdentifierId)
          Returns a patient identifier that matches the given patientIndentifier id
 PatientIdentifier getPatientIdentifierByUuid(java.lang.String uuid)
          Get patient identifier by universally unique identifier.
 java.util.List<PatientIdentifier> getPatientIdentifiers(PatientIdentifierType patientIdentifierType)
          Deprecated. replaced by getPatientIdentifiers(String, List, List, List, Boolean)
 java.util.List<PatientIdentifier> getPatientIdentifiers(java.lang.String identifier, java.util.List<PatientIdentifierType> patientIdentifierTypes, java.util.List<Location> locations, java.util.List<Patient> patients, java.lang.Boolean isPreferred)
          Get all patientIdentifiers that match all of the given criteria Voided identifiers are not returned
 java.util.List<PatientIdentifier> getPatientIdentifiers(java.lang.String identifier, PatientIdentifierType pit)
          Deprecated. replaced by getPatientIdentifiers(String, List, List, List, Boolean)
 PatientIdentifierType getPatientIdentifierType(java.lang.Integer patientIdentifierTypeId)
          Get patientIdentifierType by internal identifier
 PatientIdentifierType getPatientIdentifierType(java.lang.String name)
          Deprecated. use getPatientIdentifierTypeByName(String)
 PatientIdentifierType getPatientIdentifierTypeByName(java.lang.String name)
          Get patientIdentifierType by exact name
 PatientIdentifierType getPatientIdentifierTypeByUuid(java.lang.String uuid)
          Get patient identifierType by universally unique identifier
 java.util.List<PatientIdentifierType> getPatientIdentifierTypes()
          Deprecated. replaced by getAllPatientIdentifierTypes()
 java.util.List<PatientIdentifierType> getPatientIdentifierTypes(java.lang.String name, java.lang.String format, java.lang.Boolean required, java.lang.Boolean hasCheckDigit)
          Get all patientIdentifier types that match the given criteria
 java.util.List<Patient> getPatients(java.lang.String query)
          Generic search on patients based on the given string.
 java.util.List<Patient> getPatients(java.lang.String name, java.lang.String identifier, java.util.List<PatientIdentifierType> identifierTypes)
          Deprecated. replaced by a call to getPatients(String, String, List, boolean) with "false" as the last parameter
 java.util.List<Patient> getPatients(java.lang.String name, java.lang.String identifier, java.util.List<PatientIdentifierType> identifierTypes, boolean matchIdentifierExactly)
          Get patients based on given criteria The identifier is matched with the regex OpenmrsConstants.PATIENT_IDENTIFIER_REGEX All parameters are optional and nullable.
 java.util.List<Patient> getPatientsByIdentifier(java.lang.String identifier, boolean includeVoided)
          Deprecated. replaced by getPatients(String, String, List)
 java.util.List<Patient> getPatientsByIdentifierPattern(java.lang.String identifier, boolean includeVoided)
          Deprecated. replaced by getPatients( ... )
 java.util.List<Patient> getPatientsByName(java.lang.String name)
          Deprecated. replaced by getPatients(String, String, List)
 java.util.List<Patient> getPatientsByName(java.lang.String name, boolean includeVoided)
          Deprecated. replaced by getPatients( ... )
 Problem getProblem(java.lang.Integer problemListId)
          Returns the Problem
 java.util.List<Problem> getProblems(Person p)
          Get a list of the problems for the patient, sorted on sort_weight
 Patient identifierInUse(java.lang.String identifier, PatientIdentifierType type, Patient ignorePatient)
          Deprecated. use #getPatientByIdentifier(String) instead
 boolean isIdentifierInUseByAnotherPatient(PatientIdentifier patientIdentifier)
          Checks whether the given patient identifier is already assigned to a patient other than patientIdentifier.patient
 void mergePatients(Patient preferred, Patient notPreferred)
          Convenience method to join two patients' information into one record.
 void processDeath(Patient patient, java.util.Date dateDied, Concept causeOfDeath, java.lang.String otherReason)
          Convenience method to establish that a patient has died.
 void purgePatient(Patient patient)
          Delete patient from database.
 void purgePatientIdentifier(PatientIdentifier patientIdentifier)
          Purge PatientIdentifier (cannot be undone)
 void purgePatientIdentifierType(PatientIdentifierType patientIdentifierType)
          Purge PatientIdentifierType (cannot be undone)
 void removeAllergy(Allergy allergy, java.lang.String reason)
          Resolving the allergy, effectively removes the Allergy from the Patient's Active List by setting the stop date to now, if null.
 void removeProblem(Problem problem, java.lang.String reason)
          Effectively removes the Problem from the Patient's Active List by setting the stop date to now, if null.
 PatientIdentifierType retirePatientIdentifierType(PatientIdentifierType patientIdentifierType, java.lang.String reason)
          Retire a type of patient identifier
 void saveAllergy(Allergy allergy)
          Creates an AllergyListItem to the Patient's Allergy Active List.
 void saveCauseOfDeathObs(Patient patient, java.util.Date dateDied, Concept causeOfDeath, java.lang.String otherReason)
          Convenience method that saves the Obs that indicates when and why the patient died (including any "other" reason there might be) TODO keep this in the PatientService?
 Patient savePatient(Patient patient)
          Saved the given patient to the database
 PatientIdentifier savePatientIdentifier(PatientIdentifier patientIdentifier)
          Saved the given patientIndentifier to the database
 PatientIdentifierType savePatientIdentifierType(PatientIdentifierType patientIdentifierType)
          Create or update a PatientIdentifierType
 void saveProblem(Problem problem)
          Creates a ProblemListItem to the Patient's Problem Active List.
 void setPatientDAO(PatientDAO dao)
          Sets the DAO for this service.
 PatientIdentifierType unretirePatientIdentifierType(PatientIdentifierType patientIdentifierType)
          Unretire a type of patient identifier
 Patient unvoidPatient(Patient patient)
          Unvoid patient record
 Patient updatePatient(Patient patient)
          Deprecated. replaced by #savePatient(Patient)
 void updatePatientIdentifier(PatientIdentifier patientIdentifier)
          Deprecated. patient identifiers should not be updated directly; rather, after changing patient identifiers, use savePatient(Patient) to save changes to the database
 void voidAllergy(Allergy allergy, java.lang.String reason)
          Used only in cases where the Allergy was entered by error
 Patient voidPatient(Patient patient, java.lang.String reason)
          Void patient record (functionally delete patient from system)
 PatientIdentifier voidPatientIdentifier(PatientIdentifier patientIdentifier, java.lang.String reason)
          Void patient identifier (functionally delete patient identifier from system)
 void voidProblem(Problem problem, java.lang.String reason)
          Used only in cases where the Problem was entered by error
 
Methods inherited from interface org.openmrs.api.OpenmrsService
onShutdown, onStartup
 

Method Detail

setPatientDAO

void setPatientDAO(PatientDAO dao)
Sets the DAO for this service. This is done by DI and Spring. See the applicationContext-service.xml definition file.

Parameters:
dao - DAO for this service

createPatient

@Deprecated
@Authorized(value="Add Patients")
Patient createPatient(Patient patient)
                      throws APIException
Deprecated. replaced by #savePatient(Patient)

Throws:
APIException
See Also:
savePatient(Patient)

savePatient

@Authorized(value={"Add Patients","Edit Patients"})
Patient savePatient(Patient patient)
                    throws APIException
Saved the given patient to the database

Parameters:
patient - patient to be created or updated
Returns:
patient who was created or updated
Throws:
APIException
Expected behavior:
create new patient from existing person plus user object, not throw a NonUniqueObjectException when called with a hand constructed patient regression 1375, fail when patient does not have any patient identifiers, fail when patient does not have required patient identifiers

getPatient

@Authorized(value="View Patients")
@Transactional(readOnly=true)
Patient getPatient(java.lang.Integer patientId)
                   throws APIException
Get patient by internal identifier

Parameters:
patientId - internal patient identifier
Returns:
patient with given internal identifier
Throws:
APIException
Expected behavior:
return null object if patient id doesnt exist, fetch patient with given patient id, return null when patient with given patient id does not exist

getPatientByUuid

@Transactional(readOnly=true)
@Authorized(value="View Patients")
Patient getPatientByUuid(java.lang.String uuid)
                         throws APIException
Get patient by universally unique identifier.

Parameters:
uuid - universally unique identifier
Returns:
the patient that matches the uuid
Throws:
APIException
Expected behavior:
fetch patient with given uuid, return null if patient not found with given uuid

getPatientIdentifierByUuid

@Transactional(readOnly=true)
@Authorized(value="View Patient Identifiers")
PatientIdentifier getPatientIdentifierByUuid(java.lang.String uuid)
                                             throws APIException
Get patient identifier by universally unique identifier.

Parameters:
uuid - universally unique identifier
Returns:
the patient identifier that matches the uuid
Throws:
APIException
Expected behavior:
fetch patient identifier with given uuid, return null if patient identifier not found with given uuid

updatePatient

@Deprecated
Patient updatePatient(Patient patient)
                      throws APIException
Deprecated. replaced by #savePatient(Patient)

Throws:
APIException
See Also:
savePatient(Patient)

getAllPatients

@Authorized(value="View Patients")
@Transactional(readOnly=true)
java.util.List<Patient> getAllPatients()
                                       throws APIException
Returns all non voided patients in the system

Returns:
non voided patients in the system
Throws:
APIException
See Also:
getAllPatients(boolean)
Expected behavior:
fetch all non voided patients

getAllPatients

@Authorized(value="View Patients")
@Transactional(readOnly=true)
java.util.List<Patient> getAllPatients(boolean includeVoided)
                                       throws APIException
Returns patients in the system

Parameters:
includeVoided - if false, will limit the search to non-voided patients
Returns:
patients in the system
Throws:
APIException
Expected behavior:
fetch voided patients when given include voided is true, fetch non voided patients when given include voided is false

identifierInUse

@Deprecated
@Transactional(readOnly=true)
Patient identifierInUse(java.lang.String identifier,
                                                 PatientIdentifierType type,
                                                 Patient ignorePatient)
Deprecated. use #getPatientByIdentifier(String) instead


getPatientsByIdentifier

@Deprecated
@Transactional(readOnly=true)
java.util.List<Patient> getPatientsByIdentifier(java.lang.String identifier,
                                                                         boolean includeVoided)
                                                throws APIException
Deprecated. replaced by getPatients(String, String, List)

Throws:
APIException

getPatients

@Transactional(readOnly=true)
@Authorized(value="View Patients")
java.util.List<Patient> getPatients(java.lang.String name,
                                                                  java.lang.String identifier,
                                                                  java.util.List<PatientIdentifierType> identifierTypes,
                                                                  boolean matchIdentifierExactly)
                                    throws APIException
Get patients based on given criteria The identifier is matched with the regex OpenmrsConstants.PATIENT_IDENTIFIER_REGEX All parameters are optional and nullable. If null, it is not included in the search. Will not return voided patients

Parameters:
name - (optional) this is a slight break from the norm, patients with a partial match on this name will be returned
identifier - (optional) only patients with a matching identifier are returned
identifierTypes - (optional) the PatientIdentifierTypes to restrict to
matchIdentifierExactly - (required) if true, then the given identifier must equal the id in the database. if false, then the identifier is 'searched' for by using a regular expression
Returns:
patients that matched the given criteria (and are not voided)
Throws:
APIException
Expected behavior:
fetch all patients that partially matches given name, fetch all patients that partially matches given identifier when match identifier exactly equals false, fetch all patients that exactly matches given identifier when match identifier exactly equals true, fetch all patients that match given identifier types, not return duplicates, return empty list when no match is found, search familyName2 with name, support simple regex, support pattern using last digit as check digit

getPatients

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Patients")
java.util.List<Patient> getPatients(java.lang.String name,
                                                                             java.lang.String identifier,
                                                                             java.util.List<PatientIdentifierType> identifierTypes)
                                    throws APIException
Deprecated. replaced by a call to getPatients(String, String, List, boolean) with "false" as the last parameter

Throws:
APIException

getPatientsByIdentifierPattern

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Patients")
java.util.List<Patient> getPatientsByIdentifierPattern(java.lang.String identifier,
                                                                                                boolean includeVoided)
                                                       throws APIException
Deprecated. replaced by getPatients( ... )

Throws:
APIException

getPatientsByName

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Patients")
java.util.List<Patient> getPatientsByName(java.lang.String name)
                                          throws APIException
Deprecated. replaced by getPatients(String, String, List)

Throws:
APIException

getPatientsByName

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Patients")
java.util.List<Patient> getPatientsByName(java.lang.String name,
                                                                                   boolean includeVoided)
                                          throws APIException
Deprecated. replaced by getPatients( ... )

Throws:
APIException

voidPatient

@Authorized(value="Delete Patients")
Patient voidPatient(Patient patient,
                                    java.lang.String reason)
                    throws APIException
Void patient record (functionally delete patient from system)

Parameters:
patient - patient to be voided
reason - reason for voiding patient
Returns:
the voided patient
Throws:
APIException
Expected behavior:
void given patient with given reason, void all patient identifiers associated with given patient, return voided patient with given reason, return null when patient is null

unvoidPatient

@Authorized(value="Delete Patients")
Patient unvoidPatient(Patient patient)
                      throws APIException
Unvoid patient record

Parameters:
patient - patient to be revived
Returns:
the revived Patient
Throws:
APIException
Expected behavior:
unvoid given patient, return unvoided patient

deletePatient

@Deprecated
@Authorized(value="Purge Patients")
void deletePatient(Patient patient)
                   throws APIException
Deprecated. replaced by purgePatient(Patient)

Throws:
APIException
See Also:
purgePatient(Patient)

purgePatient

@Authorized(value="Purge Patients")
void purgePatient(Patient patient)
                  throws APIException
Delete patient from database. This should not be called except for testing and administration purposes. Use the void method instead.

Parameters:
patient - patient to be deleted
Throws:
APIException
See Also:
voidPatient(org.openmrs.Patient,java.lang.String)
Expected behavior:
delete patient from database

getPatientIdentifiers

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Patient Identifiers")
java.util.List<PatientIdentifier> getPatientIdentifiers(PatientIdentifierType patientIdentifierType)
                                                        throws APIException
Deprecated. replaced by getPatientIdentifiers(String, List, List, List, Boolean)

Throws:
APIException

getPatientIdentifiers

@Transactional(readOnly=true)
@Authorized(value="View Patient Identifiers")
java.util.List<PatientIdentifier> getPatientIdentifiers(java.lang.String identifier,
                                                                                      java.util.List<PatientIdentifierType> patientIdentifierTypes,
                                                                                      java.util.List<Location> locations,
                                                                                      java.util.List<Patient> patients,
                                                                                      java.lang.Boolean isPreferred)
                                                        throws APIException
Get all patientIdentifiers that match all of the given criteria Voided identifiers are not returned

Parameters:
identifier - the full identifier to match on
patientIdentifierTypes - the type of identifiers to get
locations - the locations of the identifiers to match
patients - the patients containing these identifiers
isPreferred - if true, limits to only preferred identifiers if false, only non preferred. if null, ignores preferred status
Returns:
PatientIdentifiers matching these criteria
Throws:
APIException
Expected behavior:
return only non voided patients and patient identifiers, fetch patient identifiers that exactly matches given identifier, fetch patient identifiers that partially matches given identifier, fetch patient identifiers that match given patient identifier types, fetch patient identifiers that match given locations, fetch patient identifiers that match given patients, fetch preferred patient identifiers when given is preferred equals true, fetch non preferred patient identifiers when given is preferred equals false, fetch preferred and non preferred patient identifiers when given is preferred is null

getPatientIdentifiers

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Patient Identifiers")
java.util.List<PatientIdentifier> getPatientIdentifiers(java.lang.String identifier,
                                                                                                 PatientIdentifierType pit)
                                                        throws APIException
Deprecated. replaced by getPatientIdentifiers(String, List, List, List, Boolean)

Throws:
APIException

updatePatientIdentifier

@Deprecated
@Authorized(value="Edit Patient Identifiers")
void updatePatientIdentifier(PatientIdentifier patientIdentifier)
                             throws APIException
Deprecated. patient identifiers should not be updated directly; rather, after changing patient identifiers, use savePatient(Patient) to save changes to the database

Update patient identifier

Parameters:
patientIdentifier - identifier to be updated
Throws:
APIException

savePatientIdentifierType

@Authorized(value="Manage Identifier Types")
PatientIdentifierType savePatientIdentifierType(PatientIdentifierType patientIdentifierType)
                                                throws APIException
Create or update a PatientIdentifierType

Parameters:
patientIdentifierType - PatientIdentifierType to create or update
Returns:
the saved type
Throws:
APIException
Expected behavior:
create new patient identifier type, update existing patient identifier type

getPatientIdentifierTypes

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Identifier Types")
java.util.List<PatientIdentifierType> getPatientIdentifierTypes()
                                                                throws APIException
Deprecated. replaced by getAllPatientIdentifierTypes()

Throws:
APIException
See Also:
getAllPatientIdentifierTypes()

getAllPatientIdentifierTypes

@Transactional(readOnly=true)
@Authorized(value="View Identifier Types")
java.util.List<PatientIdentifierType> getAllPatientIdentifierTypes()
                                                                   throws APIException
Get all patientIdentifier types

Returns:
patientIdentifier types list
Throws:
APIException
Expected behavior:
fetch all non retired patient identifier types

getAllPatientIdentifierTypes

@Transactional(readOnly=true)
@Authorized(value="View Identifier Types")
java.util.List<PatientIdentifierType> getAllPatientIdentifierTypes(boolean includeRetired)
                                                                   throws APIException
Get all patientIdentifier types

Parameters:
includeRetired - true/false whether retired types should be included
Returns:
patientIdentifier types list
Throws:
APIException
Expected behavior:
fetch patient identifier types including retired when include retired is true, fetch patient identifier types excluding retired when include retired is false

getPatientIdentifierTypes

@Transactional(readOnly=true)
@Authorized(value="View Identifier Types")
java.util.List<PatientIdentifierType> getPatientIdentifierTypes(java.lang.String name,
                                                                                              java.lang.String format,
                                                                                              java.lang.Boolean required,
                                                                                              java.lang.Boolean hasCheckDigit)
                                                                throws APIException
Get all patientIdentifier types that match the given criteria

Parameters:
name - name of the type to match on
format - the string format to match on
required - if true, limits to only identifiers marked as required if false, only non required. if null, ignores required bit
hasCheckDigit - if true, limits to only check digit'd identifiers if false, only non checkdigit'd. if null, ignores checkDigit
Returns:
patientIdentifier types list
Throws:
APIException
Expected behavior:
fetch patient identifier types that match given name with given format, fetch required patient identifier types when given required is true, fetch non required patient identifier types when given required is false, fetch any patient identifier types when given required is null, fetch patient identifier types with check digit when given has check digit is true, fetch patient identifier types without check digit when given has check digit is false, fetch any patient identifier types when given has check digit is null

getPatientIdentifierType

@Transactional(readOnly=true)
@Authorized(value="View Identifier Types")
PatientIdentifierType getPatientIdentifierType(java.lang.Integer patientIdentifierTypeId)
                                               throws APIException
Get patientIdentifierType by internal identifier

Parameters:
patientIdentifierTypeId -
Returns:
patientIdentifierType with specified internal identifier
Throws:
APIException
Expected behavior:
fetch patient identifier with given patient identifier type id, return null when patient identifier identifier does not exist

getPatientIdentifierTypeByUuid

@Transactional(readOnly=true)
@Authorized(value="View Identifier Types")
PatientIdentifierType getPatientIdentifierTypeByUuid(java.lang.String uuid)
                                                     throws APIException
Get patient identifierType by universally unique identifier

Parameters:
patientIdentifierTypeId -
Returns:
patientIdentifierType with specified internal identifier
Throws:
APIException
Expected behavior:
fetch patient identifier type with given uuid, return null when patient identifier type with given uuid does not exist

getPatientIdentifierType

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Identifier Types")
PatientIdentifierType getPatientIdentifierType(java.lang.String name)
                                               throws APIException
Deprecated. use getPatientIdentifierTypeByName(String)

Throws:
APIException

getPatientIdentifierTypeByName

@Transactional(readOnly=true)
@Authorized(value="View Identifier Types")
PatientIdentifierType getPatientIdentifierTypeByName(java.lang.String name)
                                                     throws APIException
Get patientIdentifierType by exact name

Parameters:
name -
Returns:
patientIdentifierType with given name
Throws:
APIException
Expected behavior:
fetch patient identifier type that exactly matches given name, not return patient identifier type that partially matches given name, return null when patient identifier type with given name does not exist

retirePatientIdentifierType

@Authorized(value="Manage Identifier Types")
PatientIdentifierType retirePatientIdentifierType(PatientIdentifierType patientIdentifierType,
                                                                  java.lang.String reason)
                                                  throws APIException
Retire a type of patient identifier

Parameters:
patientIdentifierType - type of patient identifier to be retired
reason - the reason to retire this identifier type
Returns:
the retired type
Throws:
APIException
Expected behavior:
retire patient identifier type with given reason, throw error when reason is empty

unretirePatientIdentifierType

@Authorized(value="Manage Identifier Types")
PatientIdentifierType unretirePatientIdentifierType(PatientIdentifierType patientIdentifierType)
                                                    throws APIException
Unretire a type of patient identifier

Parameters:
patientIdentifierType - type of patient identifier to be unretired
Returns:
the unretired type
Throws:
APIException
Expected behavior:
untire patient identifier type, return unretired patient identifier type

purgePatientIdentifierType

@Authorized(value="Purge Identifier Types")
void purgePatientIdentifierType(PatientIdentifierType patientIdentifierType)
                                throws APIException
Purge PatientIdentifierType (cannot be undone)

Parameters:
patientIdentifierType - PatientIdentifierType to purge from the database
Throws:
APIException
Expected behavior:
delete type from database, delete patient identifier type from database

checkPatientIdentifier

@Deprecated
@Authorized(value="View Patient Identifiers")
void checkPatientIdentifier(PatientIdentifier patientIdentifier)
                            throws PatientIdentifierException
Deprecated. use PatientIdentifierValidator.validateIdentifier(PatientIdentifier)

Convenience method to validate a patient identifier. Checks for things like blank identifiers, invalid check digits, etc

Parameters:
patientIdentifier - identifier to be validated
Throws:
PatientIdentifierException - if the identifier is invalid
See Also:
checkPatientIdentifiers(Patient)

checkPatientIdentifiers

@Authorized(value="View Patient Identifiers")
void checkPatientIdentifiers(Patient patient)
                             throws PatientIdentifierException
Convenience method to validate all identifiers for a given patient

Parameters:
patient - patient for which to validate identifiers
Throws:
PatientIdentifierException - if one or more of the identifiers are invalid
See Also:
checkPatientIdentifiers(Patient)
Expected behavior:
validate when patient has all required and no duplicate and no blank patient identifiers, ignore voided patient identifier, remove identifier and throw error when patient has blank patient identifier, throw error when patient has null patient identifiers, throw error when patient has empty patient identifiers, throw error when patient has identical identifiers, throw error when patient does not have one or more required identifiers, require one non voided patient identifier

findPatients

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Patients")
java.util.List<Patient> findPatients(java.lang.String query,
                                                                              boolean includeVoided)
                                     throws APIException
Deprecated. use #getPatients(String)

Throws:
APIException
See Also:
getPatients(String)

getPatients

@Transactional(readOnly=true)
@Authorized(value="View Patients")
java.util.List<Patient> getPatients(java.lang.String query)
                                    throws APIException
Generic search on patients based on the given string. Implementations can use this string to search on name, identifier, etc Voided patients are not returned in search results

Parameters:
query - the string to search on
Returns:
a list of matching Patients
Throws:
APIException
Expected behavior:
force search string to be greater than minsearchcharacters global property, allow search string to be one according to minsearchcharacters global property, fetch patients with patient identifiers matching given query, fetch patients with any name matching given query, return empty list if given query length less than minimum search characters, not fail when minimum search characters is null, not fail when minimum search characters is invalid integer

findPatient

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Patients")
Patient findPatient(Patient patientToMatch)
                    throws APIException
Deprecated. use #getPatientByExample(Patient)

Throws:
APIException
See Also:
getPatientByExample(Patient)

getPatientByExample

@Transactional(readOnly=true)
@Authorized(value="View Patients")
Patient getPatientByExample(Patient patientToMatch)
                            throws APIException
This method tries to find a patient in the database given the attributes on the given patientToMatch object. Assumes there could be a PersonAttribute on this Patient with PersonAttributeType.name = "Other Matching Information". This PersonAttribute has a "value" that is just key value pairs in the form of key:value;nextkey:nextvalue;

Parameters:
patientToMatch -
Returns:
null if no match found, a fresh patient object from the db if is found
Throws:
APIException
Expected behavior:
fetch patient matching patient id of given patient, not fetch patient matching any other patient information, return null when no patient matches given patient to match

findDuplicatePatients

@Deprecated
@Transactional(readOnly=true)
@Authorized(value="View Patients")
java.util.List<Patient> findDuplicatePatients(java.util.Set<java.lang.String> attributes)
                                              throws APIException
Deprecated. use getDuplicatePatientsByAttributes(List)

Throws:
APIException
See Also:
getDuplicatePatientsByAttributes(List)

getDuplicatePatientsByAttributes

@Transactional(readOnly=true)
@Authorized(value="View Patients")
java.util.List<Patient> getDuplicatePatientsByAttributes(java.util.List<java.lang.String> attributes)
                                                         throws APIException
Search the database for patients that both share the given attributes. Each attribute that is passed in must be identical to what is stored for at least one other patient for both patients to be returned.

Parameters:
attributes - attributes on a Person or Patient object. similar to: [gender, givenName, middleName, familyName]
Returns:
list of patients that match other patients
Throws:
APIException
Expected behavior:
fetch patients that exactly match on all given attributes, not return patients that exactly match on some but not all given attributes

mergePatients

@Authorized(value="Edit Patients")
void mergePatients(Patient preferred,
                                   Patient notPreferred)
                   throws APIException
Convenience method to join two patients' information into one record.
  1. Moves object (encounters/obs) pointing to nonPreferred to point at preferred
  2. Copies data (gender/birthdate/names/ids/etc) from nonPreferred to preferred IFF the data is missing or null in preferred
  3. notPreferred is marked as voided

Parameters:
preferred - The Patient to merge to
notPreferred - The Patient to merge from (and then void)
Throws:
APIException
Expected behavior:
not merge the same patient to itself, copy nonvoided names to preferred patient, copy nonvoided identifiers to preferred patient, copy nonvoided addresses to preferred patient, not copy over relationships that are only between the preferred and notpreferred patient, not merge patient with itself, merge non voided encounters from non preferred to preferred patient, merge non duplicate patient identifiers from non preferred to preferred patient, merge non duplicate patient names from non preferred to preferred patient, merge non duplicate addresses from non preferred to preferred patient, merge non voided patient programs from non preferred to preferred patient, merge non voided relationships from non preferred to preferred patient, merge observations associated with encounters from non preferred to preferred patient, merge non voided person attributes from non preferred to preferred patient, merge other non voided observations from non preferred to preferred patient, merge other non voided orders from non preferred to preferred patient, merge non preferred death date when preferred death date is not null or empty, merge non preferred death cause when preferred death cause is not null or empty, void non preferred person object, change user records of non preferred person to preferred person, void non preferred patient

exitFromCare

@Authorized(value="Edit Patients")
void exitFromCare(Patient patient,
                                  java.util.Date dateExited,
                                  Concept reasonForExit)
                  throws APIException
Convenience method to establish that a patient has left the care center. This API call is responsible for: 1) Closing workflow statuses 2) Terminating programs 3) Discontinuing orders 4) Flagging patient table (if applicable) 5) Creating any relevant observations about the patient TODO keep this in the PatientService? Or move to appropriate service?

Parameters:
patient - - the patient who has exited care
dateExited - - the declared date/time of the patient's exit
reasonForExit - - the concept that corresponds with why the patient has been declared as exited
Throws:
APIException
Expected behavior:
save reason for exit observation for given patient, set death date and cause when given reason for exit equals death, discontinue all orders associated with given patient, terminate all program workflows associated with given paitent, throw error when given patient is null, throw error when given date exited is null, throw error when given reason for exist is null, be tested more thoroughly

processDeath

@Authorized(value="Edit Patients")
void processDeath(Patient patient,
                                  java.util.Date dateDied,
                                  Concept causeOfDeath,
                                  java.lang.String otherReason)
                  throws APIException
Convenience method to establish that a patient has died. In addition to exiting the patient from care (see above), this method will also set the appropriate patient characteristics to indicate that they have died, when they died, etc. TODO Keep this in the PatientService? Or move to appropriate service

Parameters:
patient - - the patient who has died
dateDied - - the declared date/time of the patient's death
causeOfDeath - - the concept that corresponds with the reason the patient died
otherReason - - if the concept representing the reason is OTHER NON-CODED, and a string-based "other" reason is supplied
Throws:
APIException
Expected behavior:
be tested more thoroughly

saveCauseOfDeathObs

@Authorized(value={"View Patients","Edit Observations"},
            requireAll=true)
void saveCauseOfDeathObs(Patient patient,
                                                   java.util.Date dateDied,
                                                   Concept causeOfDeath,
                                                   java.lang.String otherReason)
                         throws APIException
Convenience method that saves the Obs that indicates when and why the patient died (including any "other" reason there might be) TODO keep this in the PatientService?

Parameters:
patient - - the patient who has died
dateDied - - the declared date/time of the patient's death
causeOfDeath - - the concept that corresponds with the reason the patient died
otherReason - - if the concept representing the reason is OTHER NON-CODED, and a string-based "other" reason is supplied
Throws:
APIException
Expected behavior:
throw error when given patient is null, throw error when given death date is null, throw error when given cause is null is null, throw error when cause of death global property is not specified, throw error when patient already has more than one cause of death observations, modify existing cause of death observation, set death attributes as long as patient is not already dead, be tested more thoroughly

getIdentifierValidator

@Transactional(readOnly=true)
IdentifierValidator getIdentifierValidator(java.lang.Class<IdentifierValidator> clazz)
Gets an identifier validator matching the given class.

Parameters:
clazz - identifierValidator which validator to get.
Expected behavior:
return patient identifier validator given class

getIdentifierValidator

@Transactional(readOnly=true)
IdentifierValidator getIdentifierValidator(java.lang.String pivClassName)
Expected behavior:
return patient identifier validator given class name, treat empty strings like a null entry

getDefaultIdentifierValidator

@Transactional(readOnly=true)
IdentifierValidator getDefaultIdentifierValidator()
Returns:
the default IdentifierValidator
Expected behavior:
return default patient identifier validator

getAllIdentifierValidators

@Transactional(readOnly=true)
java.util.Collection<IdentifierValidator> getAllIdentifierValidators()
Returns:
All registered PatientIdentifierValidators
Expected behavior:
return all registered patient identifier validators

isIdentifierInUseByAnotherPatient

@Authorized(value="View Patients")
@Transactional(readOnly=true)
boolean isIdentifierInUseByAnotherPatient(PatientIdentifier patientIdentifier)
Checks whether the given patient identifier is already assigned to a patient other than patientIdentifier.patient

Parameters:
patientIdentifier - the patient identifier to look for in other patients
Returns:
whether or not the identifier is in use by a patient other than patientIdentifier.patient
Expected behavior:
return true when patientIdentifier contains a patient and another patient has this id, return false when patientIdentifier contains a patient and no other patient has this id, return true when patientIdentifier does not contain a patient and a patient has this id, return false when patientIdentifier does not contain a patient and no patient has this id, ignore voided patientIdentifiers, ignore voided patients

getPatientIdentifier

@Authorized(value="View Patient Identifiers")
@Transactional(readOnly=true)
PatientIdentifier getPatientIdentifier(java.lang.Integer patientIdentifierId)
                                       throws APIException
Returns a patient identifier that matches the given patientIndentifier id

Parameters:
patientIdentifier - the patientIdentifier id
Returns:
the patientIdentifier matching the Id
Throws:
APIException
Expected behavior:
return the patientIdentifier with the given id

voidPatientIdentifier

@Authorized(value="Delete Patient Identifiers")
PatientIdentifier voidPatientIdentifier(PatientIdentifier patientIdentifier,
                                                        java.lang.String reason)
                                        throws APIException
Void patient identifier (functionally delete patient identifier from system)

Parameters:
patient - patientIdentifier to be voided
reason - reason for voiding patient identifier
Returns:
the voided patient identifier
Throws:
APIException
Expected behavior:
void given patient identifier with given reaso, throw an APIException if the reason is null, throw an APIException if the reason is an empty string, throw an APIException if the reason is a white space character

savePatientIdentifier

@Authorized(value={"Add Patient Identifiers","Edit Patient Identifiers"})
PatientIdentifier savePatientIdentifier(PatientIdentifier patientIdentifier)
                                        throws APIException
Saved the given patientIndentifier to the database

Parameters:
patientIndentifier - patientIndentifier to be created or updated
Returns:
patientIndentifier that was created or updated
Throws:
APIException
Expected behavior:
create new patientIndentifier, update an existing patient identifier, throw an APIException when a null argument is passed, throw an APIException when one of the required fields is null, throw an APIException if the patientIdentifier string is a white space, throw an APIException if the patientIdentifier string is an empty string

purgePatientIdentifier

@Authorized(value="Purge Patient Identifiers")
void purgePatientIdentifier(PatientIdentifier patientIdentifier)
                            throws APIException
Purge PatientIdentifier (cannot be undone)

Parameters:
patientIdentifier - PatientIdentifier to purge from the database
Throws:
APIException
Expected behavior:
delete patient identifier from database

getProblems

@Transactional(readOnly=true)
@Authorized(value="View Problems")
java.util.List<Problem> getProblems(Person p)
                                    throws APIException
Get a list of the problems for the patient, sorted on sort_weight

Parameters:
p - the Person
Returns:
sorted set based on the sort weight of the list items
Throws:
APIException
Expected behavior:
return empty list if no problems exist for this Patient

getProblem

@Transactional(readOnly=true)
@Authorized(value="View Problems")
Problem getProblem(java.lang.Integer problemListId)
                   throws APIException
Returns the Problem

Parameters:
problemListId -
Returns:
the allergy
Throws:
APIException

saveProblem

@Authorized(value={"Add Problems","Edit Problems"})
void saveProblem(Problem problem)
                 throws APIException
Creates a ProblemListItem to the Patient's Problem Active List. Sets the start date to now, if it is null. Sets the weight

Parameters:
problem - the Problem
Throws:
APIException
Expected behavior:
save the problem and set the weight for correct ordering

removeProblem

@Authorized(value="Edit Problems")
void removeProblem(Problem problem,
                                   java.lang.String reason)
                   throws APIException
Effectively removes the Problem from the Patient's Active List by setting the stop date to now, if null.

Parameters:
problem - the Problem
reason - the reason of removing the problem
Throws:
APIException
Expected behavior:
set the end date for the problem

voidProblem

@Authorized(value="Remove Problems")
void voidProblem(Problem problem,
                                 java.lang.String reason)
                 throws APIException
Used only in cases where the Problem was entered by error

Parameters:
problem -
reason -
Throws:
APIException

getAllergies

@Transactional(readOnly=true)
@Authorized(value="View Allergies")
java.util.List<Allergy> getAllergies(Person p)
                                     throws APIException
Returns a sorted set of Allergies, sorted on sort_weight

Parameters:
p - the Person
Returns:
sorted set based on the sort weight of the list items
Throws:
APIException
Expected behavior:
return empty list if no allergies exist for the Patient

getAllergy

@Transactional(readOnly=true)
@Authorized(value="View Allergies")
Allergy getAllergy(java.lang.Integer allergyListId)
                   throws APIException
Returns the Allergy

Parameters:
allergyListId -
Returns:
the allergy
Throws:
APIException

saveAllergy

@Authorized(value={"Add Allergies","Edit Allergies"})
void saveAllergy(Allergy allergy)
                 throws APIException
Creates an AllergyListItem to the Patient's Allergy Active List. Sets the start date to now, if it is null.

Parameters:
allergy - the Allergy
Throws:
APIException
Expected behavior:
save the allergy

removeAllergy

@Authorized(value="Edit Allergies")
void removeAllergy(Allergy allergy,
                                   java.lang.String reason)
                   throws APIException
Resolving the allergy, effectively removes the Allergy from the Patient's Active List by setting the stop date to now, if null.

Parameters:
allergy - the Allergy
reason - the reason of remove
Throws:
APIException
Expected behavior:
set the end date for the allergy

voidAllergy

@Authorized(value="Remove Allergies")
void voidAllergy(Allergy allergy,
                                 java.lang.String reason)
                 throws APIException
Used only in cases where the Allergy was entered by error

Parameters:
allergy -
reason -
Throws:
APIException

OpenMRS-1.7.x

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