Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch/convert between comparisons in patients.categorised_as/satifying expression #803

Open
rebkwok opened this issue May 13, 2022 · 0 comments

Comments

@rebkwok
Copy link
Contributor

rebkwok commented May 13, 2022

In a patients.satifsying expression (and by extension, patients.categorised_as), this is invalid:

patients.satisfying("20 < age < 50")

However, the study definition checks don't catch it.

cohortextractor.expressions.is_allowed checks for allowed tokens, but doesn't catch this one because the individual tokens are allowed.

The last attempt to validate (cohortextractor.expressions.validate_expression) by turning it into an SQL expression by replacing names with empty value (in this case 0) and executing a SELECT on it doesn't fail. (SELECT (20 < 0 < 50) doesn't raise any errors).

However, when executed on actual data, it fails with a SQL syntax error, which means that errors aren't raised to the user until they try to run the study against a real backend (see this thread for a real example.

We should either:

  • turn that expression into one that works (age > 20 AND age < 50)
    OR
  • check for expressions of that format and raise a validation error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant