Update buildCohorts to use new sql code

The sql code previously called by buildCohorts was based upon an older
version of CohortMethod.sql. It has now been updated to use the current
version. Furthermore, it is now compatible with the standard SqlRender
functions.