| 40 | | public void createCohort(Cohort cohort); |
|---|
| 41 | | |
|---|
| 42 | | public void updateCohort(Cohort cohort); |
|---|
| 43 | | |
|---|
| 44 | | public void voidCohort(Cohort cohort, String reason); |
|---|
| 45 | | |
|---|
| 46 | | @Transactional(readOnly=true) |
|---|
| 47 | | public Cohort getCohort(Integer id); |
|---|
| 48 | | |
|---|
| 49 | | @Transactional(readOnly=true) |
|---|
| 50 | | public List<Cohort> getCohorts(); |
|---|
| 51 | | |
|---|
| 52 | | @Transactional(readOnly=true) |
|---|
| 53 | | public List<Cohort> getCohortsContainingPatient(Patient patient); |
|---|
| 54 | | |
|---|
| 55 | | @Transactional(readOnly=true) |
|---|
| 56 | | public List<Cohort> getCohortsContainingPatientId(Integer patientId); |
|---|
| 57 | | |
|---|
| 58 | | @Transactional |
|---|
| 59 | | public void addPatientToCohort(Cohort cohort, Patient patient); |
|---|
| 60 | | |
|---|
| 61 | | @Transactional |
|---|
| 62 | | public void removePatientFromCohort(Cohort cohort, Patient patient); |
|---|
| | 46 | /** |
|---|
| | 47 | * Save a cohort to the database (create if new, or update if changed) |
|---|
| | 48 | * This method will throw an exception if any patientIds in the Cohort don't exist. |
|---|
| | 49 | * |
|---|
| | 50 | * @param cohort the cohort to be saved to the database |
|---|
| | 51 | * @return The cohort that was passed in |
|---|
| | 52 | * @throws APIException |
|---|
| | 53 | */ |
|---|
| | 54 | @Authorized({OpenmrsConstants.PRIV_ADD_COHORTS, OpenmrsConstants.PRIV_EDIT_COHORTS}) |
|---|
| | 55 | public Cohort saveCohort(Cohort cohort) throws APIException; |
|---|
| | 56 | |
|---|
| | 57 | /** |
|---|
| | 58 | * @see #saveCohort(Cohort) |
|---|
| | 59 | * @deprecated replaced by saveCohort(Cohort) |
|---|
| | 60 | */ |
|---|
| | 61 | @Authorized({OpenmrsConstants.PRIV_ADD_COHORTS}) |
|---|
| | 62 | public Cohort createCohort(Cohort cohort) throws APIException; |
|---|
| | 63 | |
|---|
| | 64 | /** |
|---|
| | 65 | * @see #saveCohort(Cohort) |
|---|
| | 66 | * @deprecated replaced by saveCohort(Cohort) |
|---|
| | 67 | */ |
|---|
| | 68 | @Authorized({OpenmrsConstants.PRIV_EDIT_COHORTS}) |
|---|
| | 69 | public Cohort updateCohort(Cohort cohort) throws APIException; |
|---|
| | 70 | |
|---|
| | 71 | /** |
|---|
| | 72 | * Voids the given cohort, deleting it from the perspective of the typical end user. |
|---|
| | 73 | * |
|---|
| | 74 | * @param cohort the cohort to delete |
|---|
| | 75 | * @param reason the reason this cohort is being retired |
|---|
| | 76 | * @return The cohort that was passed in |
|---|
| | 77 | * @throws APIException |
|---|
| | 78 | */ |
|---|
| | 79 | @Authorized({OpenmrsConstants.PRIV_DELETE_COHORTS}) |
|---|
| | 80 | public Cohort voidCohort(Cohort cohort, String reason) throws APIException; |
|---|
| | 81 | |
|---|
| | 82 | /** |
|---|
| | 83 | * Completely removes a Cohort from the database (not reversible) |
|---|
| | 84 | * |
|---|
| | 85 | * @param cohort the Cohort to completely remove from the database |
|---|
| | 86 | * @throws APIException |
|---|
| | 87 | */ |
|---|
| | 88 | public Cohort purgeCohort(Cohort cohort) throws APIException; |
|---|
| | 89 | |
|---|
| | 90 | /** |
|---|
| | 91 | * Gets a Cohort by its database primary key |
|---|
| | 92 | * |
|---|
| | 93 | * @param id |
|---|
| | 94 | * @return the Cohort with the given primary key, or null if none exists |
|---|
| | 95 | * @throws APIException |
|---|
| | 96 | */ |
|---|
| | 97 | @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_COHORTS}) |
|---|
| | 98 | public Cohort getCohort(Integer id) throws APIException; |
|---|
| | 99 | |
|---|
| | 100 | /** |
|---|
| | 101 | * Gets a Cohort by its name |
|---|
| | 102 | * |
|---|
| | 103 | * @param name |
|---|
| | 104 | * @return the Cohort with the given name, or null if none exists |
|---|
| | 105 | * @throws APIException |
|---|
| | 106 | */ |
|---|
| | 107 | @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_COHORTS}) |
|---|
| | 108 | public Cohort getCohort(String name) throws APIException; |
|---|
| | 109 | |
|---|
| | 110 | /** |
|---|
| | 111 | * Gets all Cohorts (not including voided ones) |
|---|
| | 112 | * |
|---|
| | 113 | * @return All Cohorts in the database (not including voided ones) |
|---|
| | 114 | * @throws APIException |
|---|
| | 115 | */ |
|---|
| | 116 | @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_COHORTS}) |
|---|
| | 117 | public List<Cohort> getAllCohorts() throws APIException; |
|---|
| | 118 | |
|---|
| | 119 | /** |
|---|
| | 120 | * Gets all Cohorts, possibly including the voided ones |
|---|
| | 121 | * |
|---|
| | 122 | * @param includeVoided whether or not to include voided Cohorts |
|---|
| | 123 | * @return All Cohorts, maybe including the voided ones |
|---|
| | 124 | * @throws APIException |
|---|
| | 125 | */ |
|---|
| | 126 | @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_COHORTS}) |
|---|
| | 127 | public List<Cohort> getAllCohorts(boolean includeVoided) throws APIException; |
|---|
| | 128 | |
|---|
| | 129 | /** |
|---|
| | 130 | * @see #getAllCohorts() |
|---|
| | 131 | * @deprecated replaced by getAllCohorts() |
|---|
| | 132 | */ |
|---|
| | 133 | @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_COHORTS}) |
|---|
| | 134 | public List<Cohort> getCohorts() throws APIException; |
|---|
| | 135 | |
|---|
| | 136 | /** |
|---|
| | 137 | * Returns Cohorts whose names match the given string. |
|---|
| | 138 | * Returns an empty list in the case of no results. |
|---|
| | 139 | * Returns all Cohorts in the case of null or empty input |
|---|
| | 140 | * |
|---|
| | 141 | * @param nameFragment |
|---|
| | 142 | * @return |
|---|
| | 143 | * @throws APIException |
|---|
| | 144 | */ |
|---|
| | 145 | public List<Cohort> getCohorts(String nameFragment) throws APIException; |
|---|
| | 146 | |
|---|
| | 147 | /** |
|---|
| | 148 | * Find all Cohorts that contain the given patient. (Not including voided Cohorts) |
|---|
| | 149 | * |
|---|
| | 150 | * @param patient |
|---|
| | 151 | * @return All non-voided Cohorts that contain the given patient |
|---|
| | 152 | * @throws APIException |
|---|
| | 153 | */ |
|---|
| | 154 | @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_COHORTS}) |
|---|
| | 155 | public List<Cohort> getCohortsContainingPatient(Patient patient) throws APIException; |
|---|
| | 156 | |
|---|
| | 157 | /** |
|---|
| | 158 | * Find all Cohorts that contain the given patientId. (Not including voided Cohorts) |
|---|
| | 159 | * |
|---|
| | 160 | * @param patientId |
|---|
| | 161 | * @return All non-voided Cohorts that contain the given patientId |
|---|
| | 162 | * @throws APIException |
|---|
| | 163 | */ |
|---|
| | 164 | @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_COHORTS}) |
|---|
| | 165 | public List<Cohort> getCohortsContainingPatientId(Integer patientId) throws APIException; |
|---|
| | 166 | |
|---|
| | 167 | /** |
|---|
| | 168 | * Adds a new patient to a Cohort. |
|---|
| | 169 | * If the patient is not already in the Cohort, then they are added, and the Cohort is saved, marking it as changed. |
|---|
| | 170 | * |
|---|
| | 171 | * @param cohort |
|---|
| | 172 | * @param patient |
|---|
| | 173 | * @return The cohort that was passed in |
|---|
| | 174 | * @throws APIException |
|---|
| | 175 | */ |
|---|
| | 176 | @Authorized({OpenmrsConstants.PRIV_EDIT_COHORTS}) |
|---|
| | 177 | public Cohort addPatientToCohort(Cohort cohort, Patient patient) throws APIException; |
|---|
| | 178 | |
|---|
| | 179 | /** |
|---|
| | 180 | * Removes a patient from a Cohort. |
|---|
| | 181 | * If the patient is in the Cohort, then they are removed, and the Cohort is saved, marking it as changed. |
|---|
| | 182 | * |
|---|
| | 183 | * @param cohort |
|---|
| | 184 | * @param patient |
|---|
| | 185 | * @return The cohort that was passed in |
|---|
| | 186 | * @throws APIException |
|---|
| | 187 | */ |
|---|
| | 188 | @Authorized({OpenmrsConstants.PRIV_EDIT_COHORTS}) |
|---|
| | 189 | public Cohort removePatientFromCohort(Cohort cohort, Patient patient) throws APIException; |
|---|