OHDSI Home | Forums | Wiki | Github

{2 != 0} in the cohort definition SQL template

Hi I’m using the code in OHDSI/circe-be to load JSON and get the SQL statements.

Since the default dialect for the output is sqlserver, I added on more step that uses SqlTranslate.translateSql() function to translate into postresql.

When we try to run the SQL against our OMOP dataset, we noticed some parts has this type of annotation that looks like a conditional statement
{2 != 0}? { ... some statement ... }

For example see https://github.com/OHDSI/circe-be/blob/master/src/main/resources/resources/cohortdefinition/sql/generateCohort.sql#L32
(there are 2 more instances in this file with this annotation)

We had to remove this manually before running it against our OMOP dataset since it doesn’t look to be valid postgresql syntax.

It could be that I’m missing some option or config that perhaps will replace this stmt with something valid. If we use the cohort definition builder in ATLAS the SQL output doesn’t have this annotation.

I’m wondering if other people has come across this issue before.

You need to run renderSql() on the sql statement, so that it will evaluate that expression. The part you are showing is a case where it’s going to run inclusion rule logic (I assume you have 2 inclusion rules) and so that’s the reason for the statement.

Thank you! This works.

t