org.openmrs
Class Cohort

java.lang.Object
  extended by org.openmrs.BaseOpenmrsObject
      extended by org.openmrs.BaseOpenmrsData
          extended by org.openmrs.Cohort
All Implemented Interfaces:
java.io.Serializable, Auditable, OpenmrsData, OpenmrsObject, Voidable

public class Cohort
extends BaseOpenmrsData
implements java.io.Serializable

This class represents a list of patientIds. If it is generated from a CohortDefinition via ReportService.evaluate(org.openmrs.report.ReportSchema, Cohort, EvaluationContext) then it will contain a link back to the CohortDefinition it came from and the EvalutionContext that definition was evaluated in.

See Also:
CohortDefinition, Serialized Form

Field Summary
static long serialVersionUID
           
 
Fields inherited from class org.openmrs.BaseOpenmrsData
creator
 
Constructor Summary
Cohort()
           
Cohort(java.util.Collection patientsOrIds)
          This constructor does not check whether the database contains patients with the given ids, but
Cohort(java.lang.Integer cohortId)
          Convenience constructor to create a Cohort object that has an primarykey/internal identifier of cohortId
Cohort(java.lang.String commaSeparatedIds)
          Convenience contructor taking in a string that is a list of comma separated patient ids This constructor does not check whether the database contains patients with the given ids, but
Cohort(java.lang.String name, java.lang.String description, java.util.Collection patientsOrIds)
          This constructor does not check whether the database contains patients with the given ids, but
Cohort(java.lang.String name, java.lang.String description, java.lang.Integer[] ids)
          This constructor does not check whether the database contains patients with the given ids, but
Cohort(java.lang.String name, java.lang.String description, Patient[] patients)
          This constructor does not check whether the database contains patients with the given ids, but
 
Method Summary
 void addMember(java.lang.Integer memberId)
           
 boolean contains(java.lang.Integer patientId)
           
 boolean contains(Patient patient)
           
 boolean equals(java.lang.Object obj)
           
 CohortDefinition getCohortDefinition()
          Deprecated. 
 java.lang.Integer getCohortId()
           
 java.lang.String getCommaSeparatedPatientIds()
           
 java.lang.String getDescription()
           
 EvaluationContext getEvaluationContext()
          Deprecated. 
 java.lang.Integer getId()
           
 java.util.Set<java.lang.Integer> getMemberIds()
           
 java.lang.String getName()
           
 java.util.Set<java.lang.Integer> getPatientIds()
          Deprecated. use #getMemberIds()
 int getSize()
           
 int hashCode()
           
static Cohort intersect(Cohort a, Cohort b)
          Returns the intersection of two cohorts
 boolean isEmpty()
           
 void removeMember(java.lang.Integer memberId)
           
 void setCohortDefinition(CohortDefinition cohortDefinition)
          Deprecated. 
 void setCohortId(java.lang.Integer cohortId)
           
 void setDescription(java.lang.String description)
           
 void setEvaluationContext(EvaluationContext evaluationContext)
          Deprecated. 
 void setId(java.lang.Integer id)
           
 void setMemberIds(java.util.Set<java.lang.Integer> memberIds)
           
 void setName(java.lang.String name)
           
 int size()
           
static Cohort subtract(Cohort a, Cohort b)
          Subtracts a cohort from a cohort
 java.lang.String toString()
           
static Cohort union(Cohort a, Cohort b)
          Returns the union of two cohorts
 
Methods inherited from class org.openmrs.BaseOpenmrsData
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateVoided, getVoided, getVoidedBy, getVoidReason, isVoided, setChangedBy, setCreator, setDateChanged, setDateCreated, setDateVoided, setVoided, setVoidedBy, setVoidReason
 
Methods inherited from class org.openmrs.BaseOpenmrsObject
getUuid, setUuid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openmrs.OpenmrsObject
getUuid, setUuid
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

Cohort

public Cohort()

Cohort

public Cohort(java.lang.Integer cohortId)
Convenience constructor to create a Cohort object that has an primarykey/internal identifier of cohortId

Parameters:
cohortId - the internal identifier for this cohort

Cohort

public Cohort(java.lang.String name,
              java.lang.String description,
              java.lang.Integer[] ids)
This constructor does not check whether the database contains patients with the given ids, but

Parameters:
name -
description - optional description
ids - option array of Integer ids
See Also:
will.

Cohort

public Cohort(java.lang.String name,
              java.lang.String description,
              Patient[] patients)
This constructor does not check whether the database contains patients with the given ids, but

Parameters:
name -
description - optional description
patients - optional array of patients
See Also:
will.

Cohort

public Cohort(java.util.Collection patientsOrIds)
This constructor does not check whether the database contains patients with the given ids, but

Parameters:
patientsOrIds - optional collection which may contain Patients, or patientIds which may be Integers, Strings, or anything whose toString() can be parsed to an Integer.
See Also:
will.

Cohort

public Cohort(java.lang.String name,
              java.lang.String description,
              java.util.Collection patientsOrIds)
This constructor does not check whether the database contains patients with the given ids, but

Parameters:
name -
description - optional description
patientsOrIds - optional collection which may contain Patients, or patientIds which may be Integers, Strings, or anything whose toString() can be parsed to an Integer.
See Also:
will.

Cohort

public Cohort(java.lang.String commaSeparatedIds)
Convenience contructor taking in a string that is a list of comma separated patient ids This constructor does not check whether the database contains patients with the given ids, but

Parameters:
commaSeparatedIds -
See Also:
will.
Method Detail

getCommaSeparatedPatientIds

public java.lang.String getCommaSeparatedPatientIds()
Returns:
Returns a comma-separated list of patient ids in the cohort.

contains

public boolean contains(Patient patient)

contains

public boolean contains(java.lang.Integer patientId)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

addMember

public void addMember(java.lang.Integer memberId)

removeMember

public void removeMember(java.lang.Integer memberId)

size

public int size()

getSize

public int getSize()

isEmpty

public boolean isEmpty()

union

public static Cohort union(Cohort a,
                           Cohort b)
Returns the union of two cohorts

Parameters:
a - The first Cohort
b - The second Cohort
Returns:
Cohort

intersect

public static Cohort intersect(Cohort a,
                               Cohort b)
Returns the intersection of two cohorts

Parameters:
a - The first Cohort
b - The second Cohort
Returns:
Cohort

subtract

public static Cohort subtract(Cohort a,
                              Cohort b)
Subtracts a cohort from a cohort

Parameters:
a - the original Cohort
b - the Cohort to subtract
Returns:
Cohort

getCohortId

public java.lang.Integer getCohortId()

setCohortId

public void setCohortId(java.lang.Integer cohortId)

getDescription

public java.lang.String getDescription()

setDescription

public void setDescription(java.lang.String description)

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getMemberIds

public java.util.Set<java.lang.Integer> getMemberIds()

getPatientIds

public java.util.Set<java.lang.Integer> getPatientIds()
Deprecated. use #getMemberIds()

This method is only here for some backwards compatibility with the PatientSet object that this Cohort object replaced. Do not use this method.

Returns:
the memberIds

setMemberIds

public void setMemberIds(java.util.Set<java.lang.Integer> memberIds)

getCohortDefinition

@Deprecated
public CohortDefinition getCohortDefinition()
Deprecated. 

Returns:
the cohortDefinition

setCohortDefinition

@Deprecated
public void setCohortDefinition(CohortDefinition cohortDefinition)
Deprecated. 

Parameters:
cohortDefinition - the cohortDefinition to set

getEvaluationContext

@Deprecated
public EvaluationContext getEvaluationContext()
Deprecated. 

Returns:
the evaluationContext

setEvaluationContext

@Deprecated
public void setEvaluationContext(EvaluationContext evaluationContext)
Deprecated. 

Parameters:
evaluationContext - the evaluationContext to set

getId

public java.lang.Integer getId()
Specified by:
getId in interface OpenmrsObject
Returns:
id - The unique Identifier for the object
Since:
1.5
See Also:
OpenmrsObject.getId()

setId

public void setId(java.lang.Integer id)
Specified by:
setId in interface OpenmrsObject
Parameters:
id - - The unique Identifier for the object
Since:
1.5
See Also:
OpenmrsObject.setId(java.lang.Integer)

OpenMRS-1.7.x

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