org.openmrs.api.impl
Class CohortServiceImpl

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

public class CohortServiceImpl
extends BaseOpenmrsService
implements CohortService

API functions related to Cohorts


Constructor Summary
CohortServiceImpl()
           
 
Method Summary
 Cohort addPatientToCohort(Cohort cohort, Patient patient)
          Adds a new patient to a Cohort.
 Cohort createCohort(Cohort cohort)
          Deprecated.  
 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 key)
          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 providerClass)
          Deprecated. see reportingcompatibility module
 java.util.List<Cohort> getCohorts()
          Deprecated.  
 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.
 void onShutdown()
          Clean up after this class.
 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> defClass, CohortDefinitionProvider cohortDefProvider)
          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.  
 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 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

CohortServiceImpl

public CohortServiceImpl()
Method Detail

setCohortDAO

public void setCohortDAO(CohortDAO dao)
Description copied from interface: CohortService
Sets the CohortDAO for this service to use

Specified by:
setCohortDAO in interface CohortService
See Also:
CohortService.setCohortDAO(org.openmrs.api.db.CohortDAO)

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()

saveCohort

public Cohort saveCohort(Cohort cohort)
                  throws APIException
Description copied from interface: CohortService
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.

Specified by:
saveCohort in interface CohortService
Parameters:
cohort - the cohort to be saved to the database
Returns:
The cohort that was passed in
Throws:
APIException
See Also:
CohortService.saveCohort(org.openmrs.Cohort)

createCohort

public Cohort createCohort(Cohort cohort)
Deprecated. 

Specified by:
createCohort in interface CohortService
See Also:
CohortService.createCohort(org.openmrs.Cohort)

getCohort

public Cohort getCohort(java.lang.Integer id)
Description copied from interface: CohortService
Gets a Cohort by its database primary key

Specified by:
getCohort in interface CohortService
Returns:
the Cohort with the given primary key, or null if none exists
See Also:
CohortService.getCohort(java.lang.Integer)

getCohorts

public java.util.List<Cohort> getCohorts()
Deprecated. 

Specified by:
getCohorts in interface CohortService
See Also:
CohortService.getCohorts()

voidCohort

public Cohort voidCohort(Cohort cohort,
                         java.lang.String reason)
Description copied from interface: CohortService
Voids the given cohort, deleting it from the perspective of the typical end user.

Specified by:
voidCohort in interface CohortService
Parameters:
cohort - the cohort to delete
reason - the reason this cohort is being retired
Returns:
The cohort that was passed in
See Also:
CohortService.voidCohort(org.openmrs.Cohort, java.lang.String)

getCohortByUuid

public Cohort getCohortByUuid(java.lang.String uuid)
Description copied from interface: CohortService
Get Cohort by its UUID

Specified by:
getCohortByUuid in interface CohortService
Returns:
See Also:
CohortService.getCohortByUuid(java.lang.String)

addPatientToCohort

public Cohort addPatientToCohort(Cohort cohort,
                                 Patient patient)
Description copied from interface: CohortService
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.

Specified by:
addPatientToCohort in interface CohortService
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
See Also:
CohortService.addPatientToCohort(org.openmrs.Cohort, org.openmrs.Patient)

removePatientFromCohort

public Cohort removePatientFromCohort(Cohort cohort,
                                      Patient patient)
Description copied from interface: CohortService
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.

Specified by:
removePatientFromCohort in interface CohortService
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
See Also:
CohortService.removePatientFromCohort(org.openmrs.Cohort, org.openmrs.Patient)

updateCohort

public Cohort updateCohort(Cohort cohort)
Deprecated. 

Specified by:
updateCohort in interface CohortService
See Also:
CohortService.updateCohort(org.openmrs.Cohort)

getCohortsContainingPatient

public java.util.List<Cohort> getCohortsContainingPatient(Patient patient)
Description copied from interface: CohortService
Find all Cohorts that contain the given patient. (Not including voided Cohorts)

Specified by:
getCohortsContainingPatient in interface CohortService
Returns:
All non-voided Cohorts that contain the given patient
See Also:
CohortService.getCohortsContainingPatient(org.openmrs.Patient)

getCohortsContainingPatientId

public java.util.List<Cohort> getCohortsContainingPatientId(java.lang.Integer patientId)
Description copied from interface: CohortService
Find all Cohorts that contain the given patientId. (Not including voided Cohorts)

Specified by:
getCohortsContainingPatientId in interface CohortService
Returns:
All non-voided Cohorts that contain the given patientId

getCohorts

public java.util.List<Cohort> getCohorts(java.lang.String nameFragment)
                                  throws APIException
Description copied from interface: CohortService
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

Specified by:
getCohorts in interface CohortService
Returns:
list of cohorts matching the name fragment
Throws:
APIException
See Also:
CohortService.getCohorts(java.lang.String)

getAllCohorts

public java.util.List<Cohort> getAllCohorts()
                                     throws APIException
Description copied from interface: CohortService
Gets all Cohorts (not including voided ones)

Specified by:
getAllCohorts in interface CohortService
Returns:
All Cohorts in the database (not including voided ones)
Throws:
APIException
See Also:
CohortService.getAllCohorts()

getAllCohorts

public java.util.List<Cohort> getAllCohorts(boolean includeVoided)
                                     throws APIException
Description copied from interface: CohortService
Gets all Cohorts, possibly including the voided ones

Specified by:
getAllCohorts in interface CohortService
Parameters:
includeVoided - whether or not to include voided Cohorts
Returns:
All Cohorts, maybe including the voided ones
Throws:
APIException
See Also:
CohortService.getAllCohorts(boolean)

getCohort

public Cohort getCohort(java.lang.String name)
                 throws APIException
Description copied from interface: CohortService
Gets a non voided Cohort by its name

Specified by:
getCohort in interface CohortService
Returns:
the Cohort with the given name, or null if none exists
Throws:
APIException
See Also:
CohortService.getCohort(java.lang.String)

purgeCohort

public Cohort purgeCohort(Cohort cohort)
                   throws APIException
Description copied from interface: CohortService
Completely removes a Cohort from the database (not reversible)

Specified by:
purgeCohort in interface CohortService
Parameters:
cohort - the Cohort to completely remove from the database
Throws:
APIException
See Also:
CohortService.purgeCohort(org.openmrs.Cohort)

evaluate

@Deprecated
public Cohort evaluate(CohortDefinition definition,
                                  EvaluationContext evalContext)
                throws APIException
Deprecated. see reportingcompatibility module

Description copied from interface: CohortService
TODO Auto generated method comment

Specified by:
evaluate in interface CohortService
Returns:
Cohort determined by the given CohortDefinition and EvaluationContext
Throws:
APIException
See Also:
CohortService.evaluate(org.openmrs.cohort.CohortDefinition, org.openmrs.report.EvaluationContext)

getAllPatientsCohortDefinition

@Deprecated
public CohortDefinition getAllPatientsCohortDefinition()
Deprecated. see reportingcompatibility module

Specified by:
getAllPatientsCohortDefinition in interface CohortService
See Also:
CohortService.getAllPatientsCohortDefinition()

getCohortDefinition

@Deprecated
public CohortDefinition getCohortDefinition(java.lang.Class<CohortDefinition> clazz,
                                                       java.lang.Integer id)
Deprecated. see reportingcompatibility module

Specified by:
getCohortDefinition in interface CohortService
See Also:
CohortService.getCohortDefinition(java.lang.Class, java.lang.Integer)

getCohortDefinition

@Deprecated
public CohortDefinition getCohortDefinition(java.lang.String key)
Deprecated. see reportingcompatibility module

Specified by:
getCohortDefinition in interface CohortService
See Also:
CohortService.getCohortDefinition(java.lang.String)

getAllCohortDefinitions

@Deprecated
public java.util.List<CohortDefinitionItemHolder> getAllCohortDefinitions()
Deprecated. see reportingcompatibility module

Description copied from interface: CohortService
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

Specified by:
getAllCohortDefinitions in interface CohortService
Returns:
a list of CohortDefinitionItemHolder defined
See Also:
CohortService.getAllCohortDefinitions()

purgeCohortDefinition

@Deprecated
public void purgeCohortDefinition(CohortDefinition definition)
Deprecated. see reportingcompatibility module

Specified by:
purgeCohortDefinition in interface CohortService
See Also:
CohortService.purgeCohortDefinition(org.openmrs.cohort.CohortDefinition)

setCohortDefinitionProviders

@Deprecated
public void setCohortDefinitionProviders(java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> providerClassMap)
Deprecated. see reportingcompatibility module

Description copied from interface: CohortService
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

Specified by:
setCohortDefinitionProviders in interface CohortService
Parameters:
providerClassMap - mapping from CohortDefinition to its provider
See Also:
CohortService.setCohortDefinitionProviders(Map)

getCohortDefinitionProviders

@Deprecated
public java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> getCohortDefinitionProviders()
Deprecated. see reportingcompatibility module

Description copied from interface: CohortService
Gets all the providers registered to this service. Will return an empty list instead of null.

Specified by:
getCohortDefinitionProviders in interface CohortService
Returns:
this service's providers
See Also:
CohortService.getCohortDefinitionProviders()

registerCohortDefinitionProvider

@Deprecated
public void registerCohortDefinitionProvider(java.lang.Class<? extends CohortDefinition> defClass,
                                                        CohortDefinitionProvider cohortDefProvider)
                                      throws APIException
Deprecated. see reportingcompatibility module

Description copied from interface: CohortService
Adds the given cohort definition provider to this service's list of providers

Specified by:
registerCohortDefinitionProvider in interface CohortService
Parameters:
defClass - the type of cohort definition that this provider works on
cohortDefProvider - the provider
Throws:
APIException
See Also:
CohortService.registerCohortDefinitionProvider(Class, CohortDefinitionProvider)

removeCohortDefinitionProvider

@Deprecated
public void removeCohortDefinitionProvider(java.lang.Class<? extends CohortDefinitionProvider> providerClass)
Deprecated. see reportingcompatibility module

Description copied from interface: CohortService
Removing any mapping from CohortDefinition to provider in this server where the given providerClass is the CohortDefinitionProvider

Specified by:
removeCohortDefinitionProvider in interface CohortService
Parameters:
providerClass - the provider to remove
See Also:
CohortService.removeCohortDefinitionProvider(java.lang.Class)

saveCohortDefinition

@Deprecated
public CohortDefinition saveCohortDefinition(CohortDefinition definition)
                                      throws APIException
Deprecated. see reportingcompatibility module

Specified by:
saveCohortDefinition in interface CohortService
Throws:
APIException
See Also:
CohortService.saveCohortDefinition(org.openmrs.cohort.CohortDefinition)

getCohortDefinitions

@Deprecated
public java.util.List<CohortDefinitionItemHolder> getCohortDefinitions(java.lang.Class providerClass)
Deprecated. see reportingcompatibility module

Specified by:
getCohortDefinitions in interface CohortService
See Also:
CohortService.getCohortDefinitions(java.lang.Class)

OpenMRS-1.7.x

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