Skip to content

Commit

Permalink
Added fhirVersion to tests and fixed test_report.json (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
bashir2 authored May 9, 2024
1 parent 0761d5e commit 58a3f4a
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 41 deletions.
86 changes: 45 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'}
]
}
...
Expand Down Expand Up @@ -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"
}
},
...
]
},
...
}
```

Expand Down
5 changes: 5 additions & 0 deletions tests/basic.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"title": "basic",
"description": "basic view definition",
"fhirVersion": [
"5.0.0",
"4.0.1",
"3.0.2"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
5 changes: 5 additions & 0 deletions tests/collection.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"title": "collection",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1",
"3.0.2"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
4 changes: 4 additions & 0 deletions tests/combinations.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "combinations",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1"
],
"resources": [
{
"id": "pt1",
Expand Down
4 changes: 4 additions & 0 deletions tests/constant.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "constant",
"description": "constant substitution",
"fhirVersion": [
"5.0.0",
"4.0.1"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
4 changes: 4 additions & 0 deletions tests/fhirpath.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "fhirpath",
"description": "fhirpath features",
"fhirVersion": [
"5.0.0",
"4.0.1"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
4 changes: 4 additions & 0 deletions tests/fhirpath_numbers.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "fhirpath_numbers",
"description": "fhirpath features",
"fhirVersion": [
"5.0.0",
"4.0.1"
],
"resources": [
{
"resourceType": "Observation",
Expand Down
4 changes: 4 additions & 0 deletions tests/fn_boundary.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "fn_boundary",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1"
],
"resources": [
{
"resourceType": "Observation",
Expand Down
5 changes: 5 additions & 0 deletions tests/fn_empty.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"title": "fn_empty",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1",
"3.0.2"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
4 changes: 4 additions & 0 deletions tests/fn_extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "fn_extension",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
5 changes: 5 additions & 0 deletions tests/fn_first.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"title": "fn_first",
"description": "FHIRPath `first` function.",
"fhirVersion": [
"5.0.0",
"4.0.1",
"3.0.2"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
4 changes: 4 additions & 0 deletions tests/fn_join.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "fn_join",
"description": "FHIRPath `join` function.",
"fhirVersion": [
"5.0.0",
"4.0.1"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
4 changes: 4 additions & 0 deletions tests/fn_oftype.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "fn_oftype",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1"
],
"resources": [
{
"resourceType": "Observation",
Expand Down
5 changes: 5 additions & 0 deletions tests/fn_reference_keys.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"title": "fn_reference_keys",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1",
"3.0.2"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
5 changes: 5 additions & 0 deletions tests/foreach.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"title": "foreach",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1",
"3.0.2"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
4 changes: 4 additions & 0 deletions tests/logic.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "logic",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
5 changes: 5 additions & 0 deletions tests/union.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"title": "union",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1",
"3.0.2"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
5 changes: 5 additions & 0 deletions tests/validate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"title": "validate",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1",
"3.0.2"
],
"resources": [
{
"resourceType": "Patient",
Expand Down
5 changes: 5 additions & 0 deletions tests/view_resource.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"title": "view_resource",
"description": "TBD",
"fhirVersion": [
"5.0.0",
"4.0.1",
"3.0.2"
],
"resources": [
{
"id": "pt1",
Expand Down
4 changes: 4 additions & 0 deletions tests/where.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "where",
"description": "FHIRPath `where` function.",
"fhirVersion": [
"5.0.0",
"4.0.1"
],
"resources": [
{
"resourceType": "Patient",
Expand Down

0 comments on commit 58a3f4a

Please sign in to comment.