public interface CohortService extends OpenmrsService
Cohort
Modifier and Type | Method and Description |
---|---|
Cohort |
addPatientToCohort(Cohort cohort,
Patient patient)
Adds a new patient to a Cohort.
|
CohortMembership |
endCohortMembership(CohortMembership cohortMembership,
Date onDate)
Ends the specified CohortMembership i.e. sets its end date to the current date
|
List<Cohort> |
getAllCohorts()
Gets all Cohorts (not including voided ones)
|
List<Cohort> |
getAllCohorts(boolean includeVoided)
Gets all Cohorts, possibly including the voided ones
|
Cohort |
getCohort(Integer id)
Gets a Cohort by its database primary key
|
Cohort |
getCohort(String name)
Deprecated.
|
Cohort |
getCohortByName(String name)
Gets a non voided Cohort by its name
|
Cohort |
getCohortByUuid(String uuid)
Get Cohort by its UUID
|
CohortMembership |
getCohortMembershipByUuid(String uuid)
Get CohortMembership by its UUID
|
List<CohortMembership> |
getCohortMemberships(Integer patientId,
Date activeOnDate,
boolean includeVoided)
Gets memberships for the given patient, optionally active on a specific date
|
List<Cohort> |
getCohorts(String nameFragment)
Returns Cohorts whose names match the given string.
|
List<Cohort> |
getCohortsContainingPatient(Patient patient)
Deprecated.
use
getCohortsContainingPatientId(Integer)
Find all Cohorts that contain the given patient. (Not including voided Cohorts) |
List<Cohort> |
getCohortsContainingPatientId(Integer patientId)
Find all Cohorts that contain the given patientId right now.
|
void |
notifyPatientUnvoided(Patient patient,
User originallyVoidedBy,
Date originalDateVoided)
NOTE: CLIENT CODE SHOULD NEVER CALL THIS METHOD.
|
void |
notifyPatientVoided(Patient patient)
NOTE: CLIENT CODE SHOULD NEVER CALL THIS METHOD.
|
Cohort |
purgeCohort(Cohort cohort)
Completely removes a Cohort from the database (not reversible)
|
void |
purgeCohortMembership(CohortMembership cohortMembership)
Removes a CohortMembership from its parent Cohort
|
Cohort |
removePatientFromCohort(Cohort cohort,
Patient patient)
Deprecated.
since 2.1.0 you should explicitly call either
endCohortMembership(CohortMembership, Date) or voidCohortMembership(CohortMembership, String) |
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.
|
void |
setCohortDAO(CohortDAO dao)
Sets the CohortDAO for this service to use
|
Cohort |
voidCohort(Cohort cohort,
String reason)
Voids the given cohort, deleting it from the perspective of the typical end user.
|
CohortMembership |
voidCohortMembership(CohortMembership cohortMembership,
String reason)
Marks the specified CohortMembership as voided
|
onShutdown, onStartup
void setCohortDAO(CohortDAO dao)
dao
- @Authorized(value={"Add Cohorts","Edit Cohorts"}) Cohort saveCohort(Cohort cohort) throws APIException
cohort
- the cohort to be saved to the databaseAPIException
- Should create new cohorts
Should update an existing cohort@Authorized(value="Delete Cohorts") Cohort voidCohort(Cohort cohort, String reason) throws APIException
cohort
- the cohort to deletereason
- the reason this cohort is being retiredAPIException
- Should fail if reason is null
Should fail if reason is empty
Should void cohort
Should not change an already voided cohortCohort purgeCohort(Cohort cohort) throws APIException
cohort
- the Cohort to completely remove from the databaseAPIException
- Should delete cohort from database@Authorized(value="Get Patient Cohorts") Cohort getCohort(Integer id) throws APIException
id
- APIException
- Should get cohort by id@Authorized(value="Get Patient Cohorts") Cohort getCohortByName(String name) throws APIException
name
- APIException
- Should get cohort given a name
Should get the nonvoided cohort if two exist with same name
Should only get non voided cohorts by name@Deprecated @Authorized(value="Get Patient Cohorts") Cohort getCohort(String name) throws APIException
getCohortByName(String)
APIException
@Authorized(value="Get Patient Cohorts") List<Cohort> getAllCohorts() throws APIException
APIException
- Should get all nonvoided cohorts in database
Should not return any voided cohorts@Authorized(value="Get Patient Cohorts") List<Cohort> getAllCohorts(boolean includeVoided) throws APIException
includeVoided
- whether or not to include voided CohortsAPIException
- Should return all cohorts and voidedList<Cohort> getCohorts(String nameFragment) throws APIException
nameFragment
- APIException
- Should never return null
Should match cohorts by partial name@Deprecated @Authorized(value="Get Patient Cohorts") List<Cohort> getCohortsContainingPatient(Patient patient) throws APIException
getCohortsContainingPatientId(Integer)
Find all Cohorts that contain the given patient. (Not including voided Cohorts)patient
- patient used to find the cohortsAPIException
- Should not return voided cohorts
Should return cohorts that have given patient@Authorized(value="Get Patient Cohorts") List<Cohort> getCohortsContainingPatientId(Integer patientId) throws APIException
patientId
- patient id used to find the cohortsAPIException
@Authorized(value="Edit Cohorts") Cohort addPatientToCohort(Cohort cohort, Patient patient) throws APIException
cohort
- the cohort to receive the given patientpatient
- the patient to insert into the cohortAPIException
- Should add a patient and save the cohort
Should add a patient and insert the cohort to database
Should not fail if cohort already contains patient@Deprecated @Authorized(value="Edit Cohorts") Cohort removePatientFromCohort(Cohort cohort, Patient patient) throws APIException
endCohortMembership(CohortMembership, Date)
or voidCohortMembership(CohortMembership, String)
cohort
- the cohort containing the given patientpatient
- the patient to remove from the given cohortAPIException
- Should not fail if cohort doesn't contain patient
Should save cohort after removing patient@Authorized(value="Get Patient Cohorts") Cohort getCohortByUuid(String uuid)
uuid
- @Authorized(value="Get Patient Cohorts") CohortMembership getCohortMembershipByUuid(String uuid)
uuid
- @Authorized(value="Edit Cohorts") void purgeCohortMembership(CohortMembership cohortMembership)
cohortMembership
- membership that will be removed from cohort@Authorized(value="Edit Cohorts") CohortMembership voidCohortMembership(CohortMembership cohortMembership, String reason)
cohortMembership
- the CohortMembership to voidreason
- void reason@Authorized(value="Edit Cohorts") CohortMembership endCohortMembership(CohortMembership cohortMembership, Date onDate)
cohortMembership
- the CohortMembership to endonDate
- when to end the membership (optional, defaults to now)@Authorized(value="Edit Cohorts") void notifyPatientVoided(Patient patient)
patient
- patient that was voided
Should void the membership for the patient that was passed in@Authorized(value="Edit Cohorts") void notifyPatientUnvoided(Patient patient, User originallyVoidedBy, Date originalDateVoided)
patient
- patient that was unvoidedoriginallyVoidedBy
- originalDateVoided
- Should unvoid the membership for the patient that was passed in@Authorized(value="Get Patient Cohorts") List<CohortMembership> getCohortMemberships(Integer patientId, Date activeOnDate, boolean includeVoided)
patientId
- activeOnDate
- includeVoided
- Copyright © 2024 OpenMRS Inc.. All rights reserved.