| | 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 | |
|---|