diff --git a/.DS_Store b/.DS_Store index 27e33bb..2183194 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index a647a40..2aaa558 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,19 @@ +## About the Project + +The TestScript Engine is to support FHIR testing in an integrated and systematic way by providing the following features. + +* A general purpose test execution tool to be implemented in a variety of use cases +* Support TestScript Resources as inputs and TestReport Resources as outputs to be aligned with FHIR architecture +* (TBA) Support an end-to-end pipeline of FHIR testing including authoring exception handling and analytics +* (TBA) Integration of FHIR Shorthand as a TestScript authoring environment + +### Limitations + +TestScript Execution Engine is in the early stages of development; it is neither functionally complete nor bug-free and we encourage contributions, feedback, and issue-opening from the community. + + +### Getting started + **Commands:** ``` cd lib @@ -44,6 +60,13 @@ `./TestScripts`: - Folder that contains the TestScripts to be executed. Any example resources used within those TestScripts (i.e. using a patient resource as a fixture) should be located within the `./fixtures` subfolder. +## References + +* [Testing FHIR](https://build.fhir.org/testing.html) +* [FHIR Resource: TestScript](https://build.fhir.org/testscript.html) +* [FHIR Resource: TestReport](https://build.fhir.org/testreport.html) +* [Crucible](https://github.com/fhir-crucible) + ## License Copyright 2022 The MITRE Corporation diff --git a/TestReports/.DS_Store b/TestReports/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/TestReports/.DS_Store differ diff --git a/TestReports/example_general.json b/TestReports/example_general.json index b1287de..b12644a 100644 --- a/TestReports/example_general.json +++ b/TestReports/example_general.json @@ -12,7 +12,7 @@ "result": "fail", "score": 88.89, "tester": "The MITRE Corporation", - "issued": "2022-04-25T10:03:21-04:00", + "issued": "2022-05-11T23:27:33-06:00", "setup": { "action": [ { diff --git a/TestReports/example_general_observation.json b/TestReports/example_general_observation.json new file mode 100644 index 0000000..7817f5c --- /dev/null +++ b/TestReports/example_general_observation.json @@ -0,0 +1,159 @@ +{ + "id": "testscript-example-observation", + "language": { + "system": "http://hl7.org/fhir/ValueSet/languages", + "code": "en" + }, + "name": "TestReport Example General Observation", + "status": "completed", + "testScript": { + "reference": "../TestScripts/general_test_script_obs.json" + }, + "result": "fail", + "score": 86.67, + "tester": "The MITRE Corporation", + "issued": "2022-05-11T23:27:35-06:00", + "setup": { + "action": [ + { + "operation": { + "id": "SetupDeleteObservation", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "operation": { + "id": "SetupCreateObservation", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_response_code] Expected 200 but found 201." + } + }, + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + } + ] + }, + "test": [ + { + "name": "Read Observation", + "description": "Read a Observation and validate response.", + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "id": "01-ReadObservationOK", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "badValidation" + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "warning" + }, + "message": "[.assert_minimum_id] Expected resource with id: fixture-observation-minimum in fixtures, responses, or in last reply from server. No such resource found." + } + } + ] + } + ], + "teardown": { + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + } + ] + }, + "resourceType": "TestReport" +} \ No newline at end of file diff --git a/TestReports/example_history.json b/TestReports/example_history.json new file mode 100644 index 0000000..d8c1336 --- /dev/null +++ b/TestReports/example_history.json @@ -0,0 +1,127 @@ +{ + "id": "testscript-example-history", + "language": { + "system": "http://hl7.org/fhir/ValueSet/languages", + "code": "en" + }, + "name": "TestReport Example History", + "status": "completed", + "testScript": { + "reference": "../TestScripts/history_test_script.json" + }, + "result": "fail", + "score": 36.36, + "tester": "The MITRE Corporation", + "issued": "2022-05-11T23:27:37-06:00", + "setup": { + "action": [ + { + "operation": { + "id": "SetupDeletePatient", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_response_code] Expected 200,204 but found 409." + } + }, + { + "operation": { + "id": "SetupCreatePatient", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_response_code] Expected 201 but found 200." + } + }, + { + "operation": { + "id": "SetupUpdatePatient", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_response_code] Expected 200 but found 400." + } + } + ] + }, + "test": [ + { + "name": "History Patient", + "description": "Get the history for a known Patient and validate response.", + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_response] Expected 200 but found 404." + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_resource] Expected Bundle but found OperationOutcome." + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "badValidation" + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_path] Expected history but found nothing." + } + } + ] + } + ], + "resourceType": "TestReport" +} \ No newline at end of file diff --git a/TestReports/example_history_observation.json b/TestReports/example_history_observation.json new file mode 100644 index 0000000..4f1d800 --- /dev/null +++ b/TestReports/example_history_observation.json @@ -0,0 +1,124 @@ +{ + "id": "testscript-example-history-observation", + "language": { + "system": "http://hl7.org/fhir/ValueSet/languages", + "code": "en" + }, + "name": "TestReport Example History Observation", + "status": "completed", + "testScript": { + "reference": "../TestScripts/history_test_script_obs.json" + }, + "result": "fail", + "score": 63.64, + "tester": "The MITRE Corporation", + "issued": "2022-05-11T23:27:39-06:00", + "setup": { + "action": [ + { + "operation": { + "id": "SetupDeleteObservation", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "operation": { + "id": "SetupCreateObservation", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "operation": { + "id": "SetupUpdateObservation", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + } + ] + }, + "test": [ + { + "name": "History Observation", + "description": "Get the history for a known Observation and validate response.", + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_response] Expected 200 but found 404." + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_resource] Expected Bundle but found OperationOutcome." + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "badValidation" + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_path] Expected history but found nothing." + } + } + ] + } + ], + "resourceType": "TestReport" +} \ No newline at end of file diff --git a/TestReports/example_read_test.json b/TestReports/example_read_test.json index b019453..8678d4a 100644 --- a/TestReports/example_read_test.json +++ b/TestReports/example_read_test.json @@ -12,7 +12,7 @@ "result": "fail", "score": 91.67, "tester": "The MITRE Corporation", - "issued": "2022-04-25T10:03:22-04:00", + "issued": "2022-05-11T23:27:40-06:00", "test": [ { "name": "Sprinkler Read Test R001", diff --git a/TestReports/example_read_test_observation.json b/TestReports/example_read_test_observation.json new file mode 100644 index 0000000..2497e28 --- /dev/null +++ b/TestReports/example_read_test_observation.json @@ -0,0 +1,143 @@ +{ + "id": "testscript-example-readtest-observation", + "language": { + "system": "http://hl7.org/fhir/ValueSet/languages", + "code": "en" + }, + "name": "TestReport Example Read Test Observation", + "status": "completed", + "testScript": { + "reference": "../TestScripts/read_test_script_obs.json" + }, + "result": "fail", + "score": 75.0, + "tester": "The MITRE Corporation", + "issued": "2022-05-11T23:27:41-06:00", + "test": [ + { + "name": "Sprinkler Read Test R001", + "description": "Read a known Observation and validate response.", + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_response] Expected 200 but found 404." + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_resource] Expected Observation but found OperationOutcome." + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "warning" + }, + "message": "badValidation" + } + } + ] + }, + { + "name": "Sprinkler Read Test R002", + "description": "Read an unknown Resource Type and validate response.", + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + } + ] + }, + { + "name": "Sprinkler Read Test R003", + "description": "Read a known, non-existing Observation and validate response.", + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + } + ] + }, + { + "name": "Sprinkler Read Test R004", + "description": "Read a Observation using a known bad formatted resource id and validate response.", + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_response] Expected 400 but found 404." + } + } + ] + } + ], + "resourceType": "TestReport" +} \ No newline at end of file diff --git a/TestReports/example_search.json b/TestReports/example_search.json index 770cff4..76b7da0 100644 --- a/TestReports/example_search.json +++ b/TestReports/example_search.json @@ -12,7 +12,7 @@ "result": "fail", "score": 94.44, "tester": "The MITRE Corporation", - "issued": "2022-04-25T10:03:20-04:00", + "issued": "2022-05-11T23:27:47-06:00", "setup": { "action": [ { diff --git a/TestReports/example_search_observation.json b/TestReports/example_search_observation.json new file mode 100644 index 0000000..94ad433 --- /dev/null +++ b/TestReports/example_search_observation.json @@ -0,0 +1,185 @@ +{ + "id": "testscript-example-search-observation", + "language": { + "system": "http://hl7.org/fhir/ValueSet/languages", + "code": "en" + }, + "name": "TestReport Example Search Observation", + "status": "completed", + "testScript": { + "reference": "../TestScripts/search_test_script_obs.json" + }, + "result": "fail", + "score": 72.22, + "tester": "The MITRE Corporation", + "issued": "2022-05-11T23:27:51-06:00", + "setup": { + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_navigation_links] Bundle resource does not contain first, last, and next links as expected." + } + } + ] + }, + "test": [ + { + "name": "Observation Create Search", + "description": "Create a Observation resource and capture the returned HTTP Header Location. Then search for (read) that Observation using the Location URL value and validate the response.", + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + } + ] + }, + { + "name": "Observation Search Dynamic", + "description": "Search for Observation resources using the user defined dynamic variables ${ObservationSearchCode} and ${ObservationSearchStatus} and validate response.", + "action": [ + { + "operation": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_response] Expected 200 but found 400." + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_resource] Expected Bundle but found OperationOutcome." + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "warning" + }, + "message": "badValidation" + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_path] Expected searchset but found nothing." + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "fail" + }, + "message": "[.assert_expression] Invalid Expression: Bundle.total.toInteger() >= entry.count(). Valid FHIRPath Expression is required." + } + } + ] + } + ], + "resourceType": "TestReport" +} \ No newline at end of file diff --git a/TestReports/example_update.json b/TestReports/example_update.json index cb67f63..603b696 100644 --- a/TestReports/example_update.json +++ b/TestReports/example_update.json @@ -12,7 +12,7 @@ "result": "fail", "score": 75.0, "tester": "The MITRE Corporation", - "issued": "2022-04-25T10:03:22-04:00", + "issued": "2022-05-11T23:27:52-06:00", "setup": { "action": [ { diff --git a/TestReports/example_update_observation.json b/TestReports/example_update_observation.json new file mode 100644 index 0000000..5acef50 --- /dev/null +++ b/TestReports/example_update_observation.json @@ -0,0 +1,96 @@ +{ + "id": "testscript-example-update-observation", + "language": { + "system": "http://hl7.org/fhir/ValueSet/languages", + "code": "en" + }, + "name": "TestReport Example Update Observation", + "status": "completed", + "testScript": { + "reference": "../TestScripts/update_test_script_obs.json" + }, + "result": "pass", + "score": 100.0, + "tester": "The MITRE Corporation", + "issued": "2022-05-11T23:27:53-06:00", + "setup": { + "action": [ + { + "operation": { + "id": "SetupDeleteObservation", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "operation": { + "id": "SetupCreateObservation", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + } + ] + }, + "test": [ + { + "name": "Update Observation", + "description": "Update a Observation and validate response.", + "action": [ + { + "operation": { + "id": "SetupUpdateObservation", + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + }, + { + "assert": { + "result": { + "system": "http://hl7.org/fhir/ValueSet/report-action-result-codes", + "code": "pass" + } + } + } + ] + } + ], + "resourceType": "TestReport" +} \ No newline at end of file diff --git a/TestScripts/.DS_Store b/TestScripts/.DS_Store new file mode 100644 index 0000000..876a491 Binary files /dev/null and b/TestScripts/.DS_Store differ diff --git a/TestScripts/fixtures/.DS_Store b/TestScripts/fixtures/.DS_Store new file mode 100644 index 0000000..55ca2fe Binary files /dev/null and b/TestScripts/fixtures/.DS_Store differ diff --git a/TestScripts/fixtures/Observation/example.json b/TestScripts/fixtures/Observation/example.json new file mode 100644 index 0000000..8e73dc5 --- /dev/null +++ b/TestScripts/fixtures/Observation/example.json @@ -0,0 +1,62 @@ +{ + "resourceType": "Observation", + "id": "f001", + "text": { + "status": "generated", + "div": "

Generated Narrative

Resource "f001"

identifier: id: 6323 (OFFICIAL)

status: final

code: Glucose [Moles/volume] in Blood (LOINC#15074-8)

subject: Patient/f001: P. van de Heuvel "Pieter VAN DE HEUVEL"

effective: 2013-04-02T09:30:10+01:00 --> (ongoing)

issued: Apr 3, 2013 2:30:10 PM

performer: Practitioner/f005: A. Langeveld "Langeveld ANNE"

value: 6.3 mmol/l (Details: UCUM code mmol/L = 'mmol/L')

interpretation: High (ObservationInterpretation#H)

ReferenceRanges

-LowHigh
*3.1 mmol/l (Details: UCUM code mmol/L = 'mmol/L')6.2 mmol/l (Details: UCUM code mmol/L = 'mmol/L')
" + }, + "identifier": [ + { + "use": "official", + "system": "http://www.bmc.nl/zorgportal/identifiers/observations", + "value": "6323" + } + ], + "status": "final", + "code": { + "coding": [ + { + "system": "http://loinc.org", + "code": "15074-8", + "display": "Glucose [Moles/volume] in Blood" + } + ] + }, + "effectivePeriod": { + "start": "2013-04-02T09:30:10+01:00" + }, + "issued": "2013-04-03T15:30:10+01:00", + "valueQuantity": { + "value": 6.3, + "unit": "mmol/l", + "system": "http://unitsofmeasure.org", + "code": "mmol/L" + }, + "interpretation": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", + "code": "H", + "display": "High" + } + ] + } + ], + "referenceRange": [ + { + "low": { + "value": 3.1, + "unit": "mmol/l", + "system": "http://unitsofmeasure.org", + "code": "mmol/L" + }, + "high": { + "value": 6.2, + "unit": "mmol/l", + "system": "http://unitsofmeasure.org", + "code": "mmol/L" + } + } + ] +} \ No newline at end of file diff --git a/TestScripts/fixtures/Observation/example2.json b/TestScripts/fixtures/Observation/example2.json new file mode 100644 index 0000000..247c521 --- /dev/null +++ b/TestScripts/fixtures/Observation/example2.json @@ -0,0 +1,62 @@ +{ + "resourceType": "Observation", + "id": "f001", + "text": { + "status": "generated", + "div": "

Generated Narrative

Resource "f001"

identifier: id: 6323 (OFFICIAL)

status: final

code: Glucose [Moles/volume] in Blood (LOINC#15074-8)

subject: Patient/f001: P. van de Heuvel "Pieter VAN DE HEUVEL"

effective: 2013-04-02T09:30:10+01:00 --> (ongoing)

issued: Apr 3, 2013 2:30:10 PM

performer: Practitioner/f005: A. Langeveld "Langeveld ANNE"

value: 6.3 mmol/l (Details: UCUM code mmol/L = 'mmol/L')

interpretation: High (ObservationInterpretation#H)

ReferenceRanges

-LowHigh
*3.1 mmol/l (Details: UCUM code mmol/L = 'mmol/L')6.2 mmol/l (Details: UCUM code mmol/L = 'mmol/L')
" + }, + "identifier": [ + { + "use": "official", + "system": "http://www.bmc.nl/zorgportal/identifiers/observations", + "value": "6323" + } + ], + "status": "final", + "code": { + "coding": [ + { + "system": "http://loinc.org", + "code": "718-7", + "display": "Hemoglobin [Mass/volume] in Blood" + } + ] + }, + "effectivePeriod": { + "start": "2022-01-03T09:31:10+01:00" + }, + "issued": "2022-04-03T15:20:10+01:00", + "valueQuantity": { + "value": 7.2, + "unit": "g/dl", + "system": "http://unitsofmeasure.org", + "code": "g/dL" + }, + "interpretation": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", + "code": "L", + "display": "Low" + } + ] + } + ], + "referenceRange": [ + { + "low": { + "value": 7.5, + "unit": "g/dl", + "system": "http://unitsofmeasure.org", + "code": "g/dL" + }, + "high": { + "value": 10, + "unit": "g/dl", + "system": "http://unitsofmeasure.org", + "code": "g/dL" + } + } + ] +} \ No newline at end of file diff --git a/TestScripts/fixtures/Patient/example2.json b/TestScripts/fixtures/Patient/example2.json new file mode 100644 index 0000000..ee3e6a5 --- /dev/null +++ b/TestScripts/fixtures/Patient/example2.json @@ -0,0 +1,162 @@ +{ + "resourceType": "Patient", + "id": "example2", + "text": { + "status": "generated", + "div": "
\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t
NamePeter James \n Chalmers ("Jim")\n
Address534 Erewhon, Pleasantville, Vic, 3999
ContactsHome: unknown. Work: (03) 5555 6473
IdMRN: 12345 (Acme Healthcare)
\n\t\t
" + }, + "identifier": [ + { + "use": "usual", + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "MR" + } + ] + }, + "system": "urn:oid:1.2.36.146.595.217.0.1", + "value": "12345", + "period": { + "start": "2001-05-06" + }, + "assigner": { + "display": "Acme Healthcare" + } + } + ], + "active": true, + "name": [ + { + "use": "official", + "family": "Lee", + "given": [ + "Jaehoon", + "H" + ] + }, + { + "use": "usual", + "given": [ + "J" + ] + }, + { + "use": "maiden", + "family": "Windsor", + "given": [ + "Jaehoon", + "H" + ], + "period": { + "end": "2002" + } + } + ], + "telecom": [ + { + "use": "home" + }, + { + "system": "phone", + "value": "(03) 1234 3233", + "use": "work", + "rank": 1 + }, + { + "system": "phone", + "value": "(03) 3403 1653", + "use": "mobile", + "rank": 2 + }, + { + "system": "phone", + "value": "(01) 5335 8431", + "use": "old", + "period": { + "end": "2013" + } + } + ], + "gender": "male", + "birthDate": "1978-2-15", + "_birthDate": { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime", + "valueDateTime": "1978-2-15T14:35:45-05:00" + } + ] + }, + "deceasedBoolean": false, + "address": [ + { + "use": "home", + "type": "both", + "text": "254 Berrywood Ct. Salt Lake City, UT 84012", + "line": [ + "254 Berrywood Ct" + ], + "city": "Salt Lake City", + "district": "Rainbow", + "state": "UT", + "postalCode": "84012", + "period": { + "start": "2011-12-25" + } + } + ], + "contact": [ + { + "relationship": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0131", + "code": "N" + } + ] + } + ], + "name": { + "family": "Kim", + "_family": { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/humanname-own-prefix", + "valueString": "VV" + } + ] + }, + "given": [ + "Chulsu" + ] + }, + "telecom": [ + { + "system": "phone", + "value": "+3 (337) 18327" + } + ], + "address": { + "use": "home", + "type": "both", + "line": [ + "534 Erewhon St" + ], + "city": "PleasantVille", + "district": "Rainbow", + "state": "Vic", + "postalCode": "3999", + "period": { + "start": "2011-12-25" + } + }, + "gender": "female", + "period": { + "start": "2013" + } + } + ] +} \ No newline at end of file diff --git a/TestScripts/general_test_script_obs.json b/TestScripts/general_test_script_obs.json new file mode 100644 index 0000000..cb763bc --- /dev/null +++ b/TestScripts/general_test_script_obs.json @@ -0,0 +1,273 @@ +{ + "resourceType": "TestScript", + "id": "testscript-example-observation", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: testscript-example

url: http://hl7.org/fhir/TestScript/testscript-example

identifier: urn:oid:1.3.6.1.4.1.21367.2005.3.7.9876

version: 1.0

name: TestScript Example

status: draft

experimental: true

date: 18/01/2017

publisher: HL7

contact:

description: TestScript example resource with setup to delete if present and create a new instance of a Observation; and single test definition to read the created Observation with various asserts.

useContext:

jurisdiction: United States of America (the) (Details : {urn:iso:std:iso:3166 code 'US' = 'United States of America', given as 'United States of America (the)'})

purpose: Observation Conditional Create (Update), Read and Delete Operations

copyright: © HL7.org 2011+

metadata

Links

-UrlDescription
*http://hl7.org/fhir/observation.htmlDemographics and other administrative information about an individual or animal receiving care or other health-related services.

Capabilities

-RequiredValidatedDescriptionLinkCapabilities
*truefalseObservation Update, Read and Delete Operationshttp://hl7.org/fhir/http.html#deleteCapabilityStatement/example

fixture

autocreate: false

autodelete: false

resource: Peter Chalmers

fixture

autocreate: false

autodelete: false

resource: Peter Chalmers (minimum)

profile: Generated Summary: url: http://hl7.org/fhir/StructureDefinition/Observation; version: 4.0.1; name: Observation; ACTIVE; date: 01/11/2019 9:29:23 AM; publisher: Health Level Seven International (Observation Administration); description: Demographics and other administrative information about an individual or animal receiving care or other health-related services.; purpose: Tracking Observation is the center of the healthcare process.; 4.0.1; RESOURCE; type: Observation; baseDefinition: http://hl7.org/fhir/StructureDefinition/DomainResource; SPECIALIZATION

Variables

-NamePathSourceId
*createResourceIdObservation/idfixture-observation-create

setup

action

Operations

-TypeResourceLabelDescriptionAcceptEncodeRequestUrlParams
*Delete (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code delete = 'Delete', stated as 'null')ObservationSetupDeleteObservationExecute a delete operation to insure the observation does not exist on the server.jsontrue/${createResourceId}

action

Asserts

-DescriptionDirectionOperatorResponseCodeWarningOnly
*Confirm that the returned HTTP status is 200(OK) or 204(No Content).responsein200,204false

action

Operations

-TypeResourceLabelDescriptionAcceptContentTypeEncodeRequestUrlParamsSourceId
*Update (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code update = 'Update', stated as 'null')ObservationSetupCreateObservationCreate observation resource on test server using the contents of fixture-observation-createjsonjsontrue/${createResourceId}fixture-observation-create

action

Asserts

-DescriptionDirectionResponseCodeWarningOnly
*Confirm that the returned HTTP status is 201(Created).response201false

action

Operations

-TypeResourceDescriptionEncodeRequestUrlTargetId
*Read (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code read = 'Read', stated as 'null')ObservationRead the created Observation resource on the test server using the id from fixture-Observation-create. Verify contents.truefixture-Observation-create

action

Asserts

-DescriptionDirectionResponseWarningOnly
*Confirm that the returned HTTP status is 200(OK).responseokayfalse

action

Asserts

-DescriptionCompareToSourceIdCompareToSourceExpressionOperatorWarningOnly
*Confirm that the returned Observation contains the expected family name 'Chalmers'. Uses explicit compareToSourceId reference to fixture-Observation-create used to create the Observation.fixture-Observation-createObservation.name.first().familyequalsfalse

test

name: Read Observation

description: Read a Observation and validate response.

action

Operations

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

teardown

action

Operations

-
*
" + }, + "url": "http://hl7.org/fhir/TestScript/testscript-example", + "identifier": { + "system": "urn:ietf:rfc:3986", + "value": "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9876" + }, + "version": "1.0", + "name": "TestScript Example General Observation", + "status": "draft", + "experimental": true, + "date": "2017-01-18", + "publisher": "HL7", + "contact": [ + { + "name": "Support", + "telecom": [ + { + "system": "email", + "value": "support@HL7.org", + "use": "work" + } + ] + } + ], + "description": "TestScript example resource with setup to delete if present and create a new instance of a Observation; and single test definition to read the created Observation with various asserts.", + "useContext": [ + { + "code": { + "system": "http://terminology.hl7.org/CodeSystem/usage-context-type", + "code": "focus" + }, + "valueCodeableConcept": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/variant-state", + "code": "positive" + } + ] + } + } + ], + "jurisdiction": [ + { + "coding": [ + { + "system": "urn:iso:std:iso:3166", + "code": "US", + "display": "United States of America (the)" + } + ] + } + ], + "purpose": "Observation Conditional Create (Update), Read and Delete Operations", + "copyright": "© HL7.org 2011+", + "metadata": { + "link": [ + { + "url": "http://hl7.org/fhir/observation.html", + "description": "Measurements and simple assertions made about a Observation, device or other subject." + } + ], + "capability": [ + { + "required": true, + "validated": false, + "description": "Observation Update, Read and Delete Operations", + "link": [ + "http://hl7.org/fhir/http.html#delete", + "http://hl7.org/fhir/http.html#read", + "http://hl7.org/fhir/http.html#update" + ], + "capabilities": "CapabilityStatement/example" + } + ] + }, + "fixture": [ + { + "id": "fixture-observation-create", + "autocreate": false, + "autodelete": false, + "resource": { + "reference": "Observation/example.json", + "display": "Glucose [Moles/volume] in Blood" + } + } + ], + "profile": [ + { + "id": "observation-profile", + "reference": "http://hl7.org/fhir/StructureDefinition/Observation" + } + ], + "variable": [ + { + "name": "createResourceId", + "path": "Observation/id", + "sourceId": "fixture-observation-create" + } + ], + "setup": { + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "delete" + }, + "resource": "Observation", + "label": "SetupDeleteObservation", + "description": "Execute a delete operation to ensure the observation does not exist on the server.", + "accept": "json", + "encodeRequestUrl": true, + "params": "/${createResourceId}" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK) or 204(No Content).", + "direction": "response", + "operator": "in", + "responseCode": "200,204", + "warningOnly": false + } + }, + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "update" + }, + "resource": "Observation", + "label": "SetupCreateObservation", + "description": "Create observation resource on test server using the contents of fixture-observation-create", + "accept": "json", + "contentType": "json", + "encodeRequestUrl": true, + "params": "/${createResourceId}", + "sourceId": "fixture-observation-create" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 201(Created).", + "direction": "response", + "responseCode": "200", + "warningOnly": false + } + }, + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "read" + }, + "resource": "Observation", + "description": "Read the created observation resource on the test server using the id from fixture-Observation-create. Verify contents.", + "encodeRequestUrl": true, + "targetId": "fixture-observation-create" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK).", + "direction": "response", + "response": "okay", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Observation contains the expected value: 6.3.", + "compareToSourceId": "fixture-observation-create", + "compareToSourceExpression": "Observation.valueQuantity.value", + "operator": "equals", + "warningOnly": false + } + } + ] + }, + "test": [ + { + "id": "01-ReadObservation", + "name": "Read Observation", + "description": "Read a Observation and validate response.", + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "read" + }, + "resource": "Observation", + "description": "Read the Observation resource on the test server using the id from fixture-observation-create. Prevent URL encoding of the request.", + "encodeRequestUrl": false, + "responseId": "fixture-observation-read", + "targetId": "fixture-observation-create" + } + }, + { + "assert": { + "label": "01-ReadObservationOK", + "description": "Confirm that the returned HTTP status is 200(OK).", + "direction": "response", + "response": "okay", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP Header Last-Modified is present. Warning only as the server might not support versioning.", + "direction": "response", + "headerField": "Last-Modified", + "operator": "notEmpty", + "warningOnly": true + } + }, + { + "assert": { + "description": "Confirm that the returned resource type is Observation.", + "resource": "Observation", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Observation conforms to the base FHIR specification.", + "validateProfileId": "observation-profile", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Observation contains the expected value.", + "operator": "equals", + "path": "fhir:Observation/fhir:valueQuantity/fhir:value/@value", + "sourceId": "fixture-observation-read", + "value": "6.3", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned resource contains the expected retained elements and values. Warning only to provide users with reviewable results.", + "minimumId": "fixture-observation-minimum", + "warningOnly": true + } + } + ] + } + ], + "teardown": { + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "delete" + }, + "resource": "Observation", + "description": "Delete the Observation resource on the test server using the id from fixture-Observation-create.", + "encodeRequestUrl": true, + "targetId": "fixture-observation-create" + } + } + ] + } +} \ No newline at end of file diff --git a/TestScripts/history_test_script.json b/TestScripts/history_test_script.json new file mode 100644 index 0000000..41efc8a --- /dev/null +++ b/TestScripts/history_test_script.json @@ -0,0 +1,228 @@ +{ + "resourceType": "TestScript", + "id": "testscript-example-history", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: testscript-example-history

url: http://hl7.org/fhir/TestScript/testscript-example-history

identifier: urn:oid:1.3.6.1.4.1.21367.2005.3.7.9877

version: 1.0

name: TestScript Example History

status: draft

experimental: true

date: 18/01/2017

publisher: HL7

contact:

description: TestScript example resource with setup to delete if present and create a new instance of a Patient then update that Patient to create a minimum history; and single test definition to get the history of that Patient with various asserts.

jurisdiction: United States of America (the) (Details : {urn:iso:std:iso:3166 code 'US' = 'United States of America', given as 'United States of America (the)'})

purpose: Patient (Conditional) Create, Update, Delete and History (Instance) Operations

copyright: © HL7.org 2011+

metadata

Links

-UrlDescription
*http://hl7.org/fhir/patient.htmlDemographics and other administrative information about an individual or animal receiving care or other health-related services.

Capabilities

-RequiredValidatedDescriptionLinkCapabilities
*truefalsePatient Update, Delete and History (Instance) Operationshttp://hl7.org/fhir/http.html#updateCapabilityStatement/example

fixture

autocreate: false

autodelete: false

resource: Peter Chalmers

fixture

autocreate: false

autodelete: false

resource: Donald Duck

profile: Generated Summary: url: http://hl7.org/fhir/StructureDefinition/Bundle; version: 4.0.1; name: Bundle; ACTIVE; date: 01/11/2019 9:29:23 AM; publisher: Health Level Seven International (FHIR Infrastructure); description: A container for a collection of resources.; 4.0.1; RESOURCE; type: Bundle; baseDefinition: http://hl7.org/fhir/StructureDefinition/Resource; SPECIALIZATION

Variables

-NamePathSourceId
*createResourceIdPatient/idfixture-patient-create

setup

action

Operations

-TypeResourceLabelDescriptionAcceptEncodeRequestUrlParams
*Delete (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code delete = 'Delete', stated as 'null')PatientSetupDeletePatientExecute a delete operation to insure the patient does not exist on the server.jsontrue/${createResourceId}

action

Asserts

-DescriptionDirectionOperatorResponseCodeWarningOnly
*Confirm that the returned HTTP status is 200(OK) or 204(No Content).responsein200,204false

action

Operations

-TypeResourceLabelDescriptionAcceptContentTypeEncodeRequestUrlParamsSourceId
*Update (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code update = 'Update', stated as 'null')PatientSetupCreatePatientCreate patient resource on test server using the contents of fixture-patient-createjsonjsontrue/${createResourceId}fixture-patient-create

action

Asserts

-DescriptionDirectionResponseCodeWarningOnly
*Confirm that the returned HTTP status is 201(Created).response201false

action

Operations

-TypeResourceLabelDescriptionAcceptContentTypeEncodeRequestUrlParamsSourceId
*Update (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code update = 'Update', stated as 'null')PatientSetupUpdatePatientUpdate patient resource on test server using the contents of fixture-patient-updatejsonjsontrue/${createResourceId}fixture-patient-update

action

Asserts

-DescriptionDirectionResponseCodeWarningOnly
*Confirm that the returned HTTP status is 200(OK).response200false

test

name: History Patient

description: Get the history for a known Patient and validate response.

action

Operations

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*
" + }, + "url": "http://hl7.org/fhir/TestScript/testscript-example-history", + "identifier": { + "system": "urn:ietf:rfc:3986", + "value": "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9877" + }, + "version": "1.0", + "name": "TestScript Example History", + "status": "draft", + "experimental": true, + "date": "2017-01-18", + "publisher": "HL7", + "contact": [ + { + "name": "Support", + "telecom": [ + { + "system": "email", + "value": "support@HL7.org", + "use": "work" + } + ] + } + ], + "description": "TestScript example resource with setup to delete if present and create a new instance of a Patient then update that Patient to create a minimum history; and single test definition to get the history of that Patient with various asserts.", + "jurisdiction": [ + { + "coding": [ + { + "system": "urn:iso:std:iso:3166", + "code": "US", + "display": "United States of America (the)" + } + ] + } + ], + "purpose": "Patient (Conditional) Create, Update, Delete and History (Instance) Operations", + "copyright": "© HL7.org 2011+", + "metadata": { + "link": [ + { + "url": "http://hl7.org/fhir/patient.html", + "description": "Demographics and other administrative information about an individual or animal receiving care or other health-related services." + } + ], + "capability": [ + { + "required": true, + "validated": false, + "description": "Patient Update, Delete and History (Instance) Operations", + "link": [ + "http://hl7.org/fhir/http.html#update", + "http://hl7.org/fhir/http.html#delete", + "http://hl7.org/fhir/http.html#history" + ], + "capabilities": "CapabilityStatement/example" + } + ] + }, + "fixture": [ + { + "id": "fixture-patient-create", + "autocreate": false, + "autodelete": false, + "resource": { + "reference": "Patient/example.json", + "display": "Peter Chalmers" + } + }, + { + "id": "fixture-patient-update", + "autocreate": false, + "autodelete": false, + "resource": { + "reference": "Patient/example2.json", + "display": "Jaehoon Lee" + } + } + ], + "profile": [ + { + "id": "bundle-profile", + "reference": "http://hl7.org/fhir/StructureDefinition/Bundle" + } + ], + "variable": [ + { + "name": "createResourceId", + "path": "Patient/id", + "sourceId": "fixture-patient-create" + } + ], + "setup": { + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "delete" + }, + "resource": "Patient", + "label": "SetupDeletePatient", + "description": "Execute a delete operation to insure the patient does not exist on the server.", + "accept": "json", + "encodeRequestUrl": true, + "params": "/${createResourceId}" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK) or 204(No Content).", + "direction": "response", + "operator": "in", + "responseCode": "200,204", + "warningOnly": false + } + }, + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "update" + }, + "resource": "Patient", + "label": "SetupCreatePatient", + "description": "Create patient resource on test server using the contents of fixture-patient-create", + "accept": "json", + "contentType": "json", + "encodeRequestUrl": true, + "params": "/${createResourceId}", + "sourceId": "fixture-patient-create" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 201(Created).", + "direction": "response", + "responseCode": "201", + "warningOnly": false + } + }, + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "update" + }, + "resource": "Patient", + "label": "SetupUpdatePatient", + "description": "Update patient resource on test server using the contents of fixture-patient-update", + "accept": "json", + "contentType": "json", + "encodeRequestUrl": true, + "params": "/${createResourceId}", + "sourceId": "fixture-patient-update" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK).", + "direction": "response", + "responseCode": "200", + "warningOnly": false + } + } + ] + }, + "test": [ + { + "id": "01-HistoryPatient", + "name": "History Patient", + "description": "Get the history for a known Patient and validate response.", + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "history" + }, + "resource": "Patient", + "description": "Get the Patient history on the test server using the id from fixture-patient-create.", + "accept": "json", + "contentType": "json", + "encodeRequestUrl": true, + "targetId": "fixture-patient-create" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK).", + "direction": "response", + "response": "okay", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned resource type is Bundle.", + "resource": "Bundle", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Bundle conforms to the base FHIR specification.", + "validateProfileId": "bundle-profile", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Bundle type equals 'history'.", + "operator": "equals", + "path": "fhir:Bundle/fhir:type/@value", + "value": "history", + "warningOnly": false + } + } + ] + } + ] +} \ No newline at end of file diff --git a/TestScripts/history_test_script_obs.json b/TestScripts/history_test_script_obs.json new file mode 100644 index 0000000..026fc78 --- /dev/null +++ b/TestScripts/history_test_script_obs.json @@ -0,0 +1,228 @@ +{ + "resourceType": "TestScript", + "id": "testscript-example-history-observation", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: testscript-example-history

url: http://hl7.org/fhir/TestScript/testscript-example-history

identifier: urn:oid:1.3.6.1.4.1.21367.2005.3.7.9877

version: 1.0

name: TestScript Example History

status: draft

experimental: true

date: 18/01/2017

publisher: HL7

contact:

description: TestScript example resource with setup to delete if present and create a new instance of a Observation then update that Observation to create a minimum history; and single test definition to get the history of that Observation with various asserts.

jurisdiction: United States of America (the) (Details : {urn:iso:std:iso:3166 code 'US' = 'United States of America', given as 'United States of America (the)'})

purpose: Observation (Conditional) Create, Update, Delete and History (Instance) Operations

copyright: © HL7.org 2011+

metadata

Links

-UrlDescription
*http://hl7.org/fhir/observation.htmlDemographics and other administrative information about an individual or animal receiving care or other health-related services.

Capabilities

-RequiredValidatedDescriptionLinkCapabilities
*truefalseObservation Update, Delete and History (Instance) Operationshttp://hl7.org/fhir/http.html#updateCapabilityStatement/example

fixture

autocreate: false

autodelete: false

resource: Peter Chalmers

fixture

autocreate: false

autodelete: false

resource: Donald Duck

profile: Generated Summary: url: http://hl7.org/fhir/StructureDefinition/Bundle; version: 4.0.1; name: Bundle; ACTIVE; date: 01/11/2019 9:29:23 AM; publisher: Health Level Seven International (FHIR Infrastructure); description: A container for a collection of resources.; 4.0.1; RESOURCE; type: Bundle; baseDefinition: http://hl7.org/fhir/StructureDefinition/Resource; SPECIALIZATION

Variables

-NamePathSourceId
*createResourceIdPatient/idfixture-observation-create

setup

action

Operations

-TypeResourceLabelDescriptionAcceptEncodeRequestUrlParams
*Delete (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code delete = 'Delete', stated as 'null')PatientSetupDeletePatientExecute a delete operation to insure the Observation does not exist on the server.jsontrue/${createResourceId}

action

Asserts

-DescriptionDirectionOperatorResponseCodeWarningOnly
*Confirm that the returned HTTP status is 200(OK) or 204(No Content).responsein200,204false

action

Operations

-TypeResourceLabelDescriptionAcceptContentTypeEncodeRequestUrlParamsSourceId
*Update (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code update = 'Update', stated as 'null')PatientSetupCreatePatientCreate Observation resource on test server using the contents of fixture-observation-createjsonjsontrue/${createResourceId}fixture-observation-create

action

Asserts

-DescriptionDirectionResponseCodeWarningOnly
*Confirm that the returned HTTP status is 201(Created).response201false

action

Operations

-TypeResourceLabelDescriptionAcceptContentTypeEncodeRequestUrlParamsSourceId
*Update (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code update = 'Update', stated as 'null')PatientSetupUpdatePatientUpdate Observation resource on test server using the contents of fixture-observation-updatejsonjsontrue/${createResourceId}fixture-observation-update

action

Asserts

-DescriptionDirectionResponseCodeWarningOnly
*Confirm that the returned HTTP status is 200(OK).response200false

test

name: History Patient

description: Get the history for a known Observation and validate response.

action

Operations

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*
" + }, + "url": "http://hl7.org/fhir/TestScript/testscript-example-history", + "identifier": { + "system": "urn:ietf:rfc:3986", + "value": "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9877" + }, + "version": "1.0", + "name": "TestScript Example History Observation", + "status": "draft", + "experimental": true, + "date": "2017-01-18", + "publisher": "HL7", + "contact": [ + { + "name": "Support", + "telecom": [ + { + "system": "email", + "value": "support@HL7.org", + "use": "work" + } + ] + } + ], + "description": "TestScript example resource with setup to delete if present and create a new instance of a Observation then update that Observation to create a minimum history; and single test definition to get the history of that Observation with various asserts.", + "jurisdiction": [ + { + "coding": [ + { + "system": "urn:iso:std:iso:3166", + "code": "US", + "display": "United States of America (the)" + } + ] + } + ], + "purpose": "Observation (Conditional) Create, Update, Delete and History (Instance) Operations", + "copyright": "© HL7.org 2011+", + "metadata": { + "link": [ + { + "url": "http://hl7.org/fhir/observation.html", + "description": "Demographics and other administrative information about an individual or animal receiving care or other health-related services." + } + ], + "capability": [ + { + "required": true, + "validated": false, + "description": "Observation Update, Delete and History (Instance) Operations", + "link": [ + "http://hl7.org/fhir/http.html#update", + "http://hl7.org/fhir/http.html#delete", + "http://hl7.org/fhir/http.html#history" + ], + "capabilities": "CapabilityStatement/example" + } + ] + }, + "fixture": [ + { + "id": "fixture-observation-create", + "autocreate": false, + "autodelete": false, + "resource": { + "reference": "Observation/example.json", + "display": "Glucose [Moles/volume] in Blood" + } + }, + { + "id": "fixture-observation-update", + "autocreate": false, + "autodelete": false, + "resource": { + "reference": "Observation/example2.json", + "display": "Hemoglobin" + } + } + ], + "profile": [ + { + "id": "bundle-profile", + "reference": "http://hl7.org/fhir/StructureDefinition/Bundle" + } + ], + "variable": [ + { + "name": "createResourceId", + "path": "Observation/id", + "sourceId": "fixture-observation-create" + } + ], + "setup": { + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "delete" + }, + "resource": "Observation", + "label": "SetupDeleteObservation", + "description": "Execute a delete operation to insure the Observation does not exist on the server.", + "accept": "json", + "encodeRequestUrl": true, + "params": "/${createResourceId}" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK) or 204(No Content).", + "direction": "response", + "operator": "in", + "responseCode": "200,204", + "warningOnly": false + } + }, + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "update" + }, + "resource": "Observation", + "label": "SetupCreateObservation", + "description": "Create Observation resource on test server using the contents of fixture-observation-create", + "accept": "json", + "contentType": "json", + "encodeRequestUrl": true, + "params": "/${createResourceId}", + "sourceId": "fixture-observation-create" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 201(Created).", + "direction": "response", + "responseCode": "201", + "warningOnly": false + } + }, + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "update" + }, + "resource": "Observation", + "label": "SetupUpdateObservation", + "description": "Update Observation resource on test server using the contents of fixture-observation-update", + "accept": "json", + "contentType": "json", + "encodeRequestUrl": true, + "params": "/${createResourceId}", + "sourceId": "fixture-observation-update" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK).", + "direction": "response", + "responseCode": "200", + "warningOnly": false + } + } + ] + }, + "test": [ + { + "id": "01-HistoryObservation", + "name": "History Observation", + "description": "Get the history for a known Observation and validate response.", + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "history" + }, + "resource": "Observation", + "description": "Get the Observation history on the test server using the id from fixture-observation-create.", + "accept": "json", + "contentType": "json", + "encodeRequestUrl": true, + "targetId": "fixture-observation-create" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK).", + "direction": "response", + "response": "okay", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned resource type is Bundle.", + "resource": "Bundle", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Bundle conforms to the base FHIR specification.", + "validateProfileId": "bundle-profile", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Bundle type equals 'history'.", + "operator": "equals", + "path": "fhir:Bundle/fhir:type/@value", + "value": "history", + "warningOnly": false + } + } + ] + } + ] +} \ No newline at end of file diff --git a/TestScripts/read_test_script_obs.json b/TestScripts/read_test_script_obs.json new file mode 100644 index 0000000..88ba78e --- /dev/null +++ b/TestScripts/read_test_script_obs.json @@ -0,0 +1,219 @@ +{ + "resourceType": "TestScript", + "id": "testscript-example-readtest-observation", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: testscript-example-readtest

url: http://hl7.org/fhir/TestScript/testscript-example-readtest

identifier: urn:oid:1.3.6.1.4.1.21367.2005.3.7.9879

version: 1.0

name: TestScript Example Read Test

status: draft

experimental: true

date: 18/01/2017

publisher: HL7

contact:

description: TestScript example resource with ported Sprinkler basic read tests R001, R002, R003, R004. The read tests will utilize user defined dynamic variables that will hold the Observation resource id values.

jurisdiction: United States of America (the) (Details : {urn:iso:std:iso:3166 code 'US' = 'United States of America', given as 'United States of America (the)'})

purpose: Observation Read Operation

copyright: © HL7.org 2011+

metadata

Links

-UrlDescription
*http://hl7.org/fhir/observation.htmlDemographics and other administrative information about an individual or animal receiving care or other health-related services.

Capabilities

-RequiredValidatedDescriptionLinkCapabilities
*truefalseObservation Read Operationhttp://hl7.org/fhir/http.html#readCapabilityStatement/example

profile: Generated Summary: url: http://hl7.org/fhir/StructureDefinition/Observation; version: 4.0.1; name: Observation; ACTIVE; date: 01/11/2019 9:29:23 AM; publisher: Health Level Seven International (Observation Administration); description: Demographics and other administrative information about an individual or animal receiving care or other health-related services.; purpose: Tracking Observation is the center of the healthcare process.; 4.0.1; RESOURCE; type: Observation; baseDefinition: http://hl7.org/fhir/StructureDefinition/DomainResource; SPECIALIZATION

variable

name: KnownObservationResourceId

defaultValue: example

variable

name: NonExistsObservationResourceId

defaultValue: does-not-exist

test

name: Sprinkler Read Test R001

description: Read a known Observation and validate response.

action

Operations

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

test

name: Sprinkler Read Test R002

description: Read an unknown Resource Type and validate response.

action

Operations

-
*

action

Asserts

-
*

test

name: Sprinkler Read Test R003

description: Read a known, non-existing Observation and validate response.

action

Operations

-
*

action

Asserts

-
*

test

name: Sprinkler Read Test R004

description: Read a Observation using a known bad formatted resource id and validate response.

action

Operations

-
*

action

Asserts

-
*
" + }, + "url": "http://hl7.org/fhir/TestScript/testscript-example-readtest", + "identifier": { + "system": "urn:ietf:rfc:3986", + "value": "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9879" + }, + "version": "1.0", + "name": "TestScript Example Read Test Observation", + "status": "draft", + "experimental": true, + "date": "2017-01-18", + "publisher": "HL7", + "contact": [ + { + "name": "Support", + "telecom": [ + { + "system": "email", + "value": "support@HL7.org", + "use": "work" + } + ] + } + ], + "description": "TestScript example resource with ported Sprinkler basic read tests R001, R002, R003, R004. The read tests will utilize user defined dynamic variables that will hold the Observation resource id values.", + "jurisdiction": [ + { + "coding": [ + { + "system": "urn:iso:std:iso:3166", + "code": "US", + "display": "United States of America (the)" + } + ] + } + ], + "purpose": "Observation Read Operation", + "copyright": "© HL7.org 2011+", + "metadata": { + "link": [ + { + "url": "http://hl7.org/fhir/observation.html", + "description": "Demographics and other administrative information about an individual or animal receiving care or other health-related services." + } + ], + "capability": [ + { + "required": true, + "validated": false, + "description": "Observation Read Operation", + "link": [ + "http://hl7.org/fhir/http.html#read" + ], + "capabilities": "CapabilityStatement/example" + } + ] + }, + "profile": [ + { + "id": "observation-profile", + "reference": "http://hl7.org/fhir/StructureDefinition/Observation" + } + ], + "variable": [ + { + "name": "KnownObservationResourceId", + "defaultValue": "example" + }, + { + "name": "NonExistsObservationResourceId", + "defaultValue": "does-not-exist" + } + ], + "test": [ + { + "id": "R001", + "name": "Sprinkler Read Test R001", + "description": "Read a known Observation and validate response.", + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "read" + }, + "resource": "Observation" , + "description": "Read the known Observation resource on the destination test system using the user defined dynamic variable ${KnownObservationResourceId}.", + "accept": "xml", + "encodeRequestUrl": true, + "params": "/${KnownObservationResourceId}" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK).", + "response": "okay", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned format is XML.", + "contentType": "application/fhir+xml", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP Header Last-Modified is present. Warning only as the server might not support versioning.", + "headerField": "Last-Modified", + "operator": "notEmpty", + "warningOnly": true + } + }, + { + "assert": { + "description": "Confirm that the returned resource type is Observation.", + "resource": "Observation" , + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Observation conforms to the base FHIR specification.", + "validateProfileId": "observation-profile", + "warningOnly": true + } + } + ] + }, + { + "id": "R002", + "name": "Sprinkler Read Test R002", + "description": "Read an unknown Resource Type and validate response.", + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "read" + }, + "resource": "Observation" , + "description": "Attempt to read the Parameters resource type. What we really want here is an illegal type but the build process won't allow that. Parameters is a valid resource which doesn't have an end-point so, this should fail.", + "accept": "xml", + "encodeRequestUrl": true, + "params": "/1" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 404(Not Found).", + "response": "notFound", + "warningOnly": false + } + } + ] + }, + { + "id": "R003", + "name": "Sprinkler Read Test R003", + "description": "Read a known, non-existing Observation and validate response.", + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "read" + }, + "resource": "Observation" , + "description": "Attempt to read the non-existing Observation resource on the destination test system using the user defined dynamic variable ${NonExistsObservationResourceId}.", + "accept": "xml", + "encodeRequestUrl": true, + "params": "/${NonExistsObservationResourceId}" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 404(Not Found).", + "response": "notFound", + "warningOnly": false + } + } + ] + }, + { + "id": "R004", + "name": "Sprinkler Read Test R004", + "description": "Read a Observation using a known bad formatted resource id and validate response.", + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "read" + }, + "resource": "Observation" , + "description": "Attempt to read a Observation resource on the destination test system using known bad formatted resource id.", + "accept": "xml", + "encodeRequestUrl": true, + "params": "/ID-may-not-contain-CAPITALS" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 400(Bad Request).", + "response": "bad", + "warningOnly": false + } + } + ] + } + ] +} \ No newline at end of file diff --git a/TestScripts/search_test_script_obs.json b/TestScripts/search_test_script_obs.json new file mode 100644 index 0000000..063d4ed --- /dev/null +++ b/TestScripts/search_test_script_obs.json @@ -0,0 +1,281 @@ +{ + "resourceType": "TestScript", + "id": "testscript-example-search-observation", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: testscript-example-search

url: http://hl7.org/fhir/TestScript/testscript-example-search

identifier: urn:oid:1.3.6.1.4.1.21367.2005.3.7.9881

version: 1.0

name: TestScript Example Search

status: draft

experimental: true

date: 18/01/2017

publisher: HL7

contact:

description: TestScript example resource with simple Observation search test. The read tests will utilize user defined dynamic variables that will hold the Observation search parameter values.

jurisdiction: United States of America (the) (Details : {urn:iso:std:iso:3166 code 'US' = 'United States of America', given as 'United States of America (the)'})

purpose: Observation Search Operation

copyright: © HL7.org 2011+

metadata

Links

-UrlDescription
*http://hl7.org/fhir/observation.htmlDemographics and other administrative information about an individual or animal receiving care or other health-related services.

Capabilities

-RequiredValidatedDescriptionLinkCapabilities
*truefalseObservation Search Operationhttp://hl7.org/fhir/http.html#searchCapabilityStatement/example

Fixtures

-AutocreateAutodeleteResource
*falsefalsePeter Chalmers

profile: Generated Summary: url: http://hl7.org/fhir/StructureDefinition/Bundle; version: 4.0.1; name: Bundle; ACTIVE; date: 01/11/2019 9:29:23 AM; publisher: Health Level Seven International (FHIR Infrastructure); description: A container for a collection of resources.; 4.0.1; RESOURCE; type: Bundle; baseDefinition: http://hl7.org/fhir/StructureDefinition/Resource; SPECIALIZATION

variable

name: ObservationCreateLocation

headerField: Location

sourceId: ObservationCreateResponse

variable

name: ObservationSearchCode

description: Enter Observation search criteria for a known family name on the target system

hint: [Family name]

variable

name: ObservationSearchStatus

description: Enter Observation search criteria for a known given name on the target system

hint: [Given name]

variable

name: ObservationSearchBundleTotal

description: Evaluate the returned Observation searchset Bundle.total value

expression: Bundle.total.toInteger()

setup

action

Operations

-TypeResourceDescriptionAcceptEncodeRequestUrlParams
*Search (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code search = 'Search', stated as 'null')ObservationTest simple search to verify server support.xmltrue?family=DONTEXPECTAMATCH&given=DONTEXPECTAMATCH

action

Asserts

-DescriptionDirectionOperatorRequestURLWarningOnly
*Confirm that the request url contains the family search parameter.requestcontainsfamilyfalse

action

Asserts

-DescriptionDirectionResponseCodeWarningOnly
*Confirm that the returned HTTP status is 200(OK).response200false

action

Asserts

-DescriptionResourceWarningOnly
*Confirm that the returned resource type is Bundle.Bundlefalse

action

Asserts

-DescriptionNavigationLinksWarningOnly
*Confirm that the returned Bundle correctly defines the navigation links.truefalse

test

name: Observation Create Search

description: Create a Observation resource and capture the returned HTTP Header Location. Then search for (read) that Observation using the Location URL value and validate the response.

action

Operations

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Operations

-
*

action

Asserts

-
*

action

Asserts

-
*

test

name: Observation Search Dynamic

description: Search for Observation resources using the user defined dynamic variables ${ObservationSearchCode} and ${ObservationSearchStatus} and validate response.

action

Operations

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*
" + }, + "url": "http://hl7.org/fhir/TestScript/testscript-example-search", + "identifier": { + "system": "urn:ietf:rfc:3986", + "value": "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9881" + }, + "version": "1.0", + "name": "TestScript Example Search Observation", + "status": "draft", + "experimental": true, + "date": "2017-01-18", + "publisher": "HL7", + "contact": [ + { + "name": "Support", + "telecom": [ + { + "system": "email", + "value": "support@HL7.org", + "use": "work" + } + ] + } + ], + "description": "TestScript example resource with simple Observation search test. The read tests will utilize user defined dynamic variables that will hold the Observation search parameter values.", + "jurisdiction": [ + { + "coding": [ + { + "system": "urn:iso:std:iso:3166", + "code": "US", + "display": "United States of America (the)" + } + ] + } + ], + "purpose": "Observation Search Operation", + "copyright": "© HL7.org 2011+", + "metadata": { + "link": [ + { + "url": "http://hl7.org/fhir/observation.html", + "description": "Demographics and other administrative information about an individual or animal receiving care or other health-related services." + } + ], + "capability": [ + { + "required": true, + "validated": false, + "description": "Observation Search Operation", + "link": [ + "http://hl7.org/fhir/http.html#search" + ], + "capabilities": "CapabilityStatement/example" + } + ] + }, + "fixture": [ + { + "id": "fixture-observation-create", + "autocreate": false, + "autodelete": false, + "resource": { + "reference": "Observation/example.json", + "display": "Glucose [Moles/volume] in Blood" + } + } + ], + "profile": [ + { + "id": "bundle-profile", + "reference": "http://hl7.org/fhir/StructureDefinition/Bundle" + } + ], + "variable": [ + { + "name": "ObservationCreateLocation", + "headerField": "Location", + "sourceId": "ObservationCreateResponse" + }, + { + "name": "ObservationSearchCode", + "description": "Enter Observation search criteria for a known code", + "hint": "[Code]" + }, + { + "name": "ObservationSearchStatus", + "description": "Enter Observation search criteria for a known status", + "hint": "[Status]" + }, + { + "name": "ObservationSearchBundleTotal", + "description": "Evaluate the returned Observation searchset Bundle.total value", + "expression": "Bundle.total.toInteger()" + } + ], + "setup": { + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "search" + }, + "resource": "Observation", + "description": "Test simple search to verify server support.", + "accept": "xml", + "encodeRequestUrl": true, + "params": "?code=15074-8&status=final" + } + }, + { + "assert": { + "description": "Confirm that the request url contains the code search parameter.", + "direction": "request", + "operator": "contains", + "requestURL": "code", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK).", + "direction": "response", + "responseCode": "200", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned resource type is Bundle.", + "resource": "Bundle", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Bundle correctly defines the navigation links.", + "navigationLinks": true, + "warningOnly": false + } + } + ] + }, + "test": [ + { + "id": "01-ObservationCreateSearch", + "name": "Observation Create Search", + "description": "Create a Observation resource and capture the returned HTTP Header Location. Then search for (read) that Observation using the Location URL value and validate the response.", + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "create" + }, + "resource": "Observation", + "description": "Create a Observation resource and capture the returned HTTP Header Location.", + "accept": "xml", + "contentType": "xml", + "encodeRequestUrl": true, + "responseId": "ObservationCreateResponse", + "sourceId": "fixture-observation-create" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 201(Created).", + "response": "created", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP Header Location is present.", + "direction": "response", + "headerField": "Location", + "operator": "notEmpty", + "warningOnly": false + } + }, + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "read" + }, + "description": "Read the created Observation using the captured Location URL value.", + "accept": "xml", + "encodeRequestUrl": true, + "url": "${ObservationCreateLocation}" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK).", + "response": "okay", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned resource type is Observation.", + "resource": "Observation", + "warningOnly": false + } + } + ] + }, + { + "id": "02-ObservationSearchDynamic", + "name": "Observation Search Dynamic", + "description": "Search for Observation resources using the user defined dynamic variables ${ObservationSearchCode} and ${ObservationSearchStatus} and validate response.", + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "search" + }, + "resource": "Observation", + "description": "Search for Observation resources on the destination test system.", + "accept": "xml", + "encodeRequestUrl": true, + "params": "?family=${ObservationSearchCode}&given=${ObservationSearchStatus}" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK).", + "response": "okay", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned format is XML.", + "contentType": "application/fhir+xml", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned resource type is Bundle.", + "resource": "Bundle", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Bundle conforms to the base FHIR specification.", + "validateProfileId": "bundle-profile", + "warningOnly": true + } + }, + { + "assert": { + "description": "Confirm that the returned Bundle type equals 'searchset'.", + "operator": "equals", + "path": "fhir:Bundle/fhir:type/@value", + "value": "searchset", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned Bundle total is greater than or equal to the number of returned entries.", + "expression": "Bundle.total.toInteger() >= entry.count()", + "warningOnly": false + } + } + ] + } + ] +} \ No newline at end of file diff --git a/TestScripts/update_test_script_obs.json b/TestScripts/update_test_script_obs.json new file mode 100644 index 0000000..90cda6e --- /dev/null +++ b/TestScripts/update_test_script_obs.json @@ -0,0 +1,196 @@ +{ + "resourceType": "TestScript", + "id": "testscript-example-update-observation", + "text": { + "status": "generated", + "div": "

Generated Narrative with Details

id: testscript-example-update

url: http://hl7.org/fhir/TestScript/testscript-example-update

identifier: urn:oid:1.3.6.1.4.1.21367.2005.3.7.9882

version: 1.0

name: TestScript Example Update

status: draft

experimental: true

date: 18/01/2017

publisher: HL7

contact:

description: TestScript example resource with setup to delete if present and create a new instance of a Observation; and single test definition to update that Observation with various asserts.

jurisdiction: United States of America (the) (Details : {urn:iso:std:iso:3166 code 'US' = 'United States of America', given as 'United States of America (the)'})

purpose: Observation (Conditional) Create, Update, Delete Operations

copyright: © HL7.org 2011+

metadata

Links

-UrlDescription
*http://hl7.org/fhir/observation.htmlDemographics and other administrative information about an individual or animal receiving care or other health-related services.

Capabilities

-RequiredValidatedDescriptionLinkCapabilities
*truefalseObservation Update and Delete Operationshttp://hl7.org/fhir/http.html#updateCapabilityStatement/example

fixture

autocreate: false

autodelete: false

resource: Peter Chalmers

fixture

autocreate: false

autodelete: false

resource: Donald Duck

profile: Generated Summary: url: http://hl7.org/fhir/StructureDefinition/observation; version: 4.0.1; name: Observation; ACTIVE; date: 01/11/2019 9:29:23 AM; publisher: Health Level Seven International (Observation Administration); description: Demographics and other administrative information about an individual or animal receiving care or other health-related services.; purpose: Tracking Observation is the center of the healthcare process.; 4.0.1; RESOURCE; type: Observation; baseDefinition: http://hl7.org/fhir/StructureDefinition/DomainResource; SPECIALIZATION

Variables

-NamePathSourceId
*createResourceIdobservation/idfixture-observation-create

setup

action

Operations

-TypeResourceLabelDescriptionAcceptEncodeRequestUrlParams
*Delete (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code delete = 'Delete', stated as 'null')observationSetupDeleteObservationExecute a delete operation to insure the Observation does not exist on the server.xmltrue/${createResourceId}

action

Asserts

-DescriptionDirectionOperatorResponseCodeWarningOnly
*Confirm that the returned HTTP status is 200(OK) or 204(No Content).responsein200,204false

action

Operations

-TypeResourceLabelDescriptionAcceptContentTypeEncodeRequestUrlParamsSourceId
*Update (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code update = 'Update', stated as 'null')observationSetupCreateobservationCreate Observation resource on test server using the contents of fixture-observation-createxmlxmltrue/${createResourceId}fixture-observation-create

action

Asserts

-DescriptionDirectionResponseCodeWarningOnly
*Confirm that the returned HTTP status is 201(Created).response201false

test

name: Update Observation

description: Update a Observation and validate response.

action

Operations

-
*

action

Asserts

-
*

action

Asserts

-
*

action

Asserts

-
*
" + }, + "url": "http://hl7.org/fhir/TestScript/testscript-example-update", + "identifier": { + "system": "urn:ietf:rfc:3986", + "value": "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9882" + }, + "version": "1.0", + "name": "TestScript Example Update Observation", + "status": "draft", + "experimental": true, + "date": "2017-01-18", + "publisher": "HL7", + "contact": [ + { + "name": "Support", + "telecom": [ + { + "system": "email", + "value": "support@HL7.org", + "use": "work" + } + ] + } + ], + "description": "TestScript example resource with setup to delete if present and create a new instance of a Observation; and single test definition to update that Observation with various asserts.", + "jurisdiction": [ + { + "coding": [ + { + "system": "urn:iso:std:iso:3166", + "code": "US", + "display": "United States of America (the)" + } + ] + } + ], + "purpose": "Observation (Conditional) Create, Update, Delete Operations", + "copyright": "© HL7.org 2011+", + "metadata": { + "link": [ + { + "url": "http://hl7.org/fhir/observation.html", + "description": "Demographics and other administrative information about an individual or animal receiving care or other health-related services." + } + ], + "capability": [ + { + "required": true, + "validated": false, + "description": "Observation Update and Delete Operations", + "link": [ + "http://hl7.org/fhir/http.html#update", + "http://hl7.org/fhir/http.html#delete" + ], + "capabilities": "CapabilityStatement/example" + } + ] + }, + "fixture": [ + { + "id": "fixture-observation-create", + "autocreate": false, + "autodelete": false, + "resource": { + "reference": "Observation/example.json", + "display": "Glucose [Moles/volume] in Blood" + } + }, + { + "id": "fixture-observation-update", + "autocreate": false, + "autodelete": false, + "resource": { + "reference": "Observation/example.json", + "display": "Glucose [Moles/volume] in Blood" + } + } + ], + "profile": [ + { + "id": "observation-profile", + "reference": "http://hl7.org/fhir/StructureDefinition/Observation" + } + ], + "variable": [ + { + "name": "createResourceId", + "path": "Observation/id", + "sourceId": "fixture-observation-create" + } + ], + "setup": { + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "delete" + }, + "resource": "Observation", + "label": "SetupDeleteObservation", + "description": "Execute a delete operation to ensure the Observation does not exist on the server.", + "accept": "xml", + "encodeRequestUrl": true, + "params": "/${createResourceId}" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK) or 204(No Content).", + "direction": "response", + "operator": "in", + "responseCode": "200,204", + "warningOnly": false + } + }, + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "update" + }, + "resource": "Observation", + "label": "SetupCreateObservation", + "description": "Create Observation resource on test server using the contents of fixture-observation-create", + "accept": "xml", + "contentType": "xml", + "encodeRequestUrl": true, + "params": "/${createResourceId}", + "sourceId": "fixture-observation-create" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 201(Created).", + "direction": "response", + "responseCode": "201", + "warningOnly": false + } + } + ] + }, + "test": [ + { + "id": "01-UpdateObservation", + "name": "Update Observation", + "description": "Update a Observation and validate response.", + "action": [ + { + "operation": { + "type": { + "system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes", + "code": "update" + }, + "resource": "Observation", + "label": "SetupUpdateObservation", + "description": "Update Observation resource on test server using the contents of fixture-observation-update", + "accept": "xml", + "contentType": "xml", + "encodeRequestUrl": true, + "params": "/${createResourceId}", + "sourceId": "fixture-observation-update" + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP status is 200(OK).", + "response": "okay", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned format is XML.", + "contentType": "application/fhir+xml", + "warningOnly": false + } + }, + { + "assert": { + "description": "Confirm that the returned HTTP Header Last-Modified is present. Warning only as the server might not support versioning.", + "headerField": "Last-Modified", + "operator": "notEmpty", + "warningOnly": true + } + } + ] + } + ] +} \ No newline at end of file diff --git a/lib/TestScriptEngine.rb b/lib/TestScriptEngine.rb index e6a5b2b..3612a46 100644 --- a/lib/TestScriptEngine.rb +++ b/lib/TestScriptEngine.rb @@ -37,10 +37,13 @@ def valid_testscript? script # @path [String] Optional, specifies the path to the folder containing the # TestScript Resources to-be loaded into the engine. - def load_scripts path = nil + def load_scripts path = nil, file_name = nil on_deck = Dir.glob "#{path || root}/**.{json, xml}" + FHIR.logger.info "[.load_scripts] TestScript Path: [#{path || root}]" on_deck.each do |resource| + # next unless resource.include? file_name + begin script = FHIR.from_contents File.read(resource) if valid_testscript? script diff --git a/lib/TestScriptRunnable.rb b/lib/TestScriptRunnable.rb index 5c82aea..d338d40 100644 --- a/lib/TestScriptRunnable.rb +++ b/lib/TestScriptRunnable.rb @@ -11,7 +11,8 @@ class TestScriptRunnable 'create' => :post, 'update' => :put, 'delete' => :delete, - 'search' => :get }.freeze + 'search' => :get, + 'history' => :get }.freeze attr_accessor :script, :last_reply @@ -116,10 +117,12 @@ def run client = nil def execute op return unless op + FHIR.logger.info "[.execute]: #{op.description}" + catch :exit do throw :exit, report.fail('noClient') unless client throw :exit, report.fail('noRequestType') unless op.type&.code || op.local_method - + request_type = REQUEST_TYPES[op.local_method || op.type.code] throw :exit, report.skip('notImplemented') unless request_type @@ -127,7 +130,11 @@ def execute op request.compact! begin - reply = client.send *request + if op.type.code == 'history' + reply = client.resource_instance_history(op.class, id_map[op.targetId]) + else + reply = client.send *request + end rescue StandardError => e log_error e.message report.error e.message @@ -150,7 +157,7 @@ def evaluate assertion rawType = assertion.to_hash.find { |k, v| assertTypes.include? k } assertType = rawType[0].split(/(?<=\p{Ll})(?=\p{Lu})|(?<=\p{Lu})(?=\p{Lu}\p{Ll})/).map(&:downcase).join('_') self.send(("assert_#{assertType}").to_sym, assertion) - + rescue AssertionException => e return assertion.warningOnly ? report.warning(e.message) : report.fail(e.message) rescue StandardError => e diff --git a/lib/driver.rb b/lib/driver.rb index 19a0abf..1a3d1a8 100644 --- a/lib/driver.rb +++ b/lib/driver.rb @@ -4,6 +4,7 @@ default_engine = TestScriptEngine.new 'http://hapi.fhir.org/baseR4' default_engine.load_scripts +# default_engine.load_scripts(nil, 'update_test_script_obs.json') default_engine.make_runnables default_engine.execute_runnables default_engine.write_reports