Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/24/08 09:37:02 (3 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/ProgramWorkflowService.java

    r4158 r4358  
    3131import org.openmrs.api.db.ProgramWorkflowDAO; 
    3232import org.springframework.transaction.annotation.Transactional; 
    33  
     33import org.openmrs.annotation.Authorized; 
     34import org.openmrs.util.OpenmrsConstants; 
     35 
     36/** 
     37 * Contains methods pertaining to management of Programs, ProgramWorkflows, ProgramWorkflowStates, 
     38 * PatientPrograms, PatientStates, and ConceptStateConversions 
     39 *  
     40 * Use:<br/> 
     41 * <pre> 
     42 *   Program program = new Program(); 
     43 *   program.set___(___); 
     44 *   ...etc 
     45 *   Context.getProgramWorkflowService().saveProgram(program); 
     46 * </pre> 
     47 *  
     48 */ 
    3449@Transactional 
    35 public interface ProgramWorkflowService { 
    36  
     50public interface ProgramWorkflowService extends OpenmrsService { 
     51         
     52        /** 
     53         * Setter for the ProgramWorkflow DataAccessObject (DAO).  
     54         * The DAO is used for saving and retrieving from the database 
     55         * @param dao - The DAO for this service 
     56         */ 
    3757        public void setProgramWorkflowDAO(ProgramWorkflowDAO dao); 
    38  
     58         
     59        // ************************** 
     60        // PROGRAM 
     61        // ************************** 
     62 
     63    /** 
     64     * Save <code>program</code> to database (create if new or update if changed) 
     65     * @param program is the Program to be saved to the database 
     66     * @return The Program that was saved 
     67     * @throws APIException 
     68     */ 
     69    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     70    public Program saveProgram(Program program) throws APIException; 
     71         
     72    /** 
     73     * Returns a program given that programs primary key <code>programId</code> 
     74     * A null value is returned if no program exists with this programId. 
     75     * 
     76     * @param programId integer primary key of the program to find 
     77     * @returns Program object that has program.programId = <code>programId</code> passed in. 
     78     * @throws APIException 
     79     */ 
     80    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     81    @Transactional(readOnly=true) 
     82    public Program getProgram(Integer programId) throws APIException; 
     83     
     84    /** 
     85     * @deprecated use {@link #getProgramByName(String)} 
     86     */ 
     87    @Transactional(readOnly=true) 
     88        public Program getProgram(String name); 
     89 
     90    /** 
     91     * Returns a program given the program's exact <code>name</code> 
     92     * A null value is returned if there is no program with this name 
     93     * 
     94     * @param name the exact name of the program to match on 
     95     * @returns Program matching the <code>name</code> to Program.name 
     96     * @throws APIException 
     97     */ 
     98    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     99    @Transactional(readOnly=true) 
     100    public Program getProgramByName(String name) throws APIException; 
     101     
     102    /** 
     103     * Returns all programs, includes retired programs. 
     104     * This method delegates to the #getAllPrograms(boolean) method 
     105     * 
     106     * @returns List<Program> of all existing programs, including retired programs 
     107     * @throws APIException 
     108     */ 
     109    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     110    @Transactional(readOnly=true) 
     111    public List<Program> getAllPrograms() throws APIException; 
     112    
     113    /** 
     114     * Returns all programs 
     115     * @param includeRetired whether or not to include retired programs 
     116     * @return List<Program> all existing programs, including retired based on the input parameter 
     117     * @throws APIException 
     118     */ 
     119    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     120    @Transactional(readOnly=true) 
     121    public List<Program> getAllPrograms(boolean includeRetired) throws APIException; 
     122     
     123    /** 
     124     * Returns programs that match the given string. 
     125     * A null list will never be returned.  An empty list will be returned if there are no programs 
     126     * matching this <code>nameFragment</code> 
     127     * 
     128     * @param nameFragment is the string used to search for programs 
     129     * @return List<Program> - list of Programs whose name matches the input parameter 
     130     * @throws APIException 
     131     */ 
     132    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     133    @Transactional(readOnly=true) 
     134    public List<Program> getPrograms(String nameFragment) throws APIException; 
     135     
     136    /** 
     137     * Completely remove a program from the database (not reversible) 
     138     * This method delegates to #purgeProgram(program, boolean) method 
     139     * 
     140     * @param program the Program to clean out of the database. 
     141     * @throws APIException 
     142     */ 
     143    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     144    public void purgeProgram(Program program) throws APIException; 
     145 
     146    /** 
     147     * Completely remove a program from the database (not reversible) 
     148     * @param cascade <code>true</code> to delete related content 
     149     * @throws APIException 
     150     */ 
     151    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     152    public void purgeProgram(Program program, boolean cascade) throws APIException; 
     153     
     154    /** 
     155     * Retires the given program 
     156     * @param program program to be retired 
     157     * @Program the Program which has been retired 
     158     * @throws APIException 
     159     */ 
     160    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     161    public Program retireProgram(Program program) throws APIException; 
     162     
     163    /** 
     164     * Unretires the given program 
     165     * @param program program to be unretired 
     166     * @Program the Program which has been unretired 
     167     * @throws APIException 
     168     */ 
     169    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     170    public Program unRetireProgram(Program program) throws APIException; 
     171     
     172        // ************************** 
     173        // PATIENT PROGRAM  
     174        // ************************** 
     175 
     176    /** 
     177     * Save patientProgram to database (create if new or update if changed) 
     178     * @param patientProgram is the PatientProgram to be saved to the database 
     179     * @return PatientProgram - the saved PatientProgram 
     180     * @throws APIException 
     181     */ 
     182    @Authorized({OpenmrsConstants.PRIV_ADD_PATIENT_PROGRAMS, OpenmrsConstants.PRIV_EDIT_PATIENT_PROGRAMS}) 
     183    public PatientProgram savePatientProgram(PatientProgram patientProgram) throws APIException; 
     184         
     185    /** 
     186     * Returns a PatientProgram given that PatientPrograms primary key <code>patientProgramId</code> 
     187     * A null value is returned if no PatientProgram exists with this patientProgramId. 
     188     * 
     189     * @param patientProgramId integer primary key of the PatientProgram to find 
     190     * @returns PatientProgram object that has patientProgram.patientProgramId = <code>patientProgramId</code> passed in. 
     191     * @throws APIException 
     192     */ 
     193    @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     194    @Transactional(readOnly=true) 
     195    public PatientProgram getPatientProgram(Integer patientProgramId) throws APIException; 
     196    
     197    /** 
     198     * Returns PatientPrograms that match the input parameters.  If an input parameter is set to null, the parameter will not be used. 
     199     * Calling this method will all null parameters will return all PatientPrograms in the database 
     200     * A null list will never be returned.  An empty list will be returned if there are no programs matching the input criteria 
     201     * 
     202     * @param patient - if supplied all PatientPrograms returned will be for this Patient 
     203     * @param program - if supplied all PatientPrograms returned will be for this Program 
     204     * @param minEnrollmentDate - if supplied will limit PatientPrograms to those with enrollments on or after this Date 
     205     * @param maxEnrollmentDate - if supplied will limit PatientPrograms to those with enrollments on or before this Date 
     206     * @param minCompletionDate - if supplied will limit PatientPrograms to those completed on or after this Date OR not yet completed 
     207     * @param maxCompletionDate - if supplied will limit PatientPrograms to those completed on or before this Date 
     208     * @param includeVoided - if true, will also include voided PatientPrograms 
     209     * @return List<PatientProgram> of PatientPrograms that match the passed input parameters 
     210     * @throws APIException 
     211     */ 
     212    @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     213    @Transactional(readOnly=true) 
     214    public List<PatientProgram> getPatientPrograms(Patient patient, Program program, Date minEnrollmentDate, Date maxEnrollmentDate, Date minCompletionDate, Date maxCompletionDate, boolean includeVoided) throws APIException; 
     215     
     216    /** 
     217     * Completely remove a patientProgram from the database (not reversible) 
     218     * This method delegates to #purgePatientProgram(patientProgram, boolean) method 
     219     * 
     220     * @param patientProgram the PatientProgram to clean out of the database. 
     221     * @throws APIException 
     222     */ 
     223    @Authorized({OpenmrsConstants.PRIV_PURGE_PATIENT_PROGRAMS}) 
     224    public void purgePatientProgram(PatientProgram patientProgram) throws APIException; 
     225 
     226    /** 
     227     * Completely remove a patientProgram from the database (not reversible) 
     228     * @param patientProgram the PatientProgram to clean out of the database. 
     229     * @param cascade <code>true</code> to delete related content 
     230     * @throws APIException 
     231     */ 
     232    @Authorized({OpenmrsConstants.PRIV_PURGE_PATIENT_PROGRAMS}) 
     233    public void purgePatientProgram(PatientProgram patientProgram, boolean cascade) throws APIException; 
     234     
     235    /** 
     236     * Voids the given patientProgram 
     237     * @param patientProgram patientProgram to be voided 
     238     * @param reason is the reason why the patientProgram is being voided 
     239     * @return the voided PatientProgram 
     240     * @throws APIException 
     241     */ 
     242    @Authorized({OpenmrsConstants.PRIV_DELETE_PATIENT_PROGRAMS}) 
     243    public PatientProgram voidPatientProgram(PatientProgram patientProgram, String reason) throws APIException; 
     244   
     245    /** 
     246     * Unvoids the given patientProgram 
     247     * @param patientProgram patientProgram to be un-voided 
     248     * @return the voided PatientProgram 
     249     * @throws APIException 
     250     */ 
     251    @Authorized({OpenmrsConstants.PRIV_DELETE_PATIENT_PROGRAMS}) 
     252    public PatientProgram unvoidPatientProgram(PatientProgram patientProgram) throws APIException; 
     253 
     254        // ************************** 
     255        // CONCEPT STATE CONVERSION 
     256        // ************************** 
     257 
     258    /** 
     259     * Save ConceptStateConversion to database (create if new or update if changed) 
     260     * @param conceptStateConversion - The ConceptStateConversion to save 
     261     * @return ConceptStateConversion - The saved ConceptStateConversion 
     262     * @throws APIException 
     263     */ 
     264    @Authorized({OpenmrsConstants.PRIV_ADD_PATIENT_PROGRAMS, OpenmrsConstants.PRIV_EDIT_PATIENT_PROGRAMS}) 
     265    public ConceptStateConversion saveConceptStateConversion(ConceptStateConversion conceptStateConversion) throws APIException; 
     266     
     267    /** 
     268     * Returns a conceptStateConversion given that conceptStateConversions primary key <code>conceptStateConversionId</code> 
     269     * A null value is returned if no conceptStateConversion exists with this conceptStateConversionId. 
     270     * @param conceptStateConversionId integer primary key of the conceptStateConversion to find 
     271     * @returns ConceptStateConversion object that has conceptStateConversion.conceptStateConversionId = <code>conceptStateConversionId</code> passed in. 
     272     * @throws APIException 
     273     */ 
     274    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     275    @Transactional(readOnly=true) 
     276    public ConceptStateConversion getConceptStateConversion(Integer conceptStateConversionId) throws APIException; 
     277     
     278    /** 
     279     * Returns all conceptStateConversions 
     280     * @return List<ConceptStateConversion> of all ConceptStateConversions that exist 
     281     * @throws APIException 
     282     */ 
     283    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     284    @Transactional(readOnly=true) 
     285    public List<ConceptStateConversion> getAllConceptStateConversions() throws APIException; 
     286 
     287    /** 
     288     * Completely remove a conceptStateConversion from the database (not reversible) 
     289     * This method delegates to #purgeConceptStateConversion(conceptStateConversion, boolean) method 
     290     * @param conceptStateConversion the ConceptStateConversion to clean out of the database. 
     291     * @throws APIException 
     292     */ 
     293    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     294    public void purgeConceptStateConversion(ConceptStateConversion conceptStateConversion) throws APIException; 
     295 
     296    /** 
     297     * Completely remove a conceptStateConversion from the database (not reversible) 
     298     * @param conceptStateConversion the ConceptStateConversion to clean out of the database. 
     299     * @param cascade <code>true</code> to delete related content 
     300     * @throws APIException 
     301     */ 
     302    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     303    public void purgeConceptStateConversion(ConceptStateConversion conceptStateConversion, boolean cascade) throws APIException; 
     304     
     305    /** 
     306     * Triggers any ConceptStateConversion that exists for the passed <code>reasonForExit</code> concept 
     307     * and any ProgramWorkflow in the PatientPrograms for the <code>patient</code> 
     308     * @param patient - the Patient to trigger the ConceptStateConversion on 
     309     * @param reasonForExit - the Concept to trigger the ConceptStateConversion 
     310     * @param dateConverted - the Date of the ConceptStateConversion 
     311     * @throws APIException 
     312     */ 
     313        public void triggerStateConversion(Patient patient, Concept reasonForExit, Date dateConverted) throws APIException; 
     314         
     315    /** 
     316     * Retrieves the ConceptStateConversion that matches the passed <code>ProgramWorkflow</code> and <code>Concept</code> 
     317     * @param workflow - the ProgramWorkflow to check 
     318     * @param trigger - the Concept to check 
     319     * @return ConceptStateConversion that matches the passed <code>ProgramWorkflow</code> and <code>Concept</code> 
     320     * @throws APIException 
     321     */ 
    39322        @Transactional(readOnly=true) 
    40         public List<Program> getPrograms(); 
    41  
    42         public void createOrUpdateProgram(Program p); 
    43  
    44         @Transactional(readOnly=true) 
    45         public Program getProgram(Integer id); 
    46  
    47         @Transactional(readOnly=true) 
    48         public Program getProgram(String name); 
    49  
    50         public void retireProgram(Program p); 
    51  
    52         public void createWorkflow(ProgramWorkflow w); 
    53  
    54         @Transactional(readOnly=true) 
    55         public ProgramWorkflow getWorkflow(Integer id); 
    56  
    57         @Transactional(readOnly=true) 
    58         public ProgramWorkflow getWorkflow(Program program, String name); 
    59  
    60         public void updateWorkflow(ProgramWorkflow w); 
    61  
    62         public void voidWorkflow(ProgramWorkflow w, String reason); 
    63  
    64         @Transactional(readOnly=true) 
    65         public List<ProgramWorkflowState> getStates(); 
    66          
    67         @Transactional(readOnly=true) 
    68         public List<ProgramWorkflowState> getStates(boolean includeVoided); 
    69          
    70         @Transactional(readOnly=true) 
    71         public ProgramWorkflowState getState(Integer id); 
    72  
    73         @Transactional(readOnly=true) 
    74         public ProgramWorkflowState getState(ProgramWorkflow wf, String name); 
    75  
    76         public void createPatientProgram(PatientProgram p); 
    77  
    78         public void updatePatientProgram(PatientProgram p); 
    79  
    80         @Transactional(readOnly=true) 
    81         public PatientProgram getPatientProgram(Integer id); 
    82  
    83         @Transactional(readOnly=true) 
    84         public PatientState getPatientState(Integer id); 
    85  
    86         @Transactional(readOnly=true) 
    87         public Collection<PatientProgram> getPatientPrograms(Patient patient); 
    88          
    89         @Transactional(readOnly=true) 
    90         public List<PatientProgram> getPatientPrograms(Cohort cohort, Collection<Program> programs); 
    91  
    92         public void enrollPatientInProgram(Patient patient, Program program, 
    93                         Date enrollmentDate, Date completionDate, User creator); 
    94  
    95         public void voidPatientProgram(PatientProgram p, String reason); 
    96  
     323        public ConceptStateConversion getConceptStateConversion(ProgramWorkflow workflow, Concept trigger) throws APIException; 
     324         
     325        // ************************** 
     326        // DEPRECATED PROGRAM 
     327        // ************************** 
     328         
     329    /** 
     330     * Create a new program 
     331     * @param Program to create 
     332     * @throws APIException 
     333     * @deprecated use {@link #saveProgram(Program)} 
     334     */ 
     335    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     336    public void createOrUpdateProgram(Program program) throws APIException; 
     337     
     338    /** 
     339     * Returns all programs, includes retired programs. 
     340     * @return List<Program> of all existing programs 
     341     * @deprecated use {@link #getAllPrograms()} 
     342     * @throws APIException 
     343     */ 
     344    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     345    @Transactional(readOnly=true) 
     346        public List<Program> getPrograms() throws APIException; 
     347     
     348        // ************************** 
     349        // DEPRECATED PROGRAM WORKFLOW 
     350        // ************************** 
     351     
     352    /** 
     353     * Create a new programWorkflow 
     354     * @param programWorkflow - The ProgramWorkflow to create 
     355     * @deprecated use {@link Program#addWorkflow(ProgramWorkflow) followed by @link #saveProgram(Program)} 
     356     * @throws APIException 
     357     */ 
     358    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     359    public void createWorkflow(ProgramWorkflow programWorkflow) throws APIException; 
     360     
     361    /** 
     362     * Update a programWorkflow 
     363     * @param programWorkflow - The ProgramWorkflow to update 
     364     * @deprecated use {@link #saveProgram(Program) to save changes to all ProgramWorkflows for the given Program} 
     365     * @throws APIException 
     366     */ 
     367    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     368    public void updateWorkflow(ProgramWorkflow programWorkflow) throws APIException; 
     369                 
     370    /** 
     371     * Returns a programWorkflow given that programWorkflows primary key <code>programWorkflowId</code> 
     372     * @param Id integer primary key of the ProgramWorkflow to find 
     373     * @returns ProgramWorkflow object that has an id that matches the input parameter 
     374     * @deprecated ProgramWorkflows should not be retrieved directly, but rather through the programs they belong to: use {@link Program#getWorkflow(Integer)} 
     375     * @throws APIException 
     376     */ 
     377    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     378    @Transactional(readOnly=true) 
     379        public ProgramWorkflow getWorkflow(Integer id) throws APIException; 
     380         
     381    /** 
     382     * Returns a programWorkflow with the given name within the given Program 
     383     * @param program - The Program of the ProgramWorkflow to return 
     384     * @param name - The name of the ProgramWorkflow to return 
     385     * @return ProgramWorkflow - The ProgramWorkflow that matches the passed Program and name 
     386     * @deprecated use {@link Program#getWorkflowByName(String)} 
     387     * @throws APIException 
     388     */ 
     389    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     390    @Transactional(readOnly=true) 
     391    public ProgramWorkflow getWorkflow(Program program, String name) throws APIException; 
     392     
     393    /** 
     394     * Retires the given programWorkflow 
     395     * @param programWorkflow - The ProgramWorkflow to retire 
     396     * @param reason - The reason for retiring the ProgramWorkflow 
     397     * @deprecated use {@link ProgramWorkflow#setRetired(Boolean) followed by @link #saveProgram(Program)} 
     398     * @throws APIException 
     399     */ 
     400    @Authorized({OpenmrsConstants.PRIV_MANAGE_PROGRAMS}) 
     401    public void voidWorkflow(ProgramWorkflow programWorkflow, String reason) throws APIException; 
     402 
     403        // ************************** 
     404        // DEPRECATED PROGRAM WORKFLOW STATE 
     405        // ************************** 
     406 
     407    /** 
     408     * Returns all ProgramWorkflowStates 
     409     * @return List<ProgramWorkflowState> - all ProgramWorkflowStates that exist 
     410     * @deprecated ProgramWorkflowStates should be retrieved from the {@link ProgramWorkflow} they belong to  
     411     * @see {@link ProgramWorkflow#getStates()} 
     412     * @throws APIException 
     413     */ 
     414    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     415    @Transactional(readOnly=true) 
     416        public List<ProgramWorkflowState> getStates() throws APIException; 
     417     
     418    /** 
     419     * Returns all ProgramWorkflowStates 
     420     * @param includeVoided - if false, only returns non-voided ProgramWorkflowStates 
     421     * @return List<ProgramWorkflowState> - all ProgramWorkflowStates that exist, including voided based on the input parameter 
     422     * @deprecated ProgramWorkflowStates should be retrieved from the {@link ProgramWorkflow} they belong to  
     423     * @see {@link ProgramWorkflow#getStates(boolean)} 
     424     * @throws APIException 
     425     */ 
     426    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     427    @Transactional(readOnly=true) 
     428        public List<ProgramWorkflowState> getStates(boolean includeVoided) throws APIException; 
     429         
     430    /** 
     431     * Returns ProgramWorkflowState with the passed primary key id 
     432     * @param id - The primary key id of the ProgramWorkflowState to return 
     433     * @return ProgramWorkflowState - returns ProgramWorkflowState whose primary key id matches the passed id 
     434     * @deprecated ProgramWorkflowStates should be retrieved from the {@link ProgramWorkflow} they belong to  
     435     * @see {@link ProgramWorkflow#getState(Integer)} 
     436     * @throws APIException 
     437     */ 
     438    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     439    @Transactional(readOnly=true) 
     440        public ProgramWorkflowState getState(Integer id) throws APIException; 
     441     
     442    /** 
     443     * Returns ProgramWorkflowState with the passed <code>name</code> in the passed <code>programWorkflow</code> 
     444     * @param programWorkflow - The programWorkflow to check for ProgramWorkflowState 
     445     * @param name - the name of the programWorkflowState to look for 
     446     * @return ProgramWorkflowState - the ProgramWorkflowState with the passed <code>name</code> in the passed <code>programWorkflow</code> 
     447     * @deprecated ProgramWorkflowStates should be retrieved from the {@link ProgramWorkflow} they belong to  
     448     * @see {@link ProgramWorkflow#getStateByName(String)} 
     449     * @throws APIException 
     450     */ 
     451    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     452    @Transactional(readOnly=true) 
     453        public ProgramWorkflowState getState(ProgramWorkflow programWorkflow, String name) throws APIException; 
     454     
     455    /** 
     456     * Returns List of ProgramWorkflowStates that a patient is allowed to transition into given their current program 
     457     * @param patientProgram - the PatientProgram to retrieve possible next transitions from 
     458     * @param programWorkflow - the ProgramWorkflow to retrieve possible next transitions from 
     459     * @return List<ProgramWorkflowState> - returns List<ProgramWorkflowState> that a patient with the given PatientProgram and ProgramWorkflow is allowed to transition into 
     460     * @deprecated use {@link ProgramWorkflow#getPossibleNextStates(PatientProgram)} 
     461     * @throws APIException 
     462     */ 
     463    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     464    @Transactional(readOnly=true) 
     465        public List<ProgramWorkflowState> getPossibleNextStates(PatientProgram patientProgram, ProgramWorkflow workflow) throws APIException; 
     466 
     467    /** 
     468     * Returns boolean indicating whether it is legal to transition from one ProgramWorkflowState to another 
     469     * @param fromState - the ProgramWorkflowState to use as the state to check transitions from 
     470     * @param toState - the ProgramWorkflowState to use as the state to check transitions into from <code>fromState</code> 
     471     * @return boolean - returns true if a legal transition exists from <code>fromState</code> to <code>toState</code> 
     472     * @deprecated use {@link ProgramWorkflow#isLegalTransition(ProgramWorkflowState, ProgramWorkflowState)} 
     473     * @throws APIException 
     474     */ 
     475    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     476    @Transactional(readOnly=true) 
     477        public boolean isLegalTransition(ProgramWorkflowState fromState, ProgramWorkflowState toState) throws APIException; 
     478 
     479        // ************************** 
     480        // DEPRECATED PATIENT PROGRAM  
     481        // ************************** 
     482     
     483    /** 
     484     * Create a new patientProgram 
     485     * @param patientProgram - The PatientProgram to create 
     486     * @deprecated use {@link #savePatientProgram(PatientProgram)} 
     487     * @throws APIException 
     488     */ 
     489    @Authorized({OpenmrsConstants.PRIV_ADD_PATIENT_PROGRAMS}) 
     490    public void createPatientProgram(PatientProgram patientProgram) throws APIException; 
     491     
     492    /** 
     493     * Update a patientProgram 
     494     * @param patientProgram - The PatientProgram to update 
     495     * @deprecated use {@link #savePatientProgram(PatientProgram)} 
     496     * @throws APIException 
     497     */ 
     498    @Authorized({OpenmrsConstants.PRIV_EDIT_PATIENT_PROGRAMS}) 
     499    public void updatePatientProgram(PatientProgram patientProgram) throws APIException; 
     500         
     501    /** 
     502     * Create a new PatientProgram 
     503     * @param patient - The Patient to enroll 
     504     * @param program - The Program to enroll the <code>patient</code> into 
     505     * @param enrollmentDate - The Date to use as the enrollment date in the <code>program</code> for the <code>patient</code> 
     506     * @param completionDate - The Date to use as the completion date in the <code>program</code> for the <code>patient</code> 
     507     * @param creator - The User who is enrolling this <code>patient</code> 
     508     * @deprecated use {new PatientProgram(...) followed by @link #savePatientProgram(PatientProgram)} 
     509     * @throws APIException 
     510     */ 
     511    @Authorized({OpenmrsConstants.PRIV_ADD_PATIENT_PROGRAMS}) 
     512    public void enrollPatientInProgram(Patient patient, Program program, Date enrollmentDate, Date completionDate, User creator) throws APIException; 
     513  
     514    /** 
     515     * Returns a Collection<PatientProgram> of all PatientPrograms for the passed <code>patient</code> 
     516     * @param patient - The Patient to retrieve all PatientPrograms for 
     517     * @return Collection<PatientProgram> of all PatientPrograms for the passed <code>patient</code> 
     518     * @deprecated use {@link getPatientPrograms(Patient, Program, Date, Date, Date, Date)} 
     519     * @throws APIException 
     520     */ 
     521    @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     522    @Transactional(readOnly=true) 
     523        public Collection<PatientProgram> getPatientPrograms(Patient patient) throws APIException; 
     524     
     525    /** 
     526     * Get Collection<Integer> of PatientIds for patients who are enrolled in program between fromDate and toDate 
     527     * @param program - The Program to check for patient enrollment 
     528     * @param fromDate - Used to check whether patients were enrolled in the <code>program</code> on or after this Date 
     529     * @param toDate - Used to check whether patients were enrolled in the <code>program</code> on or before this Date 
     530     * @return Collection<Integer> containing all patientIds for patients who were enrolled in the <code>program</code> between <code>fromDate</code> and <code>toDate</code> 
     531     * @deprecated use {@link getPatientPrograms(Patient, Program, Date, Date, Date, Date)} which can be Iterated across to return collection of patient ids 
     532     * @throws APIException 
     533     */ 
     534    @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     535    @Transactional(readOnly=true) 
     536        public Collection<Integer> patientsInProgram(Program program, Date fromDate, Date toDate) throws APIException; 
     537     
     538    /** 
     539     * Get Collection of PatientPrograms for patients that are current as of the passed Date 
     540     * @param patient - The Patient to check for program enrollment 
     541     * @param onDate - Specifies only to return programs that the patient is in as of this Date 
     542     * @return Collection<PatientProgram> that contains all PatientPrograms are current for the <code>patient</code> as of <code>onDate</code> 
     543     * @deprecated use {@link getPatientPrograms(Patient, Program, Date, Date, Date, Date)} 
     544     * @throws APIException 
     545     */ 
     546    @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     547    @Transactional(readOnly=true) 
     548        public Collection<PatientProgram> getCurrentPrograms(Patient patient, Date onDate) throws APIException; 
     549     
     550    /** 
     551     * Return boolean indicating if Patient was enrolled into the Program between Date and Date 
     552     * @param patient - The Patient to check for enrollment 
     553     * @param program - The Program to check for enrollment 
     554     * @param fromDate - Used to check whether patients were enrolled in the <code>program</code> on or after this Date 
     555     * @param toDate - Used to check whether patients were enrolled in the <code>program</code> on or before this Date 
     556     * @return boolean - Returns true if the <code>patient</code> was enrolled in the <code>program</code> between <code>fromDate</code> and <code>toDate</code> 
     557     * @deprecated use {@link getPatientPrograms(Patient, Program, Date, Date, Date, Date)} 
     558     * @throws APIException 
     559     */ 
     560    @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     561    @Transactional(readOnly=true) 
     562        public boolean isInProgram(Patient patient, Program program, Date fromDate, Date toDate) throws APIException; 
     563 
     564        // ************************** 
     565        // DEPRECATED PATIENT STATE  
     566        // ************************** 
     567         
     568    /** 
     569     * Get a PatientState by patientStateId 
     570     * @see PatientProgram 
     571     * @param patientStateId - The primary key id of the PatientState to return 
     572     * @return The PatientState whose primary key id matches the input <code>patientStateId</code> 
     573     * @deprecated use {@link PatientProgram#getPatientState(Integer)} 
     574     * @throws APIException 
     575     */ 
     576    @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     577    @Transactional(readOnly=true) 
     578    public PatientState getPatientState(Integer patientStateId) throws APIException; 
     579         
     580    /** 
     581     * Get the most recent PatientState for a given PatientProgram and ProgramWorkflow 
     582     * @param patientProgram - The PatientProgram whose states to check 
     583     * @param programWorkflow - The ProgramWorkflow whose current state to check within the given <code>patientProgram</code> 
     584     * @return PatientState - The PatientState that is most recent for the <code>programWorkflow</code> within the given <code>patientProgram</code> 
     585     * @deprecated use {@link PatientProgram#getCurrentState(ProgramWorkflow)} 
     586     * @throws APIException 
     587     */ 
     588    @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     589    @Transactional(readOnly=true) 
     590    public PatientState getLatestState(PatientProgram patientProgram, ProgramWorkflow programWorkflow) throws APIException; 
     591 
     592    /** 
     593     * Returns a Set of current ProgramWorkflows for the given Patient 
     594     * @param patient - The Patient to check 
     595     * @return Set<ProgramWorkflow> containing all of the current ProgramWorkflows for the <code>patient</code> 
     596     * @deprecated No current use outside of this service.  Should be retrieved from Patient, PatientProgram, and PatientState 
     597     * @throws APIException 
     598     */ 
     599    @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     600    @Transactional(readOnly=true) 
     601        public Set<ProgramWorkflow> getCurrentWorkflowsByPatient(Patient patient) throws APIException; 
     602     
     603    /** 
     604     * Returns a Set of current ProgramWorkflows for the given PatientProgram 
     605     * @param program - The PatientProgram to check 
     606     * @return Set<ProgramWorkflow> containing all of the current ProgramWorkflows for the <code>program</code> 
     607     * @deprecated No current use outside of this service.  Should be retrieved from Patient, PatientProgram, and PatientState 
     608     * @throws APIException 
     609     */ 
     610    @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     611    @Transactional(readOnly=true) 
     612        public Set<ProgramWorkflow> getCurrentWorkflowsByPatientProgram(PatientProgram program) throws APIException; 
     613     
     614    /** 
     615     * Change the state of the passed PatientPrograms ProgramWorkflow to the passed ProgramWorkflowState on the passed Date  
     616     * @param patientProgram - The PatientProgram whose state you wish to change 
     617     * @param workflow - The ProgramWorkflow whose within the <code>patientProgram</code> whose state you wish to change 
     618     * @param state - The ProgramWorkflowState you wish to change the ProgramWorkflow to 
     619     * @param onDate - The Date that you wish the State change to take place 
     620     * @deprecated use {@link PatientProgram#transitionToState(ProgramWorkflowState, Date)} 
     621     * @throws APIException 
     622     */ 
     623    @Authorized({OpenmrsConstants.PRIV_ADD_PATIENT_PROGRAMS,OpenmrsConstants.PRIV_EDIT_PATIENT_PROGRAMS}) 
     624        public void changeToState(PatientProgram patientProgram, ProgramWorkflow workflow, ProgramWorkflowState state, Date onDate) throws APIException; 
     625         
    97626        /** 
    98          * @return patientIds of all patients who are enrolled in _program_ between _fromDate_ and _toDate_  
     627         * TODO: refactor? 
     628         *  
     629         * @param cohort 
     630         * @param programs 
     631         * @return 
    99632         */ 
    100633        @Transactional(readOnly=true) 
    101         public Collection<Integer> patientsInProgram(Program program, 
    102                         Date fromDate, Date toDate); 
    103  
    104         @Transactional(readOnly=true) 
    105         public Collection<PatientProgram> getCurrentPrograms(Patient patient, 
    106                         Date onDate); 
    107  
    108         // TODO: move this into Patient (probably make this a lazily-loaded hibernate mapping). 
    109         // This is just a quick implementation without changing any hibernate mappings 
    110         @Transactional(readOnly=true) 
    111         public PatientState getLatestState(PatientProgram patientProgram, 
    112                         ProgramWorkflow workflow); 
    113  
    114         @Transactional(readOnly=true) 
    115         public List<ProgramWorkflowState> getPossibleNextStates( 
    116                         PatientProgram patientProgram, ProgramWorkflow workflow); 
    117  
    118         // TODO: once we have a table of legal state transitions, then use that instead of this simple algorithm 
    119         @Transactional(readOnly=true) 
    120         public boolean isLegalTransition(ProgramWorkflowState fromState, 
    121                         ProgramWorkflowState toState); 
    122  
    123         public void changeToState(PatientProgram patientProgram, 
    124                         ProgramWorkflow wf, ProgramWorkflowState st, Date onDate); 
    125  
    126         /** 
    127          * Voids the last unvoided state in the given workflow, and clears the endDate of the next-to-last unvoided state.   
    128          * @param patientProgram 
    129          * @param wf 
    130          * @param voidReason 
    131          */ 
    132         public void voidLastState(PatientProgram patientProgram, 
    133                         ProgramWorkflow wf, String voidReason); 
    134  
    135         /** 
    136          * @return Returns true if _patient_ is enrolled in _program_ anytime between _fromDate_ and _toDate_. (null values for those dates mean beginning-of-time and end-of-time) 
    137          */ 
    138         @Transactional(readOnly=true) 
    139         public boolean isInProgram(Patient patient, Program program, Date fromDate, 
    140                         Date toDate); 
    141  
    142         public void createConceptStateConversion(ConceptStateConversion csc); 
    143  
    144         public void updateConceptStateConversion(ConceptStateConversion csc); 
    145  
    146         public void deleteConceptStateConversion(ConceptStateConversion csc); 
    147  
    148         @Transactional(readOnly=true) 
    149         public ConceptStateConversion getConceptStateConversion(Integer id); 
    150  
    151         @Transactional(readOnly=true) 
    152         public List<ConceptStateConversion> getAllConversions(); 
    153  
    154         public void triggerStateConversion(Patient patient, Concept reasonForExit, Date dateConverted); 
    155  
    156         @Transactional(readOnly=true) 
    157         public ConceptStateConversion getConceptStateConversion(ProgramWorkflow workflow, Concept trigger); 
    158  
    159         @Transactional(readOnly=true) 
    160         public Set<ProgramWorkflow> getCurrentWorkflowsByPatient(Patient patient); 
    161  
    162         @Transactional(readOnly=true) 
    163         public Set<ProgramWorkflow> getCurrentWorkflowsByPatientProgram(PatientProgram program); 
     634        @Authorized({OpenmrsConstants.PRIV_VIEW_PATIENT_PROGRAMS}) 
     635        public List<PatientProgram> getPatientPrograms(Cohort cohort, Collection<Program> programs); 
     636 
     637    /** 
     638     * Terminatate the passed PatientPrograms ProgramWorkflow to the passed ProgramWorkflowState on the passed Date  
     639     * @param patientProgram - The PatientProgram whose state you wish to change 
     640     * @param state - The ProgramWorkflowState you wish to change the ProgramWorkflow to 
     641     * @param onDate - The Date that you wish the State change to take place 
     642     * @deprecated use {@link PatientProgram#transitionToState(ProgramWorkflowState, Date)} 
     643     * @throws APIException 
     644     */ 
     645    @Authorized({OpenmrsConstants.PRIV_ADD_PATIENT_PROGRAMS,OpenmrsConstants.PRIV_EDIT_PATIENT_PROGRAMS}) 
     646        public void terminatePatientProgram(PatientProgram patientProgram, ProgramWorkflowState finalState, Date terminatedOn); 
     647     
     648    /** 
     649     * Voids the last non-voided ProgramWorkflowState in the given ProgramWorkflow for the given PatientProgram,  
     650     * and clears the endDate of the next-to-last non-voided state.  
     651     * @param patientProgram - The patientProgram to check 
     652     * @param wf - The ProgramWorkflow to check 
     653     * @param voidReason - The reason for voiding 
     654     * @deprecated use {@link PatientProgram#voidLastState(ProgramWorkflow, User, Date, String)} 
     655     * @throws APIException 
     656     */ 
     657    @Authorized({OpenmrsConstants.PRIV_EDIT_PATIENT_PROGRAMS}) 
     658        public void voidLastState(PatientProgram patientProgram, ProgramWorkflow wf, String voidReason) throws APIException; 
     659 
     660     
     661        // ************************** 
     662        // DEPRECATED CONCEPT STATE CONVERSION 
     663        // ************************** 
     664     
     665    /** 
     666     * Create a new ConceptStateConversion 
     667     * @param conceptStateConversion - The ConceptStateConversion to create 
     668     * @deprecated use {@link #saveConceptStateConversion(ConceptStateConversion)} 
     669     * @throws APIException 
     670     */ 
     671    @Authorized({OpenmrsConstants.PRIV_ADD_PATIENT_PROGRAMS}) 
     672    public void createConceptStateConversion(ConceptStateConversion conceptStateConversion) throws APIException; 
     673     
     674    /** 
     675     * Update a ConceptStateConversion 
     676     * @param conceptStateConversion - The ConceptStateConversion to update 
     677     * @deprecated use {@link #saveConceptStateConversion(ConceptStateConversion)} 
     678     * @throws APIException 
     679     */ 
     680    @Authorized({OpenmrsConstants.PRIV_EDIT_PATIENT_PROGRAMS}) 
     681    public void updateConceptStateConversion(ConceptStateConversion conceptStateConversion) throws APIException; 
     682     
     683     
     684    /** 
     685     * Returns all conceptStateConversions, includes retired conceptStateConversions. 
     686     * @return List<ConceptStateConversion> of all ConceptStateConversions that exist, including retired 
     687     * @see #getAllConceptStateConversions() 
     688     * @deprecated use {@link #getAllConceptStateConversions()} 
     689     * @throws APIException 
     690     */ 
     691    @Authorized({OpenmrsConstants.PRIV_VIEW_PROGRAMS}) 
     692    @Transactional(readOnly=true) 
     693        public List<ConceptStateConversion> getAllConversions() throws APIException; 
     694     
     695    /** 
     696     * Delete a ConceptStateConversion 
     697     * @param csc - The ConceptStateConversion to delete from the database 
     698     * @deprecated use {@link #purgeConceptStateConversion(ConceptStateConversion)} 
     699     * @throws APIException 
     700     */ 
     701    public void deleteConceptStateConversion(ConceptStateConversion csc) throws APIException; 
    164702}