org.openmrs.api.impl
Class PatientServiceImpl

java.lang.Object
  extended by org.openmrs.api.impl.BaseOpenmrsService
      extended by org.openmrs.api.impl.PatientServiceImpl
All Implemented Interfaces:
OpenmrsService, PatientService

public class PatientServiceImpl
extends BaseOpenmrsService
implements PatientService

Default implementation of the patient service. This class should not be used on its own. The current OpenMRS implementation should be fetched from the Context via Context.getPatientService()

See Also:
Context, PatientService, PersonService

Constructor Summary
PatientServiceImpl()
           
 
Method Summary
 void checkPatientIdentifier(PatientIdentifier pi)
          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)
          This is the way 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.  
 java.util.List<Patient> findPatients(java.lang.String query, boolean includeVoided)
          Deprecated.  
 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> identifierValidator)
          Gets an identifier validator matching the given class.
 IdentifierValidator getIdentifierValidator(java.lang.String pivClassName)
           
 java.util.Map<java.lang.Class<? extends IdentifierValidator>,IdentifierValidator> getIdentifierValidators()
           
 Patient getPatient(java.lang.Integer patientId)
          Get patient by internal identifier
 Patient getPatientByExample(Patient patientToMatch)
          This default implementation simply looks at the OpenMRS internal id (patient_id).
 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 pit)
          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)
 java.util.List<PatientIdentifier> getPatientIdentifiers(java.lang.String identifier, PatientIdentifierType patientIdentifierType, boolean includeVoided)
          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.  
 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 getPatients(String, String, List, boolean)
 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 @deprecated replaced by getPatients(String, String, List)
 java.util.List<Patient> getPatientsByIdentifierPattern(java.lang.String identifier, boolean includeVoided)
          Deprecated. replaced by getPatients(String, String, List, boolean)
 java.util.List<Patient> getPatientsByName(java.lang.String name)
          Deprecated. replaced by getPatients(String, String, List, boolean)
 java.util.List<Patient> getPatientsByName(java.lang.String name, boolean includeVoided)
          Deprecated. replaced by getPatients(String, String, List, boolean)
 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)
          1) Moves object (encounters/obs) pointing to nonPreferred to 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
 void onShutdown()
          Clean up after this class.
 void processDeath(Patient patient, java.util.Date dateDied, Concept causeOfDeath, java.lang.String otherReason)
          This is the way 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 deathDate, Concept cause, 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)
          TODO: Add changedBy and DateChanged columns to table patient_identifier_type
 void saveProblem(Problem problem)
          Creates a ProblemListItem to the Patient's Problem Active List.
 void setIdentifierValidators(java.util.Map<java.lang.Class<? extends IdentifierValidator>,IdentifierValidator> identifierValidators)
          ADDs identifierValidators, doesn't replace them
 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 pi)
          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 class org.openmrs.api.impl.BaseOpenmrsService
onStartup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openmrs.api.OpenmrsService
onStartup
 

Constructor Detail

PatientServiceImpl

public PatientServiceImpl()
Method Detail

setPatientDAO

public void setPatientDAO(PatientDAO dao)
Description copied from interface: PatientService
Sets the DAO for this service. This is done by DI and Spring. See the applicationContext-service.xml definition file.

Specified by:
setPatientDAO in interface PatientService
Parameters:
dao - DAO for this service
See Also:
PatientService.setPatientDAO(org.openmrs.api.db.PatientDAO)

onShutdown

public void onShutdown()
Clean up after this class. Set the static var to null so that the classloader can reclaim the space.

Specified by:
onShutdown in interface OpenmrsService
Overrides:
onShutdown in class BaseOpenmrsService
See Also:
BaseOpenmrsService.onShutdown()

createPatient

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

Specified by:
createPatient in interface PatientService
Throws:
APIException
See Also:
savePatient(Patient), PatientService.createPatient(org.openmrs.Patient)

savePatient

public Patient savePatient(Patient patient)
                    throws APIException
Description copied from interface: PatientService
Saved the given patient to the database

Specified by:
savePatient in interface PatientService
Parameters:
patient - patient to be created or updated
Returns:
patient who was created or updated
Throws:
APIException
See Also:
PatientService.savePatient(org.openmrs.Patient)

getPatient

public Patient getPatient(java.lang.Integer patientId)
                   throws APIException
Description copied from interface: PatientService
Get patient by internal identifier

Specified by:
getPatient in interface PatientService
Parameters:
patientId - internal patient identifier
Returns:
patient with given internal identifier
Throws:
APIException
See Also:
PatientService.getPatient(java.lang.Integer)

updatePatient

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

Specified by:
updatePatient in interface PatientService
Throws:
APIException
See Also:
savePatient(Patient), PatientService.updatePatient(org.openmrs.Patient)

getAllPatients

public java.util.List<Patient> getAllPatients()
                                       throws APIException
Description copied from interface: PatientService
Returns all non voided patients in the system

Specified by:
getAllPatients in interface PatientService
Returns:
non voided patients in the system
Throws:
APIException
See Also:
PatientService.getAllPatients()

getAllPatients

public java.util.List<Patient> getAllPatients(boolean includeVoided)
                                       throws APIException
Description copied from interface: PatientService
Returns patients in the system

Specified by:
getAllPatients in interface PatientService
Parameters:
includeVoided - if false, will limit the search to non-voided patients
Returns:
patients in the system
Throws:
APIException
See Also:
PatientService.getAllPatients(boolean)

getPatients

@Deprecated
public java.util.List<Patient> getPatients(java.lang.String name,
                                                      java.lang.String identifier,
                                                      java.util.List<PatientIdentifierType> identifierTypes)
                                    throws APIException
Deprecated. replaced by getPatients(String, String, List, boolean)

Specified by:
getPatients in interface PatientService
Throws:
APIException
See Also:
PatientService.getPatients(java.lang.String, java.lang.String, java.util.List)

getPatients

public java.util.List<Patient> getPatients(java.lang.String name,
                                           java.lang.String identifier,
                                           java.util.List<PatientIdentifierType> identifierTypes,
                                           boolean matchIdentifierExactly)
                                    throws APIException
Description copied from interface: PatientService
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

Specified by:
getPatients in interface PatientService
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
See Also:
PatientService.getPatients(java.lang.String, java.lang.String, java.util.List, boolean)

checkPatientIdentifiers

public void checkPatientIdentifiers(Patient patient)
                             throws PatientIdentifierException
Description copied from interface: PatientService
Convenience method to validate all identifiers for a given patient

Specified by:
checkPatientIdentifiers in interface PatientService
Parameters:
patient - patient for which to validate identifiers
Throws:
PatientIdentifierException - if one or more of the identifiers are invalid
See Also:
PatientService.checkPatientIdentifiers(org.openmrs.Patient)

checkPatientIdentifier

@Deprecated
public void checkPatientIdentifier(PatientIdentifier pi)
                            throws PatientIdentifierException
Deprecated. use PatientIdentifierValidator.validateIdentifier(PatientIdentifier)

Description copied from interface: PatientService
Convenience method to validate a patient identifier. Checks for things like blank identifiers, invalid check digits, etc

Specified by:
checkPatientIdentifier in interface PatientService
Parameters:
pi - identifier to be validated
Throws:
PatientIdentifierException - if the identifier is invalid
See Also:
PatientService.checkPatientIdentifier(org.openmrs.PatientIdentifier)

identifierInUse

@Deprecated
public Patient identifierInUse(java.lang.String identifier,
                                          PatientIdentifierType type,
                                          Patient ignorePatient)
Deprecated. use getPatientByIdentifier(String) instead

Specified by:
identifierInUse in interface PatientService
See Also:
PatientService.identifierInUse(java.lang.String, org.openmrs.PatientIdentifierType, org.openmrs.Patient)

getPatientsByIdentifier

@Deprecated
public java.util.List<Patient> getPatientsByIdentifier(java.lang.String identifier,
                                                                  boolean includeVoided)
                                                throws APIException
Deprecated. replaced by @deprecated replaced by getPatients(String, String, List)

Specified by:
getPatientsByIdentifier in interface PatientService
Throws:
APIException
See Also:
PatientService.getPatientsByIdentifier(java.lang.String, boolean)

getPatientsByIdentifierPattern

@Deprecated
public java.util.List<Patient> getPatientsByIdentifierPattern(java.lang.String identifier,
                                                                         boolean includeVoided)
                                                       throws APIException
Deprecated. replaced by getPatients(String, String, List, boolean)

Specified by:
getPatientsByIdentifierPattern in interface PatientService
Throws:
APIException
See Also:
PatientService.getPatientsByIdentifierPattern(java.lang.String, boolean)

getPatientsByName

@Deprecated
public java.util.List<Patient> getPatientsByName(java.lang.String name)
                                          throws APIException
Deprecated. replaced by getPatients(String, String, List, boolean)

Specified by:
getPatientsByName in interface PatientService
Throws:
APIException
See Also:
PatientService.getPatientsByName(java.lang.String)

getPatientsByName

@Deprecated
public java.util.List<Patient> getPatientsByName(java.lang.String name,
                                                            boolean includeVoided)
                                          throws APIException
Deprecated. replaced by getPatients(String, String, List, boolean)

Specified by:
getPatientsByName in interface PatientService
Throws:
APIException

voidPatient

public Patient voidPatient(Patient patient,
                           java.lang.String reason)
                    throws APIException
Description copied from interface: PatientService
Void patient record (functionally delete patient from system)

Specified by:
voidPatient in interface PatientService
Parameters:
patient - patient to be voided
reason - reason for voiding patient
Returns:
the voided patient
Throws:
APIException
See Also:
PatientService.voidPatient(org.openmrs.Patient, java.lang.String)

unvoidPatient

public Patient unvoidPatient(Patient patient)
                      throws APIException
Description copied from interface: PatientService
Unvoid patient record

Specified by:
unvoidPatient in interface PatientService
Parameters:
patient - patient to be revived
Returns:
the revived Patient
Throws:
APIException
See Also:
PatientService.unvoidPatient(org.openmrs.Patient)

deletePatient

@Deprecated
public void deletePatient(Patient patient)
                   throws APIException
Deprecated. replaced by purgePatient(Patient)

Specified by:
deletePatient in interface PatientService
Throws:
APIException
See Also:
voidPatient(org.openmrs.Patient,java.lang.String)

purgePatient

public void purgePatient(Patient patient)
                  throws APIException
Description copied from interface: PatientService
Delete patient from database. This should not be called except for testing and administration purposes. Use the void method instead.

Specified by:
purgePatient in interface PatientService
Parameters:
patient - patient to be deleted
Throws:
APIException
See Also:
PatientService.purgePatient(org.openmrs.Patient)

getPatientIdentifiers

public 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
Description copied from interface: PatientService
Get all patientIdentifiers that match all of the given criteria Voided identifiers are not returned

Specified by:
getPatientIdentifiers in interface PatientService
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
See Also:
PatientService.getPatientIdentifiers(java.lang.String, java.util.List, java.util.List, java.util.List, java.lang.Boolean)

getPatientIdentifiers

@Deprecated
public java.util.List<PatientIdentifier> getPatientIdentifiers(PatientIdentifierType pit)
                                                        throws APIException
Deprecated. replaced by getPatientIdentifiers(String, List, List, List, Boolean)

Specified by:
getPatientIdentifiers in interface PatientService
Throws:
APIException
See Also:
PatientService.getPatientIdentifiers(org.openmrs.PatientIdentifierType)

getPatientIdentifiers

@Deprecated
public java.util.List<PatientIdentifier> getPatientIdentifiers(java.lang.String identifier,
                                                                          PatientIdentifierType pit)
                                                        throws APIException
Deprecated. replaced by getPatientIdentifiers(String, List, List, List, Boolean)

Specified by:
getPatientIdentifiers in interface PatientService
Throws:
APIException
See Also:
PatientService.getPatientIdentifiers(java.lang.String, org.openmrs.PatientIdentifierType)

getPatientIdentifiers

@Deprecated
public java.util.List<PatientIdentifier> getPatientIdentifiers(java.lang.String identifier,
                                                                          PatientIdentifierType patientIdentifierType,
                                                                          boolean includeVoided)
                                                        throws APIException
Deprecated. replaced by getPatientIdentifiers(String, List, List, List, Boolean)

Throws:
APIException
See Also:
PatientService.getPatientIdentifiers(String, PatientIdentifierType)

updatePatientIdentifier

@Deprecated
public void updatePatientIdentifier(PatientIdentifier pi)
                             throws APIException
Deprecated. patient identifiers should not be updated directly; rather, after changing patient identifiers, use savePatient(Patient) to save changes to the database

Description copied from interface: PatientService
Update patient identifier

Specified by:
updatePatientIdentifier in interface PatientService
Parameters:
pi - identifier to be updated
Throws:
APIException

savePatientIdentifierType

public PatientIdentifierType savePatientIdentifierType(PatientIdentifierType patientIdentifierType)
                                                throws APIException
TODO: Add changedBy and DateChanged columns to table patient_identifier_type

Specified by:
savePatientIdentifierType in interface PatientService
Parameters:
patientIdentifierType - PatientIdentifierType to create or update
Returns:
the saved type
Throws:
APIException
See Also:
PatientService.savePatientIdentifierType(org.openmrs.PatientIdentifierType)

getPatientIdentifierTypes

@Deprecated
public java.util.List<PatientIdentifierType> getPatientIdentifierTypes()
                                                                throws APIException
Deprecated. replaced by getAllPatientIdentifierTypes()

Specified by:
getPatientIdentifierTypes in interface PatientService
Throws:
APIException
See Also:
PatientService.getPatientIdentifierTypes(), PatientService.getAllPatientIdentifierTypes()

getAllPatientIdentifierTypes

public java.util.List<PatientIdentifierType> getAllPatientIdentifierTypes()
                                                                   throws APIException
Description copied from interface: PatientService
Get all patientIdentifier types

Specified by:
getAllPatientIdentifierTypes in interface PatientService
Returns:
patientIdentifier types list
Throws:
APIException
See Also:
PatientService.getAllPatientIdentifierTypes()

getAllPatientIdentifierTypes

public java.util.List<PatientIdentifierType> getAllPatientIdentifierTypes(boolean includeRetired)
                                                                   throws APIException
Description copied from interface: PatientService
Get all patientIdentifier types

Specified by:
getAllPatientIdentifierTypes in interface PatientService
Parameters:
includeRetired - true/false whether retired types should be included
Returns:
patientIdentifier types list
Throws:
APIException
See Also:
PatientService.getAllPatientIdentifierTypes(boolean)

getPatientIdentifierTypes

public java.util.List<PatientIdentifierType> getPatientIdentifierTypes(java.lang.String name,
                                                                       java.lang.String format,
                                                                       java.lang.Boolean required,
                                                                       java.lang.Boolean hasCheckDigit)
                                                                throws APIException
Description copied from interface: PatientService
Get all patientIdentifier types that match the given criteria

Specified by:
getPatientIdentifierTypes in interface PatientService
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
See Also:
PatientService.getPatientIdentifierTypes(java.lang.String, java.lang.String, java.lang.Boolean, java.lang.Boolean)

getPatientIdentifierType

public PatientIdentifierType getPatientIdentifierType(java.lang.Integer patientIdentifierTypeId)
                                               throws APIException
Description copied from interface: PatientService
Get patientIdentifierType by internal identifier

Specified by:
getPatientIdentifierType in interface PatientService
Returns:
patientIdentifierType with specified internal identifier
Throws:
APIException
See Also:
PatientService.getPatientIdentifierType(java.lang.Integer)

getPatientIdentifierType

@Deprecated
public PatientIdentifierType getPatientIdentifierType(java.lang.String name)
                                               throws APIException
Deprecated. 

Specified by:
getPatientIdentifierType in interface PatientService
Throws:
APIException
See Also:
PatientService.getPatientIdentifierType(java.lang.String)

getPatientIdentifierTypeByName

public PatientIdentifierType getPatientIdentifierTypeByName(java.lang.String name)
                                                     throws APIException
Description copied from interface: PatientService
Get patientIdentifierType by exact name

Specified by:
getPatientIdentifierTypeByName in interface PatientService
Returns:
patientIdentifierType with given name
Throws:
APIException
See Also:
PatientService.getPatientIdentifierTypeByName(java.lang.String)

retirePatientIdentifierType

public PatientIdentifierType retirePatientIdentifierType(PatientIdentifierType patientIdentifierType,
                                                         java.lang.String reason)
                                                  throws APIException
Description copied from interface: PatientService
Retire a type of patient identifier

Specified by:
retirePatientIdentifierType in interface PatientService
Parameters:
patientIdentifierType - type of patient identifier to be retired
reason - the reason to retire this identifier type
Returns:
the retired type
Throws:
APIException
See Also:
PatientService.retirePatientIdentifierType(org.openmrs.PatientIdentifierType, String)

unretirePatientIdentifierType

public PatientIdentifierType unretirePatientIdentifierType(PatientIdentifierType patientIdentifierType)
                                                    throws APIException
Description copied from interface: PatientService
Unretire a type of patient identifier

Specified by:
unretirePatientIdentifierType in interface PatientService
Parameters:
patientIdentifierType - type of patient identifier to be unretired
Returns:
the unretired type
Throws:
APIException
See Also:
PatientService.unretirePatientIdentifierType(org.openmrs.PatientIdentifierType)

purgePatientIdentifierType

public void purgePatientIdentifierType(PatientIdentifierType patientIdentifierType)
                                throws APIException
Description copied from interface: PatientService
Purge PatientIdentifierType (cannot be undone)

Specified by:
purgePatientIdentifierType in interface PatientService
Parameters:
patientIdentifierType - PatientIdentifierType to purge from the database
Throws:
APIException
See Also:
PatientService.purgePatientIdentifierType(org.openmrs.PatientIdentifierType)

findPatients

@Deprecated
public java.util.List<Patient> findPatients(java.lang.String query,
                                                       boolean includeVoided)
                                     throws APIException
Deprecated. 

Specified by:
findPatients in interface PatientService
Throws:
APIException
See Also:
PatientService.findPatients(java.lang.String, boolean)

getPatients

public java.util.List<Patient> getPatients(java.lang.String query)
                                    throws APIException
Description copied from interface: PatientService
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

Specified by:
getPatients in interface PatientService
Parameters:
query - the string to search on
Returns:
a list of matching Patients
Throws:
APIException
See Also:
PatientService.getPatients(java.lang.String)

findPatient

@Deprecated
public Patient findPatient(Patient patientToMatch)
                    throws APIException
Deprecated. 

Specified by:
findPatient in interface PatientService
Throws:
APIException
See Also:
PatientService.findPatient(org.openmrs.Patient), getPatientByExample(Patient)

getPatientByExample

public Patient getPatientByExample(Patient patientToMatch)
                            throws APIException
This default implementation simply looks at the OpenMRS internal id (patient_id). If the id is null, assume this patient isn't found. If the patient_id is not null, try and find that id in the database

Specified by:
getPatientByExample in interface PatientService
Returns:
null if no match found, a fresh patient object from the db if is found
Throws:
APIException
See Also:
PatientService.getPatientByExample(org.openmrs.Patient)

findDuplicatePatients

@Deprecated
public java.util.List<Patient> findDuplicatePatients(java.util.Set<java.lang.String> attributes)
                                              throws APIException
Deprecated. use getDuplicatePatientsByAttributes(List)

Specified by:
findDuplicatePatients in interface PatientService
Throws:
APIException
See Also:
PatientService.getDuplicatePatientsByAttributes(List)

getDuplicatePatientsByAttributes

public java.util.List<Patient> getDuplicatePatientsByAttributes(java.util.List<java.lang.String> attributes)
                                                         throws APIException
Description copied from interface: PatientService
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.

Specified by:
getDuplicatePatientsByAttributes in interface PatientService
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
See Also:
PatientService.getDuplicatePatientsByAttributes(java.util.List)

mergePatients

public void mergePatients(Patient preferred,
                          Patient notPreferred)
                   throws APIException
1) Moves object (encounters/obs) pointing to nonPreferred to 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

Specified by:
mergePatients in interface PatientService
Parameters:
preferred -
notPreferred -
Throws:
APIException
See Also:
PatientService.mergePatients(org.openmrs.Patient, org.openmrs.Patient)

exitFromCare

public void exitFromCare(Patient patient,
                         java.util.Date dateExited,
                         Concept reasonForExit)
                  throws APIException
This is the way 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
  5. Creating any relevant observations about the patient (if applicable)

Specified by:
exitFromCare in interface PatientService
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

processDeath

public void processDeath(Patient patient,
                         java.util.Date dateDied,
                         Concept causeOfDeath,
                         java.lang.String otherReason)
                  throws APIException
This is the way 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.

Specified by:
processDeath in interface 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 - - in case the causeOfDeath is 'other', a place to store more info
Throws:
APIException

saveCauseOfDeathObs

public void saveCauseOfDeathObs(Patient patient,
                                java.util.Date deathDate,
                                Concept cause,
                                java.lang.String otherReason)
                         throws APIException
Description copied from interface: PatientService
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?

Specified by:
saveCauseOfDeathObs in interface PatientService
Parameters:
patient - - the patient who has died
deathDate - - the declared date/time of the patient's death
cause - - 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
See Also:
PatientService.saveCauseOfDeathObs(org.openmrs.Patient, java.util.Date, org.openmrs.Concept, java.lang.String)

getPatientByUuid

public Patient getPatientByUuid(java.lang.String uuid)
                         throws APIException
Description copied from interface: PatientService
Get patient by universally unique identifier.

Specified by:
getPatientByUuid in interface PatientService
Parameters:
uuid - universally unique identifier
Returns:
the patient that matches the uuid
Throws:
APIException
See Also:
PatientService.getPatientByUuid(java.lang.String)

getPatientIdentifierByUuid

public PatientIdentifier getPatientIdentifierByUuid(java.lang.String uuid)
                                             throws APIException
Description copied from interface: PatientService
Get patient identifier by universally unique identifier.

Specified by:
getPatientIdentifierByUuid in interface PatientService
Parameters:
uuid - universally unique identifier
Returns:
the patient identifier that matches the uuid
Throws:
APIException

getPatientIdentifierTypeByUuid

public PatientIdentifierType getPatientIdentifierTypeByUuid(java.lang.String uuid)
                                                     throws APIException
Description copied from interface: PatientService
Get patient identifierType by universally unique identifier

Specified by:
getPatientIdentifierTypeByUuid in interface PatientService
Returns:
patientIdentifierType with specified internal identifier
Throws:
APIException
See Also:
PatientService.getPatientIdentifierTypeByUuid(java.lang.String)

getDefaultIdentifierValidator

public IdentifierValidator getDefaultIdentifierValidator()
Specified by:
getDefaultIdentifierValidator in interface PatientService
Returns:
the default IdentifierValidator
See Also:
PatientService.getDefaultIdentifierValidator()

getIdentifierValidator

public IdentifierValidator getIdentifierValidator(java.lang.Class<IdentifierValidator> identifierValidator)
Description copied from interface: PatientService
Gets an identifier validator matching the given class.

Specified by:
getIdentifierValidator in interface PatientService
Parameters:
identifierValidator - identifierValidator which validator to get.
See Also:
PatientService.getIdentifierValidator(java.lang.String)

getIdentifierValidators

public java.util.Map<java.lang.Class<? extends IdentifierValidator>,IdentifierValidator> getIdentifierValidators()

setIdentifierValidators

public void setIdentifierValidators(java.util.Map<java.lang.Class<? extends IdentifierValidator>,IdentifierValidator> identifierValidators)
ADDs identifierValidators, doesn't replace them

Parameters:
identifierValidators -

getAllIdentifierValidators

public java.util.Collection<IdentifierValidator> getAllIdentifierValidators()
Specified by:
getAllIdentifierValidators in interface PatientService
Returns:
All registered PatientIdentifierValidators
See Also:
PatientService.getAllIdentifierValidators()

getIdentifierValidator

public IdentifierValidator getIdentifierValidator(java.lang.String pivClassName)
Specified by:
getIdentifierValidator in interface PatientService
See Also:
PatientService.getIdentifierValidator(java.lang.String)

isIdentifierInUseByAnotherPatient

public boolean isIdentifierInUseByAnotherPatient(PatientIdentifier patientIdentifier)
Description copied from interface: PatientService
Checks whether the given patient identifier is already assigned to a patient other than patientIdentifier.patient

Specified by:
isIdentifierInUseByAnotherPatient in interface PatientService
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
See Also:
PatientService.isIdentifierInUseByAnotherPatient(org.openmrs.PatientIdentifier)

getPatientIdentifier

public PatientIdentifier getPatientIdentifier(java.lang.Integer patientIdentifierId)
                                       throws APIException
Description copied from interface: PatientService
Returns a patient identifier that matches the given patientIndentifier id

Specified by:
getPatientIdentifier in interface PatientService
Returns:
the patientIdentifier matching the Id
Throws:
APIException
See Also:
PatientService.getPatientIdentifier(java.lang.Integer)

voidPatientIdentifier

public PatientIdentifier voidPatientIdentifier(PatientIdentifier patientIdentifier,
                                               java.lang.String reason)
                                        throws APIException
Description copied from interface: PatientService
Void patient identifier (functionally delete patient identifier from system)

Specified by:
voidPatientIdentifier in interface PatientService
reason - reason for voiding patient identifier
Returns:
the voided patient identifier
Throws:
APIException
See Also:
PatientService.voidPatientIdentifier(org.openmrs.PatientIdentifier, java.lang.String)

savePatientIdentifier

public PatientIdentifier savePatientIdentifier(PatientIdentifier patientIdentifier)
                                        throws APIException
Description copied from interface: PatientService
Saved the given patientIndentifier to the database

Specified by:
savePatientIdentifier in interface PatientService
Returns:
patientIndentifier that was created or updated
Throws:
APIException
See Also:
PatientService.savePatientIdentifier(org.openmrs.PatientIdentifier)

purgePatientIdentifier

public void purgePatientIdentifier(PatientIdentifier patientIdentifier)
                            throws APIException
Description copied from interface: PatientService
Purge PatientIdentifier (cannot be undone)

Specified by:
purgePatientIdentifier in interface PatientService
Parameters:
patientIdentifier - PatientIdentifier to purge from the database
Throws:
APIException
See Also:
PatientService.purgePatientIdentifier(org.openmrs.PatientIdentifier)

getProblems

public java.util.List<Problem> getProblems(Person p)
                                    throws APIException
Description copied from interface: PatientService
Get a list of the problems for the patient, sorted on sort_weight

Specified by:
getProblems in interface PatientService
Parameters:
p - the Person
Returns:
sorted set based on the sort weight of the list items
Throws:
APIException
See Also:
org.openmrs.api.PatientService#getProblems(org.openmrs.api.Person)

getProblem

public Problem getProblem(java.lang.Integer problemListId)
                   throws APIException
Description copied from interface: PatientService
Returns the Problem

Specified by:
getProblem in interface PatientService
Returns:
the allergy
Throws:
APIException
See Also:
PatientService.getProblem(java.lang.Integer)

saveProblem

public void saveProblem(Problem problem)
                 throws APIException
Description copied from interface: PatientService
Creates a ProblemListItem to the Patient's Problem Active List. Sets the start date to now, if it is null. Sets the weight

Specified by:
saveProblem in interface PatientService
Parameters:
problem - the Problem
Throws:
APIException
See Also:
PatientService.saveProblem(org.openmrs.activelist.Problem)

removeProblem

public void removeProblem(Problem problem,
                          java.lang.String reason)
                   throws APIException
Description copied from interface: PatientService
Effectively removes the Problem from the Patient's Active List by setting the stop date to now, if null.

Specified by:
removeProblem in interface PatientService
Parameters:
problem - the Problem
reason - the reason of removing the problem
Throws:
APIException
See Also:
PatientService.removeProblem(org.openmrs.activelist.Problem, java.lang.String)

voidProblem

public void voidProblem(Problem problem,
                        java.lang.String reason)
                 throws APIException
Description copied from interface: PatientService
Used only in cases where the Problem was entered by error

Specified by:
voidProblem in interface PatientService
Throws:
APIException
See Also:
PatientService.voidProblem(org.openmrs.activelist.Problem, java.lang.String)

getAllergies

public java.util.List<Allergy> getAllergies(Person p)
                                     throws APIException
Description copied from interface: PatientService
Returns a sorted set of Allergies, sorted on sort_weight

Specified by:
getAllergies in interface PatientService
Parameters:
p - the Person
Returns:
sorted set based on the sort weight of the list items
Throws:
APIException
See Also:
org.openmrs.api.PatientService#getAllergies(org.openmrs.api.Person)

getAllergy

public Allergy getAllergy(java.lang.Integer allergyListId)
                   throws APIException
Description copied from interface: PatientService
Returns the Allergy

Specified by:
getAllergy in interface PatientService
Returns:
the allergy
Throws:
APIException
See Also:
PatientService.getAllergy(java.lang.Integer)

saveAllergy

public void saveAllergy(Allergy allergy)
                 throws APIException
Description copied from interface: PatientService
Creates an AllergyListItem to the Patient's Allergy Active List. Sets the start date to now, if it is null.

Specified by:
saveAllergy in interface PatientService
Parameters:
allergy - the Allergy
Throws:
APIException
See Also:
PatientService.saveAllergy(org.openmrs.activelist.Allergy)

removeAllergy

public void removeAllergy(Allergy allergy,
                          java.lang.String reason)
                   throws APIException
Description copied from interface: PatientService
Resolving the allergy, effectively removes the Allergy from the Patient's Active List by setting the stop date to now, if null.

Specified by:
removeAllergy in interface PatientService
Parameters:
allergy - the Allergy
reason - the reason of remove
Throws:
APIException
See Also:
PatientService.removeAllergy(org.openmrs.activelist.Allergy, java.lang.String)

voidAllergy

public void voidAllergy(Allergy allergy,
                        java.lang.String reason)
                 throws APIException
Description copied from interface: PatientService
Used only in cases where the Allergy was entered by error

Specified by:
voidAllergy in interface PatientService
Throws:
APIException
See Also:
PatientService.voidAllergy(org.openmrs.activelist.Allergy, java.lang.String)

OpenMRS-1.7.x

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