org.openmrs.api
Interface CohortService

All Superinterfaces:
OpenmrsService
All Known Implementing Classes:
CohortServiceImpl

@Transactional
public interface CohortService
extends OpenmrsService

API methods related to Cohorts and CohortDefinitions

See Also:
Cohort, CohortDefinition, CohortDefinitionProvider

Method Summary
 Cohort addPatientToCohort(Cohort cohort, Patient patient)
          Adds a new patient to a Cohort.
 Cohort createCohort(Cohort cohort)
          Deprecated. replaced by saveCohort(Cohort)
 Cohort evaluate(CohortDefinition definition, EvaluationContext evalContext)
          Deprecated. see reportingcompatibility module
 java.util.List<CohortDefinitionItemHolder> getAllCohortDefinitions()
          Deprecated. see reportingcompatibility module
 java.util.List<Cohort> getAllCohorts()
          Gets all Cohorts (not including voided ones)
 java.util.List<Cohort> getAllCohorts(boolean includeVoided)
          Gets all Cohorts, possibly including the voided ones
 CohortDefinition getAllPatientsCohortDefinition()
          Deprecated. see reportingcompatibility module
 Cohort getCohort(java.lang.Integer id)
          Gets a Cohort by its database primary key
 Cohort getCohort(java.lang.String name)
          Gets a non voided Cohort by its name
 Cohort getCohortByUuid(java.lang.String uuid)
          Get Cohort by its UUID
 CohortDefinition getCohortDefinition(java.lang.Class<CohortDefinition> clazz, java.lang.Integer id)
          Deprecated. see reportingcompatibility module
 CohortDefinition getCohortDefinition(java.lang.String cohortKey)
          Deprecated. see reportingcompatibility module
 java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> getCohortDefinitionProviders()
          Deprecated. see reportingcompatibility module
 java.util.List<CohortDefinitionItemHolder> getCohortDefinitions(java.lang.Class<? extends CohortDefinitionProvider> providerClass)
          Deprecated. see reportingcompatibility module
 java.util.List<Cohort> getCohorts()
          Deprecated. replaced by getAllCohorts()
 java.util.List<Cohort> getCohorts(java.lang.String nameFragment)
          Returns Cohorts whose names match the given string.
 java.util.List<Cohort> getCohortsContainingPatient(Patient patient)
          Find all Cohorts that contain the given patient.
 java.util.List<Cohort> getCohortsContainingPatientId(java.lang.Integer patientId)
          Find all Cohorts that contain the given patientId.
 Cohort purgeCohort(Cohort cohort)
          Completely removes a Cohort from the database (not reversible)
 void purgeCohortDefinition(CohortDefinition definition)
          Deprecated. see reportingcompatibility module
 void registerCohortDefinitionProvider(java.lang.Class<? extends CohortDefinition> cohortDefClass, CohortDefinitionProvider cohortDef)
          Deprecated. see reportingcompatibility module
 void removeCohortDefinitionProvider(java.lang.Class<? extends CohortDefinitionProvider> providerClass)
          Deprecated. see reportingcompatibility module
 Cohort removePatientFromCohort(Cohort cohort, Patient patient)
          Removes a patient from a Cohort.
 Cohort saveCohort(Cohort cohort)
          Save a cohort to the database (create if new, or update if changed) This method will throw an exception if any patientIds in the Cohort don't exist.
 CohortDefinition saveCohortDefinition(CohortDefinition definition)
          Deprecated. see reportingcompatibility module
 void setCohortDAO(CohortDAO dao)
          Sets the CohortDAO for this service to use
 void setCohortDefinitionProviders(java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> providerClassMap)
          Deprecated. see reportingcompatibility module
 Cohort updateCohort(Cohort cohort)
          Deprecated. replaced by saveCohort(Cohort)
 Cohort voidCohort(Cohort cohort, java.lang.String reason)
          Voids the given cohort, deleting it from the perspective of the typical end user.
 
Methods inherited from interface org.openmrs.api.OpenmrsService
onShutdown, onStartup
 

Method Detail

setCohortDAO

void setCohortDAO(CohortDAO dao)
Sets the CohortDAO for this service to use

Parameters:
dao -

saveCohort

@Authorized(value={"Add Cohorts","Edit Cohorts"})
Cohort saveCohort(Cohort cohort)
                  throws APIException
Save a cohort to the database (create if new, or update if changed) This method will throw an exception if any patientIds in the Cohort don't exist.

Parameters:
cohort - the cohort to be saved to the database
Returns:
The cohort that was passed in
Throws:
APIException
Expected behavior:
create new cohorts, update an existing cohort

createCohort

@Deprecated
@Authorized(value="Add Cohorts")
Cohort createCohort(Cohort cohort)
                    throws APIException
Deprecated. replaced by saveCohort(Cohort)

Throws:
APIException
See Also:
saveCohort(Cohort)

updateCohort

@Deprecated
@Authorized(value="Edit Cohorts")
Cohort updateCohort(Cohort cohort)
                    throws APIException
Deprecated. replaced by saveCohort(Cohort)

Throws:
APIException
See Also:
saveCohort(Cohort)

voidCohort

@Authorized(value="Delete Cohorts")
Cohort voidCohort(Cohort cohort,
                                  java.lang.String reason)
                  throws APIException
Voids the given cohort, deleting it from the perspective of the typical end user.

Parameters:
cohort - the cohort to delete
reason - the reason this cohort is being retired
Returns:
The cohort that was passed in
Throws:
APIException
Expected behavior:
fail with if reason is null or empty, void cohort, not change an already voided cohort

purgeCohort

Cohort purgeCohort(Cohort cohort)
                   throws APIException
Completely removes a Cohort from the database (not reversible)

Parameters:
cohort - the Cohort to completely remove from the database
Throws:
APIException
Expected behavior:
delete cohort from database

getCohort

@Transactional(readOnly=true)
@Authorized(value="View Patient Cohorts")
Cohort getCohort(java.lang.Integer id)
                 throws APIException
Gets a Cohort by its database primary key

Parameters:
id -
Returns:
the Cohort with the given primary key, or null if none exists
Throws:
APIException
Expected behavior:
get cohort by id

getCohort

@Authorized(value="View Patient Cohorts")
Cohort getCohort(java.lang.String name)
                 throws APIException
Gets a non voided Cohort by its name

Parameters:
name -
Returns:
the Cohort with the given name, or null if none exists
Throws:
APIException
Expected behavior:
get cohort given a name, get the nonvoided cohort if two exist with same name, only get non voided cohorts by name

getAllCohorts

@Authorized(value="View Patient Cohorts")
java.util.List<Cohort> getAllCohorts()
                                     throws APIException
Gets all Cohorts (not including voided ones)

Returns:
All Cohorts in the database (not including voided ones)
Throws:
APIException
Expected behavior:
get all cohorts in database, not return any voided cohorts

getAllCohorts

@Authorized(value="View Patient Cohorts")
java.util.List<Cohort> getAllCohorts(boolean includeVoided)
                                     throws APIException
Gets all Cohorts, possibly including the voided ones

Parameters:
includeVoided - whether or not to include voided Cohorts
Returns:
All Cohorts, maybe including the voided ones
Throws:
APIException
Expected behavior:
return all cohorts and voided

getCohorts

@Deprecated
@Authorized(value="View Patient Cohorts")
java.util.List<Cohort> getCohorts()
                                  throws APIException
Deprecated. replaced by getAllCohorts()

Throws:
APIException
See Also:
getAllCohorts()

getCohorts

java.util.List<Cohort> getCohorts(java.lang.String nameFragment)
                                  throws APIException
Returns Cohorts whose names match the given string. Returns an empty list in the case of no results. Returns all Cohorts in the case of null or empty input

Parameters:
nameFragment -
Returns:
list of cohorts matching the name fragment
Throws:
APIException
Expected behavior:
never return null, match cohorts by partial name

getCohortsContainingPatient

@Authorized(value="View Patient Cohorts")
java.util.List<Cohort> getCohortsContainingPatient(Patient patient)
                                                   throws APIException
Find all Cohorts that contain the given patient. (Not including voided Cohorts)

Parameters:
patient -
Returns:
All non-voided Cohorts that contain the given patient
Throws:
APIException
Expected behavior:
not return voided cohorts, return cohorts that have given patient

getCohortsContainingPatientId

@Authorized(value="View Patient Cohorts")
java.util.List<Cohort> getCohortsContainingPatientId(java.lang.Integer patientId)
                                                     throws APIException
Find all Cohorts that contain the given patientId. (Not including voided Cohorts)

Parameters:
patientId -
Returns:
All non-voided Cohorts that contain the given patientId
Throws:
APIException

addPatientToCohort

@Authorized(value="Edit Cohorts")
Cohort addPatientToCohort(Cohort cohort,
                                          Patient patient)
                          throws APIException
Adds a new patient to a Cohort. If the patient is not already in the Cohort, then they are added, and the Cohort is saved, marking it as changed.

Parameters:
cohort - the cohort to receive the given patient
patient - the patient to insert into the cohort
Returns:
The cohort that was passed in with the new patient in it
Throws:
APIException
Expected behavior:
add a patient and save the cohort, add a patient and insert the cohort to database, not fail if cohort already contains patient

removePatientFromCohort

@Authorized(value="Edit Cohorts")
Cohort removePatientFromCohort(Cohort cohort,
                                               Patient patient)
                               throws APIException
Removes a patient from a Cohort. If the patient is in the Cohort, then they are removed, and the Cohort is saved, marking it as changed.

Parameters:
cohort - the cohort containing the given patient
patient - the patient to remove from the given cohort
Returns:
The cohort that was passed in with the patient removed
Throws:
APIException
Expected behavior:
not fail if cohort doesn't contain patient, save cohort after removing patient

setCohortDefinitionProviders

@Transactional(readOnly=true)
@Deprecated
void setCohortDefinitionProviders(java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> providerClassMap)
                                  throws APIException
Deprecated. see reportingcompatibility module

Set the given CohortDefinitionProviders as the providers for this service. These are set via spring injection in /metadata/spring/applicationContext-service.xml . This method acts more like an "add" than a "set". All entries in the providerClassMap are added to the already set list of providers. This allows multiple Spring application context files to call this method with their own providers

Parameters:
providerClassMap - mapping from CohortDefinition to its provider
Throws:
APIException
Expected behavior:
not overwrite previously set providers if called twice

registerCohortDefinitionProvider

@Transactional(readOnly=true)
@Deprecated
void registerCohortDefinitionProvider(java.lang.Class<? extends CohortDefinition> cohortDefClass,
                                                               CohortDefinitionProvider cohortDef)
                                      throws APIException
Deprecated. see reportingcompatibility module

Adds the given cohort definition provider to this service's list of providers

Parameters:
cohortDefClass - the type of cohort definition that this provider works on
cohortDef - the provider
Throws:
APIException
Expected behavior:
overwrite provider if duplicate CcohortDefinition class

getCohortDefinitionProviders

@Transactional(readOnly=true)
@Deprecated
java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> getCohortDefinitionProviders()
                                                                                                                 throws APIException
Deprecated. see reportingcompatibility module

Gets all the providers registered to this service. Will return an empty list instead of null.

Returns:
this service's providers
Throws:
APIException
See Also:
setCohortDefinitionProviders(Map)
Expected behavior:
not return null if not providers have been set

removeCohortDefinitionProvider

@Transactional(readOnly=true)
@Deprecated
void removeCohortDefinitionProvider(java.lang.Class<? extends CohortDefinitionProvider> providerClass)
                                    throws APIException
Deprecated. see reportingcompatibility module

Removing any mapping from CohortDefinition to provider in this server where the given providerClass is the CohortDefinitionProvider

Parameters:
providerClass - the provider to remove
Throws:
APIException
Expected behavior:
not fail if providerClass not set

getAllCohortDefinitions

@Transactional(readOnly=true)
@Deprecated
java.util.List<CohortDefinitionItemHolder> getAllCohortDefinitions()
                                                                   throws APIException
Deprecated. see reportingcompatibility module

Get every cohort definition that every registered provider knows about. This is typically used for selection by an end user, and so a list of Holders are returned instead of a list of definitions so that the system knows which provider the definition came from

Returns:
a list of CohortDefinitionItemHolder defined
Throws:
APIException

getCohortDefinitions

@Transactional(readOnly=true)
@Deprecated
java.util.List<CohortDefinitionItemHolder> getCohortDefinitions(java.lang.Class<? extends CohortDefinitionProvider> providerClass)
                                                                throws APIException
Deprecated. see reportingcompatibility module

Throws:
APIException

getCohortDefinition

@Transactional(readOnly=true)
@Deprecated
CohortDefinition getCohortDefinition(java.lang.Class<CohortDefinition> clazz,
                                                              java.lang.Integer id)
                                     throws APIException
Deprecated. see reportingcompatibility module

Throws:
APIException

getCohortDefinition

@Transactional(readOnly=true)
@Deprecated
CohortDefinition getCohortDefinition(java.lang.String cohortKey)
                                     throws APIException
Deprecated. see reportingcompatibility module

Throws:
APIException

saveCohortDefinition

@Transactional(readOnly=true)
@Deprecated
CohortDefinition saveCohortDefinition(CohortDefinition definition)
                                      throws APIException
Deprecated. see reportingcompatibility module

Throws:
APIException

purgeCohortDefinition

@Transactional
@Deprecated
void purgeCohortDefinition(CohortDefinition definition)
                           throws APIException
Deprecated. see reportingcompatibility module

Throws:
APIException

evaluate

@Transactional(readOnly=true)
@Deprecated
Cohort evaluate(CohortDefinition definition,
                                         EvaluationContext evalContext)
                throws APIException
Deprecated. see reportingcompatibility module

TODO Auto generated method comment

Parameters:
definition -
evalContext -
Returns:
Cohort determined by the given CohortDefinition and EvaluationContext
Throws:
APIException
Expected behavior:
return all patients with blank patient search cohort definition provider

getAllPatientsCohortDefinition

@Transactional(readOnly=true)
@Deprecated
CohortDefinition getAllPatientsCohortDefinition()
                                                throws APIException
Deprecated. see reportingcompatibility module

Throws:
APIException

getCohortByUuid

@Transactional(readOnly=true)
@Authorized(value="View Patient Cohorts")
Cohort getCohortByUuid(java.lang.String uuid)
Get Cohort by its UUID

Parameters:
uuid -
Returns:
Expected behavior:
find object given valid uuid, return null if no object found with given uuid

OpenMRS-1.7.x

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