davinci_crd_test_kit 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/lib/davinci_crd_test_kit/card_responses/companions_prerequisites.json +58 -0
  4. data/lib/davinci_crd_test_kit/card_responses/create_update_coverage_information.json +20 -0
  5. data/lib/davinci_crd_test_kit/card_responses/external_reference.json +21 -0
  6. data/lib/davinci_crd_test_kit/card_responses/instructions.json +14 -0
  7. data/lib/davinci_crd_test_kit/card_responses/launch_smart_app.json +21 -0
  8. data/lib/davinci_crd_test_kit/card_responses/propose_alternate_request.json +71 -0
  9. data/lib/davinci_crd_test_kit/card_responses/request_form_completion.json +227 -0
  10. data/lib/davinci_crd_test_kit/cards_validation.rb +234 -0
  11. data/lib/davinci_crd_test_kit/client_fhir_api_group.rb +762 -0
  12. data/lib/davinci_crd_test_kit/client_hook_request_validation.rb +15 -0
  13. data/lib/davinci_crd_test_kit/client_hooks_group.rb +706 -0
  14. data/lib/davinci_crd_test_kit/client_tests/appointment_book_receive_request_test.rb +71 -0
  15. data/lib/davinci_crd_test_kit/client_tests/client_display_cards_attest.rb +48 -0
  16. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_create_test.rb +40 -0
  17. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_read_test.rb +39 -0
  18. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_search_test.rb +232 -0
  19. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_update_test.rb +40 -0
  20. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_validation_test.rb +60 -0
  21. data/lib/davinci_crd_test_kit/client_tests/decode_auth_token_test.rb +40 -0
  22. data/lib/davinci_crd_test_kit/client_tests/encounter_discharge_receive_request_test.rb +68 -0
  23. data/lib/davinci_crd_test_kit/client_tests/encounter_start_receive_request_test.rb +68 -0
  24. data/lib/davinci_crd_test_kit/client_tests/hook_request_optional_fields_test.rb +41 -0
  25. data/lib/davinci_crd_test_kit/client_tests/hook_request_required_fields_test.rb +40 -0
  26. data/lib/davinci_crd_test_kit/client_tests/hook_request_valid_context_test.rb +63 -0
  27. data/lib/davinci_crd_test_kit/client_tests/hook_request_valid_prefetch_test.rb +151 -0
  28. data/lib/davinci_crd_test_kit/client_tests/order_dispatch_receive_request_test.rb +79 -0
  29. data/lib/davinci_crd_test_kit/client_tests/order_select_receive_request_test.rb +76 -0
  30. data/lib/davinci_crd_test_kit/client_tests/order_sign_receive_request_test.rb +79 -0
  31. data/lib/davinci_crd_test_kit/client_tests/retrieve_jwks_test.rb +65 -0
  32. data/lib/davinci_crd_test_kit/client_tests/token_header_test.rb +34 -0
  33. data/lib/davinci_crd_test_kit/client_tests/token_payload_test.rb +61 -0
  34. data/lib/davinci_crd_test_kit/crd_client_suite.rb +156 -0
  35. data/lib/davinci_crd_test_kit/crd_jwks.json +59 -0
  36. data/lib/davinci_crd_test_kit/crd_options.rb +9 -0
  37. data/lib/davinci_crd_test_kit/crd_server_suite.rb +115 -0
  38. data/lib/davinci_crd_test_kit/ext/inferno_core/runnable.rb +22 -0
  39. data/lib/davinci_crd_test_kit/hook_request_field_validation.rb +410 -0
  40. data/lib/davinci_crd_test_kit/jwks.rb +25 -0
  41. data/lib/davinci_crd_test_kit/jwt_helper.rb +74 -0
  42. data/lib/davinci_crd_test_kit/mock_service_response.rb +421 -0
  43. data/lib/davinci_crd_test_kit/routes/cds-services.json +74 -0
  44. data/lib/davinci_crd_test_kit/routes/cds_services_discovery_handler.rb +18 -0
  45. data/lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb +93 -0
  46. data/lib/davinci_crd_test_kit/routes/jwk_set_endpoint_handler.rb +15 -0
  47. data/lib/davinci_crd_test_kit/server_appointment_book_group.rb +173 -0
  48. data/lib/davinci_crd_test_kit/server_discovery_group.rb +59 -0
  49. data/lib/davinci_crd_test_kit/server_encounter_discharge_group.rb +144 -0
  50. data/lib/davinci_crd_test_kit/server_encounter_start_group.rb +144 -0
  51. data/lib/davinci_crd_test_kit/server_hook_request_validation.rb +15 -0
  52. data/lib/davinci_crd_test_kit/server_hooks_group.rb +69 -0
  53. data/lib/davinci_crd_test_kit/server_order_dispatch_group.rb +173 -0
  54. data/lib/davinci_crd_test_kit/server_order_select_group.rb +169 -0
  55. data/lib/davinci_crd_test_kit/server_order_sign_group.rb +198 -0
  56. data/lib/davinci_crd_test_kit/server_required_card_response_validation_group.rb +23 -0
  57. data/lib/davinci_crd_test_kit/server_tests/additional_orders_validation_test.rb +70 -0
  58. data/lib/davinci_crd_test_kit/server_tests/card_optional_fields_validation_test.rb +47 -0
  59. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_across_hooks_validation_test.rb +32 -0
  60. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_received_test.rb +58 -0
  61. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb +121 -0
  62. data/lib/davinci_crd_test_kit/server_tests/create_or_update_coverage_info_response_validation_test.rb +72 -0
  63. data/lib/davinci_crd_test_kit/server_tests/discovery_endpoint_test.rb +88 -0
  64. data/lib/davinci_crd_test_kit/server_tests/discovery_services_validation_test.rb +65 -0
  65. data/lib/davinci_crd_test_kit/server_tests/external_reference_card_across_hooks_validation_test.rb +28 -0
  66. data/lib/davinci_crd_test_kit/server_tests/external_reference_card_validation_test.rb +36 -0
  67. data/lib/davinci_crd_test_kit/server_tests/form_completion_response_validation_test.rb +79 -0
  68. data/lib/davinci_crd_test_kit/server_tests/instructions_card_received_across_hooks_test.rb +25 -0
  69. data/lib/davinci_crd_test_kit/server_tests/instructions_card_received_test.rb +28 -0
  70. data/lib/davinci_crd_test_kit/server_tests/launch_smart_app_card_validation_test.rb +38 -0
  71. data/lib/davinci_crd_test_kit/server_tests/propose_alternate_request_card_validation_test.rb +65 -0
  72. data/lib/davinci_crd_test_kit/server_tests/service_call_test.rb +86 -0
  73. data/lib/davinci_crd_test_kit/server_tests/service_request_context_validation_test.rb +30 -0
  74. data/lib/davinci_crd_test_kit/server_tests/service_request_optional_fields_validation_test.rb +41 -0
  75. data/lib/davinci_crd_test_kit/server_tests/service_request_required_fields_validation_test.rb +43 -0
  76. data/lib/davinci_crd_test_kit/server_tests/service_response_validation_test.rb +82 -0
  77. data/lib/davinci_crd_test_kit/suggestion_actions_validation.rb +123 -0
  78. data/lib/davinci_crd_test_kit/tags.rb +8 -0
  79. data/lib/davinci_crd_test_kit/test_helper.rb +23 -0
  80. data/lib/davinci_crd_test_kit/urls.rb +52 -0
  81. data/lib/davinci_crd_test_kit/version.rb +3 -0
  82. data/lib/davinci_crd_test_kit.rb +2 -0
  83. metadata +170 -0
@@ -0,0 +1,173 @@
1
+ require_relative 'server_tests/service_call_test'
2
+ require_relative 'server_tests/service_response_validation_test'
3
+ require_relative 'server_tests/card_optional_fields_validation_test'
4
+ require_relative 'server_tests/external_reference_card_validation_test'
5
+ require_relative 'server_tests/coverage_information_system_action_received_test'
6
+ require_relative 'server_tests/coverage_information_system_action_validation_test'
7
+ require_relative 'server_tests/instructions_card_received_test'
8
+ require_relative 'server_tests/service_request_required_fields_validation_test'
9
+ require_relative 'server_tests/service_request_optional_fields_validation_test'
10
+ require_relative 'server_tests/service_request_context_validation_test'
11
+ require_relative 'server_tests/form_completion_response_validation_test'
12
+ require_relative 'server_tests/launch_smart_app_card_validation_test'
13
+ require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
14
+
15
+ module DaVinciCRDTestKit
16
+ class ServerAppointmentBookGroup < Inferno::TestGroup
17
+ title 'appointment-book'
18
+ id :crd_server_appointment_book
19
+ description %(
20
+ This group of tests invokes the appointment-book hook and ensures that
21
+ the user-provided requests are valid as per the requirements described
22
+ in the [CRD IG section on appointment-book hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#appointment-book)
23
+ and the [CDS Hooks specification section on appointment-book context](https://cds-hooks.hl7.org/hooks/appointment-book/2023SepSTU1Ballot/appointment-book/).
24
+ It also ensures that the contents of the server's response are valid as per the requirements described in
25
+ the [CRD IG section on appointment-book hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#appointment-book)
26
+ and the [CDS Hooks section on CDS Service Response](https://cds-hooks.hl7.org/2.0/#cds-service-response).
27
+
28
+ The [CRD IG section on appointment-book hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#appointment-book)
29
+ states that "servers SHALL, at minimum, support returning and processing the Coverage Information
30
+ system action for all invocations of this hook."
31
+
32
+ This group includes tests to validate the following CRD response types:
33
+ - [Coverage Information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#coverage-information)
34
+ - [Create or update coverage information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#create-or-update-coverage-information)\
35
+ - optional
36
+ - [External Reference](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#external-reference) - optional
37
+ - [Instructions](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#instructions) - optional
38
+ - [Launch SMART application](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#launch-smart-application) -
39
+ optional
40
+ - [Request form completion](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#request-form-completion) -
41
+ optional
42
+ )
43
+
44
+ config options: { hook_name: 'appointment-book' }
45
+ run_as_group
46
+
47
+ test from: :crd_service_call_test,
48
+ config: {
49
+ inputs: {
50
+ service_ids: {
51
+ name: :appointment_book_service_ids,
52
+ title: 'Service id for the service that invokes `appointment-book` hook'
53
+ },
54
+ service_request_bodies: {
55
+ name: :appointment_book_request_bodies,
56
+ title: 'Request bodies collection to use to invoke the `appointment-book` hook'
57
+ }
58
+ }
59
+ }
60
+
61
+ test from: :crd_service_request_required_fields_validation,
62
+ config: {
63
+ outputs: {
64
+ contexts: {
65
+ name: :appointment_book_contexts
66
+ }
67
+ }
68
+ }
69
+ test from: :crd_service_request_context_validation,
70
+ config: {
71
+ inputs: {
72
+ contexts: {
73
+ name: :appointment_book_contexts
74
+ }
75
+ }
76
+ }
77
+ test from: :crd_service_request_optional_fields_validation
78
+ test from: :crd_service_response_validation,
79
+ config: {
80
+ outputs: {
81
+ valid_cards: {
82
+ name: :appointment_book_valid_cards
83
+ },
84
+ valid_system_actions: {
85
+ name: :appointment_book_valid_system_actions
86
+ }
87
+ }
88
+ }
89
+ test from: :crd_card_optional_fields_validation,
90
+ config: {
91
+ inputs: {
92
+ valid_cards: {
93
+ name: :appointment_book_valid_cards
94
+ }
95
+ },
96
+ outputs: {
97
+ valid_cards_with_links: {
98
+ name: :appointment_book_valid_cards_with_links
99
+ },
100
+ valid_cards_with_suggestions: {
101
+ name: :appointment_book_valid_cards_with_suggestions
102
+ }
103
+ }
104
+ }
105
+ test from: :crd_external_reference_card_validation,
106
+ config: {
107
+ inputs: {
108
+ valid_cards_with_links: {
109
+ name: :appointment_book_valid_cards_with_links
110
+ }
111
+ }
112
+ }
113
+ test from: :crd_launch_smart_app_card_validation,
114
+ config: {
115
+ inputs: {
116
+ valid_cards_with_links: {
117
+ name: :appointment_book_valid_cards_with_links
118
+ }
119
+ }
120
+ }
121
+ test from: :crd_valid_instructions_card_received,
122
+ config: {
123
+ inputs: {
124
+ valid_cards: {
125
+ name: :appointment_book_valid_cards
126
+ }
127
+ }
128
+ }
129
+ test from: :crd_coverage_info_system_action_received,
130
+ config: {
131
+ inputs: {
132
+ valid_system_actions: {
133
+ name: :appointment_book_valid_system_actions
134
+ }
135
+ },
136
+ outputs: {
137
+ coverage_info: {
138
+ name: :appointment_book_coverage_info
139
+ }
140
+ }
141
+ }
142
+ test from: :crd_coverage_info_system_action_validation,
143
+ config: {
144
+ inputs: {
145
+ coverage_info: {
146
+ name: :appointment_book_coverage_info
147
+ }
148
+ }
149
+ }
150
+ test from: :crd_request_form_completion_response_validation,
151
+ config: {
152
+ inputs: {
153
+ valid_system_actions: {
154
+ name: :appointment_book_valid_system_actions
155
+ },
156
+ valid_cards_with_suggestions: {
157
+ name: :appointment_book_valid_cards_with_suggestions
158
+ }
159
+ }
160
+ }
161
+ test from: :crd_create_or_update_coverage_info_response_validation,
162
+ config: {
163
+ inputs: {
164
+ valid_system_actions: {
165
+ name: :appointment_book_valid_system_actions
166
+ },
167
+ valid_cards_with_suggestions: {
168
+ name: :appointment_book_valid_cards_with_suggestions
169
+ }
170
+ }
171
+ }
172
+ end
173
+ end
@@ -0,0 +1,59 @@
1
+ require 'tls_test_kit'
2
+ require_relative 'server_tests/discovery_endpoint_test'
3
+ require_relative 'server_tests/discovery_services_validation_test'
4
+
5
+ module DaVinciCRDTestKit
6
+ class ServerDiscoveryGroup < Inferno::TestGroup
7
+ title 'Discovery'
8
+ id :crd_server_discovery_group
9
+ description %(
10
+ # Background
11
+
12
+ The #{title} Group checks for a CDS Service's Discovery endpoint as described by the
13
+ [CDS Hooks Specification](https://cds-hooks.hl7.org/2.0/#discovery).
14
+ A CDS Service is discoverable via a stable endpoint by CDS Clients. The Discovery endpoint
15
+ includes information such as a description of the CDS Service, when it should be invoked,
16
+ and any data that is requested to be prefetched.
17
+ The Discovery endpoint SHALL always be available at `{baseUrl}/cds-services`.
18
+
19
+ # Test Methodology
20
+
21
+ This test sequence accesses the CRD server Dicovery endpoint at /cds-services using a GET request.
22
+ It parses the response and verifies that:
23
+ - The Discovery endpoint is TLS secured.
24
+ - The Discovery endpoint is available at `{baseURL}/cds-services`.
25
+ - Each CDS Service in the response contains the required fields as specified in the [CDS Hooks Spec](https://cds-hooks.hl7.org/2.0/#response).
26
+
27
+ It collects the following information that is saved in the testing session for use by later tests:
28
+ - List of supported CDS Services/Hooks
29
+ - List of service IDs for each supported Hook.
30
+ )
31
+
32
+ run_as_group
33
+
34
+ test from: :tls_version_test do
35
+ title 'CRD Server is secured by transport layer security'
36
+ description <<~DESCRIPTION
37
+ Under [Privacy, Security, and Safety](https://hl7.org/fhir/us/davinci-crd/STU2/security.html),
38
+ the CRD Implementation Guide imposes the following rule about TLS:
39
+
40
+ As per the [CDS Hook specification](https://cds-hooks.hl7.org/2.0/#security-and-safety),
41
+ communications between CRD Clients and CRD Servers SHALL
42
+ use TLS. Mutual TLS is not required by this specification but is permitted. CRD Servers and
43
+ CRD Clients SHOULD enforce a minimum version and other TLS configuration requirements based
44
+ on HRex rules for PHI exchange.
45
+
46
+ This test verifies that the CRD server is using TLS 1.2 or higher.
47
+ DESCRIPTION
48
+ id :crd_server_tls_version_stu2
49
+
50
+ config(
51
+ options: { minimum_allowed_version: OpenSSL::SSL::TLS1_2_VERSION },
52
+ inputs: { url: { name: :base_url } }
53
+ )
54
+ end
55
+
56
+ test from: :crd_discovery_endpoint_test
57
+ test from: :crd_discovery_services_validation
58
+ end
59
+ end
@@ -0,0 +1,144 @@
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_request_optional_fields_validation_test'
5
+ require_relative 'server_tests/service_response_validation_test'
6
+ require_relative 'server_tests/card_optional_fields_validation_test'
7
+ require_relative 'server_tests/external_reference_card_validation_test'
8
+ require_relative 'server_tests/launch_smart_app_card_validation_test'
9
+ require_relative 'server_tests/instructions_card_received_test'
10
+ require_relative 'server_tests/form_completion_response_validation_test'
11
+ require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
12
+
13
+ module DaVinciCRDTestKit
14
+ class ServerEncounterDischargeGroup < Inferno::TestGroup
15
+ title 'encounter-discharge'
16
+ id :crd_server_encounter_discharge
17
+ description %(
18
+ This group of tests invokes the encounter-discharge hook and ensures that
19
+ the user-provided requests are valid as per the requirements described
20
+ in the [CRD IG section on encounter-discharge hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#encounter-discharge)
21
+ and the [CDS Hooks specification section on encounter-discharge context](https://cds-hooks.hl7.org/hooks/encounter-discharge/2023SepSTU1Ballot/encounter-discharge/).
22
+ It also ensures that the contents of the server's response are valid as per the requirements described in
23
+ the [CRD IG section on encounter-discharge hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#encounter-discharge)
24
+ and the [CDS Hooks section on CDS Service Response](https://cds-hooks.hl7.org/2.0/#cds-service-response).
25
+
26
+ This group includes tests to validate the following CRD response types:
27
+ - [Create or update coverage information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#create-or-update-coverage-information)\
28
+ - optional
29
+ - [External Reference](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#external-reference) - optional
30
+ - [Instructions](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#instructions) - optional
31
+ - [Launch SMART application](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#launch-smart-application) -
32
+ optional
33
+ - [Request form completion](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#request-form-completion) -
34
+ optional
35
+ )
36
+
37
+ config options: { hook_name: 'encounter-discharge' }
38
+ run_as_group
39
+
40
+ test from: :crd_service_call_test,
41
+ config: {
42
+ inputs: {
43
+ service_ids: {
44
+ name: :encounter_discharge_service_ids,
45
+ title: 'Service id for the service that invokes `encounter-discharge` hook'
46
+ },
47
+ service_request_bodies: {
48
+ name: :encounter_discharge_request_bodies,
49
+ title: 'Request bodies collection to use to invoke the `encounter-discharge` hook'
50
+ }
51
+ }
52
+ }
53
+ test from: :crd_service_request_required_fields_validation,
54
+ config: {
55
+ outputs: {
56
+ contexts: {
57
+ name: :encounter_discharge_contexts
58
+ }
59
+ }
60
+ }
61
+ test from: :crd_service_request_context_validation,
62
+ config: {
63
+ inputs: {
64
+ contexts: {
65
+ name: :encounter_discharge_contexts
66
+ }
67
+ }
68
+ }
69
+ test from: :crd_service_request_optional_fields_validation
70
+ test from: :crd_service_response_validation,
71
+ config: {
72
+ outputs: {
73
+ valid_cards: {
74
+ name: :encounter_discharge_valid_cards
75
+ },
76
+ valid_system_actions: {
77
+ name: :encounter_discharge_valid_system_actions
78
+ }
79
+ }
80
+ }
81
+ test from: :crd_card_optional_fields_validation,
82
+ config: {
83
+ inputs: {
84
+ valid_cards: {
85
+ name: :encounter_discharge_valid_cards
86
+ }
87
+ },
88
+ outputs: {
89
+ valid_cards_with_links: {
90
+ name: :encounter_discharge_valid_cards_with_links
91
+ },
92
+ valid_cards_with_suggestions: {
93
+ name: :encounter_discharge_valid_cards_with_suggestions
94
+ }
95
+ }
96
+ }
97
+ test from: :crd_external_reference_card_validation,
98
+ config: {
99
+ inputs: {
100
+ valid_cards_with_links: {
101
+ name: :encounter_discharge_valid_cards_with_links
102
+ }
103
+ }
104
+ }
105
+ test from: :crd_launch_smart_app_card_validation,
106
+ config: {
107
+ inputs: {
108
+ valid_cards_with_links: {
109
+ name: :encounter_discharge_valid_cards_with_links
110
+ }
111
+ }
112
+ }
113
+ test from: :crd_valid_instructions_card_received,
114
+ config: {
115
+ inputs: {
116
+ valid_cards: {
117
+ name: :encounter_discharge_valid_cards
118
+ }
119
+ }
120
+ }
121
+ test from: :crd_request_form_completion_response_validation,
122
+ config: {
123
+ inputs: {
124
+ valid_system_actions: {
125
+ name: :encounter_discharge_valid_system_actions
126
+ },
127
+ valid_cards_with_suggestions: {
128
+ name: :encounter_discharge_valid_cards_with_suggestions
129
+ }
130
+ }
131
+ }
132
+ test from: :crd_create_or_update_coverage_info_response_validation,
133
+ config: {
134
+ inputs: {
135
+ valid_system_actions: {
136
+ name: :encounter_discharge_valid_system_actions
137
+ },
138
+ valid_cards_with_suggestions: {
139
+ name: :encounter_discharge_valid_cards_with_suggestions
140
+ }
141
+ }
142
+ }
143
+ end
144
+ end
@@ -0,0 +1,144 @@
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_request_optional_fields_validation_test'
5
+ require_relative 'server_tests/service_response_validation_test'
6
+ require_relative 'server_tests/card_optional_fields_validation_test'
7
+ require_relative 'server_tests/external_reference_card_validation_test'
8
+ require_relative 'server_tests/launch_smart_app_card_validation_test'
9
+ require_relative 'server_tests/instructions_card_received_test'
10
+ require_relative 'server_tests/form_completion_response_validation_test'
11
+ require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
12
+
13
+ module DaVinciCRDTestKit
14
+ class ServerEncounterStartGroup < Inferno::TestGroup
15
+ title 'encounter-start'
16
+ id :crd_server_encounter_start
17
+ description %(
18
+ This group of tests invokes the encounter-start hook and ensures that
19
+ the user-provided requests are valid as per the requirements described
20
+ in the [CRD IG section on encounter-start hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#encounter-start)
21
+ and the [CDS Hooks specification section on encounter-start context](https://cds-hooks.hl7.org/hooks/encounter-start/2023SepSTU1Ballot/encounter-start/).
22
+ It also ensures that the contents of the server's response are valid as per the requirements described in
23
+ the [CRD IG section on encounter-start hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#encounter-start)
24
+ and the [CDS Hooks section on CDS Service Response](https://cds-hooks.hl7.org/2.0/#cds-service-response).
25
+
26
+ This group includes tests to validate the following CRD response types:
27
+ - [Create or update coverage information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#create-or-update-coverage-information)\
28
+ - optional
29
+ - [External Reference](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#external-reference) - optional
30
+ - [Instructions](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#instructions) - optional
31
+ - [Launch SMART application](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#launch-smart-application) -
32
+ optional
33
+ - [Request form completion](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#request-form-completion) -
34
+ optional
35
+ )
36
+
37
+ config options: { hook_name: 'encounter-start' }
38
+ run_as_group
39
+
40
+ test from: :crd_service_call_test,
41
+ config: {
42
+ inputs: {
43
+ service_ids: {
44
+ name: :encounter_start_service_ids,
45
+ title: 'Service id for the service that invokes `encounter-start` hook'
46
+ },
47
+ service_request_bodies: {
48
+ name: :encounter_start_request_bodies,
49
+ title: 'Request bodies collection to use to invoke the `encounter-start` hook'
50
+ }
51
+ }
52
+ }
53
+ test from: :crd_service_request_required_fields_validation,
54
+ config: {
55
+ outputs: {
56
+ contexts: {
57
+ name: :encounter_start_contexts
58
+ }
59
+ }
60
+ }
61
+ test from: :crd_service_request_context_validation,
62
+ config: {
63
+ inputs: {
64
+ contexts: {
65
+ name: :encounter_start_contexts
66
+ }
67
+ }
68
+ }
69
+ test from: :crd_service_request_optional_fields_validation
70
+ test from: :crd_service_response_validation,
71
+ config: {
72
+ outputs: {
73
+ valid_cards: {
74
+ name: :encounter_start_valid_cards
75
+ },
76
+ valid_system_actions: {
77
+ name: :encounter_start_valid_system_actions
78
+ }
79
+ }
80
+ }
81
+ test from: :crd_card_optional_fields_validation,
82
+ config: {
83
+ inputs: {
84
+ valid_cards: {
85
+ name: :encounter_start_valid_cards
86
+ }
87
+ },
88
+ outputs: {
89
+ valid_cards_with_links: {
90
+ name: :encounter_start_valid_cards_with_links
91
+ },
92
+ valid_cards_with_suggestions: {
93
+ name: :encounter_start_valid_cards_with_suggestions
94
+ }
95
+ }
96
+ }
97
+ test from: :crd_external_reference_card_validation,
98
+ config: {
99
+ inputs: {
100
+ valid_cards_with_links: {
101
+ name: :encounter_start_valid_cards_with_links
102
+ }
103
+ }
104
+ }
105
+ test from: :crd_launch_smart_app_card_validation,
106
+ config: {
107
+ inputs: {
108
+ valid_cards_with_links: {
109
+ name: :encounter_start_valid_cards_with_links
110
+ }
111
+ }
112
+ }
113
+ test from: :crd_valid_instructions_card_received,
114
+ config: {
115
+ inputs: {
116
+ valid_cards: {
117
+ name: :encounter_start_valid_cards
118
+ }
119
+ }
120
+ }
121
+ test from: :crd_request_form_completion_response_validation,
122
+ config: {
123
+ inputs: {
124
+ valid_system_actions: {
125
+ name: :encounter_start_valid_system_actions
126
+ },
127
+ valid_cards_with_suggestions: {
128
+ name: :encounter_start_valid_cards_with_suggestions
129
+ }
130
+ }
131
+ }
132
+ test from: :crd_create_or_update_coverage_info_response_validation,
133
+ config: {
134
+ inputs: {
135
+ valid_system_actions: {
136
+ name: :encounter_start_valid_system_actions
137
+ },
138
+ valid_cards_with_suggestions: {
139
+ name: :encounter_start_valid_cards_with_suggestions
140
+ }
141
+ }
142
+ }
143
+ end
144
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'hook_request_field_validation'
2
+
3
+ module DaVinciCRDTestKit
4
+ module ServerHookRequestValidation
5
+ include DaVinciCRDTestKit::HookRequestFieldValidation
6
+
7
+ def client_test?
8
+ false
9
+ end
10
+
11
+ def server_test?
12
+ true
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,69 @@
1
+ require_relative 'server_appointment_book_group'
2
+ require_relative 'server_encounter_start_group'
3
+ require_relative 'server_encounter_discharge_group'
4
+ require_relative 'server_order_select_group'
5
+ require_relative 'server_order_dispatch_group'
6
+ require_relative 'server_order_sign_group'
7
+ require_relative 'server_required_card_response_validation_group'
8
+
9
+ module DaVinciCRDTestKit
10
+ class ServerHooksGroup < Inferno::TestGroup
11
+ title 'Hook Tests'
12
+ id :crd_server_hooks
13
+ description %(
14
+ # Background
15
+
16
+ The #{title} Group verifies that a [CRD Server](https://hl7.org/fhir/us/davinci-crd/STU2/CapabilityStatement-crd-server.html)
17
+ supports at least one of the hooks supported by the [CRD IG](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#supported-hooks).
18
+ The supported hooks include:
19
+ - [appointment-book](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#appointment-book)
20
+ - [encounter-start](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#encounter-start)
21
+ - [encounter-discharge](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#encounter-discharge)
22
+ - [order-select](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-select)
23
+ - [order-dispatch](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-dispatch)
24
+ - [order-sign](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-sign)
25
+
26
+ The [CRD STU2 IG section on Supported Hooks](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#supported-hooks)
27
+ states that "CRD Servers conforming to this implementation guide
28
+ SHALL provide a service for all hooks and order resource types required of
29
+ CRD clients by this implementation guide unless the server has determined that
30
+ the hook will not be reasonably useful in determining coverage or documentation
31
+ expectations for the types of coverage provided."
32
+
33
+ # Test Methodology
34
+
35
+ In these tests, Inferno acts as a [CRD Client](https://hl7.org/fhir/us/davinci-crd/STU2/CapabilityStatement-crd-client.html)
36
+ that initiates CDS Hooks calls. This test sequence is broken up into groups,
37
+ each group corresponding to a supported hook and defining a set of tests verifying
38
+ the ability of the server to respond to the given hook invocation. Additionally, an additional
39
+ group checks the required [response types](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#potential-crd-response-types)
40
+ across all hooks invoked.
41
+
42
+ Each hook group test verifies that:
43
+ - The hook can be invoked.
44
+ - The user-provided request payload contains the required fields as specified
45
+ in the [CDS Hooks section on HTTP request requirements](https://cds-hooks.hl7.org/2.0/#http-request_1).
46
+ - The user-provided request payload contains the optional fields as specified
47
+ in the [CDS Hooks section on HTTP request requirements](https://cds-hooks.hl7.org/2.0/#http-request_1) -
48
+ optional.
49
+ - Each card and system action returned by the server is valid as described in the
50
+ [CDS Hooks section on CDS Service Response](https://cds-hooks.hl7.org/2.0/#cds-service-response).
51
+ - Each [CRD response type](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#potential-crd-response-types)
52
+ returned is valid - optional for some response types. See the individual test groups for more details.
53
+ )
54
+
55
+ group from: :crd_server_appointment_book,
56
+ optional: true
57
+ group from: :crd_server_encounter_start,
58
+ optional: true
59
+ group from: :crd_server_encounter_discharge,
60
+ optional: true
61
+ group from: :crd_server_order_select,
62
+ optional: true
63
+ group from: :crd_server_order_dispatch,
64
+ optional: true
65
+ group from: :crd_server_order_sign,
66
+ optional: true
67
+ group from: :crd_server_required_card_response_validation
68
+ end
69
+ end