class HibernateDiagnosisDAO implements DiagnosisDAO {

	@SuppressWarnings("unchecked")
	@Override
	public List<Diagnosis> getActiveDiagnoses(Patient patient, Date fromDate) {
		String fromDateCriteria = "";
		if(fromDate != null){
			fromDateCriteria = " and d.dateCreated >= :fromDate ";
		}
		Query query = sessionFactory.getCurrentSession().createQuery(
			"from Diagnosis d where d.patient.patientId = :patientId and d.voided = false " 
				+ fromDateCriteria  
				+ " order by d.dateCreated desc");
		query.setInteger("patientId", patient.getId());
		if(fromDate != null){
			query.setDate("fromDate", fromDate);
		}
		return query.list();
	}

}