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)
           
 Cohort evaluate(CohortDefinition definition, EvaluationContext evalContext)
           
 java.util.List<CohortDefinition> getAllCohortDefinitions()
           
 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()
           
 Cohort getCohort(java.lang.Integer id)
          Gets a Cohort by its database primary key
 Cohort getCohort(java.lang.String name)
          Gets a Cohort by its name
 CohortDefinition getCohortDefinition(java.lang.Class<CohortDefinition> clazz, java.lang.Integer id)
           
 java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> getCohortDefinitionProviders()
          Gets all the providers registered to this service
 java.util.List<CohortDefinition> getCohortDefinitions(java.lang.Class providerClass)
           
 java.util.List<Cohort> getCohorts()
           
 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)
           
 void registerCohortDefinitionProvider(java.lang.Class<? extends CohortDefinition> defClass, CohortDefinitionProvider cohortDefProvider)
          Adds the given cohort definition to this service's providers
 void removeCohortDefinitionProvider(java.lang.Class<? extends CohortDefinitionProvider> providerClass)
           
 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)
           
 void setCohortDAO(CohortDAO dao)
          Sets the CohortDAO for this service to use
 void setCohortDefinitionProviders(java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> providerClassMap)
          Set the given CohortDefinitionProviders as the providers for this service.
 Cohort updateCohort(Cohort 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 class org.openmrs.api.impl.BaseOpenmrsService
onShutdown, 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
onShutdown, 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)

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

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
Returns:
The cohort that was passed in
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
Returns:
The cohort that was passed in
See Also:
CohortService.removePatientFromCohort(org.openmrs.Cohort, org.openmrs.Patient)

updateCohort

public Cohort updateCohort(Cohort cohort)
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:
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 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

public Cohort evaluate(CohortDefinition definition,
                       EvaluationContext evalContext)
                throws APIException
Specified by:
evaluate in interface CohortService
Throws:
APIException
See Also:
CohortService.evaluate(org.openmrs.cohort.CohortDefinition, org.openmrs.report.EvaluationContext)

getAllPatientsCohortDefinition

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

getCohortDefinition

public CohortDefinition getCohortDefinition(java.lang.Class<CohortDefinition> clazz,
                                            java.lang.Integer id)
Specified by:
getCohortDefinition in interface CohortService
See Also:
CohortService.getCohortDefinition(java.lang.Class, java.lang.Integer)

getAllCohortDefinitions

public java.util.List<CohortDefinition> getAllCohortDefinitions()
Specified by:
getAllCohortDefinitions in interface CohortService
See Also:
org.openmrs.api.CohortService#getCohortDefinitions()

purgeCohortDefinition

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

setCohortDefinitionProviders

public void setCohortDefinitionProviders(java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> providerClassMap)
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

Specified by:
setCohortDefinitionProviders in interface CohortService
See Also:
CohortService.setCohortDefinitionProviders(Map)

getCohortDefinitionProviders

public java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> getCohortDefinitionProviders()
Description copied from interface: CohortService
Gets all the providers registered to this service

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

registerCohortDefinitionProvider

public void registerCohortDefinitionProvider(java.lang.Class<? extends CohortDefinition> defClass,
                                             CohortDefinitionProvider cohortDefProvider)
                                      throws APIException
Description copied from interface: CohortService
Adds the given cohort definition to this service's providers

Specified by:
registerCohortDefinitionProvider in interface CohortService
Throws:
APIException
See Also:
org.openmrs.api.CohortService#registerCohortDefinitionProvider(java.lang.Class, org.openmrs.api.CohortDefinitionService)

removeCohortDefinitionProvider

public void removeCohortDefinitionProvider(java.lang.Class<? extends CohortDefinitionProvider> providerClass)
Specified by:
removeCohortDefinitionProvider in interface CohortService
See Also:
CohortService.removeCohortDefinitionProvider(java.lang.Class)

saveCohortDefinition

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

getCohortDefinitions

public java.util.List<CohortDefinition> getCohortDefinitions(java.lang.Class providerClass)
Specified by:
getCohortDefinitions in interface CohortService
See Also:
CohortService.getCohortDefinitions(java.lang.Class)

OpenMRS-trunk

Generated May 29 2008 02:01 AM. NOTE - these libraries are in active development and subject to change