davinci_crd_test_kit 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/davinci_crd_test_kit/card_responses/propose_alternate_request.json +2 -52
- data/lib/davinci_crd_test_kit/card_responses/request_form_completion.json +46 -31
- data/lib/davinci_crd_test_kit/cards_validation.rb +8 -4
- data/lib/davinci_crd_test_kit/client_hooks_group.rb +22 -660
- data/lib/davinci_crd_test_kit/client_tests/appointment_book_receive_request_test.rb +17 -6
- data/lib/davinci_crd_test_kit/client_tests/client_appointment_book_group.rb +70 -0
- data/lib/davinci_crd_test_kit/client_tests/client_encounter_discharge_group.rb +71 -0
- data/lib/davinci_crd_test_kit/client_tests/client_encounter_start_group.rb +70 -0
- data/lib/davinci_crd_test_kit/client_tests/client_order_dispatch_group.rb +70 -0
- data/lib/davinci_crd_test_kit/client_tests/client_order_select_group.rb +72 -0
- data/lib/davinci_crd_test_kit/client_tests/client_order_sign_group.rb +71 -0
- data/lib/davinci_crd_test_kit/client_tests/decode_auth_token_test.rb +43 -23
- data/lib/davinci_crd_test_kit/client_tests/encounter_discharge_receive_request_test.rb +19 -6
- data/lib/davinci_crd_test_kit/client_tests/encounter_start_receive_request_test.rb +18 -6
- data/lib/davinci_crd_test_kit/client_tests/hook_request_optional_fields_test.rb +26 -10
- data/lib/davinci_crd_test_kit/client_tests/hook_request_required_fields_test.rb +20 -11
- data/lib/davinci_crd_test_kit/client_tests/hook_request_valid_context_test.rb +14 -10
- data/lib/davinci_crd_test_kit/client_tests/hook_request_valid_prefetch_test.rb +27 -110
- data/lib/davinci_crd_test_kit/client_tests/order_dispatch_receive_request_test.rb +18 -6
- data/lib/davinci_crd_test_kit/client_tests/order_select_receive_request_test.rb +18 -6
- data/lib/davinci_crd_test_kit/client_tests/order_sign_receive_request_test.rb +18 -6
- data/lib/davinci_crd_test_kit/client_tests/retrieve_jwks_test.rb +66 -29
- data/lib/davinci_crd_test_kit/client_tests/submitted_response_validation.rb +44 -0
- data/lib/davinci_crd_test_kit/client_tests/token_header_test.rb +45 -14
- data/lib/davinci_crd_test_kit/client_tests/token_payload_test.rb +43 -26
- data/lib/davinci_crd_test_kit/crd_client_suite.rb +0 -4
- data/lib/davinci_crd_test_kit/hook_request_field_validation.rb +240 -50
- data/lib/davinci_crd_test_kit/mock_service_response.rb +134 -120
- data/lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb +26 -42
- data/lib/davinci_crd_test_kit/server_encounter_discharge_group.rb +24 -0
- data/lib/davinci_crd_test_kit/server_encounter_start_group.rb +24 -0
- data/lib/davinci_crd_test_kit/server_order_select_group.rb +24 -0
- data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_received_test.rb +4 -1
- data/lib/davinci_crd_test_kit/server_tests/service_request_optional_fields_validation_test.rb +8 -10
- data/lib/davinci_crd_test_kit/server_tests/service_request_required_fields_validation_test.rb +5 -10
- data/lib/davinci_crd_test_kit/tags.rb +6 -6
- data/lib/davinci_crd_test_kit/version.rb +1 -1
- metadata +9 -2
@@ -9,7 +9,7 @@ module DaVinciCRDTestKit
|
|
9
9
|
['appointment-book', 'order-dispatch', 'order-sign']
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def load_json_file(filename)
|
13
13
|
json = JSON.parse(File.read(File.join(__dir__, 'card_responses', filename)))
|
14
14
|
return json unless filename == 'launch_smart_app.json'
|
15
15
|
|
@@ -18,6 +18,15 @@ module DaVinciCRDTestKit
|
|
18
18
|
json
|
19
19
|
end
|
20
20
|
|
21
|
+
def request_body
|
22
|
+
@request_body ||=
|
23
|
+
JSON.parse(request.params.to_json)
|
24
|
+
end
|
25
|
+
|
26
|
+
def context
|
27
|
+
request_body['context']
|
28
|
+
end
|
29
|
+
|
21
30
|
def format_missing_response_types(missing_response_types)
|
22
31
|
missing_response_types
|
23
32
|
.map do |response_type|
|
@@ -44,10 +53,12 @@ module DaVinciCRDTestKit
|
|
44
53
|
end
|
45
54
|
end
|
46
55
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
56
|
+
def coverage_information_required?
|
57
|
+
coverage_information_required_hooks.include? hook_name
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_missing_response_types(hook_card_response)
|
61
|
+
selected_response_types.append('coverage_information').uniq! if coverage_information_required?
|
51
62
|
|
52
63
|
selected_response_types
|
53
64
|
.select do |response_type|
|
@@ -60,20 +71,25 @@ module DaVinciCRDTestKit
|
|
60
71
|
end
|
61
72
|
end
|
62
73
|
|
63
|
-
def create_warning_messages(
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
74
|
+
def create_warning_messages(hook_card_response)
|
75
|
+
return if custom_response.present?
|
76
|
+
|
77
|
+
missing_response_types =
|
78
|
+
if hook_card_response.nil?
|
79
|
+
selected_response_types
|
80
|
+
else
|
81
|
+
get_missing_response_types(hook_card_response)
|
82
|
+
end
|
69
83
|
|
70
84
|
return if missing_response_types.empty?
|
71
85
|
|
72
86
|
missing_response_types = format_missing_response_types(missing_response_types)
|
73
87
|
missing_response_types.each do |missing_response_type|
|
74
|
-
Inferno::Repositories::Messages.new.create(
|
75
|
-
|
76
|
-
|
88
|
+
Inferno::Repositories::Messages.new.create(
|
89
|
+
result_id: result.id,
|
90
|
+
type: 'warning',
|
91
|
+
message: %(Unable to return response type: `#{missing_response_type}` for #{hook_name} hook)
|
92
|
+
)
|
77
93
|
end
|
78
94
|
end
|
79
95
|
|
@@ -90,7 +106,7 @@ module DaVinciCRDTestKit
|
|
90
106
|
end
|
91
107
|
end
|
92
108
|
|
93
|
-
def update_specific_hook_card_info(card_response
|
109
|
+
def update_specific_hook_card_info(card_response)
|
94
110
|
return if card_response.nil?
|
95
111
|
|
96
112
|
hook_display = hook_name.split('-').map(&:capitalize).join(' ')
|
@@ -101,47 +117,34 @@ module DaVinciCRDTestKit
|
|
101
117
|
card_response
|
102
118
|
end
|
103
119
|
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
'Encounter')
|
114
|
-
hook_card_response = update_specific_hook_card_info(cards_response, 'encounter-start')
|
115
|
-
create_warning_messages(selected_response_types, hook_card_response, 'encounter-start')
|
116
|
-
create_card_response(hook_card_response)
|
117
|
-
end
|
118
|
-
|
119
|
-
def encounter_discharge_response(selected_response_types)
|
120
|
-
cards_response = create_cards_and_system_actions(selected_response_types, 'encounter-discharge', 'encounterId',
|
121
|
-
'Encounter')
|
122
|
-
hook_card_response = update_specific_hook_card_info(cards_response, 'encounter-discharge')
|
123
|
-
create_warning_messages(selected_response_types, hook_card_response, 'encounter-discharge')
|
124
|
-
create_card_response(hook_card_response)
|
120
|
+
def resource_to_update_field_name
|
121
|
+
{
|
122
|
+
'appointment-book' => 'appointments',
|
123
|
+
'encounter-start' => 'encounterId',
|
124
|
+
'encounter-discharge' => 'encounterId',
|
125
|
+
'order-dispatch' => 'order',
|
126
|
+
'order-select' => 'draftOrders',
|
127
|
+
'order-sign' => 'draftOrders'
|
128
|
+
}[hook_name]
|
125
129
|
end
|
126
130
|
|
127
|
-
def
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
131
|
+
def resource_type_to_update
|
132
|
+
{
|
133
|
+
'encounter-start' => 'Encounter',
|
134
|
+
'encounter-discharge' => 'Encounter'
|
135
|
+
}[hook_name]
|
132
136
|
end
|
133
137
|
|
134
|
-
def
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
138
|
+
def hook_response
|
139
|
+
hook_card_response =
|
140
|
+
if custom_response.present?
|
141
|
+
JSON.parse(custom_response)
|
142
|
+
else
|
143
|
+
cards_response = create_cards_and_system_actions
|
144
|
+
update_specific_hook_card_info(cards_response)
|
145
|
+
end
|
140
146
|
|
141
|
-
|
142
|
-
cards_response = create_cards_and_system_actions(selected_response_types, 'order-sign', 'draftOrders')
|
143
|
-
hook_card_response = update_specific_hook_card_info(cards_response, 'order-sign')
|
144
|
-
create_warning_messages(selected_response_types, hook_card_response, 'order-sign')
|
147
|
+
create_warning_messages(hook_card_response)
|
145
148
|
create_card_response(hook_card_response)
|
146
149
|
end
|
147
150
|
|
@@ -156,7 +159,7 @@ module DaVinciCRDTestKit
|
|
156
159
|
resource.entry.first.resource
|
157
160
|
end
|
158
161
|
|
159
|
-
def get_patient_coverage
|
162
|
+
def get_patient_coverage # rubocop:disable Naming/AccessorMethodName
|
160
163
|
prefetch = request_body['prefetch']
|
161
164
|
if prefetch.present? && prefetch['coverage']
|
162
165
|
FHIR.from_contents(prefetch['coverage'].to_json)
|
@@ -164,7 +167,7 @@ module DaVinciCRDTestKit
|
|
164
167
|
fhir_server = request_body['fhirServer']
|
165
168
|
if fhir_server.present?
|
166
169
|
access_token = request_body['fhirAuthorization']['access_token'] if request_body['fhirAuthorization']
|
167
|
-
patient_id =
|
170
|
+
patient_id = context['patientId']
|
168
171
|
|
169
172
|
make_resource_request(
|
170
173
|
"#{fhir_server}/Coverage?patient=#{patient_id}&status=active",
|
@@ -174,10 +177,10 @@ module DaVinciCRDTestKit
|
|
174
177
|
end
|
175
178
|
end
|
176
179
|
|
177
|
-
def get_context_resource(
|
178
|
-
update_resource_id = "#{
|
180
|
+
def get_context_resource(update_resource_id)
|
181
|
+
update_resource_id = "#{resource_type_to_update}/#{update_resource_id}" unless update_resource_id.include? '/'
|
179
182
|
fhir_server = request_body['fhirServer']
|
180
|
-
return
|
183
|
+
return if fhir_server.blank?
|
181
184
|
|
182
185
|
access_token = request_body['fhirAuthorization']['access_token'] if request_body['fhirAuthorization']
|
183
186
|
make_resource_request(
|
@@ -186,27 +189,24 @@ module DaVinciCRDTestKit
|
|
186
189
|
)
|
187
190
|
end
|
188
191
|
|
189
|
-
def add_coverage_cards?
|
192
|
+
def add_coverage_cards?
|
190
193
|
(['coverage_information', 'create_update_coverage_info'].any? { |x| selected_response_types.include?(x) }) ||
|
191
|
-
|
194
|
+
coverage_information_required?
|
192
195
|
end
|
193
196
|
|
194
|
-
def create_cards_and_system_actions
|
195
|
-
request_body = JSON.parse(request.params.to_json)
|
196
|
-
context = request_body['context']
|
197
|
+
def create_cards_and_system_actions
|
197
198
|
return if context.nil?
|
198
199
|
|
199
200
|
cards = []
|
200
201
|
|
201
|
-
add_basic_cards(
|
202
|
+
add_basic_cards(cards)
|
202
203
|
|
203
|
-
add_order_hook_cards(
|
204
|
+
add_order_hook_cards(cards)
|
204
205
|
|
205
|
-
system_actions = add_coverage_cards(
|
206
|
-
update_resource_name, resource_type)
|
206
|
+
system_actions = add_coverage_cards(cards)
|
207
207
|
|
208
|
-
cards.append(
|
209
|
-
|
208
|
+
cards.append(load_json_file('instructions.json')) if selected_response_types.include?('instructions') ||
|
209
|
+
(cards.empty? && system_actions.nil?)
|
210
210
|
cards_response = { 'cards' => cards }
|
211
211
|
cards_response['systemActions'] = system_actions if system_actions.present?
|
212
212
|
cards_response
|
@@ -214,53 +214,50 @@ module DaVinciCRDTestKit
|
|
214
214
|
nil
|
215
215
|
end
|
216
216
|
|
217
|
-
def add_order_hook_cards(
|
218
|
-
if selected_response_types.include?('companions_prerequisites')
|
219
|
-
cards.append(create_companions_prerequisites_card(request_body['context']))
|
220
|
-
end
|
217
|
+
def add_order_hook_cards(cards)
|
218
|
+
cards.append(create_companions_prerequisites_card) if selected_response_types.include?('companions_prerequisites')
|
221
219
|
|
222
220
|
return unless selected_response_types.include?('propose_alternate_request')
|
223
221
|
|
224
|
-
cards.append(create_alternate_request_card
|
222
|
+
cards.append(create_alternate_request_card)
|
225
223
|
end
|
226
224
|
|
227
|
-
def add_basic_cards(
|
228
|
-
cards.append(create_form_completion_card
|
229
|
-
cards.append(
|
230
|
-
cards.append(
|
225
|
+
def add_basic_cards(cards)
|
226
|
+
cards.append(create_form_completion_card) if selected_response_types.include?('request_form_completion')
|
227
|
+
cards.append(load_json_file('launch_smart_app.json')) if selected_response_types.include?('launch_smart_app')
|
228
|
+
cards.append(load_json_file('external_reference.json')) if selected_response_types.include?('external_reference')
|
231
229
|
end
|
232
230
|
|
233
|
-
def add_coverage_cards(
|
234
|
-
|
235
|
-
return unless add_coverage_cards?(selected_response_types, hook_name)
|
231
|
+
def add_coverage_cards(cards)
|
232
|
+
return unless add_coverage_cards?
|
236
233
|
|
237
|
-
coverage = get_patient_coverage
|
234
|
+
coverage = get_patient_coverage
|
238
235
|
if coverage.present?
|
239
|
-
if selected_response_types.include?('coverage_information') ||
|
240
|
-
|
241
|
-
|
242
|
-
coverage.id, resource_type)
|
236
|
+
if selected_response_types.include?('coverage_information') || coverage_information_required?
|
237
|
+
system_actions =
|
238
|
+
create_coverage_extension_system_actions(coverage.id)
|
243
239
|
end
|
244
240
|
|
245
241
|
if selected_response_types.include?('create_update_coverage_info')
|
246
|
-
cards.append(create_or_update_coverage(coverage
|
242
|
+
cards.append(create_or_update_coverage(coverage))
|
247
243
|
end
|
248
244
|
end
|
249
245
|
system_actions
|
250
246
|
end
|
251
247
|
|
252
|
-
def create_coverage_extension_system_actions(
|
253
|
-
|
254
|
-
|
255
|
-
|
248
|
+
def create_coverage_extension_system_actions(coverage_id)
|
249
|
+
update_resource = context[resource_to_update_field_name]
|
250
|
+
prefetch_id = resource_to_update_field_name.split(/(?=[A-Z])/).first
|
251
|
+
|
252
|
+
fhir_resource =
|
253
|
+
if update_resource.is_a? Hash
|
254
|
+
FHIR.from_contents(update_resource.to_json)
|
255
|
+
elsif request_body['prefetch'] && request_body['prefetch'][prefetch_id]
|
256
|
+
FHIR.from_contents(request_body['prefetch'][prefetch_id].to_json)
|
257
|
+
else
|
258
|
+
get_context_resource(update_resource)
|
259
|
+
end
|
256
260
|
|
257
|
-
fhir_resource = if update_resource.is_a? Hash
|
258
|
-
FHIR.from_contents(update_resource.to_json)
|
259
|
-
elsif request_body['prefetch'] && request_body['prefetch'][prefetch_id]
|
260
|
-
FHIR.from_contents(request_body['prefetch'][prefetch_id].to_json)
|
261
|
-
else
|
262
|
-
get_context_resource(request_body, resource_type, update_resource)
|
263
|
-
end
|
264
261
|
create_system_actions(fhir_resource, coverage_id)
|
265
262
|
rescue StandardError
|
266
263
|
nil
|
@@ -274,16 +271,23 @@ module DaVinciCRDTestKit
|
|
274
271
|
resource.entry.each do |entry|
|
275
272
|
entry_resource = entry.resource
|
276
273
|
add_coverage_extension(entry_resource, coverage_id)
|
277
|
-
system_actions.append(
|
278
|
-
|
279
|
-
|
280
|
-
|
274
|
+
system_actions.append(
|
275
|
+
{
|
276
|
+
'type' => 'update',
|
277
|
+
'description' => "Added coverage information to #{entry_resource.resourceType} resource.",
|
278
|
+
'resource' => entry_resource
|
279
|
+
}
|
280
|
+
)
|
281
281
|
end
|
282
282
|
else
|
283
283
|
add_coverage_extension(resource, coverage_id)
|
284
|
-
system_actions.append(
|
285
|
-
|
286
|
-
|
284
|
+
system_actions.append(
|
285
|
+
{
|
286
|
+
'type' => 'update',
|
287
|
+
'description' => "Added coverage information to #{resource.resourceType} resource.",
|
288
|
+
'resource' => resource
|
289
|
+
}
|
290
|
+
)
|
287
291
|
end
|
288
292
|
system_actions
|
289
293
|
end
|
@@ -301,7 +305,11 @@ module DaVinciCRDTestKit
|
|
301
305
|
),
|
302
306
|
FHIR::Extension.new(
|
303
307
|
url: 'covered',
|
304
|
-
valueCode: '
|
308
|
+
valueCode: 'covered'
|
309
|
+
),
|
310
|
+
FHIR::Extension.new(
|
311
|
+
url: 'pa-needed',
|
312
|
+
valueCode: 'no-auth'
|
305
313
|
),
|
306
314
|
FHIR::Extension.new(
|
307
315
|
url: 'date',
|
@@ -340,28 +348,31 @@ module DaVinciCRDTestKit
|
|
340
348
|
)
|
341
349
|
end
|
342
350
|
|
343
|
-
def create_or_update_coverage(coverage
|
351
|
+
def create_or_update_coverage(coverage)
|
344
352
|
return if context.nil?
|
345
353
|
|
346
354
|
if coverage.present?
|
347
355
|
action = { 'type' => 'update', 'description' => 'Update current coverage record' }
|
348
|
-
coverage.period =
|
349
|
-
|
356
|
+
coverage.period =
|
357
|
+
FHIR::Period.new(
|
358
|
+
start: current_time.strftime('%Y-%m-%d'),
|
359
|
+
end: (current_time + 1.month).strftime('%Y-%m-%d')
|
360
|
+
)
|
350
361
|
action['resource'] = coverage
|
351
362
|
else
|
352
363
|
action = { 'type' => 'create', 'description' => 'Create coverage record' }
|
353
364
|
new_coverage = create_coverage_resource(context['patientId'])
|
354
365
|
action['resource'] = new_coverage
|
355
366
|
end
|
356
|
-
coverage_info_card =
|
367
|
+
coverage_info_card = load_json_file('create_update_coverage_information.json')
|
357
368
|
coverage_info_card['suggestions'][0]['actions'] = [action]
|
358
369
|
coverage_info_card
|
359
370
|
end
|
360
371
|
|
361
|
-
def create_form_completion_card
|
372
|
+
def create_form_completion_card
|
362
373
|
return if context.nil?
|
363
374
|
|
364
|
-
request_form_completion_card =
|
375
|
+
request_form_completion_card = load_json_file('request_form_completion.json')
|
365
376
|
form_completion_task = request_form_completion_card['suggestions'][0]['actions'].find do |action|
|
366
377
|
action['resource']['resourceType'] == 'Task'
|
367
378
|
end['resource']
|
@@ -371,7 +382,7 @@ module DaVinciCRDTestKit
|
|
371
382
|
request_form_completion_card
|
372
383
|
end
|
373
384
|
|
374
|
-
def update_service_request(service_request
|
385
|
+
def update_service_request(service_request)
|
375
386
|
return if context.nil?
|
376
387
|
|
377
388
|
service_request['subject']['reference'] = "Patient/#{context['patientId']}"
|
@@ -379,23 +390,22 @@ module DaVinciCRDTestKit
|
|
379
390
|
service_request['authoredOn'] = current_time.strftime('%Y-%m-%d')
|
380
391
|
end
|
381
392
|
|
382
|
-
def create_companions_prerequisites_card
|
393
|
+
def create_companions_prerequisites_card
|
383
394
|
return if context.nil?
|
384
395
|
|
385
|
-
companions_prerequisites_card =
|
396
|
+
companions_prerequisites_card = load_json_file('companions_prerequisites.json')
|
386
397
|
card_service_request = companions_prerequisites_card['suggestions'][0]['actions'][0]['resource']
|
387
|
-
update_service_request(card_service_request
|
398
|
+
update_service_request(card_service_request)
|
388
399
|
companions_prerequisites_card
|
389
400
|
end
|
390
401
|
|
391
|
-
def create_alternate_request_card
|
392
|
-
context = request_body['context']
|
402
|
+
def create_alternate_request_card
|
393
403
|
return if context.nil?
|
394
404
|
|
395
|
-
propose_alternate_request_card =
|
405
|
+
propose_alternate_request_card = load_json_file('propose_alternate_request.json')
|
396
406
|
|
397
407
|
if hook_name == 'order-dispatch'
|
398
|
-
order_resource = get_context_resource(
|
408
|
+
order_resource = get_context_resource(context['order'])
|
399
409
|
else
|
400
410
|
draft_orders = context['draftOrders']['entry']
|
401
411
|
draft_order_resource = draft_orders[0]['resource']
|
@@ -407,14 +417,18 @@ module DaVinciCRDTestKit
|
|
407
417
|
order_resource_id = order_resource.id
|
408
418
|
|
409
419
|
card_actions = propose_alternate_request_card['suggestions'][0]['actions']
|
410
|
-
card_actions.
|
420
|
+
card_actions.push(
|
411
421
|
{
|
412
422
|
'type' => 'delete',
|
413
423
|
'description' => 'Remove current order until health assessment has been done',
|
414
424
|
'resourceId' => ["#{order_resource_type}/#{order_resource_id}"]
|
425
|
+
},
|
426
|
+
{
|
427
|
+
'type' => 'create',
|
428
|
+
'description' => 'Order for patient health assessment',
|
429
|
+
'resource' => order_resource
|
415
430
|
}
|
416
431
|
)
|
417
|
-
update_service_request(card_actions[0]['resource'], context)
|
418
432
|
propose_alternate_request_card
|
419
433
|
end
|
420
434
|
end
|
@@ -5,56 +5,45 @@ module DaVinciCRDTestKit
|
|
5
5
|
include DaVinciCRDTestKit::MockServiceResponse
|
6
6
|
|
7
7
|
def selected_response_types
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
@selected_response_types ||=
|
9
|
+
JSON.parse(result.input_json)
|
10
|
+
.find { |input| input['name'].include?('selected_response_types') }
|
11
|
+
&.dig('value')
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
-
|
14
|
+
def custom_response
|
15
|
+
@custom_response ||=
|
16
|
+
JSON.parse(result.input_json)
|
17
|
+
.find { |input| input['name'].include?('custom_response') }
|
18
|
+
&.dig('value')
|
15
19
|
end
|
16
20
|
|
17
|
-
def
|
18
|
-
|
19
|
-
iss = extract_iss_claim_from_token(request).to_s
|
20
|
-
|
21
|
-
"#{hook} #{iss}"
|
21
|
+
def test_run_identifier
|
22
|
+
"#{hook_name} #{iss}"
|
22
23
|
end
|
23
24
|
|
24
|
-
def
|
25
|
-
|
26
|
-
begin
|
27
|
-
payload, = JWT.decode(token, nil, false)
|
28
|
-
payload['iss']
|
29
|
-
rescue JWT::DecodeError
|
30
|
-
nil
|
31
|
-
end
|
25
|
+
def hook_name
|
26
|
+
@hook_name ||= request.params[:hook]
|
32
27
|
end
|
33
28
|
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
def iss
|
30
|
+
@iss ||=
|
31
|
+
begin
|
32
|
+
payload, = JWT.decode(token, nil, false)
|
33
|
+
payload['iss']
|
34
|
+
rescue JWT::DecodeError
|
35
|
+
nil
|
36
|
+
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
request.
|
39
|
+
def token
|
40
|
+
@token ||= request.headers['authorization']&.delete_prefix('Bearer ')
|
41
41
|
end
|
42
42
|
|
43
43
|
def make_response
|
44
|
-
hook_name = extract_hook_name(request)
|
45
44
|
case hook_name
|
46
|
-
when 'appointment-book'
|
47
|
-
|
48
|
-
when 'encounter-start'
|
49
|
-
encounter_start_response(selected_response_types)
|
50
|
-
when 'encounter-discharge'
|
51
|
-
encounter_discharge_response(selected_response_types)
|
52
|
-
when 'order-select'
|
53
|
-
order_select_response(selected_response_types)
|
54
|
-
when 'order-sign'
|
55
|
-
order_sign_response(selected_response_types)
|
56
|
-
when 'order-dispatch'
|
57
|
-
order_dispatch_response(selected_response_types)
|
45
|
+
when 'appointment-book', 'encounter-start', 'encounter-discharge', 'order-select', 'order-sign', 'order-dispatch'
|
46
|
+
hook_response
|
58
47
|
else
|
59
48
|
response.status = 400
|
60
49
|
response.body = 'Invalid Request: Request did not contain a valid hook in the `hook` field.'
|
@@ -62,7 +51,6 @@ module DaVinciCRDTestKit
|
|
62
51
|
end
|
63
52
|
|
64
53
|
def tags
|
65
|
-
hook_name = extract_hook_name(request)
|
66
54
|
case hook_name
|
67
55
|
when 'appointment-book'
|
68
56
|
[APPOINTMENT_BOOK_TAG]
|
@@ -83,11 +71,7 @@ module DaVinciCRDTestKit
|
|
83
71
|
end
|
84
72
|
|
85
73
|
def name
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
def update_result
|
90
|
-
results_repo.update(result.id, result: 'pass')
|
74
|
+
hook_name.gsub('-', '_')
|
91
75
|
end
|
92
76
|
end
|
93
77
|
end
|
@@ -24,6 +24,7 @@ module DaVinciCRDTestKit
|
|
24
24
|
and the [CDS Hooks section on CDS Service Response](https://cds-hooks.hl7.org/2.0/#cds-service-response).
|
25
25
|
|
26
26
|
This group includes tests to validate the following CRD response types:
|
27
|
+
- [Coverage Information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#coverage-information) - optional
|
27
28
|
- [Create or update coverage information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#create-or-update-coverage-information)\
|
28
29
|
- optional
|
29
30
|
- [External Reference](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#external-reference) - optional
|
@@ -118,6 +119,29 @@ module DaVinciCRDTestKit
|
|
118
119
|
}
|
119
120
|
}
|
120
121
|
}
|
122
|
+
test from: :crd_coverage_info_system_action_received,
|
123
|
+
optional: true,
|
124
|
+
config: {
|
125
|
+
inputs: {
|
126
|
+
valid_system_actions: {
|
127
|
+
name: :encounter_discharge_valid_system_actions
|
128
|
+
}
|
129
|
+
},
|
130
|
+
outputs: {
|
131
|
+
coverage_info: {
|
132
|
+
name: :encounter_discharge_coverage_info
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
test from: :crd_coverage_info_system_action_validation,
|
137
|
+
optional: true,
|
138
|
+
config: {
|
139
|
+
inputs: {
|
140
|
+
coverage_info: {
|
141
|
+
name: :encounter_discharge_coverage_info
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
121
145
|
test from: :crd_request_form_completion_response_validation,
|
122
146
|
config: {
|
123
147
|
inputs: {
|
@@ -24,6 +24,7 @@ module DaVinciCRDTestKit
|
|
24
24
|
and the [CDS Hooks section on CDS Service Response](https://cds-hooks.hl7.org/2.0/#cds-service-response).
|
25
25
|
|
26
26
|
This group includes tests to validate the following CRD response types:
|
27
|
+
- [Coverage Information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#coverage-information) - optional
|
27
28
|
- [Create or update coverage information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#create-or-update-coverage-information)\
|
28
29
|
- optional
|
29
30
|
- [External Reference](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#external-reference) - optional
|
@@ -118,6 +119,29 @@ module DaVinciCRDTestKit
|
|
118
119
|
}
|
119
120
|
}
|
120
121
|
}
|
122
|
+
test from: :crd_coverage_info_system_action_received,
|
123
|
+
optional: true,
|
124
|
+
config: {
|
125
|
+
inputs: {
|
126
|
+
valid_system_actions: {
|
127
|
+
name: :encounter_start_valid_system_actions
|
128
|
+
}
|
129
|
+
},
|
130
|
+
outputs: {
|
131
|
+
coverage_info: {
|
132
|
+
name: :encounter_start_coverage_info
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
test from: :crd_coverage_info_system_action_validation,
|
137
|
+
optional: true,
|
138
|
+
config: {
|
139
|
+
inputs: {
|
140
|
+
coverage_info: {
|
141
|
+
name: :encounter_start_coverage_info
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
121
145
|
test from: :crd_request_form_completion_response_validation,
|
122
146
|
config: {
|
123
147
|
inputs: {
|
@@ -28,6 +28,7 @@ module DaVinciCRDTestKit
|
|
28
28
|
This group includes tests to validate the following CRD response types:
|
29
29
|
- [additional orders as companions/prerequisites](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#identify-additional-orders-as-companionsprerequisites-for-current-order)\
|
30
30
|
- optional
|
31
|
+
- [Coverage Information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#coverage-information) - optional
|
31
32
|
- [Create or update coverage information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#create-or-update-coverage-information)\
|
32
33
|
- optional
|
33
34
|
- [External Reference](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#external-reference) - optional
|
@@ -124,6 +125,29 @@ module DaVinciCRDTestKit
|
|
124
125
|
}
|
125
126
|
}
|
126
127
|
}
|
128
|
+
test from: :crd_coverage_info_system_action_received,
|
129
|
+
optional: true,
|
130
|
+
config: {
|
131
|
+
inputs: {
|
132
|
+
valid_system_actions: {
|
133
|
+
name: :order_select_valid_system_actions
|
134
|
+
}
|
135
|
+
},
|
136
|
+
outputs: {
|
137
|
+
coverage_info: {
|
138
|
+
name: :order_select_coverage_info
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
test from: :crd_coverage_info_system_action_validation,
|
143
|
+
optional: true,
|
144
|
+
config: {
|
145
|
+
inputs: {
|
146
|
+
coverage_info: {
|
147
|
+
name: :order_select_coverage_info
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
127
151
|
test from: :crd_propose_alternate_request_card_validation,
|
128
152
|
config: {
|
129
153
|
inputs: {
|