class HibernateConceptDAO implements ConceptDAO {

	@Override
	@SuppressWarnings("unchecked")
	public List<Drug> getDrugs(String drugName, Concept concept, boolean includeRetired) throws DAOException {
		Criteria searchCriteria = sessionFactory.getCurrentSession().createCriteria(Drug.class, "drug");
		if (!includeRetired) {
			searchCriteria.add(Restrictions.eq("drug.retired", false));
		}
		if (concept != null) {
			searchCriteria.add(Restrictions.eq("drug.concept", concept));
		}
		if (drugName != null) {
			SimpleExpression eq = Restrictions.eq("drug.name", drugName);
			if (Context.getAdministrationService().isDatabaseStringComparisonCaseSensitive()) {
				eq = eq.ignoreCase();
			}
			searchCriteria.add(eq);
		}
		return (List<Drug>) searchCriteria.list();
	}

}