Skip to content

Commit

Permalink
Add logic.json
Browse files Browse the repository at this point in the history
Add tests for basic logic operations AND, OR and NOT

Add boolean logic test
  • Loading branch information
monilchheda authored and jmandel committed Oct 24, 2023
1 parent 3adbdf2 commit 4ee878e
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
98 changes: 98 additions & 0 deletions tests/content/logic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"title": "logic",
"resources": [
{
"resourceType": "Patient",
"id": "m0",
"gender": "male",
"deceasedBoolean": false
},
{
"resourceType": "Patient",
"id": "f0",
"deceasedBoolean": false,
"gender": "female"
},
{
"resourceType": "Patient",
"id": "m1",
"gender": "male",
"deceasedBoolean": true
},
{
"resourceType": "Patient",
"id": "f1",
"gender": "female"
}
],
"tests": [
{
"title": "filtering with 'and'",
"view": {
"resource": "Patient",
"where": [{"path": "gender = 'male' and deceased.ofType(boolean) = false"}],
"select": [{
"column": [
{
"path": "id",
"name": "id"
}
]
}]
},
"expect": [
{
"id": "m0"
}
]
},
{
"title": "filtering with 'or'",
"view": {
"resource": "Patient",
"where": [{"path": "gender = 'male' or deceased.ofType(boolean) = false"}],
"select": [{
"column": [
{
"path": "id",
"name": "id"
}
]
}]
},
"expect": [
{
"id": "m0"
},
{
"id": "m1"
},{
"id": "f0"
}
]
},
{
"title": "filtering with 'not'",
"view": {
"resource": "Patient",
"where": [{"path": "(gender = 'male').not()"}],
"select": [{
"column": [
{
"path": "id",
"name": "id"
}
]
}]
},
"expect": [
{
"id": "f0"
},
{
"id": "f1"
}
]
}
]
}
2 changes: 2 additions & 0 deletions tests/generate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function validatePathToSubset(path) {
'EqualityExpression',
'AndExpression',
'OrExpression',
'ParenthesizedTerm',
'Identifier',
'LiteralTerm',
'BooleanLiteral',
Expand All @@ -39,6 +40,7 @@ function validatePathToSubset(path) {
'exists',
'where',
'empty',
'not',
'ofType',
'lowBoundary',
'highBoundary',
Expand Down

0 comments on commit 4ee878e

Please sign in to comment.