From 4ee878eb08054e3ceb36695e6f1edb13cba7138c Mon Sep 17 00:00:00 2001 From: monilchheda Date: Sat, 9 Sep 2023 17:59:40 -0400 Subject: [PATCH] Add logic.json Add tests for basic logic operations AND, OR and NOT Add boolean logic test --- tests/content/logic.json | 98 ++++++++++++++++++++++++++++++++++++++++ tests/generate.test.js | 2 + 2 files changed, 100 insertions(+) create mode 100644 tests/content/logic.json diff --git a/tests/content/logic.json b/tests/content/logic.json new file mode 100644 index 0000000..f1859e4 --- /dev/null +++ b/tests/content/logic.json @@ -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" + } + ] + } + ] +} diff --git a/tests/generate.test.js b/tests/generate.test.js index 7f840e9..8472891 100644 --- a/tests/generate.test.js +++ b/tests/generate.test.js @@ -15,6 +15,7 @@ function validatePathToSubset(path) { 'EqualityExpression', 'AndExpression', 'OrExpression', + 'ParenthesizedTerm', 'Identifier', 'LiteralTerm', 'BooleanLiteral', @@ -39,6 +40,7 @@ function validatePathToSubset(path) { 'exists', 'where', 'empty', + 'not', 'ofType', 'lowBoundary', 'highBoundary',