ips_test_kit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,40 @@
1
+ module IPS
2
+ class DeviceObserver < Inferno::TestGroup
3
+ title 'Device (performer, observer) Tests'
4
+ description 'Verify support for the server capabilities required by the Device (performer, observer) profile.'
5
+ id :ips_device_observer
6
+
7
+ test do
8
+ title 'Server returns correct Device resource from the Device read interaction'
9
+ description %(
10
+ This test will verify that Device resources can be read from the server.
11
+ )
12
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/Device-observer-uv-ips'
13
+
14
+ input :device_id
15
+ makes_request :device_observer
16
+
17
+ run do
18
+ fhir_read(:device, device_id, name: :device_observer)
19
+
20
+ assert_response_status(200)
21
+ assert_resource_type(:device)
22
+ assert resource.id == device_id,
23
+ "Requested resource with id #{device_id}, received resource with id #{resource.id}"
24
+ end
25
+ end
26
+
27
+ test do
28
+ title 'Server returns Device resource that matches the Device (performer, observer) profile'
29
+ description %(
30
+ This test will validate that the Device resource returned from the server matches the Device (performer, observer) profile.
31
+ )
32
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/Device-observer-uv-ips'
33
+ uses_request :device_observer
34
+
35
+ run do
36
+ assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/Device-observer-uv-ips')
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ module IPS
2
+ class DeviceUseStatement < Inferno::TestGroup
3
+ title 'Device Use Statement (IPS) Tests'
4
+ description 'Verify support for the server capabilities required by the Device Use Statement (IPS) profile.'
5
+ id :ips_device_use_statement
6
+
7
+ test do
8
+ title 'Server returns correct DeviceUseStatement resource from the DeviceUseStatement read interaction'
9
+ description %(
10
+ This test will verify that DeviceUseStatement resources can be read from the server.
11
+ )
12
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/DeviceUseStatement-uv-ips'
13
+
14
+ input :device_use_statement_id
15
+ makes_request :device_use_statement
16
+
17
+ run do
18
+ fhir_read(:device_use_statement, device_use_statement_id, name: :device_use_statement)
19
+
20
+ assert_response_status(200)
21
+ assert_resource_type(:device_use_statement)
22
+ assert resource.id == device_use_statement_id,
23
+ "Requested resource with id #{device_use_statement_id}, received resource with id #{resource.id}"
24
+ end
25
+ end
26
+
27
+ test do
28
+ title 'Server returns DeviceUseStatement resource that matches the Device Use Statement (IPS) profile'
29
+ description %(
30
+ This test will validate that the DeviceUseStatement resource returned from the server matches the Device Use Statement (IPS) profile.
31
+ )
32
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/DeviceUseStatement-uv-ips'
33
+ uses_request :device_use_statement
34
+
35
+ run do
36
+ assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/DeviceUseStatement-uv-ips')
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ module IPS
2
+ class DiagnosticReport < Inferno::TestGroup
3
+ title 'DiagnosticReport (IPS) Tests'
4
+ description 'Verify support for the server capabilities required by the DiagnosticReport (IPS) profile.'
5
+ id :ips_diagnostic_report
6
+
7
+ test do
8
+ title 'Server returns correct DiagnosticReport resource from the DiagnosticReport read interaction'
9
+ description %(
10
+ This test will verify that DiagnosticReport resources can be read from the server.
11
+ )
12
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/DiagnosticReport-uv-ips'
13
+
14
+ input :diagnostic_report_id
15
+ makes_request :diagnostic_report
16
+
17
+ run do
18
+ fhir_read(:diagnostic_report, diagnostic_report_id, name: :diagnostic_report)
19
+
20
+ assert_response_status(200)
21
+ assert_resource_type(:diagnostic_report)
22
+ assert resource.id == diagnostic_report_id,
23
+ "Requested resource with id #{diagnostic_report_id}, received resource with id #{resource.id}"
24
+ end
25
+ end
26
+
27
+ test do
28
+ title 'Server returns DiagnosticReport resource that matches the DiagnosticReport (IPS) profile'
29
+ description %(
30
+ This test will validate that the DiagnosticReport resource returned from the server matches the DiagnosticReport (IPS) profile.
31
+ )
32
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/DiagnosticReport-uv-ips'
33
+ uses_request :diagnostic_report
34
+
35
+ run do
36
+ assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/DiagnosticReport-uv-ips')
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,192 @@
1
+ module IPS
2
+ class DocumentOperation < Inferno::TestGroup
3
+ title 'Document Operation Tests'
4
+ description 'Verify support for the $document operation required by the Specimen (IPS) profile.'
5
+ id :ips_document_operation
6
+
7
+ test do
8
+ title 'IPS Server declares support for $document operation in CapabilityStatement'
9
+ description %(
10
+ The IPS Server SHALL declare support for Composition/[id]/$document operation in its server CapabilityStatement
11
+ )
12
+ # link 'http://build.fhir.org/composition-operation-document.html'
13
+
14
+ run do
15
+ fhir_get_capability_statement
16
+ assert_response_status(200)
17
+ assert_resource_type(:capability_statement)
18
+
19
+ operations = resource.rest&.flat_map do |rest|
20
+ rest.resource
21
+ &.select { |r| r.type == 'Composition' && r.respond_to?(:operation) }
22
+ &.flat_map(&:operation)
23
+ end&.compact
24
+
25
+ operation_defined = operations.any? do |operation|
26
+ operation.definition == 'http://hl7.org/fhir/OperationDefinition/Composition-document' ||
27
+ ['document', 'composition-document'].include?(operation.name.downcase)
28
+ end
29
+
30
+ assert operation_defined, 'Server CapabilityStatement did not declare support for $document operation in Composition resource.'
31
+ end
32
+ end
33
+
34
+ test do
35
+ title 'Server returns a fully bundled document from a Composition resource'
36
+ description %(
37
+ This test will perform the $document operation on the chosen composition resource with the persist option on.
38
+ It will verify that all referenced resources in the composition are in the document bundle and that we are able to retrieve the bundle after it's generated.
39
+ )
40
+ # link 'https://www.hl7.org/fhir/composition-operation-document.html'
41
+
42
+ input :composition_id
43
+ makes_request :document_operation
44
+
45
+ run do
46
+ fhir_read(:composition, composition_id)
47
+
48
+ assert_response_status(200)
49
+ assert_resource_type(:composition)
50
+ assert resource.id == composition_id,
51
+ "Requested resource with id #{composition_id}, received resource with id #{resource.id}"
52
+
53
+ assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/Composition-uv-ips')
54
+
55
+ composition = resource
56
+ references_in_composition = []
57
+ walk_resource(composition) do |value, meta, _path|
58
+ next if meta['type'] != 'Reference'
59
+ next if value.reference.blank?
60
+
61
+ references_in_composition << value
62
+ end
63
+
64
+ fhir_operation("Composition/#{composition.id}/$document?persist=true", name: :document_operation)
65
+ assert_response_status(200)
66
+ assert_resource_type(:bundle)
67
+
68
+ bundled_resources = resource.entry.map(&:resource)
69
+ missing_resources =
70
+ references_in_composition
71
+ .select(&:relative?)
72
+ .select do |reference|
73
+ resource_class = reference.resource_class
74
+ resource_id = reference.reference.split('/').last
75
+ bundled_resources.none? do |resource|
76
+ resource.instance_of?(resource_class) && resource.id == resource_id
77
+ end
78
+ end
79
+
80
+ assert missing_resources.empty?,
81
+ 'The following resources were missing in the response from the document ' \
82
+ "operation: #{missing_resources.map(&:reference).join(',')}"
83
+ end
84
+ end
85
+
86
+ test do
87
+ title 'IPS Server returns Bundle resource for Composition/id/$document operation'
88
+ description %(
89
+ IPS Server return valid IPS Bundle resource as successful result of $document operation
90
+
91
+ POST [base]/Composition/id/$document
92
+ )
93
+ # link 'https://www.hl7.org/fhir/composition-operation-document.html'
94
+ uses_request :document_operation
95
+
96
+ run do
97
+ skip_if !resource.is_a?(FHIR::Bundle), 'No Bundle returned from document operation'
98
+
99
+ assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/Bundle-uv-ips')
100
+ end
101
+ end
102
+
103
+ test do
104
+ title 'IPS Server returns Bundle resource containing valid IPS Composition entry'
105
+ description %(
106
+ IPS Server return valid IPS Composition resource in the Bundle as first entry
107
+ )
108
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition-Composition-uv-ips.html'
109
+ uses_request :document_operation
110
+
111
+ run do
112
+ skip_if !resource.is_a?(FHIR::Bundle), 'No Bundle returned from document operation'
113
+
114
+ assert resource.entry.length.positive?, 'Bundle has no entries'
115
+
116
+ entry = resource.entry.first
117
+
118
+ assert entry.resource.is_a?(FHIR::Composition), 'The first entry in the Bundle is not a Composition'
119
+ assert_valid_resource(resource: entry, profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/Composition-uv-ips')
120
+ end
121
+ end
122
+
123
+ test do
124
+ title 'IPS Server returns Bundle resource containing valid IPS MedicationStatement entry'
125
+ description %(
126
+ IPS Server return valid IPS MedicationStatement resource in the Bundle as first entry
127
+ )
128
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition-MedicationStatement-uv-ips.html'
129
+ uses_request :document_operation
130
+
131
+ run do
132
+ skip_if !resource.is_a?(FHIR::Bundle), 'No Bundle returned from document operation'
133
+
134
+ resources_present = resource.entry.any? { |r| r.resource.is_a?(FHIR::MedicationStatement) }
135
+
136
+ assert resources_present, 'Bundle does not contain any MedicationStatement resources'
137
+
138
+ assert_valid_bundle_entries(
139
+ resource_types: {
140
+ medication_statement: 'http://hl7.org/fhir/uv/ips/StructureDefinition/MedicationStatement-uv-ips'
141
+ }
142
+ )
143
+ end
144
+ end
145
+
146
+ test do
147
+ title 'IPS Server returns Bundle resource containing valid IPS AllergyIntolerance entry'
148
+ description %(
149
+ IPS Server return valid IPS AllergyIntolerance resource in the Bundle as first entry
150
+ )
151
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition-AllergyIntolerance-uv-ips.html'
152
+ uses_request :document_operation
153
+
154
+ run do
155
+ skip_if !resource.is_a?(FHIR::Bundle), 'No Bundle returned from document operation'
156
+
157
+ resources_present = resource.entry.any? { |r| r.resource.is_a?(FHIR::AllergyIntolerance) }
158
+
159
+ assert resources_present, 'Bundle does not contain any AllergyIntolerance resources'
160
+
161
+ assert_valid_bundle_entries(
162
+ resource_types: {
163
+ allergy_intolerance: 'http://hl7.org/fhir/uv/ips/StructureDefinition/AllergyIntolerance-uv-ips'
164
+ }
165
+ )
166
+ end
167
+ end
168
+
169
+ test do
170
+ title 'IPS Server returns Bundle resource containing valid IPS Condition entry'
171
+ description %(
172
+ IPS Server return valid IPS Condition resource in the Bundle as first entry
173
+ )
174
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition-Condition-uv-ips.html'
175
+ uses_request :document_operation
176
+
177
+ run do
178
+ skip_if !resource.is_a?(FHIR::Bundle), 'No Bundle returned from document operation'
179
+
180
+ resources_present = resource.entry.any? { |r| r.resource.is_a?(FHIR::Condition) }
181
+
182
+ assert resources_present, 'Bundle does not contain any Condition resources'
183
+
184
+ assert_valid_bundle_entries(
185
+ resource_types: {
186
+ condition: 'http://hl7.org/fhir/uv/ips/StructureDefinition/Condition-uv-ips'
187
+ }
188
+ )
189
+ end
190
+ end
191
+ end
192
+ end
@@ -0,0 +1,40 @@
1
+ module IPS
2
+ class ImagingStudy < Inferno::TestGroup
3
+ title 'Imaging Study (IPS) Tests'
4
+ description 'Verify support for the server capabilities required by the Imaging Study (IPS) profile.'
5
+ id :ips_imaging_study
6
+
7
+ test do
8
+ title 'Server returns correct ImagingStudy resource from the ImagingStudy read interaction'
9
+ description %(
10
+ This test will verify that ImagingStudy resources can be read from the server.
11
+ )
12
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/ImagingStudy-uv-ips'
13
+
14
+ input :imaging_study_id
15
+ makes_request :imaging_study
16
+
17
+ run do
18
+ fhir_read(:imaging_study, imaging_study_id, name: :imaging_study)
19
+
20
+ assert_response_status(200)
21
+ assert_resource_type(:imaging_study)
22
+ assert resource.id == imaging_study_id,
23
+ "Requested resource with id #{imaging_study_id}, received resource with id #{resource.id}"
24
+ end
25
+ end
26
+
27
+ test do
28
+ title 'Server returns ImagingStudy resource that matches the Imaging Study (IPS) profile'
29
+ description %(
30
+ This test will validate that the ImagingStudy resource returned from the server matches the Imaging Study (IPS) profile.
31
+ )
32
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/ImagingStudy-uv-ips'
33
+ uses_request :imaging_study
34
+
35
+ run do
36
+ assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/ImagingStudy-uv-ips')
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ module IPS
2
+ class Immunization < Inferno::TestGroup
3
+ title 'Immunization (IPS) Tests'
4
+ description 'Verify support for the server capabilities required by the Immunization (IPS) profile.'
5
+ id :ips_immunization
6
+
7
+ test do
8
+ title 'Server returns correct Immunization resource from the Immunization read interaction'
9
+ description %(
10
+ This test will verify that Immunization resources can be read from the server.
11
+ )
12
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/Immunization-uv-ips'
13
+
14
+ input :immunization_id
15
+ makes_request :immunization
16
+
17
+ run do
18
+ fhir_read(:immunization, immunization_id, name: :immunization)
19
+
20
+ assert_response_status(200)
21
+ assert_resource_type(:immunization)
22
+ assert resource.id == immunization_id,
23
+ "Requested resource with id #{immunization_id}, received resource with id #{resource.id}"
24
+ end
25
+ end
26
+
27
+ test do
28
+ title 'Server returns Immunization resource that matches the Immunization (IPS) profile'
29
+ description %(
30
+ This test will validate that the Immunization resource returned from the server matches the Immunization (IPS) profile.
31
+ )
32
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/Immunization-uv-ips'
33
+ uses_request :immunization
34
+
35
+ run do
36
+ assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/Immunization-uv-ips')
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ module IPS
2
+ class MediaObservation < Inferno::TestGroup
3
+ title 'Media observation (Results: laboratory, media) Tests'
4
+ description 'Verify support for the server capabilities required by the Media observation (Results: laboratory, media) profile.'
5
+ id :ips_media_observation
6
+
7
+ test do
8
+ title 'Server returns correct Media resource from the Media read interaction'
9
+ description %(
10
+ This test will verify that Media resources can be read from the server.
11
+ )
12
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/Media-observation-uv-ips'
13
+
14
+ input :media_id
15
+ makes_request :media
16
+
17
+ run do
18
+ fhir_read(:media, media_id, name: :media)
19
+
20
+ assert_response_status(200)
21
+ assert_resource_type(:media)
22
+ assert resource.id == media_id,
23
+ "Requested resource with id #{media_id}, received resource with id #{resource.id}"
24
+ end
25
+ end
26
+
27
+ test do
28
+ title 'Server returns Media resource that matches the Media observation (Results: laboratory, media) profile'
29
+ description %(
30
+ This test will validate that the Media resource returned from the server matches the Media observation (Results: laboratory, media) profile.
31
+ )
32
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/Media-observation-uv-ips'
33
+ uses_request :media
34
+
35
+ run do
36
+ assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/Media-observation-uv-ips')
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ module IPS
2
+ class Medication < Inferno::TestGroup
3
+ title 'Medication (IPS) Tests'
4
+ description 'Verify support for the server capabilities required by the Medication (IPS) profile.'
5
+ id :ips_medication
6
+
7
+ test do
8
+ title 'Server returns correct Medication resource from the Medication read interaction'
9
+ description %(
10
+ This test will verify that Medication resources can be read from the server.
11
+ )
12
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/Medication-uv-ips'
13
+
14
+ input :medication_id
15
+ makes_request :medication
16
+
17
+ run do
18
+ fhir_read(:medication, medication_id, name: :medication)
19
+
20
+ assert_response_status(200)
21
+ assert_resource_type(:medication)
22
+ assert resource.id == medication_id,
23
+ "Requested resource with id #{medication_id}, received resource with id #{resource.id}"
24
+ end
25
+ end
26
+
27
+ test do
28
+ title 'Server returns Medication resource that matches the Medication (IPS) profile'
29
+ description %(
30
+ This test will validate that the Medication resource returned from the server matches the Medication (IPS) profile.
31
+ )
32
+ # link 'http://hl7.org/fhir/uv/ips/StructureDefinition/Medication-uv-ips'
33
+ uses_request :medication
34
+
35
+ run do
36
+ assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/Medication-uv-ips')
37
+ end
38
+ end
39
+ end
40
+ end