at_home_in_vitro_test_kit 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,65 @@
1
+ require_relative 'request_fhir_bundle_validation'
2
+ require_relative 'request_fhir_bundle_entry_validation'
3
+ require_relative 'request_receive_post'
4
+
5
+ module AtHomeInVitroTestKit
6
+ class BundleValidatorRequestGroup< Inferno::TestGroup
7
+
8
+ title 'At-Home In-Vitro Test'
9
+ short_description 'Validate a FHIR Bundle and all of its nested resources.'
10
+ description %(
11
+ # Background
12
+
13
+ The At-Home In-Vitro Test sequence verifies that
14
+ a At-Home In-Vitro FHIR Bundle and its entries, constructed either manually or by
15
+ a digital testing application, can be sent via a POST request and conforms to the resource profile
16
+ outlined in the [At-Home In-Vitro FHIR Implementation Guide](http://hl7.org/fhir/us/home-lab-report/ImplementationGuide/hl7.fhir.us.home-lab-report).
17
+
18
+ # Testing Methodology
19
+ ## POST Request verification
20
+
21
+ The first test in this sequence prepares the kit for POST request handling. The user will enter an input string identifier for this test session
22
+ and will be prompted with a message about the Inferno endpoint a POST request should be sent to. The request MUST include 'id=<INPUT VALUE>' as
23
+ a query parameter so the test kit can associate a POST with a particular testing session. The FHIR bundle MUST be sent as raw JSON in the body
24
+ of the POST request.
25
+
26
+ ## Bundle Validation
27
+
28
+ The second test in this sequence verifies that the FHIR Bundle
29
+ received via POST request conforms to the specifications outlined in the
30
+ [At-Home In-Vitro Bundle Profile](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Bundle-at-home-in-vitro-test).
31
+
32
+ According to the Profile description, a valid Bundle MUST contain the following elements:
33
+
34
+ * identifier - Persistent identifier for the bundle
35
+ * type - fixed value code that identifies the bundle type ('message')
36
+ * timestamp - identifies time that the bundle was assembled
37
+ * entry:messageHeader - bundle entry and resource of type [MessageHeader](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/MessageHeader-at-home-in-vitro-test-results)
38
+
39
+ While a MessageHeader entry is required for all bundles to conform, a bundle
40
+ may contain multiple entry resources that conform to other resource profiles outlined
41
+ in the IG.
42
+
43
+ ## Entry Validation
44
+
45
+ The third test in this sequence uses the FHIR Bundle
46
+ from the first test, and validates each entry resource against its
47
+ profile outlined in the IG. Entry types that can be validated (aside from MessageHeader) include
48
+ the following:
49
+
50
+ * [Device](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Bundle-at-home-in-vitro-test)
51
+ * [DiagnosticSupport](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/DiagnosticReport-at-home-in-vitro-results)
52
+ * [Observation -At-Home In-Vitro Test Result](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Observation-at-home-in-vitro-test-result)
53
+ * [Observation -Pateint Question Answer](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Observation-patient-question-answer)
54
+ * [Patient](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Patient-at-home-in-vitro-test)
55
+ * [Specimen](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Specimen-at-home-in-vitro-test)
56
+ )
57
+ id :bundle_validator_request_group
58
+
59
+ run_as_group(true)
60
+
61
+ test from: :request_receive_post
62
+ test from: :request_fhir_bundle_validation
63
+ test from: :request_fhir_bundle_entry_validation
64
+ end
65
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../test_common/fhir_bundle_validation'
2
+
3
+ module AtHomeInVitroTestKit
4
+ class RequestFhirBundleEntryValidation < Inferno::Test
5
+ include AtHomeInVitroTestKit::FhirBundleValidator
6
+ title 'FHIR Bundle Entry Validation'
7
+ description %(
8
+ Validate that the FHIR Bundle entries conform to their relative At-Home In-Vitro Test Report IG specifications.
9
+ )
10
+ id :request_fhir_bundle_entry_validation
11
+
12
+ uses_request :bundle
13
+
14
+ def fhir_resource
15
+ FHIR::Json.from_json(request.request_body)
16
+ end
17
+
18
+ run do
19
+ validate_bundle_entries(fhir_resource)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../test_common/fhir_bundle_validation'
2
+
3
+ module AtHomeInVitroTestKit
4
+ class RequestFhirBundleValidation < Inferno::Test
5
+ include AtHomeInVitroTestKit::FhirBundleValidator
6
+ title 'FHIR Bundle Validation'
7
+ description %(
8
+ Validate that the FHIR Bundle conforms to the At-Home In-Vitro Test Report IG specifications.
9
+ )
10
+ id :request_fhir_bundle_validation
11
+
12
+ uses_request :bundle
13
+
14
+ def fhir_resource
15
+ FHIR::Json.from_json(request.request_body);
16
+ end
17
+
18
+ run do
19
+ validate_bundle(fhir_resource)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,35 @@
1
+ require_relative '../test_common/fhir_bundle_validation'
2
+ require 'inferno'
3
+
4
+ module AtHomeInVitroTestKit
5
+ class RequestReceivePost < Inferno::Test
6
+ include AtHomeInVitroTestKit::FhirBundleValidator
7
+ title 'Receive FHIR Bundle via POST request.'
8
+ description %(
9
+ Confirm that App Server or Data Hub correctly passes a FHIR bundle to the At-Home In-Vitro test kit.
10
+ )
11
+ id :request_receive_post
12
+
13
+ input :session_id,
14
+ type: 'text',
15
+ description: 'Value used to identify test session. Whatever value is entered here MUST be included in the POST request as a query parameter.'
16
+
17
+ receives_request :bundle
18
+
19
+ run do
20
+ wait(
21
+ identifier: session_id,
22
+ message: %(
23
+ Make a request to this endpoint within the next 24 hours.
24
+
25
+ #{Inferno::Application['base_url']}/custom/at_home_test_kit/bundle?id=#{session_id}
26
+
27
+ If the test times out or is cancelled for any reason, rerunning the test group will restart the timeout.
28
+
29
+ Your request body MUST be your FHIR Bundle in raw json format. Testing will resume automatically after a valid POST is received.
30
+ ),
31
+ timeout: 86400
32
+ )
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,57 @@
1
+ require_relative 'manual_fhir_bundle_validation'
2
+ require_relative 'manual_fhir_bundle_entry_validation'
3
+
4
+ module AtHomeInVitroTestKit
5
+ class BundleValidatorManualEntry < Inferno::TestGroup
6
+
7
+ title 'At-Home In-Vitro Manual Input Test'
8
+ short_description 'Validate a manually input FHIR Bundle and all of its nested resources.'
9
+ description %(
10
+ # Background
11
+
12
+ The At-Home In-Vitro Manual Input Test sequence verifies that
13
+ a At-Home In-Vitro FHIR Bundle and its entries, constructed either manually or by
14
+ a digital testing application, conforms to the resource profile
15
+ outlined in the [At-Home In-Vitro FHIR Implementation Guide](http://hl7.org/fhir/us/home-lab-report/ImplementationGuide/hl7.fhir.us.home-lab-report).
16
+
17
+ # Testing Methodology
18
+ ## Bundle Validation
19
+
20
+ The first test in this sequence verifies that the FHIR Bundle
21
+ taken from user input conforms to the specifications outlined in the
22
+ [At-Home In-Vitro Bundle Profile](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Bundle-at-home-in-vitro-test).
23
+
24
+ According to the Profile description, a valid Bundle MUST contain the following elements:
25
+
26
+ * identifier - Persistent identifier for the bundle
27
+ * type - fixed value code that identifies the bundle type ('message')
28
+ * timestamp - identifies time that the bundle was assembled
29
+ * entry:messageHeader - bundle entry and resource of type [MessageHeader](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/MessageHeader-at-home-in-vitro-test-results)
30
+
31
+ While as MessageHeader entry is required for all bundles to conform, a bundle
32
+ may contain multiple entry resources that conform to other resource profiles outlined
33
+ in the IG.
34
+
35
+ ## Entry Validation
36
+
37
+ The second test in this sequence uses the manualy input FHIR Bundle
38
+ from the first test, and validates each entry resource against its
39
+ profile outlined in the IG. Entry types that can be validated (aside from MessageHeader) include
40
+ the following:
41
+
42
+ * [Device](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Bundle-at-home-in-vitro-test)
43
+ * [DiagnosticSupport](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/DiagnosticReport-at-home-in-vitro-results)
44
+ * [Observation -At-Home In-Vitro Test Result](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Observation-at-home-in-vitro-test-result)
45
+ * [Observation -Pateint Question Answer](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Observation-patient-question-answer)
46
+ * [Patient](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Patient-at-home-in-vitro-test)
47
+ * [Specimen](http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Specimen-at-home-in-vitro-test)
48
+
49
+ )
50
+ id :bundle_validator_manual_entry
51
+
52
+ run_as_group(true)
53
+
54
+ test from: :manual_fhir_bundle_validation
55
+ test from: :manual_fhir_bundle_entry_validation
56
+ end
57
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../test_common/fhir_bundle_validation'
2
+
3
+ module AtHomeInVitroTestKit
4
+ class ManualFhirBundleEntryValidation < Inferno::Test
5
+ include AtHomeInVitroTestKit::FhirBundleValidator
6
+ title 'FHIR Bundle Entry Validation'
7
+ description %(
8
+ Validate that the FHIR Bundle entries conform to their relative At-Home In-Vitro Test Report IG specifications.
9
+ )
10
+ id :manual_fhir_bundle_entry_validation
11
+ input :fhir_bundle
12
+
13
+ def fhir_resource
14
+ resource = FHIR::Json.from_json(fhir_bundle);
15
+ resource
16
+ end
17
+
18
+ run do
19
+ validate_bundle_entries(fhir_resource)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ require_relative '../test_common/fhir_bundle_validation'
2
+
3
+ module AtHomeInVitroTestKit
4
+ class ManualFhirBundleValidation < Inferno::Test
5
+ include AtHomeInVitroTestKit::FhirBundleValidator
6
+ title 'FHIR Bundle Validation'
7
+ description %(
8
+ Validate that the FHIR Bundle conforms to the At-Home In-Vitro Test Report IG specification.
9
+ )
10
+ id :manual_fhir_bundle_validation
11
+ input :fhir_bundle,
12
+ type: 'textarea',
13
+ description: 'At-Home In-Vitro Bundle'
14
+
15
+ def fhir_resource
16
+ resource = FHIR::Json.from_json(fhir_bundle);
17
+ resource
18
+ end
19
+
20
+ run do
21
+ validate_bundle(fhir_resource)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,14 @@
1
+
2
+ module AtHomeInVitroTestKit
3
+ module FhirBundleValidator
4
+ def validate_bundle(resource)
5
+
6
+ assert_resource_type(:bundle, resource: resource)
7
+ assert_valid_resource(resource: resource, profile_url: 'http://hl7.org/fhir/us/home-lab-report/StructureDefinition/Bundle-at-home-in-vitro-test')
8
+ end
9
+
10
+ def validate_bundle_entries(resource)
11
+ assert_valid_bundle_entries(bundle: resource, resource_types: {})
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AtHomeInVitroTestKit
4
+ VERSION = '0.9.0'
5
+ end
@@ -0,0 +1,45 @@
1
+ require_relative 'at_home_in_vitro_test_kit/manual_entry_group/bundle_validator_manual_entry'
2
+ require_relative 'at_home_in_vitro_test_kit/http_request_group/bundle_validator_request_group'
3
+ module AtHomeInVitroTestKit
4
+ require 'inferno'
5
+ class Suite < Inferno::TestSuite
6
+ id :at_home_test_kit
7
+ title 'At-Home In-Vitro Test Kit'
8
+ description 'An Inferno Test Kit used for validating At-Home In-Vitro FHIR Bundles and their entry resources.'
9
+
10
+ # All FHIR validation requsets will use this FHIR validator
11
+ validator do
12
+
13
+ url ENV.fetch('VALIDATOR_URL', 'http://validator_service:4567')
14
+
15
+ exclude_message do |message|
16
+ (message.type == 'warning' &&
17
+ message.message.match?(/Global Profile reference .* could not be resolved, so has not been checked/)) ||
18
+ (message.type == 'info' && message.message.match?(/.* This element does not match any known slice defined in the profile .*/))
19
+ end
20
+
21
+ end
22
+
23
+ resume_test_route :post, '/bundle' do |request|
24
+ request.query_parameters["id"]
25
+ end
26
+
27
+ links [
28
+ {
29
+ label: 'Report Issue',
30
+ url: 'https://github.com/inferno-framework/at-home-in-vitro-test-kit/issues'
31
+ },
32
+ {
33
+ label: 'Open Source',
34
+ url: 'https://github.com/inferno-framework/at-home-in-vitro-test-kit/'
35
+ },
36
+ {
37
+ label: 'At-Home In-Vitro Test Report IG',
38
+ url: 'http://hl7.org/fhir/us/home-lab-report/STU1/'
39
+ }
40
+ ]
41
+
42
+ group from: :bundle_validator_request_group
43
+ group from: :bundle_validator_manual_entry
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: at_home_in_vitro_test_kit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Inferno Team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: inferno_core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.4.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.4.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: database_cleaner-sequel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: factory_bot
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '6.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '6.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.11'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.11'
83
+ description: Inferno tests for the At Home In Vitro IG
84
+ email:
85
+ - inferno@groups.mitre.org
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE
91
+ - lib/at_home_in_vitro_test_kit.rb
92
+ - lib/at_home_in_vitro_test_kit/examples/Bundle-bundle-at-home-in-vitro-test-results-p-noelle.json
93
+ - lib/at_home_in_vitro_test_kit/examples/Bundle-bundle-at-home-in-vitro-test-results-s-trevor.json
94
+ - lib/at_home_in_vitro_test_kit/http_request_group/bundle_validator_request_group.rb
95
+ - lib/at_home_in_vitro_test_kit/http_request_group/request_fhir_bundle_entry_validation.rb
96
+ - lib/at_home_in_vitro_test_kit/http_request_group/request_fhir_bundle_validation.rb
97
+ - lib/at_home_in_vitro_test_kit/http_request_group/request_receive_post.rb
98
+ - lib/at_home_in_vitro_test_kit/manual_entry_group/bundle_validator_manual_entry.rb
99
+ - lib/at_home_in_vitro_test_kit/manual_entry_group/manual_fhir_bundle_entry_validation.rb
100
+ - lib/at_home_in_vitro_test_kit/manual_entry_group/manual_fhir_bundle_validation.rb
101
+ - lib/at_home_in_vitro_test_kit/test_common/fhir_bundle_validation.rb
102
+ - lib/at_home_in_vitro_test_kit/version.rb
103
+ homepage: https://github.com/inferno-framework/inferno-template
104
+ licenses:
105
+ - Apache-2.0
106
+ metadata:
107
+ homepage_uri: https://github.com/inferno-framework/inferno-template
108
+ source_code_uri: https://github.com/inferno-framework/at-home-in-vitro-test-kit
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 3.1.2
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubygems_version: 3.3.7
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Inferno tests for the At Home In Vitro IG
128
+ test_files: []