From 58a3f4ae75ee2a0aa2aaa999f885407fc444bef1 Mon Sep 17 00:00:00 2001 From: Bashir Sadjad Date: Wed, 8 May 2024 23:30:27 -0400 Subject: [PATCH] Added fhirVersion to tests and fixed test_report.json (#236) --- README.md | 86 +++++++++++++++++++----------------- tests/basic.json | 5 +++ tests/collection.json | 5 +++ tests/combinations.json | 4 ++ tests/constant.json | 4 ++ tests/fhirpath.json | 4 ++ tests/fhirpath_numbers.json | 4 ++ tests/fn_boundary.json | 4 ++ tests/fn_empty.json | 5 +++ tests/fn_extension.json | 4 ++ tests/fn_first.json | 5 +++ tests/fn_join.json | 4 ++ tests/fn_oftype.json | 4 ++ tests/fn_reference_keys.json | 5 +++ tests/foreach.json | 5 +++ tests/logic.json | 4 ++ tests/union.json | 5 +++ tests/validate.json | 5 +++ tests/view_resource.json | 5 +++ tests/where.json | 4 ++ 20 files changed, 130 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 19d2539..ecd3b53 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,10 @@ components of a test case file are: - **Description** (`description` attribute): A detailed explanation of what the test case aims to validate, including any relevant context or specifications that the test is based on. +- **FHIR version**: A list of FHIR version strings like `['4.0.1', '5.0.0']`. + This applies to all FHIR resources in the test suite. The version numbers come + from [this ValueSet](https://hl7.org/fhir/R5/valueset-FHIR-version.html) and + can only include "Release" versions. - **Fixtures** (`resources` attribute): A set of FHIR resources that serve as input data for the test. These fixtures are essential for setting up the test environment and conditions. @@ -83,26 +87,27 @@ Below is an abstract representation of what a test case file might look like: ```js { // unique name of test - title: 'title', - description: '...', + 'title': 'title', + 'description': '...', + 'fhirVersion': ['5.0.0', '4.0.1'], // fixtures - resources: [ - {resourceType: 'Patient', id: 'pt-1'}, - {resourceType: 'Patient', id: 'pt-2'} + 'resources': [ + {'resourceType': 'Patient', 'id': 'pt-1'}, + {'resourceType': 'Patient', 'id': 'pt-2'} ] - tests: [ + 'tests': [ ... { - title: 'title of test case', + 'title': 'title of test case', // ViewDefintion - view: { - select: [ - {column: [{name: 'id', path: 'id'}]} - ]}, + 'view': { + 'select': [ + {'column': [{'name': 'id', 'path': 'id'}]} + ]}, // expected result - expect: [ - {id: 'pt-1'}, - {id: 'pt-2'} + 'expect': [ + {'id': 'pt-1'}, + {'id': 'pt-2'} ] } ... @@ -150,37 +155,36 @@ runner: The test runner should produce a `test_report.json` file containing the results of the test executions. The structure of the test -report should mirror that of the original test cases, with an additional -attribute `result` added to each test object. This attribute should contain the -set of rows returned by the implementation when evaluating the test. Ensure -the result accurately reflects the output of your implementation for each -test, facilitating a straightforward comparison between expected and actual -outcomes. +report is a map where: +- each key is the name of a test file, +- each value is a map with a single `tests` list, +- each element of the `tests` list has a `name` and a `result` field, reporting + whether the `name` test `passed` or not. Beside `passed`, the `result` map + may also have a `reason` text field describing why the test did not pass. +Here is an example: ```js //example test_report.json { - "title": "Example Test Case", - "description": "This test case validates...", - "resources": [...], - "tests": [ - { - "title": "Test Object 1", - "view": {...}, - "expect": [...], - "result": [ - // Actual rows returned by your implementation - ] - }, - { - "title": "Test Object 2", - "view": {...}, - "expect": [...], - "result": [ - // Actual rows returned by your implementation - ] - } - ] + "logic.json": { + "tests": [ + { + "name": "filtering with 'and'", + "result": { + "passed": true + } + }, + { + "name": "filtering with 'or'", + "result": { + "passed": false, + "reason": "skipped" + } + }, + ... + ] + }, + ... } ``` diff --git a/tests/basic.json b/tests/basic.json index 20dcd9b..3ab3f1a 100644 --- a/tests/basic.json +++ b/tests/basic.json @@ -1,6 +1,11 @@ { "title": "basic", "description": "basic view definition", + "fhirVersion": [ + "5.0.0", + "4.0.1", + "3.0.2" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/collection.json b/tests/collection.json index 1be6bf3..3b33ffb 100644 --- a/tests/collection.json +++ b/tests/collection.json @@ -1,6 +1,11 @@ { "title": "collection", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1", + "3.0.2" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/combinations.json b/tests/combinations.json index 606e46a..03a6816 100644 --- a/tests/combinations.json +++ b/tests/combinations.json @@ -1,6 +1,10 @@ { "title": "combinations", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1" + ], "resources": [ { "id": "pt1", diff --git a/tests/constant.json b/tests/constant.json index ddf93ec..dcaa708 100644 --- a/tests/constant.json +++ b/tests/constant.json @@ -1,6 +1,10 @@ { "title": "constant", "description": "constant substitution", + "fhirVersion": [ + "5.0.0", + "4.0.1" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/fhirpath.json b/tests/fhirpath.json index b4df139..184ab06 100644 --- a/tests/fhirpath.json +++ b/tests/fhirpath.json @@ -1,6 +1,10 @@ { "title": "fhirpath", "description": "fhirpath features", + "fhirVersion": [ + "5.0.0", + "4.0.1" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/fhirpath_numbers.json b/tests/fhirpath_numbers.json index 8297e14..07a5292 100644 --- a/tests/fhirpath_numbers.json +++ b/tests/fhirpath_numbers.json @@ -1,6 +1,10 @@ { "title": "fhirpath_numbers", "description": "fhirpath features", + "fhirVersion": [ + "5.0.0", + "4.0.1" + ], "resources": [ { "resourceType": "Observation", diff --git a/tests/fn_boundary.json b/tests/fn_boundary.json index a76996c..f98d414 100644 --- a/tests/fn_boundary.json +++ b/tests/fn_boundary.json @@ -1,6 +1,10 @@ { "title": "fn_boundary", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1" + ], "resources": [ { "resourceType": "Observation", diff --git a/tests/fn_empty.json b/tests/fn_empty.json index fb60b72..d083f3d 100644 --- a/tests/fn_empty.json +++ b/tests/fn_empty.json @@ -1,6 +1,11 @@ { "title": "fn_empty", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1", + "3.0.2" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/fn_extension.json b/tests/fn_extension.json index 6606637..1dc903f 100644 --- a/tests/fn_extension.json +++ b/tests/fn_extension.json @@ -1,6 +1,10 @@ { "title": "fn_extension", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/fn_first.json b/tests/fn_first.json index db1a161..1cf0943 100644 --- a/tests/fn_first.json +++ b/tests/fn_first.json @@ -1,6 +1,11 @@ { "title": "fn_first", "description": "FHIRPath `first` function.", + "fhirVersion": [ + "5.0.0", + "4.0.1", + "3.0.2" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/fn_join.json b/tests/fn_join.json index cb74ecf..3e3be75 100644 --- a/tests/fn_join.json +++ b/tests/fn_join.json @@ -1,6 +1,10 @@ { "title": "fn_join", "description": "FHIRPath `join` function.", + "fhirVersion": [ + "5.0.0", + "4.0.1" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/fn_oftype.json b/tests/fn_oftype.json index 5c47bad..581d667 100644 --- a/tests/fn_oftype.json +++ b/tests/fn_oftype.json @@ -1,6 +1,10 @@ { "title": "fn_oftype", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1" + ], "resources": [ { "resourceType": "Observation", diff --git a/tests/fn_reference_keys.json b/tests/fn_reference_keys.json index 67c6416..8a4a31e 100644 --- a/tests/fn_reference_keys.json +++ b/tests/fn_reference_keys.json @@ -1,6 +1,11 @@ { "title": "fn_reference_keys", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1", + "3.0.2" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/foreach.json b/tests/foreach.json index 14197a8..da592ee 100644 --- a/tests/foreach.json +++ b/tests/foreach.json @@ -1,6 +1,11 @@ { "title": "foreach", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1", + "3.0.2" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/logic.json b/tests/logic.json index d16a8b4..9480b32 100644 --- a/tests/logic.json +++ b/tests/logic.json @@ -1,6 +1,10 @@ { "title": "logic", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/union.json b/tests/union.json index 3394eef..25f7abb 100644 --- a/tests/union.json +++ b/tests/union.json @@ -1,6 +1,11 @@ { "title": "union", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1", + "3.0.2" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/validate.json b/tests/validate.json index 95f438f..6e2141a 100644 --- a/tests/validate.json +++ b/tests/validate.json @@ -1,6 +1,11 @@ { "title": "validate", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1", + "3.0.2" + ], "resources": [ { "resourceType": "Patient", diff --git a/tests/view_resource.json b/tests/view_resource.json index e31a641..9d71180 100644 --- a/tests/view_resource.json +++ b/tests/view_resource.json @@ -1,6 +1,11 @@ { "title": "view_resource", "description": "TBD", + "fhirVersion": [ + "5.0.0", + "4.0.1", + "3.0.2" + ], "resources": [ { "id": "pt1", diff --git a/tests/where.json b/tests/where.json index 8ba0257..10fa9c7 100644 --- a/tests/where.json +++ b/tests/where.json @@ -1,6 +1,10 @@ { "title": "where", "description": "FHIRPath `where` function.", + "fhirVersion": [ + "5.0.0", + "4.0.1" + ], "resources": [ { "resourceType": "Patient",