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,706 @@
1
+ require_relative 'client_tests/appointment_book_receive_request_test'
2
+ require_relative 'client_tests/encounter_start_receive_request_test'
3
+ require_relative 'client_tests/encounter_discharge_receive_request_test'
4
+ require_relative 'client_tests/order_dispatch_receive_request_test'
5
+ require_relative 'client_tests/order_select_receive_request_test'
6
+ require_relative 'client_tests/order_sign_receive_request_test'
7
+ require_relative 'client_tests/client_display_cards_attest'
8
+
9
+ require_relative 'client_tests/decode_auth_token_test'
10
+ require_relative 'client_tests/retrieve_jwks_test'
11
+ require_relative 'client_tests/token_header_test'
12
+ require_relative 'client_tests/token_payload_test'
13
+
14
+ require_relative 'client_tests/hook_request_required_fields_test'
15
+ require_relative 'client_tests/hook_request_optional_fields_test'
16
+
17
+ require_relative 'client_tests/hook_request_valid_context_test'
18
+
19
+ require_relative 'client_tests/hook_request_valid_prefetch_test'
20
+
21
+ require_relative 'jwt_helper'
22
+ require_relative 'urls'
23
+
24
+ module DaVinciCRDTestKit
25
+ class ClientHooksGroup < Inferno::TestGroup
26
+ title 'Hooks'
27
+ description <<~DESCRIPTION
28
+ This Group contains tests which verify that valid hook requests can be made for each of the following
29
+ [six hooks contained in the
30
+ implementation guide](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html):
31
+ * [appointment-book](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#appointment-book)
32
+ * [encounter-start](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#encounter-start)
33
+ * [encounter-discharge](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#encounter-discharge)
34
+ * [order-select](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-select)
35
+ * [order-dispatch](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-dispatch)
36
+ * [order-sign](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-sign)
37
+
38
+ Each hook group contains a test which waits for incoming hook requests from the CRD client, and tests which
39
+ verify the incoming hook requests conform to the specific hook requirements specified the
40
+ CRD IG and the [CDS hooks spec](https://cds-hooks.hl7.org/2.0/).
41
+
42
+ Each hook group tests the following:
43
+ * If the CRD Client can invoke the specific hook service request
44
+ * If the incoming hook request is properly authorized with a JWT Bearer token according to the [CDS Hooks authorization requirements](https://cds-hooks.hl7.org/2.0/#trusting-cds-clients)
45
+ * If the incoming hook request contains the required fields listed in the [CDS Hooks HTTP request requirements](https://cds-hooks.hl7.org/2.0/#http-request_1)
46
+ * OPTIONAL: If the incoming hook request contains the optional fields listed in the [CDS Hooks HTTP request requirements](https://cds-hooks.hl7.org/2.0/#http-request_1)
47
+ * If the hook request's `context` field is valid according to the specific `context` requirements defined for
48
+ each hook type
49
+ * OPTIONAL: If the incoming hook contains the optional `prefetch` field with valid resources
50
+ * If the client can properly display the cards returned as a result of the hook request
51
+ DESCRIPTION
52
+ id :crd_client_hooks
53
+
54
+ input :iss,
55
+ title: 'JWT Issuer',
56
+ description: 'The `iss` claim of the JWT in the Authorization header ' \
57
+ 'will be used to associate incoming requests with this test session'
58
+
59
+ group do
60
+ title 'appointment-book'
61
+ description <<~DESCRIPTION
62
+ The appointment-book hook is invoked when the user is scheduling one or more future encounters/visits for the
63
+ patient. These tests are based on the following criteria:
64
+ * [CRD IG requirements for this hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#appointment-book),
65
+ which include the profiles that are expected to be used for the resources resolved to by `context` FHIR ID
66
+ fields
67
+ * Specific [appointment-book `context` requirements](https://cds-hooks.hl7.org/hooks/appointment-book/2023SepSTU1Ballot/appointment-book/)
68
+ defined in the CDS Hooks specification
69
+
70
+ This version of the CRD implementation guide refers to version 1.0 of the hook.
71
+ DESCRIPTION
72
+
73
+ run_as_group
74
+
75
+ test from: :crd_appointment_book_request
76
+
77
+ test from: :crd_decode_auth_token,
78
+ config: {
79
+ requests: {
80
+ hook_request: { name: :appointment_book }
81
+ },
82
+ outputs: {
83
+ auth_token: { name: :appointment_book_auth_token },
84
+ auth_token_payload_json: { name: :appointment_book_auth_token_payload_json },
85
+ auth_token_header_json: { name: :appointment_book_auth_token_header_json }
86
+ }
87
+ }
88
+ test from: :crd_retrieve_jwks,
89
+ config: {
90
+ inputs: {
91
+ auth_token_header_json: { name: :appointment_book_auth_token_header_json }
92
+ },
93
+ outputs: {
94
+ crd_jwks_json: { name: :appointment_book_crd_jwks_json },
95
+ crd_jwks_keys_json: { name: :appointment_book_crd_jwks_keys_json }
96
+ }
97
+ }
98
+ test from: :crd_token_header,
99
+ config: {
100
+ inputs: {
101
+ auth_token_header_json: { name: :appointment_book_auth_token_header_json },
102
+ crd_jwks_keys_json: { name: :appointment_book_crd_jwks_keys_json }
103
+ },
104
+ outputs: {
105
+ auth_token_jwk_json: { name: :appointment_book_auth_token_jwk_json }
106
+ }
107
+ }
108
+ test from: :crd_token_payload,
109
+ config: {
110
+ options: { hook_path: APPOINTMENT_BOOK_PATH },
111
+ inputs: {
112
+ auth_token: { name: :appointment_book_auth_token },
113
+ auth_token_jwk_json: { name: :appointment_book_auth_token_jwk_json }
114
+ }
115
+ }
116
+
117
+ test from: :crd_hook_request_required_fields,
118
+ config: {
119
+ options: {
120
+ hook_path: APPOINTMENT_BOOK_PATH,
121
+ hook_name: 'appointment-book'
122
+ },
123
+ requests: {
124
+ hook_request: { name: :appointment_book }
125
+ }
126
+ }
127
+ test from: :crd_hook_request_optional_fields,
128
+ config: {
129
+ outputs: {
130
+ client_fhir_server: { name: :appointment_book_client_fhir_server },
131
+ client_access_token: { name: :appointment_book_client_access_token }
132
+ },
133
+ requests: {
134
+ hook_request: { name: :appointment_book }
135
+ }
136
+ }
137
+
138
+ test from: :crd_hook_request_valid_context,
139
+ config: {
140
+ inputs: {
141
+ client_fhir_server: { name: :appointment_book_client_fhir_server },
142
+ client_access_token: { name: :appointment_book_client_access_token }
143
+ },
144
+ options: { hook_name: 'appointment-book' },
145
+ requests: {
146
+ hook_request: { name: :appointment_book }
147
+ }
148
+ }
149
+
150
+ test from: :crd_hook_request_valid_prefetch,
151
+ config: {
152
+ options: { hook_name: 'appointment-book' },
153
+ requests: {
154
+ hook_request: { name: :appointment_book }
155
+ }
156
+ }
157
+
158
+ test from: :crd_card_display_attest_test,
159
+ config: {
160
+ inputs: {
161
+ selected_response_types: { name: :appointment_book_selected_response_types }
162
+ }
163
+ }
164
+ end
165
+
166
+ group do
167
+ title 'encounter-start'
168
+ description <<~DESCRIPTION
169
+ The encounter-start hook is invoked when the user is initiating a new encounter. These tests are based on the
170
+ following criteria:
171
+ * [CRD IG requirements for this hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#encounter-start),
172
+ which include the profiles that are expected to be used for the resources resolved to by `context` FHIR ID
173
+ fields
174
+ * Specific [encounter-start `context` requirements](https://cds-hooks.hl7.org/hooks/encounter-start/2023SepSTU1Ballot/encounter-start/)
175
+ defined in the CDS Hooks specification
176
+
177
+ This version of the CRD implementation guide refers to version 1.0 of the hook.
178
+ DESCRIPTION
179
+
180
+ run_as_group
181
+
182
+ test from: :crd_encounter_start_request
183
+
184
+ test from: :crd_decode_auth_token,
185
+ config: {
186
+ requests: {
187
+ hook_request: { name: :encounter_start }
188
+ },
189
+ outputs: {
190
+ auth_token: { name: :encounter_start_auth_token },
191
+ auth_token_payload_json: { name: :encounter_start_auth_token_payload_json },
192
+ auth_token_header_json: { name: :encounter_start_auth_token_header_json }
193
+ }
194
+ }
195
+ test from: :crd_retrieve_jwks,
196
+ config: {
197
+ inputs: {
198
+ auth_token_header_json: { name: :encounter_start_auth_token_header_json }
199
+ },
200
+ outputs: {
201
+ crd_jwks_json: { name: :encounter_start_crd_jwks_json },
202
+ crd_jwks_keys_json: { name: :encounter_start_crd_jwks_keys_json }
203
+ }
204
+ }
205
+ test from: :crd_token_header,
206
+ config: {
207
+ inputs: {
208
+ auth_token_header_json: { name: :encounter_start_auth_token_header_json },
209
+ crd_jwks_keys_json: { name: :encounter_start_crd_jwks_keys_json }
210
+ },
211
+ outputs: {
212
+ auth_token_jwk_json: { name: :encounter_start_auth_token_jwk_json }
213
+ }
214
+ }
215
+ test from: :crd_token_payload,
216
+ config: {
217
+ options: { hook_path: ENCOUNTER_START_PATH },
218
+ inputs: {
219
+ auth_token: { name: :encounter_start_auth_token },
220
+ auth_token_jwk_json: { name: :encounter_start_auth_token_jwk_json }
221
+ }
222
+ }
223
+
224
+ test from: :crd_hook_request_required_fields,
225
+ config: {
226
+ options: {
227
+ hook_path: ENCOUNTER_START_PATH,
228
+ hook_name: 'encounter-start'
229
+ },
230
+ requests: {
231
+ hook_request: { name: :encounter_start }
232
+ }
233
+ }
234
+ test from: :crd_hook_request_optional_fields,
235
+ config: {
236
+ outputs: {
237
+ client_fhir_server: { name: :encounter_start_client_fhir_server },
238
+ client_access_token: { name: :encounter_start_client_access_token }
239
+ },
240
+ requests: {
241
+ hook_request: { name: :encounter_start }
242
+ }
243
+ }
244
+
245
+ test from: :crd_hook_request_valid_context,
246
+ config: {
247
+ inputs: {
248
+ client_fhir_server: { name: :encounter_start_client_fhir_server },
249
+ client_access_token: { name: :encounter_start_client_access_token }
250
+ },
251
+ options: { hook_name: 'encounter-start' },
252
+ requests: {
253
+ hook_request: { name: :encounter_start }
254
+ }
255
+ }
256
+
257
+ test from: :crd_hook_request_valid_prefetch,
258
+ config: {
259
+ options: { hook_name: 'encounter-start' },
260
+ requests: {
261
+ hook_request: { name: :encounter_start }
262
+ }
263
+ }
264
+
265
+ test from: :crd_card_display_attest_test,
266
+ config: {
267
+ inputs: {
268
+ selected_response_types: { name: :encounter_start_selected_response_types }
269
+ }
270
+ }
271
+ end
272
+
273
+ group do
274
+ title 'encounter-discharge'
275
+ description <<~DESCRIPTION
276
+ The encounter-discharge hook is invoked when the user is performing the discharge process for an encounter where
277
+ the notion of 'discharge' is relevant - typically an inpatient encounter. These tests are based on the
278
+ following criteria:
279
+ * [CRD IG requirements for this hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#encounter-discharge),
280
+ which includes the profiles that are expected to be used for the resources resolved to by `context`
281
+ FHIR ID fields
282
+ * Specific [encounter-discharge `context` requirements](https://cds-hooks.hl7.org/hooks/encounter-discharge/2023SepSTU1Ballot/encounter-discharge/)
283
+ defined in the CDS Hooks specification
284
+
285
+ This version of the CRD implementation guide refers to version 1.0 of the hook.
286
+ DESCRIPTION
287
+
288
+ run_as_group
289
+
290
+ test from: :crd_encounter_discharge_request
291
+
292
+ test from: :crd_decode_auth_token,
293
+ config: {
294
+ requests: {
295
+ hook_request: { name: :encounter_discharge }
296
+ },
297
+ outputs: {
298
+ auth_token: { name: :encounter_discharge_auth_token },
299
+ auth_token_payload_json: { name: :encounter_discharge_auth_token_payload_json },
300
+ auth_token_header_json: { name: :encounter_discharge_auth_token_header_json }
301
+ }
302
+ }
303
+ test from: :crd_retrieve_jwks,
304
+ config: {
305
+ inputs: {
306
+ auth_token_header_json: { name: :encounter_discharge_auth_token_header_json }
307
+ },
308
+ outputs: {
309
+ crd_jwks_json: { name: :encounter_discharge_crd_jwks_json },
310
+ crd_jwks_keys_json: { name: :encounter_discharge_crd_jwks_keys_json }
311
+ }
312
+ }
313
+ test from: :crd_token_header,
314
+ config: {
315
+ inputs: {
316
+ auth_token_header_json: { name: :encounter_discharge_auth_token_header_json },
317
+ crd_jwks_keys_json: { name: :encounter_discharge_crd_jwks_keys_json }
318
+ },
319
+ outputs: {
320
+ auth_token_jwk_json: { name: :encounter_discharge_auth_token_jwk_json }
321
+ }
322
+ }
323
+ test from: :crd_token_payload,
324
+ config: {
325
+ options: { hook_path: ENCOUNTER_DISCHARGE_PATH },
326
+ inputs: {
327
+ auth_token: { name: :encounter_discharge_auth_token },
328
+ auth_token_jwk_json: { name: :encounter_discharge_auth_token_jwk_json }
329
+ }
330
+ }
331
+
332
+ test from: :crd_hook_request_required_fields,
333
+ config: {
334
+ options: {
335
+ hook_path: ENCOUNTER_DISCHARGE_PATH,
336
+ hook_name: 'encounter-discharge'
337
+ },
338
+ requests: {
339
+ hook_request: { name: :encounter_discharge }
340
+ }
341
+ }
342
+ test from: :crd_hook_request_optional_fields,
343
+ config: {
344
+ outputs: {
345
+ client_fhir_server: { name: :encounter_discharge_client_fhir_server },
346
+ client_access_token: { name: :encounter_discharge_client_access_token }
347
+ },
348
+ requests: {
349
+ hook_request: { name: :encounter_discharge }
350
+ }
351
+ }
352
+
353
+ test from: :crd_hook_request_valid_context,
354
+ config: {
355
+ inputs: {
356
+ client_fhir_server: { name: :encounter_discharge_client_fhir_server },
357
+ client_access_token: { name: :encounter_discharge_client_access_token }
358
+ },
359
+ options: { hook_name: 'encounter-discharge' },
360
+ requests: {
361
+ hook_request: { name: :encounter_discharge }
362
+ }
363
+ }
364
+
365
+ test from: :crd_hook_request_valid_prefetch,
366
+ config: {
367
+ options: { hook_name: 'encounter-discharge' },
368
+ requests: {
369
+ hook_request: { name: :encounter_discharge }
370
+ }
371
+ }
372
+
373
+ test from: :crd_card_display_attest_test,
374
+ config: {
375
+ inputs: {
376
+ selected_response_types: { name: :encounter_discharge_selected_response_types }
377
+ }
378
+ }
379
+ end
380
+
381
+ group do
382
+ title 'order-select'
383
+ description <<~DESCRIPTION
384
+ The order-select hook fires when a clinician selects one or more orders to place for a patient,
385
+ (including orders for medications, procedures, labs and other orders). If supported by the CDS Client, this
386
+ hook may also be invoked each time the clinician selects a detail regarding the order. These tests are based on
387
+ the following criteria:
388
+ * [CRD IG requirements for this hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-selecte),
389
+ which includes the profiles that are expected to be used for the resources resolved to by `context`
390
+ FHIR ID fields
391
+ * Specific [order-select `context` requirements](https://cds-hooks.hl7.org/hooks/order-select/2023SepSTU1Ballot/order-select/)
392
+ defined in the CDS Hooks specification
393
+
394
+ This version of the CRD implementation guide refers to version 1.0 of the hook.
395
+ DESCRIPTION
396
+ run_as_group
397
+
398
+ test from: :crd_order_select_request
399
+
400
+ test from: :crd_decode_auth_token,
401
+ config: {
402
+ requests: {
403
+ hook_request: { name: :order_select }
404
+ },
405
+ outputs: {
406
+ auth_token: { name: :order_select_auth_token },
407
+ auth_token_payload_json: { name: :order_select_auth_token_payload_json },
408
+ auth_token_header_json: { name: :order_select_auth_token_header_json }
409
+ }
410
+ }
411
+
412
+ test from: :crd_retrieve_jwks,
413
+ config: {
414
+ inputs: {
415
+ auth_token_header_json: { name: :order_select_auth_token_header_json }
416
+ },
417
+ outputs: {
418
+ crd_jwks_json: { name: :order_select_crd_jwks_json },
419
+ crd_jwks_keys_json: { name: :order_select_crd_jwks_keys_json }
420
+ }
421
+ }
422
+ test from: :crd_token_header,
423
+ config: {
424
+ inputs: {
425
+ auth_token_header_json: { name: :order_select_auth_token_header_json },
426
+ crd_jwks_keys_json: { name: :order_select_crd_jwks_keys_json }
427
+ },
428
+ outputs: {
429
+ auth_token_jwk_json: { name: :order_select_auth_token_jwk_json }
430
+ }
431
+ }
432
+ test from: :crd_token_payload,
433
+ config: {
434
+ options: { hook_path: ORDER_SELECT_PATH },
435
+ inputs: {
436
+ auth_token: { name: :order_select_auth_token },
437
+ auth_token_jwk_json: { name: :order_select_auth_token_jwk_json }
438
+ }
439
+ }
440
+
441
+ test from: :crd_hook_request_required_fields,
442
+ config: {
443
+ options: {
444
+ hook_path: ORDER_SELECT_PATH,
445
+ hook_name: 'order-select'
446
+ },
447
+ requests: {
448
+ hook_request: { name: :order_select }
449
+ }
450
+ }
451
+ test from: :crd_hook_request_optional_fields,
452
+ config: {
453
+ outputs: {
454
+ client_fhir_server: { name: :order_select_client_fhir_server },
455
+ client_access_token: { name: :order_select_client_access_token }
456
+ },
457
+ requests: {
458
+ hook_request: { name: :order_select }
459
+ }
460
+ }
461
+
462
+ test from: :crd_hook_request_valid_context,
463
+ config: {
464
+ inputs: {
465
+ client_fhir_server: { name: :order_select_client_fhir_server },
466
+ client_access_token: { name: :order_select_client_access_token }
467
+ },
468
+ options: { hook_name: 'order-select' },
469
+ requests: {
470
+ hook_request: { name: :order_select }
471
+ }
472
+ }
473
+
474
+ test from: :crd_hook_request_valid_prefetch,
475
+ config: {
476
+ options: { hook_name: 'order-select' },
477
+ requests: {
478
+ hook_request: { name: :order_select }
479
+ }
480
+ }
481
+
482
+ test from: :crd_card_display_attest_test,
483
+ config: {
484
+ inputs: {
485
+ selected_response_types: { name: :order_select_selected_response_types }
486
+ }
487
+ }
488
+ end
489
+
490
+ group do
491
+ title 'order-dispatch'
492
+ description <<~DESCRIPTION
493
+ The order-dispatch hook fires when a practitioner is selecting a candidate performer for a pre-existing order
494
+ that was not tied to a specific performer. These tests are based on the following criteria:
495
+ * [CRD IG requirements for this hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-dispatch),
496
+ which includes the profiles that are expected to be used for the resources resolved to by `context`
497
+ FHIR ID fields
498
+ * Specific [order-dispatch `context` requirements](https://cds-hooks.hl7.org/hooks/order-dispatch/2023SepSTU1Ballot/order-dispatch/)
499
+ defined in the CDS Hooks specification
500
+
501
+ This version of the CRD implementation guide refers to version 1.0 of the hook.
502
+ DESCRIPTION
503
+
504
+ run_as_group
505
+
506
+ test from: :crd_order_dispatch_request
507
+
508
+ test from: :crd_decode_auth_token,
509
+ config: {
510
+ requests: {
511
+ hook_request: { name: :order_dispatch }
512
+ },
513
+ outputs: {
514
+ auth_token: { name: :order_dispatch_auth_token },
515
+ auth_token_payload_json: { name: :order_dispatch_auth_token_payload_json },
516
+ auth_token_header_json: { name: :order_dispatch_auth_token_header_json }
517
+ }
518
+ }
519
+
520
+ test from: :crd_retrieve_jwks,
521
+ config: {
522
+ inputs: {
523
+ auth_token_header_json: { name: :order_dispatch_auth_token_header_json }
524
+ },
525
+ outputs: {
526
+ crd_jwks_json: { name: :order_dispatch_crd_jwks_json },
527
+ crd_jwks_keys_json: { name: :order_dispatch_crd_jwks_keys_json }
528
+ }
529
+ }
530
+ test from: :crd_token_header,
531
+ config: {
532
+ inputs: {
533
+ auth_token_header_json: { name: :order_dispatch_auth_token_header_json },
534
+ crd_jwks_keys_json: { name: :order_dispatch_crd_jwks_keys_json }
535
+ },
536
+ outputs: {
537
+ auth_token_jwk_json: { name: :order_dispatch_auth_token_jwk_json }
538
+ }
539
+ }
540
+ test from: :crd_token_payload,
541
+ config: {
542
+ options: { hook_path: ORDER_DISPATCH_PATH },
543
+ inputs: {
544
+ auth_token: { name: :order_dispatch_auth_token },
545
+ auth_token_jwk_json: { name: :order_dispatch_auth_token_jwk_json }
546
+ }
547
+ }
548
+
549
+ test from: :crd_hook_request_required_fields,
550
+ config: {
551
+ options: {
552
+ hook_path: ORDER_DISPATCH_PATH,
553
+ hook_name: 'order-dispatch'
554
+ },
555
+ requests: {
556
+ hook_request: { name: :order_dispatch }
557
+ }
558
+ }
559
+ test from: :crd_hook_request_optional_fields,
560
+ config: {
561
+ outputs: {
562
+ client_fhir_server: { name: :order_dispatch_client_fhir_server },
563
+ client_access_token: { name: :order_dispatch_client_access_token }
564
+ },
565
+ requests: {
566
+ hook_request: { name: :order_dispatch }
567
+ }
568
+ }
569
+
570
+ test from: :crd_hook_request_valid_context,
571
+ config: {
572
+ inputs: {
573
+ client_fhir_server: { name: :order_dispatch_client_fhir_server },
574
+ client_access_token: { name: :order_dispatch_client_access_token }
575
+ },
576
+ options: { hook_name: 'order-dispatch' },
577
+ requests: {
578
+ hook_request: { name: :order_dispatch }
579
+ }
580
+ }
581
+
582
+ test from: :crd_hook_request_valid_prefetch,
583
+ config: {
584
+ options: { hook_name: 'order-dispatch' },
585
+ requests: {
586
+ hook_request: { name: :order_dispatch }
587
+ }
588
+ }
589
+
590
+ test from: :crd_card_display_attest_test,
591
+ config: {
592
+ inputs: {
593
+ selected_response_types: { name: :order_dispatch_selected_response_types }
594
+ }
595
+ }
596
+ end
597
+
598
+ group do
599
+ title 'order-sign'
600
+ description <<~DESCRIPTION
601
+ The order-sign hook fires when a clinician is ready to sign one or more orders for a patient, (including orders
602
+ for medications, procedures, labs and other orders). These tests are based on the following criteria:
603
+ * [CRD IG requirements for this hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-sign),
604
+ which includes the profiles that are expected to be used for the resources resolved to by `context`
605
+ FHIR ID fields
606
+ * Specific [order-sign `context` requirements](https://cds-hooks.org/hooks/order-sign/)
607
+ defined in the CDS Hooks specification
608
+
609
+ This version of the CRD implementation guide refers to version 1.1 of the hook which, at the time of publication,
610
+ was not available as a snapshot. Therefore the preceding link refers to the CDS hooks current build.
611
+ DESCRIPTION
612
+
613
+ run_as_group
614
+
615
+ test from: :crd_order_sign_request
616
+
617
+ test from: :crd_decode_auth_token,
618
+ config: {
619
+ requests: {
620
+ hook_request: { name: :order_sign }
621
+ },
622
+ outputs: {
623
+ auth_token: { name: :order_sign_auth_token },
624
+ auth_token_payload_json: { name: :order_sign_auth_token_payload_json },
625
+ auth_token_header_json: { name: :order_sign_auth_token_header_json }
626
+ }
627
+ }
628
+ test from: :crd_retrieve_jwks,
629
+ config: {
630
+ inputs: {
631
+ auth_token_header_json: { name: :order_sign_auth_token_header_json }
632
+ },
633
+ outputs: {
634
+ crd_jwks_json: { name: :order_sign_crd_jwks_json },
635
+ crd_jwks_keys_json: { name: :order_sign_crd_jwks_keys_json }
636
+ }
637
+ }
638
+ test from: :crd_token_header,
639
+ config: {
640
+ inputs: {
641
+ auth_token_header_json: { name: :order_sign_auth_token_header_json },
642
+ crd_jwks_keys_json: { name: :order_sign_crd_jwks_keys_json }
643
+ },
644
+ outputs: {
645
+ auth_token_jwk_json: { name: :order_sign_auth_token_jwk_json }
646
+ }
647
+ }
648
+ test from: :crd_token_payload,
649
+ config: {
650
+ options: { hook_path: ORDER_SIGN_PATH },
651
+ inputs: {
652
+ auth_token: { name: :order_sign_auth_token },
653
+ auth_token_jwk_json: { name: :order_sign_auth_token_jwk_json }
654
+ }
655
+ }
656
+
657
+ test from: :crd_hook_request_required_fields,
658
+ config: {
659
+ options: {
660
+ hook_path: ORDER_SIGN_PATH,
661
+ hook_name: 'order-sign'
662
+ },
663
+ requests: {
664
+ hook_request: { name: :order_sign }
665
+ }
666
+ }
667
+ test from: :crd_hook_request_optional_fields,
668
+ config: {
669
+ outputs: {
670
+ client_fhir_server: { name: :order_sign_client_fhir_server },
671
+ client_access_token: { name: :order_sign_client_access_token }
672
+ },
673
+ requests: {
674
+ hook_request: { name: :order_sign }
675
+ }
676
+ }
677
+
678
+ test from: :crd_hook_request_valid_context,
679
+ config: {
680
+ inputs: {
681
+ client_fhir_server: { name: :order_sign_client_fhir_server },
682
+ client_access_token: { name: :order_sign_client_access_token }
683
+ },
684
+ options: { hook_name: 'order-sign' },
685
+ requests: {
686
+ hook_request: { name: :order_sign }
687
+ }
688
+ }
689
+
690
+ test from: :crd_hook_request_valid_prefetch,
691
+ config: {
692
+ options: { hook_name: 'order-sign' },
693
+ requests: {
694
+ hook_request: { name: :order_sign }
695
+ }
696
+ }
697
+
698
+ test from: :crd_card_display_attest_test,
699
+ config: {
700
+ inputs: {
701
+ selected_response_types: { name: :order_sign_selected_response_types }
702
+ }
703
+ }
704
+ end
705
+ end
706
+ end