Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/24/08 14:37:02 (8 months ago)
Author:
bwolfe
Message:

Merging api-refactoring to trunk [3595]:[4355]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/trunk/src/api/org/openmrs/api/CohortService.java

    r4158 r4358  
    1919import org.openmrs.Cohort; 
    2020import org.openmrs.Patient; 
     21import org.openmrs.annotation.Authorized; 
    2122import org.openmrs.api.db.CohortDAO; 
     23import org.openmrs.util.OpenmrsConstants; 
    2224import org.openmrs.cohort.CohortDefinition; 
    2325import org.openmrs.cohort.CohortDefinitionProvider; 
     
    3335 * @see org.openmrs.api.CohortDefinitionProvider 
    3436 */ 
    35 @Transactional 
    36 public interface CohortService { 
    37          
     37public interface CohortService extends OpenmrsService { 
     38         
     39        /** 
     40         * Sets the CohortDAO for this service to use  
     41         *  
     42         * @param dao 
     43         */ 
    3844        public void setCohortDAO(CohortDAO dao); 
    3945         
    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; 
    63190         
    64191        /** 
     
    94221        @Transactional(readOnly=true) 
    95222        public void removeCohortDefinitionProvider(Class<? extends CohortDefinitionProvider> providerClass); 
    96  
     223         
    97224        @Transactional(readOnly=true) 
    98225        public List<CohortDefinition> getAllCohortDefinitions(); 
     
    100227        @Transactional(readOnly=true) 
    101228        public List<CohortDefinition> getCohortDefinitions(Class<? extends CohortDefinitionProvider> providerClass); 
    102  
     229         
    103230        @Transactional(readOnly=true) 
    104231        public CohortDefinition getCohortDefinition(Class<CohortDefinition> clazz, Integer id); 
     
    112239        @Transactional(readOnly=true) 
    113240        public Cohort evaluate(CohortDefinition definition, EvaluationContext evalContext); 
    114  
     241         
    115242        @Transactional(readOnly=true) 
    116243        public CohortDefinition getAllPatientsCohortDefinition();