onc_certification_g10_test_kit 2.3.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/inferno/terminology/expected_manifest.yml +242 -29
  3. data/lib/inferno/terminology/fhir_package_manager.rb +27 -0
  4. data/lib/inferno/terminology/loader.rb +22 -1
  5. data/lib/inferno/terminology/tasks/create_value_set_validators.rb +1 -1
  6. data/lib/inferno/terminology/tasks/download_fhir_terminology.rb +5 -0
  7. data/lib/inferno/terminology/value_set.rb +51 -5
  8. data/lib/onc_certification_g10_test_kit/base_token_refresh_group.rb +5 -4
  9. data/lib/onc_certification_g10_test_kit/bulk_data_group_export_stu1.rb +5 -0
  10. data/lib/onc_certification_g10_test_kit/bulk_data_group_export_stu2.rb +2 -0
  11. data/lib/onc_certification_g10_test_kit/bulk_data_group_export_validation.rb +206 -28
  12. data/lib/onc_certification_g10_test_kit/bulk_export_validation_tester.rb +25 -40
  13. data/lib/onc_certification_g10_test_kit/encounter_context_test.rb +30 -0
  14. data/lib/onc_certification_g10_test_kit/feature.rb +5 -8
  15. data/lib/onc_certification_g10_test_kit/limited_scope_grant_test.rb +18 -5
  16. data/lib/onc_certification_g10_test_kit/profile_selector.rb +175 -0
  17. data/lib/onc_certification_g10_test_kit/restricted_resource_type_access_group.rb +54 -4
  18. data/lib/onc_certification_g10_test_kit/single_patient_us_core_5_api_group.rb +93 -0
  19. data/lib/onc_certification_g10_test_kit/smart_app_launch_invalid_aud_group.rb +50 -5
  20. data/lib/onc_certification_g10_test_kit/smart_ehr_patient_launch_group.rb +94 -0
  21. data/lib/onc_certification_g10_test_kit/smart_ehr_patient_launch_group_stu2.rb +94 -0
  22. data/lib/onc_certification_g10_test_kit/smart_ehr_practitioner_app_group.rb +197 -13
  23. data/lib/onc_certification_g10_test_kit/smart_invalid_pkce_group.rb +310 -0
  24. data/lib/onc_certification_g10_test_kit/smart_invalid_token_group_stu2.rb +211 -0
  25. data/lib/onc_certification_g10_test_kit/smart_limited_app_group.rb +135 -9
  26. data/lib/onc_certification_g10_test_kit/smart_public_standalone_launch_group.rb +16 -4
  27. data/lib/onc_certification_g10_test_kit/smart_public_standalone_launch_group_stu2.rb +130 -0
  28. data/lib/onc_certification_g10_test_kit/smart_scopes_test.rb +134 -67
  29. data/lib/onc_certification_g10_test_kit/smart_standalone_patient_app_group.rb +166 -11
  30. data/lib/onc_certification_g10_test_kit/unrestricted_resource_type_access_group.rb +119 -135
  31. data/lib/onc_certification_g10_test_kit/version.rb +1 -1
  32. data/lib/onc_certification_g10_test_kit/visual_inspection_and_attestations_group.rb +19 -0
  33. data/lib/onc_certification_g10_test_kit/well_known_capabilities_test.rb +7 -1
  34. data/lib/onc_certification_g10_test_kit.rb +115 -74
  35. metadata +19 -11
  36. data/lib/onc_certification_g10_test_kit/profile_guesser.rb +0 -72
@@ -11,8 +11,7 @@ module ONCCertificationG10TestKit
11
11
  resources on the server.
12
12
 
13
13
  Token refreshes are accomplished through a `POST` request to the token
14
- exchange endpoint as described in the [SMART App Launch
15
- Framework](http://hl7.org/fhir/smart-app-launch/1.0.0/index.html#step-5-later-app-uses-a-refresh-token-to-obtain-a-new-access-token).
14
+ exchange endpoint as described in the SMART App Launch Framework.
16
15
 
17
16
  # Test Methodology
18
17
 
@@ -24,8 +23,10 @@ module ONCCertificationG10TestKit
24
23
 
25
24
  * [The OAuth 2.0 Authorization
26
25
  Framework](https://tools.ietf.org/html/rfc6749)
27
- * [Using a refresh token to obtain a new access
28
- token](http://hl7.org/fhir/smart-app-launch/1.0.0/index.html#step-5-later-app-uses-a-refresh-token-to-obtain-a-new-access-token)
26
+ * [Using a refresh token to obtain a new access token
27
+ (STU1)](http://hl7.org/fhir/smart-app-launch/1.0.0/index.html#step-5-later-app-uses-a-refresh-token-to-obtain-a-new-access-token)
28
+ * [Using a refresh token to obtain a new access token
29
+ (STU2)](http://hl7.org/fhir/smart-app-launch/STU2/app-launch.html#refresh-access-token)
29
30
  )
30
31
  id :g10_token_refresh
31
32
 
@@ -265,6 +265,11 @@ module ONCCertificationG10TestKit
265
265
  ['type', 'url'].each do |key|
266
266
  assert file.key?(key), "Output file did not contain \"#{key}\" as required"
267
267
  end
268
+
269
+ if config.options[:require_absolute_urls_in_output]
270
+ assert file['url'].to_s.match?(%r{\Ahttps?://}),
271
+ "URLs in output file must be absolute, but found `#{file['url']}`."
272
+ end
268
273
  end
269
274
  end
270
275
  end
@@ -6,6 +6,8 @@ module ONCCertificationG10TestKit
6
6
  title 'Group Compartment Export Tests STU2'
7
7
  id :bulk_data_group_export_stu2
8
8
 
9
+ config(options: { require_absolute_urls_in_output: true })
10
+
9
11
  test do
10
12
  title 'Bulk Data Server supports "_outputFormat" query parameter'
11
13
  description <<~DESCRIPTION
@@ -79,8 +79,9 @@ module ONCCertificationG10TestKit
79
79
  test do
80
80
  title 'Patient resources returned conform to the US Core Patient Profile'
81
81
  description <<~DESCRIPTION
82
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This#{' '}
83
- includes checking for missing data elements and value set verification.
82
+ This test verifies that the resources returned from bulk data export
83
+ conform to the US Core Patient profile. This includes checking for missing data
84
+ elements and value set verification.
84
85
  DESCRIPTION
85
86
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient'
86
87
 
@@ -136,7 +137,9 @@ module ONCCertificationG10TestKit
136
137
  test do
137
138
  title 'AllergyIntolerance resources returned conform to the US Core AllergyIntolerance Profile'
138
139
  description <<~DESCRIPTION
139
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
140
+ This test verifies that the resources returned from bulk data export
141
+ conform to the US Core AllergyIntolerance profile. This includes
142
+ checking for missing data elements and value set verification.
140
143
  DESCRIPTION
141
144
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-allergyintolerance'
142
145
 
@@ -154,7 +157,9 @@ module ONCCertificationG10TestKit
154
157
  test do
155
158
  title 'CarePlan resources returned conform to the US Core CarePlan Profile'
156
159
  description <<~DESCRIPTION
157
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
160
+ This test verifies that the resources returned from bulk data export
161
+ conform to the US Core CarePlan profile. This includes checking for
162
+ missing data elements and value set verification.
158
163
  DESCRIPTION
159
164
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-careplan'
160
165
 
@@ -172,7 +177,9 @@ module ONCCertificationG10TestKit
172
177
  test do
173
178
  title 'CareTeam resources returned conform to the US Core CareTeam Profile'
174
179
  description <<~DESCRIPTION
175
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
180
+ This test verifies that the resources returned from bulk data export
181
+ conform to the US Core CareTeam profile. This includes checking for missing data
182
+ elements and value set verification.
176
183
  DESCRIPTION
177
184
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-careteam'
178
185
 
@@ -188,11 +195,23 @@ module ONCCertificationG10TestKit
188
195
  end
189
196
 
190
197
  test do
191
- title 'Condition resources returned conform to the US Core Condition Profile'
198
+ title 'Condition resources returned conform to the relevant US Core Condition Profile'
192
199
  description <<~DESCRIPTION
193
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
200
+ This test verifies that the server can provide evidence of support for
201
+ the following US Core Condition profiles. This includes checking for
202
+ missing data elements and value set verification.
203
+
204
+ For US Core v3.1.1 and v4.0.0 all resources must conform to the following profile:
205
+
206
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition
207
+
208
+
209
+ For US Core v5.0.1, evidence of support for the following two profiles must be demonstrated:
210
+
211
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition-encounter-diagnosis
212
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition-problems-health-concerns
213
+
194
214
  DESCRIPTION
195
- # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition'
196
215
 
197
216
  include BulkExportValidationTester
198
217
 
@@ -208,7 +227,13 @@ module ONCCertificationG10TestKit
208
227
  test do
209
228
  title 'Device resources returned conform to the US Core Implantable Device Profile'
210
229
  description <<~DESCRIPTION
211
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
230
+ This test verifies that relevant resources returned from bulk data export
231
+ conform to the US Core Implantable Device profile. This includes
232
+ checking for missing data elements and value set verification.
233
+
234
+ Because not all Device resources on a system must conform to the Implantable Device
235
+ profile, the tester may choose to provide a list of relevant Device Type Codes
236
+ as an input to this test.
212
237
  DESCRIPTION
213
238
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-implantable-device'
214
239
 
@@ -224,14 +249,16 @@ module ONCCertificationG10TestKit
224
249
  end
225
250
 
226
251
  test do
227
- title 'DiagnosticReport resources returned conform to the US Core DiagnosticReport Profile'
252
+ title 'DiagnosticReport resources returned conform to the relevant US Core DiagnosticReport Profile'
228
253
  description <<~DESCRIPTION
229
- This test verifies that the resources returned from bulk data export conform to the following US Core profiles. This includes checking for missing data elements and value set verification.
254
+ This test verifies that the server can provide evidence of support for
255
+ the following US Core DiagnosticReport profile based on the category of
256
+ the DiagnosticReport. This includes checking for missing data elements
257
+ and value set verification.
230
258
 
231
259
  * http://hl7.org/fhir/us/core/StructureDefinition/us-core-diagnosticreport-lab
232
260
  * http://hl7.org/fhir/us/core/StructureDefinition/us-core-diagnosticreport-note
233
261
  DESCRIPTION
234
- # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-diagnosticreport-l'
235
262
 
236
263
  include BulkExportValidationTester
237
264
 
@@ -247,7 +274,9 @@ module ONCCertificationG10TestKit
247
274
  test do
248
275
  title 'DocumentReference resources returned conform to the US Core DocumentReference Profile'
249
276
  description <<~DESCRIPTION
250
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
277
+ This test verifies that the resources returned from bulk data export
278
+ conform to the US Core DocumenReference profile. This includes checking
279
+ for missing data elements and value set verification.
251
280
  DESCRIPTION
252
281
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-documentreference'
253
282
 
@@ -265,7 +294,9 @@ module ONCCertificationG10TestKit
265
294
  test do
266
295
  title 'Goal resources returned conform to the US Core Goal Profile'
267
296
  description <<~DESCRIPTION
268
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
297
+ This test verifies that the resources returned from bulk data export
298
+ conform to the US Core Goal profile. This includes checking for missing
299
+ data elements and value set verification.
269
300
  DESCRIPTION
270
301
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-goal'
271
302
 
@@ -283,7 +314,9 @@ module ONCCertificationG10TestKit
283
314
  test do
284
315
  title 'Immunization resources returned conform to the US Core Immunization Profile'
285
316
  description <<~DESCRIPTION
286
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
317
+ This test verifies that the resources returned from bulk data export
318
+ conform to the US Core Immunization profile. This includes checking for
319
+ missing data elements and value set verification.
287
320
  DESCRIPTION
288
321
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-Immunization'
289
322
 
@@ -301,7 +334,9 @@ module ONCCertificationG10TestKit
301
334
  test do
302
335
  title 'MedicationRequest resources returned conform to the US Core MedicationRequest Profile'
303
336
  description <<~DESCRIPTION
304
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
337
+ This test verifies that the resources returned from bulk data export
338
+ conform to the US Core MedicationRequest profile. This includes checking
339
+ for missing data elements and value set verification.
305
340
  DESCRIPTION
306
341
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-medicationrequest'
307
342
 
@@ -317,11 +352,14 @@ module ONCCertificationG10TestKit
317
352
  end
318
353
 
319
354
  test do
320
- title 'Observation resources returned conform to the US Core Observation Profile'
355
+ title 'Observation resources returned conform to the relevant US Core Observation Profile'
321
356
  description <<~DESCRIPTION
322
- This test verifies that the resources returned from bulk data
323
- export conform to the following US Core profiles. This includes
324
- checking for missing data elements and value set verification.
357
+ This test verifies that the resources returned from bulk data export
358
+ conform to the following US Core profiles, based on the category or code
359
+ associated with the Observation. This includes checking for missing data
360
+ elements and value set verification.
361
+
362
+ For US Core v3.1.1, this test expects evidence of the following US Core profiles
325
363
 
326
364
  * http://hl7.org/fhir/us/core/StructureDefinition/pediatric-bmi-for-age
327
365
  * http://hl7.org/fhir/us/core/StructureDefinition/pediatric-weight-for-height
@@ -335,8 +373,47 @@ module ONCCertificationG10TestKit
335
373
  * http://hl7.org/fhir/StructureDefinition/bodyweight
336
374
  * http://hl7.org/fhir/StructureDefinition/heartrate
337
375
  * http://hl7.org/fhir/StructureDefinition/resprate
376
+
377
+ For US Core v4.0.0, this test expects evidence of the following US Core profiles
378
+
379
+ * http://hl7.org/fhir/us/core/StructureDefinition/pediatric-bmi-for-age
380
+ * http://hl7.org/fhir/us/core/StructureDefinition/pediatric-weight-for-height
381
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-lab
382
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-pulse-oximetry
383
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-smokingstatus
384
+ * http://hl7.org/fhir/us/core/StructureDefinition/head-occipital-frontal-circumference-percentile
385
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-blood-pressure
386
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-bmi
387
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-head-circumference
388
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-height
389
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-weight
390
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-temperature
391
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-heart-rate
392
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-respiratory-rate
393
+
394
+ For US Core v5.0.1, this test expects evidence of the following US Core profiles
395
+
396
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-clinical-test
397
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-imaging
398
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-sexual-orientation
399
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-social-history
400
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-sdoh-assessment
401
+ * http://hl7.org/fhir/us/core/StructureDefinition/pediatric-bmi-for-age
402
+ * http://hl7.org/fhir/us/core/StructureDefinition/pediatric-weight-for-height
403
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-lab
404
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-pulse-oximetry
405
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-smokingstatus
406
+ * http://hl7.org/fhir/us/core/StructureDefinition/head-occipital-frontal-circumference-percentile
407
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-blood-pressure
408
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-bmi
409
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-head-circumference
410
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-height
411
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-weight
412
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-temperature
413
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-heart-rate
414
+ * http://hl7.org/fhir/us/core/StructureDefinition/us-core-respiratory-rate
415
+
338
416
  DESCRIPTION
339
- # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-lab'
340
417
 
341
418
  include BulkExportValidationTester
342
419
 
@@ -352,7 +429,9 @@ module ONCCertificationG10TestKit
352
429
  test do
353
430
  title 'Procedure resources returned conform to the US Core Procedure Profile'
354
431
  description <<~DESCRIPTION
355
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
432
+ This test verifies that the resources returned from bulk data export
433
+ conform to the US Core Procedure profile. This includes checking for
434
+ missing data elements and value set verification.
356
435
  DESCRIPTION
357
436
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-procedure'
358
437
 
@@ -370,7 +449,9 @@ module ONCCertificationG10TestKit
370
449
  test do
371
450
  title 'Encounter resources returned conform to the US Core Encounter Profile'
372
451
  description <<~DESCRIPTION
373
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
452
+ This test verifies that the resources returned from bulk data export
453
+ conform to the US Core Encounter profile. This includes checking for
454
+ missing data elements and value set verification.
374
455
  DESCRIPTION
375
456
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter'
376
457
 
@@ -388,7 +469,9 @@ module ONCCertificationG10TestKit
388
469
  test do
389
470
  title 'Organization resources returned conform to the US Core Organization Profile'
390
471
  description <<~DESCRIPTION
391
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
472
+ This test verifies that the resources returned from bulk data export
473
+ conform to the US Core Organization profile. This includes checking for
474
+ missing data elements and value set verification.
392
475
  DESCRIPTION
393
476
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization'
394
477
 
@@ -406,7 +489,9 @@ module ONCCertificationG10TestKit
406
489
  test do
407
490
  title 'Practitioner resources returned conform to the US Core Practitioner Profile'
408
491
  description <<~DESCRIPTION
409
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
492
+ This test verifies that the resources returned from bulk data export
493
+ conform to the US Core Practioner profile. This includes checking for
494
+ missing data elements and value set verification.
410
495
  DESCRIPTION
411
496
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner'
412
497
 
@@ -424,7 +509,9 @@ module ONCCertificationG10TestKit
424
509
  test do
425
510
  title 'Provenance resources returned conform to the US Core Provenance Profile'
426
511
  description <<~DESCRIPTION
427
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification.
512
+ This test verifies that the resources returned from bulk data export
513
+ conform to the US Core profiles. This includes checking for missing data
514
+ elements and value set verification.
428
515
  DESCRIPTION
429
516
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-provenance'
430
517
 
@@ -443,7 +530,10 @@ module ONCCertificationG10TestKit
443
530
  title 'Location resources returned conform to the HL7 FHIR Specification Location Resource if bulk data export ' \
444
531
  'has Location resources'
445
532
  description <<~DESCRIPTION
446
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification. This test is omitted if bulk data export does not return any Location resources.
533
+ This test verifies that the resources returned from bulk data export
534
+ conform to the HL7 FHIR Specification Location Resource. This includes
535
+ checking for missing data elements and value set verification. This test
536
+ is omitted if bulk data export does not return any Location resources.
447
537
  DESCRIPTION
448
538
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-location'
449
539
 
@@ -462,7 +552,10 @@ module ONCCertificationG10TestKit
462
552
  title 'Medication resources returned conform to the US Core Medication Profile if bulk data export has ' \
463
553
  'Medication resources'
464
554
  description <<~DESCRIPTION
465
- This test verifies that the resources returned from bulk data export conform to the US Core profiles. This includes checking for missing data elements and value set verification. This test is omitted if bulk data export does not return any Medication resources.
555
+ This test verifies that the resources returned from bulk data export
556
+ conform to the US Core Medication profile, if available. This includes
557
+ checking for missing data elements and value set verification. This test
558
+ is omitted if bulk data export does not return any Medication resources.
466
559
  DESCRIPTION
467
560
  # link 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-medication'
468
561
 
@@ -476,5 +569,90 @@ module ONCCertificationG10TestKit
476
569
  perform_bulk_export_validation
477
570
  end
478
571
  end
572
+
573
+ test do
574
+ title 'ServiceRequest resources returned conform to the US Core ServiceRequest Profile'
575
+ description <<~DESCRIPTION
576
+ This test verifies that the resources returned from bulk data export
577
+ conform to the US Core ServiceRequest profile. This includes checking
578
+ for missing data elements and value set verification.
579
+ DESCRIPTION
580
+
581
+ required_suite_options us_core_version: 'us_core_5'
582
+
583
+ include BulkExportValidationTester
584
+
585
+ def resource_type
586
+ 'ServiceRequest'
587
+ end
588
+
589
+ run do
590
+ perform_bulk_export_validation
591
+ end
592
+ end
593
+
594
+ test do
595
+ title 'RelatedPerson resources returned conform to the US Core RelatedPerson Profile'
596
+ description <<~DESCRIPTION
597
+ This test verifies that the resources returned from bulk data export
598
+ conform to the US Core RelatedPerson profile. This includes checking
599
+ for missing data elements and value set verification.
600
+ DESCRIPTION
601
+ required_suite_options us_core_version: 'us_core_5'
602
+
603
+ include BulkExportValidationTester
604
+
605
+ def resource_type
606
+ 'RelatedPerson'
607
+ end
608
+
609
+ run do
610
+ perform_bulk_export_validation
611
+ end
612
+ end
613
+
614
+ test do
615
+ title 'QuestionnaireResponse resources returned conform to the US Core QuestionnaireResponse Profile if ' \
616
+ 'bulk data has QuestionnaireResponse resources'
617
+ description <<~DESCRIPTION
618
+ This test verifies that the resources returned from bulk data export
619
+ conform to the US Core QuestionnaireResponse profile. This includes checking for missing
620
+ data elements and value set verification. This test is omitted if bulk
621
+ data export does not return any QuestionnaireResponse resources.
622
+ DESCRIPTION
623
+ required_suite_options us_core_version: 'us_core_5'
624
+
625
+ include BulkExportValidationTester
626
+
627
+ def resource_type
628
+ 'QuestionnaireResponse'
629
+ end
630
+
631
+ run do
632
+ perform_bulk_export_validation
633
+ end
634
+ end
635
+
636
+ test do
637
+ title 'PractionerRole resources returned conform to the US Core PractionerRole Profile if bulk data export ' \
638
+ 'has PractionerRole resources'
639
+ description <<~DESCRIPTION
640
+ This test verifies that the resources returned from bulk data export
641
+ conform to the US Core PractitionerRole profile. This includes checking for missing
642
+ data elements and value set verification. This test is omitted if bulk
643
+ data export does not return any resources.
644
+ DESCRIPTION
645
+ required_suite_options us_core_version: 'us_core_5'
646
+
647
+ include BulkExportValidationTester
648
+
649
+ def resource_type
650
+ 'PractitionerRole'
651
+ end
652
+
653
+ run do
654
+ perform_bulk_export_validation
655
+ end
656
+ end
479
657
  end
480
658
  end
@@ -1,54 +1,32 @@
1
- require_relative 'profile_guesser'
1
+ require_relative 'profile_selector'
2
2
 
3
3
  module ONCCertificationG10TestKit
4
4
  module BulkExportValidationTester
5
5
  include USCoreTestKit::MustSupportTest
6
- include ProfileGuesser
6
+ include ProfileSelector
7
7
 
8
8
  attr_reader :metadata
9
9
 
10
10
  MAX_NUM_COLLECTED_LINES = 100
11
11
  MIN_RESOURCE_COUNT = 2
12
- OMIT_KLASS = ['Medication', 'Location'].freeze
13
-
14
- def observation_metadata
15
- [
16
- USCoreTestKit::USCoreV311::PediatricBmiForAgeGroup.metadata,
17
- USCoreTestKit::USCoreV311::PediatricWeightForHeightGroup.metadata,
18
- USCoreTestKit::USCoreV311::ObservationLabGroup.metadata,
19
- USCoreTestKit::USCoreV311::PulseOximetryGroup.metadata,
20
- USCoreTestKit::USCoreV311::SmokingstatusGroup.metadata,
21
- USCoreTestKit::USCoreV311::HeadCircumferenceGroup.metadata,
22
- USCoreTestKit::USCoreV311::BpGroup.metadata,
23
- USCoreTestKit::USCoreV311::BodyheightGroup.metadata,
24
- USCoreTestKit::USCoreV311::BodytempGroup.metadata,
25
- USCoreTestKit::USCoreV311::BodyweightGroup.metadata,
26
- USCoreTestKit::USCoreV311::HeartrateGroup.metadata,
27
- USCoreTestKit::USCoreV311::ResprateGroup.metadata
28
- ]
29
- end
30
-
31
- def diagnostic_metadata
32
- [
33
- USCoreTestKit::USCoreV311::DiagnosticReportLabGroup.metadata,
34
- USCoreTestKit::USCoreV311::DiagnosticReportNoteGroup.metadata
35
- ]
36
- end
37
-
38
- def determine_metadata
39
- return observation_metadata if resource_type == 'Observation'
40
- return diagnostic_metadata if resource_type == 'DiagnosticReport'
41
-
42
- if resource_type == 'Location' || resource_type == 'Medication'
43
- return Array.wrap(USCoreTestKit::USCoreV311::USCoreTestSuite.metadata.find do |meta|
44
- meta.resource == resource_type
45
- end)
12
+ OMIT_KLASS = ['Medication', 'Location', 'QuestionnaireResponse', 'PractitionerRole'].freeze
13
+
14
+ def versioned_us_core_module
15
+ case suite_options[:us_core_version]
16
+ when 'us_core_5'
17
+ USCoreTestKit::USCoreV501
18
+ when 'us_core_4'
19
+ USCoreTestKit::USCoreV400
20
+ else
21
+ USCoreTestKit::USCoreV311
46
22
  end
47
- ["USCoreTestKit::USCoreV311::#{resource_type}Group".constantize.metadata]
48
23
  end
49
24
 
50
25
  def metadata_list
51
- @metadata_list ||= determine_metadata
26
+ @metadata_list ||=
27
+ versioned_us_core_module::USCoreTestSuite
28
+ .metadata
29
+ .select { |metadata| metadata.resource == resource_type }
52
30
  end
53
31
 
54
32
  def resources_from_all_files
@@ -122,7 +100,7 @@ module ONCCertificationG10TestKit
122
100
  def determine_profile(resource)
123
101
  return if resource.resourceType == 'Device' && !predefined_device_type?(resource)
124
102
 
125
- guess_profile(resource)
103
+ select_profile(resource)
126
104
  end
127
105
 
128
106
  def validate_conformance(resources)
@@ -143,6 +121,12 @@ module ONCCertificationG10TestKit
143
121
  end
144
122
  end
145
123
 
124
+ def versioned_profile_url(profile_url)
125
+ profile_version = metadata_list.find { |metadata| metadata.profile_url == profile_url }&.profile_version
126
+
127
+ profile_version ? "#{profile_url}|#{profile_version}" : profile_url
128
+ end
129
+
146
130
  def check_file_request(url) # rubocop:disable Metrics/CyclomaticComplexity
147
131
  line_count = 0
148
132
  resources = Hash.new { |h, k| h[k] = [] }
@@ -169,7 +153,8 @@ module ONCCertificationG10TestKit
169
153
  resources[profile_url] << resource
170
154
  scratch[:patient_ids_seen] = patient_ids_seen | [resource.id] if resource_type == 'Patient'
171
155
 
172
- unless resource_is_valid?(resource: resource, profile_url: profile_url)
156
+ profile_with_version = versioned_profile_url(profile_url)
157
+ unless resource_is_valid?(resource: resource, profile_url: profile_with_version)
173
158
  if first_error.key?(:line_number)
174
159
  @invalid_resource_count += 1
175
160
  else
@@ -0,0 +1,30 @@
1
+ module ONCCertificationG10TestKit
2
+ class EncounterContextTest < Inferno::Test
3
+ title 'OAuth token exchange response body contains encounter context and encounter resource can be retrieved'
4
+ description %(
5
+ The `encounter` field is a String value with a encounter id, indicating that
6
+ the app was launched in the context of this FHIR Encounter.
7
+ )
8
+ id :g10_encounter_context
9
+ input :encounter_id, :url
10
+ input :smart_credentials, type: :oauth_credentials
11
+
12
+ fhir_client :authenticated do
13
+ url :url
14
+ oauth_credentials :smart_credentials
15
+ end
16
+
17
+ run do
18
+ skip_if smart_credentials.access_token.blank?, 'No access token was received during the SMART launch'
19
+
20
+ skip_if encounter_id.blank?, 'Token response did not contain `encounter` field'
21
+
22
+ skip_if request.status != 200, 'Token was not successfully refreshed' if config.options[:refresh_test]
23
+
24
+ fhir_read(:encounter, encounter_id, client: :authenticated)
25
+
26
+ assert_response_status(200)
27
+ assert_resource_type(:encounter)
28
+ end
29
+ end
30
+ end
@@ -1,13 +1,10 @@
1
1
  module ONCCertificationG10TestKit
2
2
  module Feature
3
- class << self
4
- def us_core_v4?
5
- ENV.fetch('US_CORE_4_ENABLED', 'false')&.casecmp?('true')
6
- end
7
-
8
- def bulk_data_v2?
9
- ENV.fetch('BULk_DATA_V2_ENABLED', 'false')&.casecmp?('true')
10
- end
3
+ class << self # rubocop:disable Lint/EmptyClass
4
+ # This is how you can define feature flags to be used in the g10 test kit
5
+ # def us_core_v4?
6
+ # ENV.fetch('US_CORE_4_ENABLED', 'false')&.casecmp?('true')
7
+ # end
11
8
  end
12
9
  end
13
10
  end
@@ -12,7 +12,7 @@ module ONCCertificationG10TestKit
12
12
 
13
13
  input :received_scopes, :expected_resources
14
14
 
15
- def possible_resources
15
+ POSSIBLE_RESOURCES =
16
16
  [
17
17
  'AllergyIntolerance',
18
18
  'CarePlan',
@@ -27,13 +27,26 @@ module ONCCertificationG10TestKit
27
27
  'Observation',
28
28
  'Procedure',
29
29
  'Patient'
30
- ]
30
+ ].freeze
31
+
32
+ V5_POSSIBLE_RESOURCES =
33
+ (POSSIBLE_RESOURCES + ['Encounter', 'ServiceRequest']).freeze
34
+
35
+ def possible_resources
36
+ return V5_POSSIBLE_RESOURCES if suite_options[:us_core_version] == 'us_core_5'
37
+
38
+ POSSIBLE_RESOURCES
31
39
  end
32
40
 
33
41
  def scope_granting_access?(resource_type, scopes)
34
- scopes.any? do |scope|
35
- scope.start_with?("patient/#{resource_type}", 'patient/*') && scope.end_with?('*', 'read')
36
- end
42
+ scopes
43
+ .select { |scope| scope.start_with?("patient/#{resource_type}", 'patient/*') }
44
+ .any? do |scope|
45
+ _type, resource_access = scope.split('/')
46
+ _resource, access_level = resource_access.split('.')
47
+
48
+ access_level.match?(/\A(\*|read|c?ru?d?s?\b)/)
49
+ end
37
50
  end
38
51
 
39
52
  run do