fixed SQL syntax
updated cohort definitions to use facility parameters
reordered queries to match indexes