Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/09/08 10:53:35 (2 months ago)
Author:
bwolfe
Message:

Merging report-api-refactoring to trunk [2696]:[4157]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/trunk/src/api/org/openmrs/api/db/hibernate/HibernateProgramWorkflowDAO.java

    r4095 r4158  
    2929import org.hibernate.criterion.Order; 
    3030import org.hibernate.criterion.Restrictions; 
     31import org.openmrs.Cohort; 
    3132import org.openmrs.Concept; 
    3233import org.openmrs.ConceptStateConversion; 
     
    128129        } 
    129130         
     131    public List<PatientProgram> getPatientPrograms(Cohort cohort, Collection<Program> programs) { 
     132                String hql = "from PatientProgram "; 
     133                if (cohort != null || programs != null) 
     134                        hql += "where "; 
     135                if (cohort != null) 
     136                        hql += "patient.patientId in (:patientIds) "; 
     137                if (programs != null) { 
     138                        if (cohort != null) 
     139                                hql += "and "; 
     140                        hql += " program in (:programs)"; 
     141                } 
     142                hql += " order by patient.patientId, dateEnrolled"; 
     143                Query query = sessionFactory.getCurrentSession().createQuery(hql); 
     144                if (cohort != null) 
     145                        query.setParameterList("patientIds", cohort.getMemberIds()); 
     146                if (programs != null) 
     147                        query.setParameterList("programs", programs); 
     148                return query.list(); 
     149    } 
     150 
    130151        public ProgramWorkflow getWorkflow(Integer id) { 
    131152                return (ProgramWorkflow) sessionFactory.getCurrentSession().get(ProgramWorkflow.class, id);