ips_test_kit 0.1.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ips/composition.rb +0 -41
- data/lib/ips/docref_operation.rb +71 -0
- data/lib/ips/ips_resource_validation.rb +16 -2
- data/lib/ips/medication_request.rb +40 -0
- data/lib/ips/summary_operation.rb +26 -15
- data/lib/ips/version.rb +1 -1
- data/lib/ips_test_kit.rb +61 -7
- metadata +6 -5
- data/lib/ips/document_operation.rb +0 -192
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08f2c86440184d9a85aa426ee93f205d2c5f4c43dd440cb68ceaf0e5190e52b7'
|
4
|
+
data.tar.gz: 2305ca26944ca2fedeaab8afe3b40dc368ccebd5841f334555943e2708c22865
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5011ad2a089725196601c2ac4e43f8314fca677bae1f75247c2d1cc973a3601ca874c8dca309de8be05804e4792079de4a4901e5e3934f4e6a2c9da523b5aa4a
|
7
|
+
data.tar.gz: 795e384158a473b796f9299cbe4a829f1fc868121ba2d341035f1c616bba1f56d0f889556eb8a14c4fb297b012fe2f5a9368f08703cdc9505c62bf46a6b767e8
|
data/lib/ips/composition.rb
CHANGED
@@ -37,46 +37,5 @@ module IPS
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
test do
|
41
|
-
title 'Server returns a fully bundled document from a Composition resource'
|
42
|
-
description %(
|
43
|
-
This test will perform the $document operation on the chosen composition resource with the persist option on.
|
44
|
-
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.
|
45
|
-
)
|
46
|
-
# link 'https://www.hl7.org/fhir/composition-operation-document.html'
|
47
|
-
uses_request :composition
|
48
|
-
|
49
|
-
run do
|
50
|
-
skip_if resource.blank?, 'No resource found from Read test'
|
51
|
-
composition = resource
|
52
|
-
references_in_composition = []
|
53
|
-
walk_resource(composition) do |value, meta, _path|
|
54
|
-
next if meta['type'] != 'Reference'
|
55
|
-
next if value.reference.blank?
|
56
|
-
|
57
|
-
references_in_composition << value
|
58
|
-
end
|
59
|
-
|
60
|
-
fhir_client.get("Composition/#{resource.id}/$document?persist=true")
|
61
|
-
assert_response_status(200)
|
62
|
-
assert_resource_type(:bundle)
|
63
|
-
|
64
|
-
bundled_resources = resource.entry.map(&:resource)
|
65
|
-
missing_resources =
|
66
|
-
references_in_composition
|
67
|
-
.select(&:relative?)
|
68
|
-
.select do |reference|
|
69
|
-
resource_class = reference.resource_class
|
70
|
-
resource_id = reference.reference.split('/').last
|
71
|
-
bundled_resources.none? do |resource|
|
72
|
-
resource.instance_of?(resource_class) && resource.id == resource_id
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
assert missing_resources.empty?,
|
77
|
-
'The following resources were missing in the response from the document' \
|
78
|
-
"operation: #{missing_resources.map(&:to_s).join(',')}"
|
79
|
-
end
|
80
|
-
end
|
81
40
|
end
|
82
41
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module IPS
|
2
|
+
class DocRefOperation < Inferno::TestGroup
|
3
|
+
title 'DocRef Operation Tests'
|
4
|
+
|
5
|
+
description %(
|
6
|
+
Verify support for the $docref operation as as described in the [IPS
|
7
|
+
Guidance](http://hl7.org/fhir/uv/ips/STU1.1/ipsGeneration.html).
|
8
|
+
|
9
|
+
Note that this currently does not request an IPS bundle specifically
|
10
|
+
therefore does not validate the content.
|
11
|
+
)
|
12
|
+
id :ips_docref_operation
|
13
|
+
run_as_group
|
14
|
+
optional
|
15
|
+
|
16
|
+
test do
|
17
|
+
title 'IPS Server declares support for $docref operation in CapabilityStatement'
|
18
|
+
description %(
|
19
|
+
The IPS Server declares support for DocumentReference/$docref operation in its server CapabilityStatement
|
20
|
+
)
|
21
|
+
# link 'http://build.fhir.org/composition-operation-document.html'
|
22
|
+
|
23
|
+
run do
|
24
|
+
fhir_get_capability_statement
|
25
|
+
assert_response_status(200)
|
26
|
+
assert_resource_type(:capability_statement)
|
27
|
+
|
28
|
+
operations = resource.rest&.flat_map do |rest|
|
29
|
+
rest.resource
|
30
|
+
&.select { |r| r.type == 'DocumentReference' && r.respond_to?(:operation) }
|
31
|
+
&.flat_map(&:operation)
|
32
|
+
end&.compact
|
33
|
+
|
34
|
+
operation_defined = operations.any? do |operation|
|
35
|
+
operation.definition == 'http://hl7.org/fhir/uv/ipa/OperationDefinition/docref' || 'docref' == operation.name.downcase
|
36
|
+
end
|
37
|
+
|
38
|
+
assert operation_defined, 'Server CapabilityStatement did not declare support for $docref operation in DocumentReference resource.'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
test do
|
43
|
+
title 'Server responds successfully to a $docref operation'
|
44
|
+
description %(
|
45
|
+
This test creates a $docref operation request for a patient. Note that this
|
46
|
+
currently does not request an IPS bundle specifically therefore does not validate
|
47
|
+
the content.
|
48
|
+
)
|
49
|
+
|
50
|
+
input :patient_id
|
51
|
+
makes_request :docref_operation
|
52
|
+
|
53
|
+
run do
|
54
|
+
|
55
|
+
# Perform a FHIR Operation
|
56
|
+
parameters = FHIR::Parameters.new(
|
57
|
+
parameter: [
|
58
|
+
{
|
59
|
+
name: 'patient',
|
60
|
+
valueId: patient_id
|
61
|
+
}
|
62
|
+
]
|
63
|
+
)
|
64
|
+
fhir_operation("/DocumentReference/$docref", body: parameters)
|
65
|
+
|
66
|
+
assert_response_status(200)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -2,19 +2,33 @@ module IPS
|
|
2
2
|
class IPSResourceValidation < Inferno::TestGroup
|
3
3
|
title 'IPS Resource Validation Tests'
|
4
4
|
id :ips_resource_validation
|
5
|
+
description %(
|
6
|
+
This group performs content validation, which is useful for evaluating
|
7
|
+
conformance of systems that produce IPS bundles but do not generate
|
8
|
+
content using a FHIR interface as described in the [IPS
|
9
|
+
Guidance](http://hl7.org/fhir/uv/ips/STU1.1/ipsGeneration.html).
|
10
|
+
|
11
|
+
There is currently a single validation test for IPS bundles without any
|
12
|
+
other context-specific constraints. Therefore, this test measures a
|
13
|
+
systems ability to produce a single, valid IPS bundle. Future enhancements
|
14
|
+
to these tests should require systems to demonstrate more than just a
|
15
|
+
single valid IPS bundle.
|
16
|
+
)
|
5
17
|
|
6
18
|
group do
|
7
19
|
title 'IPS Bundle with no other constraints'
|
8
20
|
|
9
21
|
test do
|
10
|
-
title '
|
22
|
+
title 'IPS Bundle meets constraints provided in the IPS Bundle profile'
|
11
23
|
description %(
|
12
24
|
This test will validate the content of an IPS bundle to ensure it is valid.
|
13
25
|
)
|
14
|
-
input :bundle_content, title: 'IPS Bundle', type: 'textarea'
|
26
|
+
input :bundle_content, title: 'IPS Bundle', type: 'textarea', optional: true, description: 'Validate a single IPS bundle (optional)'
|
15
27
|
|
16
28
|
run do
|
17
29
|
|
30
|
+
skip_if bundle_content.blank?, 'No IPS Bundle provided'
|
31
|
+
|
18
32
|
resource_instance = FHIR.from_contents(bundle_content)
|
19
33
|
|
20
34
|
assert_resource_type(:bundle, resource: resource_instance)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module IPS
|
2
|
+
class MedicationRequest < Inferno::TestGroup
|
3
|
+
title 'MedicationRequest (IPS) Tests'
|
4
|
+
description 'Verify support for the server capabilities required by the MedicationRequest (IPS) profile.'
|
5
|
+
id :ips_medication_request
|
6
|
+
|
7
|
+
test do
|
8
|
+
title 'Server returns correct MedicationRequest resource from the MedicationRequest read interaction'
|
9
|
+
description %(
|
10
|
+
This test will verify that MedicationRequest resources can be read from the server.
|
11
|
+
)
|
12
|
+
# link 'http://hl7.org/fhir/uv/ips/StructureDefinition/MedicationRequest-uv-ips'
|
13
|
+
|
14
|
+
input :medication_request_id
|
15
|
+
makes_request :medication_request
|
16
|
+
|
17
|
+
run do
|
18
|
+
fhir_read(:medication_request, medication_request_id, name: :medication_request)
|
19
|
+
|
20
|
+
assert_response_status(200)
|
21
|
+
assert_resource_type(:medication_request)
|
22
|
+
assert resource.id == medication_request_id,
|
23
|
+
"Requested resource with id #{medication_request_id}, received resource with id #{resource.id}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
test do
|
28
|
+
title 'Server returns MedicationRequest resource that matches the MedicationRequest (IPS) profile'
|
29
|
+
description %(
|
30
|
+
This test will validate that the MedicationRequest resource returned from the server matches the MedicationRequest (IPS) profile.
|
31
|
+
)
|
32
|
+
# link 'http://hl7.org/fhir/uv/ips/StructureDefinition/MedicationRequest-uv-ips'
|
33
|
+
uses_request :medication_request
|
34
|
+
|
35
|
+
run do
|
36
|
+
assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/MedicationRequest-uv-ips')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,15 +1,18 @@
|
|
1
1
|
module IPS
|
2
2
|
class SummaryOperation < Inferno::TestGroup
|
3
|
-
title 'Summary Operation
|
4
|
-
description
|
3
|
+
title 'Summary Operation Tests'
|
4
|
+
description %(
|
5
|
+
Verify support for the $summary operation as as described in the [IPS
|
6
|
+
Guidance](http://hl7.org/fhir/uv/ips/STU1.1/ipsGeneration.html).
|
7
|
+
)
|
5
8
|
id :ips_summary_operation
|
9
|
+
run_as_group
|
6
10
|
|
7
11
|
test do
|
8
12
|
title 'IPS Server declares support for $summary operation in CapabilityStatement'
|
9
13
|
description %(
|
10
|
-
The IPS Server
|
14
|
+
The IPS Server declares support for Patient/[id]/$summary operation in its server CapabilityStatement
|
11
15
|
)
|
12
|
-
# link 'http://build.fhir.org/ig/HL7/fhir-ips/index.html'
|
13
16
|
|
14
17
|
run do
|
15
18
|
fhir_get_capability_statement
|
@@ -17,32 +20,40 @@ module IPS
|
|
17
20
|
|
18
21
|
operations = resource.rest&.flat_map do |rest|
|
19
22
|
rest.resource
|
20
|
-
&.select { |r| r.type == '
|
23
|
+
&.select { |r| r.type == 'Patient' && r.respond_to?(:operation) }
|
21
24
|
&.flat_map(&:operation)
|
22
25
|
end&.compact
|
23
26
|
|
24
27
|
operation_defined = operations.any? do |operation|
|
25
|
-
operation.definition == 'http://hl7.org/fhir/OperationDefinition/
|
28
|
+
operation.definition == 'http://hl7.org/fhir/uv/ips/OperationDefinition/summary' ||
|
26
29
|
['summary', 'patient-summary'].include?(operation.name.downcase)
|
27
30
|
end
|
28
31
|
|
29
|
-
assert operation_defined, 'Server CapabilityStatement did not declare support for $summary operation in
|
32
|
+
assert operation_defined, 'Server CapabilityStatement did not declare support for $summary operation in Patient resource.'
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
test do
|
34
|
-
title 'IPS Server returns Bundle resource for Patient/id/$summary operation'
|
37
|
+
title 'IPS Server returns Bundle resource for Patient/[id]/$summary GET operation'
|
35
38
|
description %(
|
36
|
-
IPS Server
|
39
|
+
IPS Server returns a valid IPS Bundle resource as successful result of
|
40
|
+
$summary operation.
|
37
41
|
|
38
|
-
|
42
|
+
This test currently only issues a GET request for the summary due to a
|
43
|
+
limitation in Inferno in issuing POST requests that omit a Content-Type
|
44
|
+
header when the body is empty. Inferno currently adds a `Content-Type:
|
45
|
+
application/x-www-form-urlencoded` header when issuing a POST with no
|
46
|
+
body, which causes issues in known reference implementations.
|
47
|
+
|
48
|
+
A future update to this test suite should include a required POST
|
49
|
+
request as well as an optional GET request for this content.
|
39
50
|
)
|
40
|
-
|
51
|
+
|
41
52
|
input :patient_id
|
42
53
|
makes_request :summary_operation
|
43
54
|
|
44
55
|
run do
|
45
|
-
fhir_operation("Patient/#{patient_id}/$summary", name: :summary_operation)
|
56
|
+
fhir_operation("Patient/#{patient_id}/$summary", name: :summary_operation, operation_method: :get)
|
46
57
|
assert_response_status(200)
|
47
58
|
assert_resource_type(:bundle)
|
48
59
|
assert_valid_resource(profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/Bundle-uv-ips')
|
@@ -62,10 +73,10 @@ module IPS
|
|
62
73
|
|
63
74
|
assert resource.entry.length.positive?, 'Bundle has no entries'
|
64
75
|
|
65
|
-
|
76
|
+
first_resource = resource.entry.first.resource
|
66
77
|
|
67
|
-
assert
|
68
|
-
assert_valid_resource(resource:
|
78
|
+
assert first_resource.is_a?(FHIR::Composition), 'The first entry in the Bundle is not a Composition'
|
79
|
+
assert_valid_resource(resource: first_resource, profile_url: 'http://hl7.org/fhir/uv/ips/StructureDefinition/Composition-uv-ips')
|
69
80
|
end
|
70
81
|
end
|
71
82
|
|
data/lib/ips/version.rb
CHANGED
data/lib/ips_test_kit.rb
CHANGED
@@ -1,36 +1,89 @@
|
|
1
1
|
Dir.glob(File.join(__dir__, 'ips', '*.rb')).each { |path| require_relative path.delete_prefix("#{__dir__}/") }
|
2
|
+
require_relative 'ips/version'
|
2
3
|
|
3
4
|
module IPS
|
4
5
|
class Suite < Inferno::TestSuite
|
5
|
-
title 'International Patient Summary (IPS)'
|
6
|
-
|
6
|
+
title 'International Patient Summary (IPS) v1.1.0'
|
7
|
+
short_title 'IPS v1.1.0'
|
8
|
+
description %(
|
9
|
+
This test suite evaluates the ability of a system to provide patient
|
10
|
+
summary data expressed using HL7® FHIR® in accordance with the
|
11
|
+
[International Patient Summary Implementation Guide (IPS
|
12
|
+
IG) v1.1.0](https://www.hl7.org/fhir/uv/ips/STU1.1).
|
13
|
+
|
14
|
+
Because IPS bundles can be generated and transmitted in many different
|
15
|
+
ways beyond a traditional FHIR RESTful server, this test suite allows you
|
16
|
+
to optionally evaluate a single bundle that is not being provided by a server in the
|
17
|
+
'IPS Resource Validation Tests'.
|
18
|
+
|
19
|
+
For systems that support a standard API for generating and communicating
|
20
|
+
these bundles in accordance with the guidance provided in the IG, use the
|
21
|
+
'IPS Operation Tests'.
|
22
|
+
|
23
|
+
For systems that also provide a FHIR API access to the components resources
|
24
|
+
of the IPS bundle, use the 'IPS Read Tests'.
|
25
|
+
|
26
|
+
This suite provides two presets:
|
27
|
+
* HL7.org IPS Server: Hosted reference IPS Server. This is suitable for running
|
28
|
+
the 'Operation' and 'Read' tests. Resource IDs may not remain valid as this is an
|
29
|
+
open server.
|
30
|
+
* IPS Example Summary Bundle: Populates the 'IPS Resource Validation Test' with an
|
31
|
+
example provided in the IG.
|
32
|
+
)
|
7
33
|
|
8
34
|
id 'ips'
|
35
|
+
version IPS::VERSION
|
9
36
|
|
10
37
|
validator do
|
11
38
|
url ENV.fetch('VALIDATOR_URL', 'http://validator_service:4567')
|
12
39
|
end
|
40
|
+
|
41
|
+
links [
|
42
|
+
{
|
43
|
+
label: 'Report Issue',
|
44
|
+
url: 'https://github.com/inferno-framework/ips-test-kit/issues/'
|
45
|
+
},
|
46
|
+
{
|
47
|
+
label: 'Open Source',
|
48
|
+
url: 'https://github.com/inferno-framework/ips-test-kit/'
|
49
|
+
},
|
50
|
+
{
|
51
|
+
label: 'International Patient Summary IG v1.1.0',
|
52
|
+
url: 'http://hl7.org/fhir/uv/ips/STU1.1/'
|
53
|
+
}
|
54
|
+
]
|
13
55
|
|
14
56
|
# Comment this out to remove
|
15
57
|
group from: :ips_resource_validation
|
16
58
|
|
17
59
|
group do
|
18
|
-
title 'IPS Operations'
|
60
|
+
title 'IPS Server Operations for Generating IPS Bundles Tests'
|
61
|
+
short_title 'IPS Operation Tests'
|
62
|
+
description %(
|
63
|
+
This group evaluates the ability of systems to provide a standard FHIR
|
64
|
+
API for generating and communicating an IPS Bundle as described in the
|
65
|
+
[IPS Data Generation and Inclusion Guidance](http://hl7.org/fhir/uv/ips/STU1.1/ipsGeneration.html).
|
66
|
+
|
67
|
+
Please note that the DocRef tests are currently of limited scope.
|
68
|
+
)
|
69
|
+
|
19
70
|
|
20
|
-
input :url
|
71
|
+
input :url, title: 'IPS FHIR Server Base URL'
|
21
72
|
|
22
73
|
fhir_client do
|
23
74
|
url :url
|
24
75
|
end
|
25
76
|
|
26
|
-
group from: :ips_document_operation
|
27
77
|
group from: :ips_summary_operation
|
78
|
+
group from: :ips_docref_operation
|
28
79
|
end
|
29
80
|
|
30
81
|
group do
|
31
|
-
title 'IPS Read and Validate Profiles'
|
82
|
+
title 'IPS Server Read and Validate Profiles Tests'
|
83
|
+
short_title 'IPS Read Tests'
|
84
|
+
optional
|
32
85
|
|
33
|
-
input :url
|
86
|
+
input :url, title: 'IPS FHIR Server Base URL'
|
34
87
|
|
35
88
|
fhir_client do
|
36
89
|
url :url
|
@@ -48,6 +101,7 @@ module IPS
|
|
48
101
|
group from: :ips_immunization
|
49
102
|
group from: :ips_media_observation
|
50
103
|
group from: :ips_medication
|
104
|
+
group from: :ips_medication_request
|
51
105
|
group from: :ips_medication_statement
|
52
106
|
group do
|
53
107
|
title 'Observation Profiles'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ips_test_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MITRE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inferno_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.4.
|
19
|
+
version: 0.4.21
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.4.
|
26
|
+
version: 0.4.21
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: database_cleaner-sequel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,12 +96,13 @@ files:
|
|
96
96
|
- lib/ips/device_observer.rb
|
97
97
|
- lib/ips/device_use_statement.rb
|
98
98
|
- lib/ips/diagnostic_report.rb
|
99
|
-
- lib/ips/
|
99
|
+
- lib/ips/docref_operation.rb
|
100
100
|
- lib/ips/imaging_study.rb
|
101
101
|
- lib/ips/immunization.rb
|
102
102
|
- lib/ips/ips_resource_validation.rb
|
103
103
|
- lib/ips/media_observation.rb
|
104
104
|
- lib/ips/medication.rb
|
105
|
+
- lib/ips/medication_request.rb
|
105
106
|
- lib/ips/medication_statement.rb
|
106
107
|
- lib/ips/observation_alcohol_use.rb
|
107
108
|
- lib/ips/observation_pregnancy_edd.rb
|
@@ -1,192 +0,0 @@
|
|
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
|
-
composition.each_element 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
|