@Transactional public class CohortServiceImpl extends BaseOpenmrsService implements CohortService
Constructor and Description |
---|
CohortServiceImpl() |
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) |
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) |
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)
Removes a patient from a Cohort, by voiding their membership.
|
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onShutdown, onStartup
public void setCohortDAO(CohortDAO dao)
CohortService
setCohortDAO
in interface CohortService
CohortService.setCohortDAO(org.openmrs.api.db.CohortDAO)
public Cohort saveCohort(Cohort cohort) throws APIException
CohortService
saveCohort
in interface CohortService
cohort
- the cohort to be saved to the databaseAPIException
- Should create new cohorts
Should update an existing cohortCohortService.saveCohort(org.openmrs.Cohort)
@Transactional(readOnly=true) public Cohort getCohort(Integer id)
CohortService
getCohort
in interface CohortService
CohortService.getCohort(java.lang.Integer)
public Cohort voidCohort(Cohort cohort, String reason)
CohortService
voidCohort
in interface CohortService
cohort
- the cohort to deletereason
- the reason this cohort is being retiredCohortService.voidCohort(org.openmrs.Cohort, java.lang.String)
@Transactional(readOnly=true) public Cohort getCohortByUuid(String uuid)
CohortService
getCohortByUuid
in interface CohortService
CohortService.getCohortByUuid(java.lang.String)
@Transactional(readOnly=true) public CohortMembership getCohortMembershipByUuid(String uuid)
CohortService
getCohortMembershipByUuid
in interface CohortService
CohortService.getCohortMembershipByUuid(java.lang.String)
public Cohort addPatientToCohort(Cohort cohort, Patient patient)
CohortService
addPatientToCohort
in interface CohortService
cohort
- the cohort to receive the given patientpatient
- the patient to insert into the cohortCohortService.addPatientToCohort(org.openmrs.Cohort,
org.openmrs.Patient)
public Cohort removePatientFromCohort(Cohort cohort, Patient patient)
CohortService
removePatientFromCohort
in interface CohortService
cohort
- the cohort containing the given patientpatient
- the patient to remove from the given cohortCohortService.removePatientFromCohort(org.openmrs.Cohort,
org.openmrs.Patient)
@Transactional(readOnly=true) public List<Cohort> getCohortsContainingPatient(Patient patient)
getCohortsContainingPatient
in interface CohortService
patient
- patient used to find the cohorts@Transactional(readOnly=true) public List<Cohort> getCohortsContainingPatientId(Integer patientId)
CohortService
getCohortsContainingPatientId
in interface CohortService
patientId
- patient id used to find the cohorts@Transactional(readOnly=true) public List<Cohort> getCohorts(String nameFragment) throws APIException
CohortService
getCohorts
in interface CohortService
APIException
- Should never return null
Should match cohorts by partial nameCohortService.getCohorts(java.lang.String)
@Transactional(readOnly=true) public List<Cohort> getAllCohorts() throws APIException
CohortService
getAllCohorts
in interface CohortService
APIException
- Should get all nonvoided cohorts in database
Should not return any voided cohortsCohortService.getAllCohorts()
@Transactional(readOnly=true) public List<Cohort> getAllCohorts(boolean includeVoided) throws APIException
CohortService
getAllCohorts
in interface CohortService
includeVoided
- whether or not to include voided CohortsAPIException
- Should return all cohorts and voidedCohortService.getAllCohorts(boolean)
@Transactional(readOnly=true) public Cohort getCohortByName(String name) throws APIException
CohortService
getCohortByName
in interface CohortService
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 nameCohortService.getCohortByName(java.lang.String)
@Transactional(readOnly=true) public Cohort getCohort(String name) throws APIException
getCohort
in interface CohortService
APIException
CohortService.getCohort(java.lang.String)
public Cohort purgeCohort(Cohort cohort) throws APIException
CohortService
purgeCohort
in interface CohortService
cohort
- the Cohort to completely remove from the databaseAPIException
- Should delete cohort from databaseCohortService.purgeCohort(org.openmrs.Cohort)
public void purgeCohortMembership(CohortMembership cohortMembership) throws APIException
CohortService
purgeCohortMembership
in interface CohortService
cohortMembership
- membership that will be removed from cohortAPIException
CohortService.purgeCohortMembership(CohortMembership)
public CohortMembership voidCohortMembership(CohortMembership cohortMembership, String reason)
CohortService
voidCohortMembership
in interface CohortService
cohortMembership
- the CohortMembership to voidreason
- void reasonCohortService.voidCohortMembership(CohortMembership, String)
public CohortMembership endCohortMembership(CohortMembership cohortMembership, Date onDate)
CohortService
endCohortMembership
in interface CohortService
cohortMembership
- the CohortMembership to endonDate
- when to end the membership (optional, defaults to now)CohortService.endCohortMembership(CohortMembership, Date)
public void notifyPatientVoided(Patient patient) throws APIException
CohortService
notifyPatientVoided
in interface CohortService
patient
- patient that was voided
Should void the membership for the patient that was passed inAPIException
CohortService.notifyPatientVoided(org.openmrs.Patient)
public void notifyPatientUnvoided(Patient patient, User originallyVoidedBy, Date originalDateVoided) throws APIException
CohortService
notifyPatientUnvoided
in interface CohortService
patient
- patient that was unvoidedoriginalDateVoided
- Should unvoid the membership for the patient that was passed inAPIException
CohortService.notifyPatientUnvoided(Patient, User, Date)
public List<CohortMembership> getCohortMemberships(Integer patientId, Date activeOnDate, boolean includeVoided)
CohortService
getCohortMemberships
in interface CohortService
Copyright © 2024 OpenMRS Inc.. All rights reserved.