davinci_crd_test_kit 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/config/presets/inferno_crd_client_suite.json.erb +110 -0
  3. data/config/presets/inferno_crd_server_suite.json.erb +173 -0
  4. data/config/presets/ri_crd_request_generator.json.erb +74 -0
  5. data/config/presets/ri_crd_server.json.erb +116 -0
  6. data/lib/davinci_crd_test_kit/crd_client_suite.rb +0 -3
  7. data/lib/davinci_crd_test_kit/crd_server_suite.rb +11 -9
  8. data/lib/davinci_crd_test_kit/igs/.keep +0 -0
  9. data/lib/davinci_crd_test_kit/igs/davinci-crd-2.0.1.tgz +0 -0
  10. data/lib/davinci_crd_test_kit/metadata.rb +75 -0
  11. data/lib/davinci_crd_test_kit/server_appointment_book_group.rb +4 -3
  12. data/lib/davinci_crd_test_kit/server_demonstrate_hook_response_group.rb +77 -0
  13. data/lib/davinci_crd_test_kit/server_encounter_discharge_group.rb +4 -3
  14. data/lib/davinci_crd_test_kit/server_encounter_start_group.rb +4 -3
  15. data/lib/davinci_crd_test_kit/server_hook_helper.rb +43 -0
  16. data/lib/davinci_crd_test_kit/server_order_dispatch_group.rb +4 -3
  17. data/lib/davinci_crd_test_kit/server_order_select_group.rb +4 -3
  18. data/lib/davinci_crd_test_kit/server_order_sign_group.rb +4 -3
  19. data/lib/davinci_crd_test_kit/server_tests/additional_orders_validation_test.rb +4 -6
  20. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_received_test.rb +6 -7
  21. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb +0 -4
  22. data/lib/davinci_crd_test_kit/server_tests/create_or_update_coverage_info_response_validation_test.rb +3 -5
  23. data/lib/davinci_crd_test_kit/server_tests/discovery_endpoint_test.rb +1 -1
  24. data/lib/davinci_crd_test_kit/server_tests/external_reference_card_validation_test.rb +4 -5
  25. data/lib/davinci_crd_test_kit/server_tests/form_completion_response_validation_test.rb +3 -5
  26. data/lib/davinci_crd_test_kit/server_tests/instructions_card_received_test.rb +3 -5
  27. data/lib/davinci_crd_test_kit/server_tests/launch_smart_app_card_validation_test.rb +4 -5
  28. data/lib/davinci_crd_test_kit/server_tests/propose_alternate_request_card_validation_test.rb +3 -5
  29. data/lib/davinci_crd_test_kit/server_tests/service_call_test.rb +23 -8
  30. data/lib/davinci_crd_test_kit/server_tests/service_request_context_validation_test.rb +4 -6
  31. data/lib/davinci_crd_test_kit/server_tests/service_request_optional_fields_validation_test.rb +4 -6
  32. data/lib/davinci_crd_test_kit/server_tests/service_request_required_fields_validation_test.rb +7 -7
  33. data/lib/davinci_crd_test_kit/server_tests/service_response_validation_test.rb +7 -8
  34. data/lib/davinci_crd_test_kit/tags.rb +2 -0
  35. data/lib/davinci_crd_test_kit/version.rb +2 -1
  36. data/lib/davinci_crd_test_kit.rb +1 -0
  37. metadata +20 -10
@@ -6,7 +6,6 @@ require_relative 'urls'
6
6
  require_relative 'crd_options'
7
7
  require_relative 'routes/hook_request_endpoint'
8
8
  require_relative 'ext/inferno_core/runnable'
9
- require_relative 'version'
10
9
 
11
10
  module DaVinciCRDTestKit
12
11
  class CRDClientSuite < Inferno::TestSuite
@@ -83,8 +82,6 @@ module DaVinciCRDTestKit
83
82
  Implementation Guide](https://hl7.org/fhir/us/davinci-crd/STU2).
84
83
  SUMMARY
85
84
 
86
- version VERSION
87
-
88
85
  links [
89
86
  {
90
87
  label: 'Report Issue',
@@ -1,8 +1,8 @@
1
1
  require_relative 'jwt_helper'
2
2
  require_relative 'routes/jwk_set_endpoint_handler'
3
3
  require_relative 'server_discovery_group'
4
+ require_relative 'server_demonstrate_hook_response_group'
4
5
  require_relative 'server_hooks_group'
5
- require_relative 'version'
6
6
 
7
7
  module DaVinciCRDTestKit
8
8
  class CRDServerSuite < Inferno::TestSuite
@@ -14,12 +14,14 @@ module DaVinciCRDTestKit
14
14
  Implementation Guide](https://hl7.org/fhir/us/davinci-crd/STU2).
15
15
 
16
16
  ## Overview
17
- This suite contains two groups of tests. The Discovery group validates a
18
- CRD server's discovery response. The Hooks group makes CDS Hooks calls to
19
- the server and validates the responses. By default, the hook requests are
20
- based on examples from the CDS Hooks specification, but testers can
21
- replace these with request bodies to elicit a particular response from
22
- their system.
17
+ This suite contains three groups of tests:
18
+ 1. The *Discovery* group validates a CRD server's discovery response.
19
+ 2. The *Demonstrate A Hook Response* group validates that the server
20
+ can respond to a single hook invocation and return conformant cards.
21
+ 3. The *Hooks* group makes one or more CDS Hooks calls for each hook
22
+ type that the tester provides request bodies for. It then validates that the
23
+ responses are conformant and cover the full range of cards as
24
+ required by the hook type.
23
25
 
24
26
  ## Trusting CDS Clients
25
27
  As specified in the [CDS Hooks Spec](https://cds-hooks.hl7.org/2.0/#trusting-cds-clients),
@@ -73,8 +75,6 @@ module DaVinciCRDTestKit
73
75
  Implementation Guide](https://hl7.org/fhir/us/davinci-crd/STU2).
74
76
  SUMMARY
75
77
 
76
- version VERSION
77
-
78
78
  links [
79
79
  {
80
80
  label: 'Report Issue',
@@ -110,6 +110,8 @@ module DaVinciCRDTestKit
110
110
 
111
111
  group from: :crd_server_discovery_group
112
112
 
113
+ group from: :crd_server_demonstrate_hook_response
114
+
113
115
  group from: :crd_server_hooks
114
116
  end
115
117
  end
File without changes
@@ -0,0 +1,75 @@
1
+ require_relative 'version'
2
+
3
+ module DaVinciCRDTestKit
4
+ class Metadata < Inferno::TestKit
5
+ id :davinci_crd_test_kit
6
+ title 'Da Vinci Coverage Requirements Discovery (CRD) Test Kit'
7
+ description <<~DESCRIPTION
8
+ The Da Vinci Coverage Requirements Discovery (CRD) Test Kit tests the
9
+ conformance of client and server systems to [version 2.0.1 of the Da Vinci
10
+ Coverage Requirements Discovery (CRD) Implementation
11
+ Guide](https://hl7.org/fhir/us/davinci-crd/STU2).
12
+
13
+ <!-- break -->
14
+
15
+ ## Status
16
+
17
+ These tests are a **DRAFT** intended to allow CRD implementers to perform
18
+ preliminary checks of their implementations against the CRD IG requirements and
19
+ provide feedback on the tests. Future versions of these tests may validate other
20
+ requirements and may change how these are tested.
21
+
22
+ Additional details on the IG requirements that underlie this test kit can be
23
+ found in this [CRD testing note](https://github.com/inferno-framework/davinci-crd-test-kit/blob/main/docs/crd-testing-notes.md). The document
24
+ includes the requirements extracted from the IG and specified the ones that are
25
+ not testable.
26
+
27
+ ## Test Scope and Limitations
28
+
29
+ Documentation of the current tests and their limitations can be found in each
30
+ suite's (client and server) description when the tests are run.
31
+
32
+ ### Test Scope
33
+
34
+ At a high-level, the tests check:
35
+
36
+ - **Client Suite**:
37
+ - The ability of a CRD client to initiate CDS Hooks calls.
38
+ - The ability of a CRD client to support the FHIR interactions defined in the
39
+ implementation guide.
40
+ - **Server Suite**:
41
+ - The ability of a CRD server to return a valid response when invoking its
42
+ discovery endpoint.
43
+ - The ability of a CRD server to return a valid response when invoking a
44
+ supported hook, including producing the required response types across all
45
+ hooks invoked.
46
+
47
+ ### Limitations
48
+
49
+ - **Client Suite**:
50
+ - This suite does not implement any payer business logic, so the responses to
51
+ hook calls are simple hard-coded responses.
52
+ - The tests cannot verify that a client is able to consume the received
53
+ decision support. Testers should consider this requirement to be verified
54
+ through attestation and should not represent their systems as having passed
55
+ these tests if this requirement is not met.
56
+ - Hook configuration is not tested.
57
+ - **Server Suite**:
58
+ - Inferno is unable to determine what requests will result in specific kinds
59
+ of responses from the server under test (e.g., what will result in
60
+ Instructions being returned vs. Coverage Information). As a result, the
61
+ tester must supply the request bodies that will cause the system under test
62
+ to return the desired response types.
63
+ - The ability of a CRD server to request additional FHIR resources is not
64
+ tested.
65
+ - Hook configuration is not tested.
66
+ DESCRIPTION
67
+ suite_ids [:crd_client, :crd_server]
68
+ tags ['Da Vinci', 'CRD']
69
+ last_updated LAST_UPDATED
70
+ version VERSION
71
+ maturity 'Low'
72
+ authors ['Stephen MacVicar', 'Vanessa Fotso', 'Emily Michaud']
73
+ repo 'https://github.com/inferno-framework/davinci-crd-test-kit'
74
+ end
75
+ end
@@ -11,6 +11,7 @@ require_relative 'server_tests/service_request_context_validation_test'
11
11
  require_relative 'server_tests/form_completion_response_validation_test'
12
12
  require_relative 'server_tests/launch_smart_app_card_validation_test'
13
13
  require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
14
+ require_relative 'tags'
14
15
 
15
16
  module DaVinciCRDTestKit
16
17
  class ServerAppointmentBookGroup < Inferno::TestGroup
@@ -41,7 +42,7 @@ module DaVinciCRDTestKit
41
42
  optional
42
43
  )
43
44
 
44
- config options: { hook_name: 'appointment-book' }
45
+ config options: { hook_name: APPOINTMENT_BOOK_TAG }
45
46
  run_as_group
46
47
 
47
48
  test from: :crd_service_call_test,
@@ -49,11 +50,11 @@ module DaVinciCRDTestKit
49
50
  inputs: {
50
51
  service_ids: {
51
52
  name: :appointment_book_service_ids,
52
- title: 'Service id for the service that invokes `appointment-book` hook'
53
+ title: 'Service id for the service that implements the `appointment-book` hook'
53
54
  },
54
55
  service_request_bodies: {
55
56
  name: :appointment_book_request_bodies,
56
- title: 'Request bodies collection to use to invoke the `appointment-book` hook'
57
+ title: 'Request body or bodies for invoking the `appointment-book` hook'
57
58
  }
58
59
  }
59
60
  }
@@ -0,0 +1,77 @@
1
+ require_relative 'server_tests/service_call_test'
2
+ require_relative 'server_tests/service_request_required_fields_validation_test'
3
+ require_relative 'server_tests/service_request_context_validation_test'
4
+ require_relative 'server_tests/service_response_validation_test'
5
+ require_relative 'tags'
6
+
7
+ module DaVinciCRDTestKit
8
+ class ServerDemonstrateHookResponseGroup < Inferno::TestGroup
9
+ title 'Demonstrate A Hook Response'
10
+ id :crd_server_demonstrate_hook_response
11
+ description %(
12
+ This group of tests allows the system to demonstrate its ability to respond to a CRD Hook invocation
13
+ and return a valid response. Inferno will use the provided request body and will either use the provided service
14
+ id or infer one from the hook indicated in the request and the server's discovery response.
15
+ It ensures that the user-provided request and the server's response are both
16
+ valid as per the requirements described in the [CRD IG section](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html)
17
+ and the [CDS Hooks](https://cds-hooks.hl7.org/) hook specification for the corresponding hook.
18
+ )
19
+
20
+ config options: { hook_name: ANY_HOOK_TAG }
21
+ run_as_group
22
+
23
+ test from: :crd_service_call_test,
24
+ config: {
25
+ inputs: {
26
+ service_ids: {
27
+ name: :any_hook_service_ids,
28
+ title: 'Service id to use for the "Demonstrate a Hook Response" test',
29
+ description: %(
30
+ If blank, Inferno will attempt to infer the service id to use by finding a service entry in the
31
+ Discovery response for the hook indicated in the provided request body. If it cannot be inferred,
32
+ the tests will be skipped.
33
+ )
34
+ },
35
+ service_request_bodies: {
36
+ name: :any_hook_request_body,
37
+ title: 'Request body to use for the "Demonstrate a Hook Response" test',
38
+ description: %(
39
+ Provide a single JSON request body to submit for the hook invocation. The type of hook invoked
40
+ will be inferred based on the `hook` element in the request.
41
+ )
42
+ }
43
+ }
44
+ }
45
+
46
+ test from: :crd_service_request_required_fields_validation,
47
+ config: {
48
+ outputs: {
49
+ contexts: {
50
+ name: :any_hook_contexts
51
+ }
52
+ }
53
+ }
54
+ test from: :crd_service_request_context_validation,
55
+ config: {
56
+ inputs: {
57
+ contexts: {
58
+ name: :any_hook_contexts
59
+ },
60
+ request_body: {
61
+ name: :any_hook_request_body
62
+ }
63
+ }
64
+ }
65
+ test from: :crd_service_response_validation,
66
+ config: {
67
+ outputs: {
68
+ valid_cards: {
69
+ name: :any_hook_valid_cards
70
+ },
71
+ valid_system_actions: {
72
+ name: :any_hook_valid_system_actions
73
+ }
74
+ }
75
+ }
76
+ end
77
+ end
@@ -9,6 +9,7 @@ require_relative 'server_tests/launch_smart_app_card_validation_test'
9
9
  require_relative 'server_tests/instructions_card_received_test'
10
10
  require_relative 'server_tests/form_completion_response_validation_test'
11
11
  require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
12
+ require_relative 'tags'
12
13
 
13
14
  module DaVinciCRDTestKit
14
15
  class ServerEncounterDischargeGroup < Inferno::TestGroup
@@ -35,7 +36,7 @@ module DaVinciCRDTestKit
35
36
  optional
36
37
  )
37
38
 
38
- config options: { hook_name: 'encounter-discharge' }
39
+ config options: { hook_name: ENCOUNTER_DISCHARGE_TAG }
39
40
  run_as_group
40
41
 
41
42
  test from: :crd_service_call_test,
@@ -43,11 +44,11 @@ module DaVinciCRDTestKit
43
44
  inputs: {
44
45
  service_ids: {
45
46
  name: :encounter_discharge_service_ids,
46
- title: 'Service id for the service that invokes `encounter-discharge` hook'
47
+ title: 'Service id for the service that implements the `encounter-discharge` hook'
47
48
  },
48
49
  service_request_bodies: {
49
50
  name: :encounter_discharge_request_bodies,
50
- title: 'Request bodies collection to use to invoke the `encounter-discharge` hook'
51
+ title: 'Request body or bodies for invoking the `encounter-discharge` hook'
51
52
  }
52
53
  }
53
54
  }
@@ -9,6 +9,7 @@ require_relative 'server_tests/launch_smart_app_card_validation_test'
9
9
  require_relative 'server_tests/instructions_card_received_test'
10
10
  require_relative 'server_tests/form_completion_response_validation_test'
11
11
  require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
12
+ require_relative 'tags'
12
13
 
13
14
  module DaVinciCRDTestKit
14
15
  class ServerEncounterStartGroup < Inferno::TestGroup
@@ -35,7 +36,7 @@ module DaVinciCRDTestKit
35
36
  optional
36
37
  )
37
38
 
38
- config options: { hook_name: 'encounter-start' }
39
+ config options: { hook_name: ENCOUNTER_START_TAG }
39
40
  run_as_group
40
41
 
41
42
  test from: :crd_service_call_test,
@@ -43,11 +44,11 @@ module DaVinciCRDTestKit
43
44
  inputs: {
44
45
  service_ids: {
45
46
  name: :encounter_start_service_ids,
46
- title: 'Service id for the service that invokes `encounter-start` hook'
47
+ title: 'Service id for the service that implements the `encounter-start` hook'
47
48
  },
48
49
  service_request_bodies: {
49
50
  name: :encounter_start_request_bodies,
50
- title: 'Request bodies collection to use to invoke the `encounter-start` hook'
51
+ title: 'Request body or bodies for invoking the `encounter-start` hook'
51
52
  }
52
53
  }
53
54
  }
@@ -0,0 +1,43 @@
1
+ require_relative 'tags'
2
+
3
+ module DaVinciCRDTestKit
4
+ module ServerHookHelper
5
+ # configured hook
6
+ # used for tagging the request
7
+ # "any" is an option
8
+ def tested_hook_name
9
+ config.options[:hook_name]
10
+ end
11
+
12
+ # identify the hook to invoke
13
+ def identify_hook(payloads)
14
+ if tested_hook_name == ANY_HOOK_TAG
15
+ hook_list_from_payloads = payloads.map { |body| body['hook'] }.uniq
16
+
17
+ assert hook_list_from_payloads.length == 1,
18
+ 'Could not identify the tested hook for the *Demonstrated Any Hook tests* from the request bodies.'
19
+
20
+ hook_list_from_payloads.first
21
+ else
22
+ tested_hook_name
23
+ end
24
+ end
25
+
26
+ # target service id for invocation
27
+ # if a list isn't provided, use the discovery response and the target hook to find one
28
+ def target_service_id(service_ids, hook_name)
29
+ return service_ids.split(', ').first.strip if service_ids.present?
30
+
31
+ discovered_service_id_for_hook(hook_name)
32
+ end
33
+
34
+ # load discovery response to get the target service id
35
+ def discovered_service_id_for_hook(hook_name)
36
+ discovery_requests = load_tagged_requests(DaVinciCRDTestKit::DISCOVERY_TAG)
37
+ services = discovery_requests&.first&.response_body
38
+ return unless services.present?
39
+
40
+ JSON.parse(services)['services']&.find { |service| service['hook'] == hook_name }&.dig('id')
41
+ end
42
+ end
43
+ end
@@ -11,6 +11,7 @@ require_relative 'server_tests/coverage_information_system_action_received_test'
11
11
  require_relative 'server_tests/coverage_information_system_action_validation_test'
12
12
  require_relative 'server_tests/form_completion_response_validation_test'
13
13
  require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
14
+ require_relative 'tags'
14
15
 
15
16
  module DaVinciCRDTestKit
16
17
  class ServerOrderDispatchGroup < Inferno::TestGroup
@@ -41,7 +42,7 @@ module DaVinciCRDTestKit
41
42
  optional
42
43
  )
43
44
 
44
- config options: { hook_name: 'order-dispatch' }
45
+ config options: { hook_name: ORDER_DISPATCH_TAG }
45
46
  run_as_group
46
47
 
47
48
  test from: :crd_service_call_test,
@@ -49,11 +50,11 @@ module DaVinciCRDTestKit
49
50
  inputs: {
50
51
  service_ids: {
51
52
  name: :order_dispatch_service_ids,
52
- title: 'Service id for the service that invokes `order-dispatch` hook'
53
+ title: 'Service id for the service that implements the `order-dispatch` hook'
53
54
  },
54
55
  service_request_bodies: {
55
56
  name: :order_dispatch_request_bodies,
56
- title: 'Request bodies collection to use to invoke the `order-dispatch` hook'
57
+ title: 'Request body or bodies for invoking the `order-dispatch` hook'
57
58
  }
58
59
  }
59
60
  }
@@ -11,6 +11,7 @@ require_relative 'server_tests/propose_alternate_request_card_validation_test'
11
11
  require_relative 'server_tests/additional_orders_validation_test'
12
12
  require_relative 'server_tests/form_completion_response_validation_test'
13
13
  require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
14
+ require_relative 'tags'
14
15
 
15
16
  module DaVinciCRDTestKit
16
17
  class ServerOrderSelectGroup < Inferno::TestGroup
@@ -41,7 +42,7 @@ module DaVinciCRDTestKit
41
42
  optional
42
43
  )
43
44
 
44
- config options: { hook_name: 'order-select' }
45
+ config options: { hook_name: ORDER_SELECT_TAG }
45
46
  run_as_group
46
47
 
47
48
  test from: :crd_service_call_test,
@@ -49,11 +50,11 @@ module DaVinciCRDTestKit
49
50
  inputs: {
50
51
  service_ids: {
51
52
  name: :order_select_service_ids,
52
- title: 'Service id for the service that invokes `order-select` hook'
53
+ title: 'Service id for the service that implements the `order-select` hook'
53
54
  },
54
55
  service_request_bodies: {
55
56
  name: :order_select_request_bodies,
56
- title: 'Request bodies collection to use to invoke the `order-select` hook'
57
+ title: 'Request body or bodies for invoking the `order-select` hook'
57
58
  }
58
59
  }
59
60
  }
@@ -13,6 +13,7 @@ require_relative 'server_tests/propose_alternate_request_card_validation_test'
13
13
  require_relative 'server_tests/additional_orders_validation_test'
14
14
  require_relative 'server_tests/form_completion_response_validation_test'
15
15
  require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
16
+ require_relative 'tags'
16
17
 
17
18
  module DaVinciCRDTestKit
18
19
  class ServerOrderSignGroup < Inferno::TestGroup
@@ -47,7 +48,7 @@ module DaVinciCRDTestKit
47
48
  optional
48
49
  )
49
50
 
50
- config options: { hook_name: 'order-sign' }
51
+ config options: { hook_name: ORDER_SIGN_TAG }
51
52
  run_as_group
52
53
 
53
54
  test from: :crd_service_call_test,
@@ -55,11 +56,11 @@ module DaVinciCRDTestKit
55
56
  inputs: {
56
57
  service_ids: {
57
58
  name: :order_sign_service_ids,
58
- title: 'Service id for the service that invokes `order-sign` hook'
59
+ title: 'Service id for the service that implements the `order-sign` hook'
59
60
  },
60
61
  service_request_bodies: {
61
62
  name: :order_sign_request_bodies,
62
- title: 'Request bodies collection to use to invoke the `order-sign` hook'
63
+ title: 'Request body or bodies for invoking the `order-sign` hook'
63
64
  }
64
65
  }
65
66
  }
@@ -1,10 +1,12 @@
1
1
  require_relative '../test_helper'
2
+ require_relative '../server_hook_helper'
2
3
  require_relative '../suggestion_actions_validation'
3
4
 
4
5
  module DaVinciCRDTestKit
5
6
  class AdditionalOrdersValidationTest < Inferno::Test
6
7
  include DaVinciCRDTestKit::TestHelper
7
8
  include DaVinciCRDTestKit::SuggestionActionsValidation
9
+ include DaVinciCRDTestKit::ServerHookHelper
8
10
 
9
11
  title 'Valid Additional Orders as companions/prerequisites cards received'
10
12
  id :crd_additional_orders_card_validation
@@ -39,10 +41,6 @@ module DaVinciCRDTestKit
39
41
  VisionPrescription
40
42
  ].freeze
41
43
 
42
- def hook_name
43
- config.options[:hook_name]
44
- end
45
-
46
44
  def additional_orders_card?(card)
47
45
  card['suggestions'].all? do |suggestion|
48
46
  actions = suggestion['actions']
@@ -56,7 +54,7 @@ module DaVinciCRDTestKit
56
54
  parsed_cards = parse_json(valid_cards_with_suggestions)
57
55
  additional_orders_cards = parsed_cards.filter { |card| additional_orders_card?(card) }
58
56
  skip_if additional_orders_cards.blank?,
59
- "#{hook_name} hook response does not contain an Additional Orders as companions/prerequisites card."
57
+ "#{tested_hook_name} hook response does not include Additional Orders as companion/prerequisite cards."
60
58
 
61
59
  additional_orders_cards.each do |card|
62
60
  card['suggestions'].each do |suggestion|
@@ -64,7 +62,7 @@ module DaVinciCRDTestKit
64
62
  end
65
63
  end
66
64
 
67
- no_error_validation('Some Additional Orders as companions/prerequisites cards are not valid.')
65
+ no_error_validation('Some companions/prerequisites Additional Order cards are not valid.')
68
66
  end
69
67
  end
70
68
  end
@@ -1,7 +1,10 @@
1
1
  require_relative '../test_helper'
2
+ require_relative '../server_hook_helper'
3
+
2
4
  module DaVinciCRDTestKit
3
5
  class CoverageInformationSystemActionReceivedTest < Inferno::Test
4
6
  include DaVinciCRDTestKit::TestHelper
7
+ include DaVinciCRDTestKit::ServerHookHelper
5
8
 
6
9
  title 'Coverage Information system action was received'
7
10
  id :crd_coverage_info_system_action_received
@@ -15,13 +18,9 @@ module DaVinciCRDTestKit
15
18
  - Then, among the target actions, checking if their resource has the [coverage-information extension](http://hl7.org/fhir/us/davinci-crd/StructureDefinition/ext-coverage-information).
16
19
  )
17
20
 
18
- input :valid_system_actions
21
+ input :valid_system_actions, :invoked_hook
19
22
  output :coverage_info
20
23
 
21
- def hook_name
22
- config.options[:hook_name]
23
- end
24
-
25
24
  def resources_by_hook
26
25
  shared_resources = [
27
26
  'DeviceRequest', 'MedicationRequest', 'NutritionOrder',
@@ -39,7 +38,7 @@ module DaVinciCRDTestKit
39
38
 
40
39
  run do
41
40
  parsed_actions = parse_json(valid_system_actions)
42
- target_resources = resources_by_hook[hook_name]
41
+ target_resources = resources_by_hook[invoked_hook]
43
42
 
44
43
  target_actions = parsed_actions.select do |action|
45
44
  resource = FHIR.from_contents(action['resource'].to_json)
@@ -53,7 +52,7 @@ module DaVinciCRDTestKit
53
52
  end
54
53
 
55
54
  assert coverage_info_system_actions.present?,
56
- "Coverage Information system action was not returned in the #{hook_name} hook response."
55
+ "Coverage Information system action was not returned in the #{tested_hook_name} hook response."
57
56
 
58
57
  output coverage_info: coverage_info_system_actions.to_json
59
58
  end
@@ -22,10 +22,6 @@ module DaVinciCRDTestKit
22
22
  )
23
23
  input :coverage_info
24
24
 
25
- def hook_name
26
- config.options[:hook_name]
27
- end
28
-
29
25
  def find_extension_value(extension, url, *properties)
30
26
  found_extension = extension.extension.find { |ext| ext.url == url }
31
27
  return nil unless found_extension
@@ -1,10 +1,12 @@
1
1
  require_relative '../test_helper'
2
2
  require_relative '../suggestion_actions_validation'
3
+ require_relative '../server_hook_helper'
3
4
 
4
5
  module DaVinciCRDTestKit
5
6
  class CreateOrUpdateCoverageInfoResponseValidationTest < Inferno::Test
6
7
  include DaVinciCRDTestKit::TestHelper
7
8
  include DaVinciCRDTestKit::SuggestionActionsValidation
9
+ include DaVinciCRDTestKit::ServerHookHelper
8
10
 
9
11
  title 'Valid Create or Update Coverage Information cards or system actions received'
10
12
  id :crd_create_or_update_coverage_info_response_validation
@@ -29,10 +31,6 @@ module DaVinciCRDTestKit
29
31
  optional
30
32
  input :valid_cards_with_suggestions, :valid_system_actions
31
33
 
32
- def hook_name
33
- config.options[:hook_name]
34
- end
35
-
36
34
  def coverage_actions(actions)
37
35
  return [] if actions.nil?
38
36
 
@@ -53,7 +51,7 @@ module DaVinciCRDTestKit
53
51
  create_or_update_coverage_info_cards = parsed_cards.filter { |card| create_or_update_coverage_info_card?(card) }
54
52
  create_or_update_coverage_info_actions = coverage_actions(parsed_actions)
55
53
 
56
- skip_msg = "#{hook_name} hook response does not contain any Create or Update Coverage Information " \
54
+ skip_msg = "#{tested_hook_name} hook response does not contain any Create or Update Coverage Information " \
57
55
  'cards or system actions.'
58
56
  skip_if create_or_update_coverage_info_cards.blank? && create_or_update_coverage_info_actions.blank?, skip_msg
59
57
 
@@ -78,7 +78,7 @@ module DaVinciCRDTestKit
78
78
  )
79
79
  headers['Authorization'] = "Bearer #{token}"
80
80
  end
81
- get(discovery_url, headers:)
81
+ get(discovery_url, headers:, tags: [DISCOVERY_TAG])
82
82
  assert_response_status(200)
83
83
  assert_valid_json(request.response_body)
84
84
 
@@ -1,8 +1,10 @@
1
1
  require_relative '../test_helper'
2
+ require_relative '../server_hook_helper'
2
3
 
3
4
  module DaVinciCRDTestKit
4
5
  class ExternalReferenceCardValidationTest < Inferno::Test
5
6
  include DaVinciCRDTestKit::TestHelper
7
+ include DaVinciCRDTestKit::ServerHookHelper
6
8
 
7
9
  title 'Valid External Reference cards received'
8
10
  id :crd_external_reference_card_validation
@@ -19,10 +21,6 @@ module DaVinciCRDTestKit
19
21
  input :valid_cards_with_links
20
22
  optional
21
23
 
22
- def hook_name
23
- config.options[:hook_name]
24
- end
25
-
26
24
  run do
27
25
  parsed_cards = parse_json(valid_cards_with_links)
28
26
  external_reference_cards = parsed_cards.select do |card|
@@ -30,7 +28,8 @@ module DaVinciCRDTestKit
30
28
  links.present? && links.all? { |link| link['type'] == 'absolute' }
31
29
  end
32
30
 
33
- assert external_reference_cards.present?, "#{hook_name} hook response did not contain an External Reference card."
31
+ assert external_reference_cards.present?,
32
+ "#{tested_hook_name} hook response did not contain an External Reference card."
34
33
  end
35
34
  end
36
35
  end
@@ -1,10 +1,12 @@
1
1
  require_relative '../test_helper'
2
2
  require_relative '../suggestion_actions_validation'
3
+ require_relative '../server_hook_helper'
3
4
 
4
5
  module DaVinciCRDTestKit
5
6
  class FormCompletionResponseValidationTest < Inferno::Test
6
7
  include DaVinciCRDTestKit::TestHelper
7
8
  include DaVinciCRDTestKit::SuggestionActionsValidation
9
+ include DaVinciCRDTestKit::ServerHookHelper
8
10
 
9
11
  title 'Valid Request Form Completion cards or system actions received'
10
12
  id :crd_request_form_completion_response_validation
@@ -31,10 +33,6 @@ module DaVinciCRDTestKit
31
33
  optional
32
34
  input :valid_cards_with_suggestions, :valid_system_actions
33
35
 
34
- def hook_name
35
- config.options[:hook_name]
36
- end
37
-
38
36
  def task_actions(actions)
39
37
  actions&.select { |action| action['type'] == 'create' && action_resource_type_check(action, ['Task']) }
40
38
  end
@@ -61,7 +59,7 @@ module DaVinciCRDTestKit
61
59
  form_completion_actions = task_actions(parsed_actions).select { |action| task_questionnaire?(action) }
62
60
 
63
61
  skip_if form_completion_cards.blank? && form_completion_actions.blank?,
64
- "#{hook_name} hook response does not contain any Request Form Completion cards or system actions."
62
+ "#{tested_hook_name} hook response does not contain any Request Form Completion cards or system actions."
65
63
 
66
64
  actions_check(form_completion_actions) if form_completion_actions.present?
67
65