org.openmrs.api
Interface CohortService

All Superinterfaces:
OpenmrsService
All Known Implementing Classes:
CohortServiceImpl

public interface CohortService
extends OpenmrsService

API methods related to Cohorts and CohortDefinitions A Cohort is a list of patient ids. A CohortDefinition is a search strategy which can be used to arrive at a cohort.

See Also:
Cohort, CohortDefinition, org.openmrs.api.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)
           
 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<? extends CohortDefinitionProvider> providerClass)
           
 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)
           
 void registerCohortDefinitionProvider(java.lang.Class<? extends CohortDefinition> cohortDefClass, CohortDefinitionProvider cohortDef)
          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)
          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

createCohort

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

Throws:
APIException
See Also:
saveCohort(Cohort)

updateCohort

@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

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

getCohort

@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

getCohort

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

Parameters:
name -
Returns:
the Cohort with the given name, or null if none exists
Throws:
APIException

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

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

getCohorts

@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:
Throws:
APIException

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

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 -
patient -
Returns:
The cohort that was passed in
Throws:
APIException

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 -
patient -
Returns:
The cohort that was passed in
Throws:
APIException

setCohortDefinitionProviders

@Transactional(readOnly=true)
void setCohortDefinitionProviders(java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> providerClassMap)
Set the given CohortDefinitionProviders as the providers for this service. These are set via spring injection in /metadata/spring/applicationContext-service.xml

Parameters:
providerClassMap -

registerCohortDefinitionProvider

@Transactional(readOnly=true)
void registerCohortDefinitionProvider(java.lang.Class<? extends CohortDefinition> cohortDefClass,
                                                    CohortDefinitionProvider cohortDef)
                                      throws APIException
Adds the given cohort definition to this service's providers

Parameters:
cohortDefClass -
cohortDef -
Throws:
APIException

getCohortDefinitionProviders

@Transactional(readOnly=true)
java.util.Map<java.lang.Class<? extends CohortDefinition>,CohortDefinitionProvider> getCohortDefinitionProviders()
Gets all the providers registered to this service

Returns:
this service's providers
See Also:
setCohortDefinitionProviders(Map)

removeCohortDefinitionProvider

@Transactional(readOnly=true)
void removeCohortDefinitionProvider(java.lang.Class<? extends CohortDefinitionProvider> providerClass)

getAllCohortDefinitions

@Transactional(readOnly=true)
java.util.List<CohortDefinition> getAllCohortDefinitions()

getCohortDefinitions

@Transactional(readOnly=true)
java.util.List<CohortDefinition> getCohortDefinitions(java.lang.Class<? extends CohortDefinitionProvider> providerClass)

getCohortDefinition

@Transactional(readOnly=true)
CohortDefinition getCohortDefinition(java.lang.Class<CohortDefinition> clazz,
                                                   java.lang.Integer id)

saveCohortDefinition

@Transactional(readOnly=true)
CohortDefinition saveCohortDefinition(CohortDefinition definition)

purgeCohortDefinition

@Transactional
void purgeCohortDefinition(CohortDefinition definition)

evaluate

@Transactional(readOnly=true)
Cohort evaluate(CohortDefinition definition,
                              EvaluationContext evalContext)

getAllPatientsCohortDefinition

@Transactional(readOnly=true)
CohortDefinition getAllPatientsCohortDefinition()

OpenMRS-trunk

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