davinci_dtr_test_kit 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_adaptive_questionnaire_completion_group.rb +23 -0
  3. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_adaptive_questionnaire_followup_questions_group.rb +26 -0
  4. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_adaptive_questionnaire_next_question_request_test.rb +93 -0
  5. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_adaptive_questionnaire_next_question_request_validation_test.rb +62 -0
  6. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_adaptive_questionnaire_next_question_retrieval_group.rb +23 -0
  7. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_adaptive_questionnaire_response_validation_test.rb +66 -0
  8. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_full_ehr_adaptive_dinner_questionnaire_workflow_group.rb +76 -0
  9. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_full_ehr_adaptive_questionnaire_initial_retrieval_group.rb +27 -0
  10. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_full_ehr_adaptive_questionnaire_request_test.rb +63 -0
  11. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_smart_app_adaptive_questionnaire_initial_retrieval_group.rb +24 -0
  12. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_smart_app_adaptive_questionnaire_request_test.rb +148 -0
  13. data/lib/davinci_dtr_test_kit/client_groups/dinner_adaptive/dtr_smart_app_questionnaire_workflow_group.rb +75 -0
  14. data/lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_full_ehr_questionnaire_workflow_group.rb +22 -38
  15. data/lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_smart_app_dinner_questionnaire_package_request_test.rb +13 -16
  16. data/lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_smart_app_questionnaire_workflow_group.rb +9 -31
  17. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static → full_ehr}/dtr_full_ehr_launch_attestation_test.rb +7 -6
  18. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static → full_ehr}/dtr_full_ehr_prepopulation_attestation_test.rb +7 -7
  19. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static → full_ehr}/dtr_full_ehr_prepopulation_override_attestation_test.rb +7 -7
  20. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static/dtr_full_ehr_dinner_questionnaire_package_request_test.rb → full_ehr/dtr_full_ehr_questionnaire_package_request_test.rb} +2 -3
  21. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static/dtr_full_ehr_dinner_static_questionnaire_response_conformance_test.rb → full_ehr/dtr_full_ehr_questionnaire_response_conformance_test.rb} +7 -3
  22. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static/dtr_full_ehr_dinner_static_questionnaire_response_correctness_test.rb → full_ehr/dtr_full_ehr_questionnaire_response_correctness_test.rb} +14 -7
  23. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static → full_ehr}/dtr_full_ehr_rendering_enabled_questions_attestation_test.rb +7 -7
  24. data/lib/davinci_dtr_test_kit/client_groups/full_ehr/dtr_full_ehr_saving_questionnaire_response_group.rb +29 -0
  25. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static → full_ehr}/dtr_full_ehr_store_attestation_test.rb +7 -7
  26. data/lib/davinci_dtr_test_kit/client_groups/resp_assist_device/dtr_questionnaire_rendering_attestation_test.rb +7 -6
  27. data/lib/davinci_dtr_test_kit/client_groups/resp_assist_device/dtr_resp_questionnaire_package_request_test.rb +15 -18
  28. data/lib/davinci_dtr_test_kit/client_groups/shared/dtr_questionnaire_response_basic_conformance_test.rb +5 -1
  29. data/lib/davinci_dtr_test_kit/client_groups/shared/dtr_questionnaire_response_pre_population_test.rb +12 -5
  30. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static → smart_app}/dtr_smart_app_prepopulation_attestation_test.rb +7 -7
  31. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static → smart_app}/dtr_smart_app_prepopulation_override_attestation_test.rb +7 -6
  32. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static → smart_app}/dtr_smart_app_questionnaire_response_save_test.rb +17 -7
  33. data/lib/davinci_dtr_test_kit/client_groups/{dinner_static → smart_app}/dtr_smart_app_rendering_enabled_questions_attestation_test.rb +7 -7
  34. data/lib/davinci_dtr_test_kit/client_groups/smart_app/dtr_smart_app_saving_questionnaire_response_group.rb +27 -0
  35. data/lib/davinci_dtr_test_kit/cql_test.rb +37 -140
  36. data/lib/davinci_dtr_test_kit/create_test.rb +25 -0
  37. data/lib/davinci_dtr_test_kit/docs/dtr_full_ehr_suite_description_v201.md +95 -37
  38. data/lib/davinci_dtr_test_kit/docs/dtr_light_ehr_suite_description_v201.md +11 -6
  39. data/lib/davinci_dtr_test_kit/docs/dtr_payer_server_suite_description_v201.md +32 -29
  40. data/lib/davinci_dtr_test_kit/docs/dtr_smart_app_suite_description_v201.md +48 -32
  41. data/lib/davinci_dtr_test_kit/dtr_full_ehr_suite.rb +13 -17
  42. data/lib/davinci_dtr_test_kit/dtr_light_ehr_suite.rb +67 -2
  43. data/lib/davinci_dtr_test_kit/dtr_payer_server_suite.rb +9 -20
  44. data/lib/davinci_dtr_test_kit/dtr_questionnaire_response_validation.rb +18 -10
  45. data/lib/davinci_dtr_test_kit/dtr_smart_app_suite.rb +32 -59
  46. data/lib/davinci_dtr_test_kit/endpoints/cors.rb +20 -0
  47. data/lib/davinci_dtr_test_kit/endpoints/mock_authorization/authorize_endpoint.rb +32 -0
  48. data/lib/davinci_dtr_test_kit/endpoints/mock_authorization/simple_token_endpoint.rb +19 -0
  49. data/lib/davinci_dtr_test_kit/endpoints/mock_authorization/token_endpoint.rb +116 -0
  50. data/lib/davinci_dtr_test_kit/endpoints/mock_authorization.rb +83 -0
  51. data/lib/davinci_dtr_test_kit/endpoints/mock_ehr/fhir_get_endpoint.rb +95 -0
  52. data/lib/davinci_dtr_test_kit/endpoints/mock_ehr/questionnaire_response_endpoint.rb +22 -0
  53. data/lib/davinci_dtr_test_kit/endpoints/mock_ehr.rb +25 -0
  54. data/lib/davinci_dtr_test_kit/endpoints/mock_payer/full_ehr_next_question_endpoint.rb +11 -0
  55. data/lib/davinci_dtr_test_kit/endpoints/mock_payer/full_ehr_questionnaire_package_endpoint.rb +11 -0
  56. data/lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb +162 -0
  57. data/lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_proxy_endpoint.rb +36 -0
  58. data/lib/davinci_dtr_test_kit/endpoints/mock_payer/questionnaire_package_endpoint.rb +62 -0
  59. data/lib/davinci_dtr_test_kit/endpoints/mock_payer/questionnaire_package_proxy_endpoint.rb +38 -0
  60. data/lib/davinci_dtr_test_kit/endpoints/mock_payer.rb +36 -0
  61. data/lib/davinci_dtr_test_kit/fixtures/dinner_adaptive/dinner_order_adaptive_next_question_burrito.json +10 -2
  62. data/lib/davinci_dtr_test_kit/fixtures/dinner_adaptive/dinner_order_adaptive_next_question_hamburger.json +10 -2
  63. data/lib/davinci_dtr_test_kit/fixtures/dinner_adaptive/dinner_order_adaptive_next_question_initial.json +10 -2
  64. data/lib/davinci_dtr_test_kit/fixtures/dinner_adaptive/questionnaire_dinner_order_adaptive.json +4 -3
  65. data/lib/davinci_dtr_test_kit/fixtures.rb +24 -1
  66. data/lib/davinci_dtr_test_kit/payer_server_groups/adaptive_form_libraries_test.rb +2 -2
  67. data/lib/davinci_dtr_test_kit/payer_server_groups/adaptive_form_questionnaire_expressions_test.rb +4 -3
  68. data/lib/davinci_dtr_test_kit/payer_server_groups/adaptive_form_questionnaire_extensions_test.rb +3 -2
  69. data/lib/davinci_dtr_test_kit/payer_server_groups/adaptive_next_questionnaire_expressions_test.rb +6 -6
  70. data/lib/davinci_dtr_test_kit/payer_server_groups/adaptive_next_questionnaire_extensions_test.rb +6 -5
  71. data/lib/davinci_dtr_test_kit/payer_server_groups/payer_server_adaptive_group.rb +2 -2
  72. data/lib/davinci_dtr_test_kit/payer_server_groups/payer_server_adaptive_response_bundles_validation_test.rb +6 -9
  73. data/lib/davinci_dtr_test_kit/payer_server_groups/payer_server_adaptive_response_search_validation_test.rb +15 -12
  74. data/lib/davinci_dtr_test_kit/payer_server_groups/payer_server_adaptive_response_validation_test.rb +33 -23
  75. data/lib/davinci_dtr_test_kit/payer_server_groups/payer_server_next_response_complete_test.rb +4 -4
  76. data/lib/davinci_dtr_test_kit/payer_server_groups/payer_server_next_response_validation_test.rb +16 -12
  77. data/lib/davinci_dtr_test_kit/payer_server_groups/static_form_libraries_test.rb +2 -2
  78. data/lib/davinci_dtr_test_kit/payer_server_groups/static_form_questionnaire_expressions_test.rb +5 -4
  79. data/lib/davinci_dtr_test_kit/payer_server_groups/static_form_questionnaire_extensions_test.rb +4 -3
  80. data/lib/davinci_dtr_test_kit/payer_server_groups/static_form_response_validation_test.rb +32 -25
  81. data/lib/davinci_dtr_test_kit/profiles/communication_request/communication_request_read.rb +29 -0
  82. data/lib/davinci_dtr_test_kit/profiles/communication_request/communication_request_validation.rb +35 -0
  83. data/lib/davinci_dtr_test_kit/profiles/communication_request_group.rb +39 -0
  84. data/lib/davinci_dtr_test_kit/profiles/coverage/coverage_read.rb +29 -0
  85. data/lib/davinci_dtr_test_kit/profiles/coverage/coverage_validation.rb +35 -0
  86. data/lib/davinci_dtr_test_kit/profiles/coverage_group.rb +38 -0
  87. data/lib/davinci_dtr_test_kit/profiles/device_request/device_request_read.rb +29 -0
  88. data/lib/davinci_dtr_test_kit/profiles/device_request/device_request_validation.rb +35 -0
  89. data/lib/davinci_dtr_test_kit/profiles/device_request_group.rb +39 -0
  90. data/lib/davinci_dtr_test_kit/profiles/encounter/encounter_read.rb +29 -0
  91. data/lib/davinci_dtr_test_kit/profiles/encounter/encounter_validation.rb +35 -0
  92. data/lib/davinci_dtr_test_kit/profiles/encounter_group.rb +39 -0
  93. data/lib/davinci_dtr_test_kit/profiles/medication_request/medication_request_read.rb +29 -0
  94. data/lib/davinci_dtr_test_kit/profiles/medication_request/medication_request_validation.rb +35 -0
  95. data/lib/davinci_dtr_test_kit/profiles/medication_request_group.rb +39 -0
  96. data/lib/davinci_dtr_test_kit/profiles/nutrition_order/nutrition_order_read.rb +29 -0
  97. data/lib/davinci_dtr_test_kit/profiles/nutrition_order/nutrition_order_validation.rb +35 -0
  98. data/lib/davinci_dtr_test_kit/profiles/nutrition_order_group.rb +39 -0
  99. data/lib/davinci_dtr_test_kit/profiles/questionnaire_response/questionnaire_response_context_search.rb +35 -0
  100. data/lib/davinci_dtr_test_kit/profiles/questionnaire_response/questionnaire_response_create.rb +26 -0
  101. data/lib/davinci_dtr_test_kit/profiles/questionnaire_response/questionnaire_response_patient_search.rb +55 -0
  102. data/lib/davinci_dtr_test_kit/profiles/questionnaire_response/questionnaire_response_read.rb +22 -0
  103. data/lib/davinci_dtr_test_kit/profiles/questionnaire_response/questionnaire_response_update.rb +26 -0
  104. data/lib/davinci_dtr_test_kit/profiles/questionnaire_response/questionnaire_response_validation.rb +37 -0
  105. data/lib/davinci_dtr_test_kit/profiles/questionnaire_response_group.rb +66 -0
  106. data/lib/davinci_dtr_test_kit/profiles/service_request/service_request_read.rb +29 -0
  107. data/lib/davinci_dtr_test_kit/profiles/service_request/service_request_validation.rb +35 -0
  108. data/lib/davinci_dtr_test_kit/profiles/service_request_group.rb +39 -0
  109. data/lib/davinci_dtr_test_kit/profiles/task/task_create.rb +26 -0
  110. data/lib/davinci_dtr_test_kit/profiles/task/task_read.rb +29 -0
  111. data/lib/davinci_dtr_test_kit/profiles/task/task_update.rb +26 -0
  112. data/lib/davinci_dtr_test_kit/profiles/task/task_validation.rb +35 -0
  113. data/lib/davinci_dtr_test_kit/profiles/task_group.rb +52 -0
  114. data/lib/davinci_dtr_test_kit/profiles/vision_prescription/vision_prescription_read.rb +29 -0
  115. data/lib/davinci_dtr_test_kit/profiles/vision_prescription/vision_prescription_validation.rb +35 -0
  116. data/lib/davinci_dtr_test_kit/profiles/vision_prescription_group.rb +39 -0
  117. data/lib/davinci_dtr_test_kit/read_test.rb +22 -0
  118. data/lib/davinci_dtr_test_kit/tags.rb +5 -7
  119. data/lib/davinci_dtr_test_kit/update_test.rb +25 -0
  120. data/lib/davinci_dtr_test_kit/validation_test.rb +19 -4
  121. data/lib/davinci_dtr_test_kit/version.rb +1 -1
  122. metadata +109 -20
  123. data/lib/davinci_dtr_test_kit/ext/inferno_core/record_response_route.rb +0 -98
  124. data/lib/davinci_dtr_test_kit/ext/inferno_core/request.rb +0 -19
  125. data/lib/davinci_dtr_test_kit/ext/inferno_core/runnable.rb +0 -35
  126. data/lib/davinci_dtr_test_kit/mock_auth_server.rb +0 -228
  127. data/lib/davinci_dtr_test_kit/mock_ehr.rb +0 -105
  128. data/lib/davinci_dtr_test_kit/mock_payer.rb +0 -100
@@ -1,10 +1,10 @@
1
1
  require_relative '../cql_test'
2
2
  module DaVinciDTRTestKit
3
- class PayerStaticFormExtensionsTest < Inferno::Test
3
+ class PayerAdaptiveNexQuestionExtensionsTest < Inferno::Test
4
4
  include DaVinciDTRTestKit::CQLTest
5
5
 
6
- id :dtr_v201_payer_adaptive_next_form_extensions_test
7
- title 'Questionnaire(s) contains extensions necessary for pre-population'
6
+ id :dtr_v201_payer_adaptive_next_question_extensions_test
7
+ title 'Adaptive Next Question questionnaire(s) contain extensions necessary for pre-population'
8
8
  description %(
9
9
  Inferno checks that the payer server response has appropriate extensions and references to libraries within
10
10
  those extensions.
@@ -12,8 +12,9 @@ module DaVinciDTRTestKit
12
12
 
13
13
  run do
14
14
  skip_if retrieval_method == 'Static', 'Performing only static flow tests - only one flow is required.'
15
- skip_if scratch[:next_responses].nil?, 'No questionnaires returned.'
16
- questionnaire_extensions_test(scratch[:next_responses])
15
+ skip_if scratch[:next_question_questionnaire_responses].nil?, 'No questionnaires returned.'
16
+ questionnaires = extract_contained_questionnaires(scratch[:next_question_questionnaire_responses])
17
+ verify_questionnaire_extensions(questionnaires)
17
18
  end
18
19
  end
19
20
  end
@@ -81,8 +81,8 @@ module DaVinciDTRTestKit
81
81
 
82
82
  # pass request to payer server, validate adaptive questionnaire response
83
83
  test from: :payer_server_next_response_validation_test
84
- test from: :dtr_v201_payer_adaptive_next_form_extensions_test
85
- test from: :dtr_v201_payer_adaptive_next_form_expressions_test
84
+ test from: :dtr_v201_payer_adaptive_next_question_extensions_test
85
+ test from: :dtr_v201_payer_adaptive_next_question_expressions_test
86
86
  test from: :payer_server_adaptive_completion_test
87
87
  end
88
88
  end
@@ -22,15 +22,12 @@ module DaVinciDTRTestKit
22
22
  skip_if retrieval_method == 'Static', 'Performing only static flow tests - only one flow is required.'
23
23
  test_passed = true
24
24
  profile_url = 'http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/DTR-QPackageBundle|2.0.1'
25
- assert !scratch[:adaptive_responses].nil?, 'No resources to validate.'
26
- scratch[:adaptive_responses].each_with_index do |resource, index|
27
- fhir_resource = FHIR.from_contents(resource.response[:body])
28
- fhir_resource.parameter.each do |param|
29
- resource_is_valid = validate_resource(param.resource, :bundle, profile_url, index)
30
- test_passed = false unless resource_is_valid
31
- rescue StandardError
32
- next
33
- end
25
+ assert !scratch[:adaptive_questionnaire_bundles].nil?, 'No resources to validate.'
26
+ scratch[:adaptive_questionnaire_bundles].each_with_index do |bundle, index|
27
+ resource_is_valid = validate_resource(bundle, :bundle, profile_url, index)
28
+ test_passed = false unless resource_is_valid
29
+ rescue StandardError
30
+ next
34
31
  end
35
32
  if !test_passed && !tests_failed[profile_url].blank?
36
33
  assert test_passed, "Not all returned resources conform to the profile: #{profile_url}"
@@ -3,7 +3,7 @@ module DaVinciDTRTestKit
3
3
  class PayerAdaptiveFormResponseSearchTest < Inferno::Test
4
4
  include DaVinciDTRTestKit::ValidationTest
5
5
  id :payer_server_adaptive_response_search_validation_test
6
- title 'Validate that the adaptive response contains valid a Adaptive Form Search resource'
6
+ title 'Validate that the adaptive response contains a valid Adaptive Form Search resource'
7
7
  description %(
8
8
  This test validates the conformance of the payer's response to the
9
9
  [DTR Questionnaire for Adaptive Form Search](http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-questionnaire-adapt-search)
@@ -22,18 +22,21 @@ module DaVinciDTRTestKit
22
22
  skip_if retrieval_method == 'Static', 'Performing only static flow tests - only one flow is required.'
23
23
  test_passed = true
24
24
  profile_url = 'http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-questionnaire-adapt-search|2.0.1'
25
- assert !scratch[:adaptive_responses].nil?, 'No resources to validate.'
26
- scratch[:adaptive_responses].each_with_index do |resource, index|
27
- fhir_resource = FHIR.from_contents(resource.response[:body])
28
- fhir_resource.parameter.each do |param|
29
- param.resource.entry.each do |entry|
30
- resource_is_valid = validate_resource(entry.resource, :questionnaire, profile_url, index)
31
- test_passed = false unless resource_is_valid
32
- end
33
- rescue StandardError
34
- next
35
- end
25
+ assert !scratch[:adaptive_questionnaire_bundles].nil?, 'No questionnaire bundles to validate.'
26
+
27
+ questionnaires = scratch[:adaptive_questionnaire_bundles].filter_map do |bundle|
28
+ bundle.entry&.filter_map { |entry| entry.resource if entry.resource&.resourceType == 'Questionnaire' }
29
+ end&.flatten&.compact
30
+
31
+ assert questionnaires&.any?, 'No adaptive questionnaires to validate.'
32
+
33
+ questionnaires.each_with_index do |questionnaire, index|
34
+ resource_is_valid = validate_resource(questionnaire, :questionnaire, profile_url, index)
35
+ test_passed = false unless resource_is_valid
36
+ rescue StandardError
37
+ next
36
38
  end
39
+
37
40
  if !test_passed && !tests_failed[profile_url].blank?
38
41
  assert test_passed, "Not all returned resources conform to the profile: #{profile_url}"
39
42
  end
@@ -3,12 +3,16 @@ module DaVinciDTRTestKit
3
3
  class PayerAdaptiveFormQuestionnaireResponseTest < Inferno::Test
4
4
  include DaVinciDTRTestKit::ValidationTest
5
5
  id :payer_server_adaptive_response_validation_test
6
- title 'Validate that the adaptive response conforms to the Output Parameters profile'
6
+ title 'Validate that the adaptive response conforms to the DTR Questionnaire Package operation definition'
7
7
  # output :questionnaire_response
8
8
  description %(
9
- This test validates the conformance of the payer's response to the
10
- [DTR Output Parameters](http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-qpackage-output-parameters)
11
- structure.
9
+ Inferno will validate that the payer server's response to the questionnaire-package operation is conformant
10
+ to the
11
+ [Questionnaire Package operation definition](https://hl7.org/fhir/us/davinci-dtr/STU2/OperationDefinition-questionnaire-package.html).
12
+ This includes verifying that the response conforms to the
13
+ [DTR Questionnaire Package Bundle profile](https://hl7.org/fhir/us/davinci-dtr/STU2/StructureDefinition-DTR-QPackageBundle.html)
14
+ and, in the event that the server includes that Bundle in a Parameters object, the
15
+ [DTR Questionnaire Package Output Parameters profile](https://hl7.org/fhir/us/davinci-dtr/STU2/StructureDefinition-dtr-qpackage-output-parameters.html).
12
16
 
13
17
  It verifies the presence of mandatory elements and that elements with required bindings contain appropriate
14
18
  values. CodeableConcept element bindings will fail if none of their codings have a code/system belonging
@@ -21,28 +25,34 @@ module DaVinciDTRTestKit
21
25
 
22
26
  run do
23
27
  skip_if retrieval_method == 'Static', 'Performing only static flow tests - only one flow is required.'
24
- profile_with_version = 'http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-qpackage-output-parameters|2.0.1'
25
28
  endpoint = custom_endpoint.blank? ? '/Questionnaire/$questionnaire-package' : custom_endpoint
26
- if initial_adaptive_questionnaire_request.nil?
27
- # making the assumption that only one response was received - if there were multiple, we are only validating the
28
- # first
29
- response = load_tagged_requests(QUESTIONNAIRE_TAG)[0]
30
- scratch[:adaptive_responses] = [response]
31
- resource = FHIR.from_contents(response.response[:body])
29
+ req = if initial_adaptive_questionnaire_request.nil?
30
+ # making the assumption that only one response was received - if there were multiple, we are only
31
+ # validating the first
32
+ load_tagged_requests(QUESTIONNAIRE_TAG)[0]
33
+ else
34
+ fhir_operation("#{url}#{endpoint}", body: JSON.parse(initial_adaptive_questionnaire_request),
35
+ headers: { 'Content-Type': 'application/fhir+json' })
36
+ end
37
+ skip_if req.nil?, 'No request resource received from the client.'
38
+ assert_response_status([200, 201], response: req.response)
39
+
40
+ resource = FHIR.from_contents(req.response_body)
41
+ if resource&.resourceType == 'Parameters'
42
+ scratch[:adaptive_questionnaire_bundles] = resource.parameter.filter_map do |param|
43
+ param.resource if param.resource&.resourceType == 'Bundle'
44
+ end
45
+ assert_valid_resource(resource:,
46
+ profile_url: 'http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-qpackage-output-parameters|2.0.1')
47
+ questionnaire_bundle = resource.parameter.find { |param| param.resource.resourceType == 'Bundle' }&.resource
48
+ assert questionnaire_bundle, 'No questionnaire bundle found in the response'
49
+ elsif resource&.resourceType == 'Bundle'
50
+ scratch[:adaptive_questionnaire_bundles] = [resource]
51
+ assert_valid_resource(resource:,
52
+ profile_url: 'http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/DTR-QPackageBundle|2.0.1')
32
53
  else
33
- response = fhir_operation("#{url}#{endpoint}", body: JSON.parse(initial_adaptive_questionnaire_request),
34
- headers: { 'Content-Type': 'application/json' })
35
- resource = FHIR.from_contents(response.response[:body])
36
- scratch[:adaptive_responses] = [response]
54
+ assert(false, "Unexpected resourceType: #{resource&.resourceType}. Expected Parameters or Bundle")
37
55
  end
38
-
39
- assert !scratch[:adaptive_responses].nil?, 'No resources to validate.'
40
- assert_response_status([200, 201], response: response.response)
41
- assert_resource_type(:parameters, resource:)
42
- assert_valid_resource(resource:, profile_url: profile_with_version)
43
- questionnaire_bundle = resource.parameter.find { |param| param.resource.resourceType == 'Bundle' }&.resource
44
- assert questionnaire_bundle, 'No questionnaire bundle found in the response'
45
- assert_valid_resource(resource: questionnaire_bundle, profile_url: 'http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/DTR-QPackageBundle|2.0.1')
46
56
  end
47
57
  end
48
58
  end
@@ -8,10 +8,10 @@ module DaVinciDTRTestKit
8
8
 
9
9
  run do
10
10
  skip_if retrieval_method == 'Static', 'Performing only static flow tests - only one flow is required.'
11
- assert !scratch[:next_responses].nil?, 'No resources to validate.'
12
- assert scratch[:next_responses].any? { |r|
13
- JSON.parse(r.response_body)['status'] == 'completed'
14
- }, 'Next request sequence did not result in a completed questionnaire.'
11
+ assert !scratch[:next_question_questionnaire_responses].nil?, 'No resources to validate.'
12
+ assert scratch[:next_question_questionnaire_responses].any? { |qr| qr.status == 'completed' },
13
+ 'Next request sequence did not result in a completed questionnaire.'
14
+ scratch[:next_question_questionnaire_responses] = nil
15
15
  end
16
16
  end
17
17
  end
@@ -20,20 +20,24 @@ module DaVinciDTRTestKit
20
20
 
21
21
  run do
22
22
  skip_if retrieval_method == 'Static', 'Performing only static flow tests - only one flow is required.'
23
- if next_question_requests.nil?
24
- resources = load_tagged_requests(NEXT_TAG)
25
- else
26
- json_requests = JSON.parse(next_question_requests)
27
- resources = json_requests.map do |resource|
28
- fhir_operation("#{url}/Questionnaire/$next-question",
29
- body: resource,
30
- headers: { 'Content-Type': 'application/json' })
31
- end
23
+ reqs = if next_question_requests.nil?
24
+ load_tagged_requests(NEXT_TAG)
25
+ else
26
+ json_requests = JSON.parse(next_question_requests)
27
+ json_requests.map do |resource|
28
+ fhir_operation("#{url}/Questionnaire/$next-question",
29
+ body: resource,
30
+ headers: { 'Content-Type': 'application/fhir+json' })
31
+ end
32
+ end
33
+ assert !reqs.nil?, 'No requests to validate.'
34
+ scratch[:next_question_questionnaire_responses] = reqs.map do |req|
35
+ assert_response_status([200, 202], request: req)
36
+ FHIR.from_contents(req.response_body)
32
37
  end
33
- assert !resources.nil?, 'No resources to validate.'
34
- scratch[:next_responses] = resources
38
+
35
39
  perform_response_validation_test(
36
- resources,
40
+ scratch[:next_question_questionnaire_responses],
37
41
  :questionnaireResponse,
38
42
  'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse'
39
43
  )
@@ -12,8 +12,8 @@ module DaVinciDTRTestKit
12
12
 
13
13
  run do
14
14
  skip_if retrieval_method == 'Adaptive', 'Performing only adaptive flow tests - only one flow is required.'
15
- skip_if scratch[:output_parameters].nil?, 'No questionnaire bundle returned.'
16
- check_libraries(scratch[:output_parameters])
15
+ skip_if scratch[:static_questionnaire_bundles].nil?, 'No questionnaire bundle returned.'
16
+ check_libraries(scratch[:static_questionnaire_bundles])
17
17
  end
18
18
  end
19
19
  end
@@ -4,7 +4,7 @@ module DaVinciDTRTestKit
4
4
  include DaVinciDTRTestKit::CQLTest
5
5
 
6
6
  id :dtr_v201_payer_static_form_expressions_test
7
- title 'Questionnaire(s) contains items with expressions necessary for pre-population'
7
+ title 'Static questionnaire(s) contain items with expressions necessary for pre-population'
8
8
  description %(
9
9
  Inferno checks that the payer server response has appropriate expressions and that expressions are
10
10
  written in cql.
@@ -12,9 +12,10 @@ module DaVinciDTRTestKit
12
12
 
13
13
  run do
14
14
  skip_if retrieval_method == 'Adaptive', 'Performing only adaptive flow tests - only one flow is required.'
15
- skip_if scratch[:output_parameters].nil?, 'No questionnaire bundle returned.'
16
- questionnaire_items_test(scratch[:output_parameters], final_cql_test: true)
17
- scratch[:output_parameters] = nil
15
+ skip_if scratch[:static_questionnaire_bundles].nil?, 'No questionnaire bundle returned.'
16
+ questionnaires = extract_questionnaires_from_bundles(scratch[:static_questionnaire_bundles])
17
+ verify_questionnaire_items(questionnaires, final_cql_test: true)
18
+ scratch[:static_questionnaire_bundles] = nil
18
19
  end
19
20
  end
20
21
  end
@@ -4,7 +4,7 @@ module DaVinciDTRTestKit
4
4
  include DaVinciDTRTestKit::CQLTest
5
5
 
6
6
  id :dtr_v201_payer_static_form_extensions_test
7
- title 'Questionnaire(s) contains extensions necessary for pre-population'
7
+ title 'Static questionnaire(s) contain extensions necessary for pre-population'
8
8
  description %(
9
9
  Inferno checks that the payer server response has appropriate extensions and references to libraries within
10
10
  those extensions.
@@ -12,8 +12,9 @@ module DaVinciDTRTestKit
12
12
 
13
13
  run do
14
14
  skip_if retrieval_method == 'Adaptive', 'Performing only adaptive flow tests - only one flow is required.'
15
- skip_if scratch[:output_parameters].nil?, 'No questionnaire bundle returned.'
16
- questionnaire_extensions_test(scratch[:output_parameters])
15
+ skip_if scratch[:static_questionnaire_bundles].nil?, 'No questionnaire bundle returned.'
16
+ questionnaires = extract_questionnaires_from_bundles(scratch[:static_questionnaire_bundles])
17
+ verify_questionnaire_extensions(questionnaires)
17
18
  end
18
19
  end
19
20
  end
@@ -5,44 +5,51 @@ module DaVinciDTRTestKit
5
5
  include URLs
6
6
  include DaVinciDTRTestKit::ValidationTest
7
7
  id :dtr_v201_payer_static_form_response_test
8
- title 'Validate that the static response conforms to the Output Parameters profile'
8
+ title 'Validate that the static response conforms to the DTR Questionnaire Package operation definition.'
9
9
  description %(
10
- Inferno will validate that the payer server response conforms to the
11
- [Output Parameters profile](http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-qpackage-output-parameters).
10
+ Inferno will validate that the payer server's response to the questionnaire-package operation is conformant
11
+ to the
12
+ [Questionnaire Package operation definition](https://hl7.org/fhir/us/davinci-dtr/STU2/OperationDefinition-questionnaire-package.html).
13
+ This includes verifying that the response conforms to the
14
+ [DTR Questionnaire Package Bundle profile](https://hl7.org/fhir/us/davinci-dtr/STU2/StructureDefinition-DTR-QPackageBundle.html)
15
+ and, in the event that the server includes that Bundle in a Parameters object, the
16
+ [DTR Questionnaire Package Output Parameters profile](https://hl7.org/fhir/us/davinci-dtr/STU2/StructureDefinition-dtr-qpackage-output-parameters.html).
12
17
 
13
18
  It verifies the presence of mandatory elements and that elements with required bindings contain appropriate
14
19
  values. CodeableConcept element bindings will fail if none of their codings have a code/system belonging
15
20
  to the bound ValueSet. Quantity, Coding, and code element bindings will fail if their code/system are not found in
16
21
  the valueset.
17
-
18
22
  )
19
23
  input :url
20
24
 
21
25
  run do
22
26
  skip_if retrieval_method == 'Adaptive', 'Performing only adaptive flow tests - only one flow is required.'
23
- profile_with_version = 'http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-qpackage-output-parameters|2.0.1'
24
- if initial_static_questionnaire_request.nil?
25
- skip_if access_token.nil?, 'No access token provided - required for client flow.'
26
- resources = load_tagged_requests(QUESTIONNAIRE_TAG)
27
- skip_if resources.nil?, 'No request resource received from the client.'
28
- scratch[:output_parameters] = resources
29
- # making the assumption that only one response was received- if there were multiple, we are only validating the
30
- # first
31
- assert_valid_resource(resource: FHIR.from_contents(resources[0].request[:body]),
32
- profile_url: profile_with_version)
33
- else
34
- request = fhir_operation("#{url}/Questionnaire/$questionnaire-package",
35
- body: JSON.parse(initial_static_questionnaire_request),
36
- headers: { 'Content-Type': 'application/json' })
37
- assert_valid_json(request.response[:body])
38
- resource = FHIR.from_contents(request.response[:body])
39
- scratch[:output_parameters] = resource
40
- assert_response_status([200, 201], response: request.response)
41
- assert_resource_type(:parameters, resource:)
42
- assert_valid_resource(resource:, profile_url: profile_with_version)
27
+ req = if initial_static_questionnaire_request.nil?
28
+ load_tagged_requests(QUESTIONNAIRE_TAG)
29
+ else
30
+ fhir_operation("#{url}/Questionnaire/$questionnaire-package",
31
+ body: JSON.parse(initial_static_questionnaire_request),
32
+ headers: { 'Content-Type': 'application/fhir+json' })
33
+ end
34
+
35
+ skip_if req.nil?, 'No request resource received from the client.'
36
+ assert_response_status([200, 201], response: req.response)
37
+
38
+ resource = FHIR.from_contents(req.response_body)
39
+ if resource&.resourceType == 'Parameters'
40
+ scratch[:static_questionnaire_bundles] = resource.parameter&.filter_map do |param|
41
+ param.resource if param.resource&.resourceType == 'Bundle'
42
+ end
43
+ assert_valid_resource(resource:,
44
+ profile_url: 'http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/dtr-qpackage-output-parameters|2.0.1')
43
45
  questionnaire_bundle = resource.parameter.find { |param| param.resource.resourceType == 'Bundle' }&.resource
44
46
  assert questionnaire_bundle, 'No questionnaire bundle found in the response'
45
- assert_valid_resource(resource: questionnaire_bundle, profile_url: 'http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/DTR-QPackageBundle|2.0.1')
47
+ elsif resource&.resourceType == 'Bundle'
48
+ scratch[:static_questionnaire_bundles] = [resource]
49
+ assert_valid_resource(resource:,
50
+ profile_url: 'http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/DTR-QPackageBundle|2.0.1')
51
+ else
52
+ assert(false, "Unexpected resourceType: #{resource&.resourceType}. Expected Parameters or Bundle")
46
53
  end
47
54
  end
48
55
  end
@@ -0,0 +1,29 @@
1
+ require_relative '../../read_test'
2
+
3
+ module DaVinciDTRTestKit
4
+ class CommunicationRequestReadTest < Inferno::Test
5
+ include DaVinciDTRTestKit::ReadTest
6
+
7
+ title 'Server returns correct CommunicationRequest resource from CommunicationRequest read interaction'
8
+ description 'A server SHOULD support the CommunicationRequest read interaction.'
9
+
10
+ id :communication_request_read
11
+ output :communication_request_resources
12
+
13
+ def resource_type
14
+ 'CommunicationRequest'
15
+ end
16
+
17
+ def communication_request_id_list
18
+ return [nil] unless respond_to? :communication_request_ids
19
+
20
+ communication_request_ids&.split(',')&.map(&:strip)
21
+ end
22
+
23
+ run do
24
+ resources = perform_read_test(communication_request_id_list, resource_type)
25
+
26
+ output communication_request_resources: resources.to_json
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,35 @@
1
+ require_relative '../../validation_test'
2
+
3
+ module DaVinciDTRTestKit
4
+ class CommunicationRequestValidationTest < Inferno::Test
5
+ include DaVinciDTRTestKit::ValidationTest
6
+
7
+ title 'CommunicationRequest resources returned during previous tests conform to the CRD CommunicationRequest'
8
+ description %(
9
+ This test verifies resources returned from the read step conform to
10
+ the [CRD CommunicationRequest](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-communicationrequest).
11
+ Systems must demonstrate at least one valid example in order to pass this test.
12
+
13
+ It verifies the presence of mandatory elements and that elements with
14
+ required bindings contain appropriate values. CodeableConcept element
15
+ bindings will fail if none of their codings have a code/system belonging
16
+ to the bound ValueSet. Quantity, Coding, and code element bindings will
17
+ fail if their code/system are not found in the valueset.
18
+
19
+ )
20
+
21
+ id :communication_request_validation
22
+ input :communication_request_resources,
23
+ optional: true
24
+
25
+ def resource_type
26
+ 'CommunicationRequest'
27
+ end
28
+
29
+ run do
30
+ skip_if(communication_request_ids.nil?, "No `#{resource_type}` IDs provided, skipping test.")
31
+ perform_profile_validation_test(communication_request_resources, resource_type,
32
+ 'http://hl7.org/fhir/us/davinci-crd/StructureDefinition/profile-communicationrequest|2.0.1')
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,39 @@
1
+ require_relative 'communication_request/communication_request_read'
2
+ require_relative 'communication_request/communication_request_validation'
3
+
4
+ module DaVinciDTRTestKit
5
+ class CommunicationRequestGroup < Inferno::TestGroup
6
+ title 'CRD CommunicationRequest Tests'
7
+ short_description 'Verify support for the server capabilities required by the CRD CommunicationRequest Profile'
8
+ description %(
9
+ # Background
10
+
11
+ The CRD CommunicationRequest sequence verifies that the system under test is
12
+ able to provide correct responses for CommunicationRequest queries. These queries
13
+ must return resources conforming to the [CRD CommunicationRequest Profile](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-communicationrequest.html).
14
+
15
+ # Testing Methodology
16
+ ## Read
17
+ First, Inferno will attempt to read each CommunicationRequest resource id provided in
18
+ the CommunicationRequest IDs input. The server SHOULD be capable of returning a
19
+ CommunicationRequest resource using the read interaction.
20
+
21
+ ## Profile Validation
22
+ Each resource returned from the read step SHALL conform to
23
+ the [CRD CommunicationRequest Profile](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-communicationrequest.html).
24
+ Each element is checked against terminology binding and cardinality requirements.
25
+
26
+ )
27
+ id :communication_request_group
28
+ optional
29
+ run_as_group
30
+
31
+ input :communication_request_ids,
32
+ title: 'Communication Request IDs',
33
+ description: 'Comma separated list of CommunicationRequest IDs',
34
+ optional: true
35
+
36
+ test from: :communication_request_read
37
+ test from: :communication_request_validation
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ require_relative '../../read_test'
2
+
3
+ module DaVinciDTRTestKit
4
+ class CoverageReadTest < Inferno::Test
5
+ include DaVinciDTRTestKit::ReadTest
6
+
7
+ title 'Server returns correct Coverage resource from Coverage read interaction'
8
+ description 'A server SHALL support the Coverage read interaction.'
9
+
10
+ id :coverage_read
11
+ output :coverage_resources
12
+
13
+ def resource_type
14
+ 'Coverage'
15
+ end
16
+
17
+ def coverage_id_list
18
+ return [nil] unless respond_to? :coverage_ids
19
+
20
+ coverage_ids&.split(',')&.map(&:strip)
21
+ end
22
+
23
+ run do
24
+ resources = perform_read_test(coverage_id_list, resource_type)
25
+
26
+ output coverage_resources: resources.to_json
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,35 @@
1
+ require_relative '../../validation_test'
2
+
3
+ module DaVinciDTRTestKit
4
+ class CoverageValidationTest < Inferno::Test
5
+ include DaVinciDTRTestKit::ValidationTest
6
+
7
+ title 'Coverage resources returned during previous tests conform to the CRD Coverage'
8
+ description %(
9
+ This test verifies resources returned from the read step conform to
10
+ the [CRD Coverage](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-coverage).
11
+ Systems must demonstrate at least one valid example in order to pass this test.
12
+
13
+ It verifies the presence of mandatory elements and that elements with
14
+ required bindings contain appropriate values. CodeableConcept element
15
+ bindings will fail if none of their codings have a code/system belonging
16
+ to the bound ValueSet. Quantity, Coding, and code element bindings will
17
+ fail if their code/system are not found in the valueset.
18
+
19
+ )
20
+
21
+ id :coverage_validation
22
+ input :coverage_resources,
23
+ optional: true
24
+
25
+ def resource_type
26
+ 'Coverage'
27
+ end
28
+
29
+ run do
30
+ skip_if(coverage_ids.nil?, "No `#{resource_type}` IDs provided, skipping test.")
31
+ perform_profile_validation_test(coverage_resources, resource_type,
32
+ 'http://hl7.org/fhir/us/davinci-crd/StructureDefinition/profile-coverage|2.0.1')
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'coverage/coverage_read'
2
+ require_relative 'coverage/coverage_validation'
3
+
4
+ module DaVinciDTRTestKit
5
+ class CoverageGroup < Inferno::TestGroup
6
+ title 'CRD Coverage Tests'
7
+ short_description 'Verify support for the server capabilities required by the CRD Coverage Profile'
8
+ description %(
9
+ # Background
10
+
11
+ The CRD Coverage sequence verifies that the system under test is
12
+ able to provide correct responses for Coverage queries. These queries
13
+ must return resources conforming to the [CRD Coverage Profile](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-coverage.html).
14
+
15
+ # Testing Methodology
16
+ ## Read
17
+ First, Inferno will attempt to read each Coverage resource id provided in
18
+ the Coverage IDs input. The server SHALL be capable of returning a
19
+ Coverage resource using the read interaction.
20
+
21
+ ## Profile Validation
22
+ Each resource returned from the read step SHALL conform to
23
+ the [CRD Coverage Profile](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-coverage.html).
24
+ Each element is checked against terminology binding and cardinality requirements.
25
+
26
+ )
27
+ id :coverage_group
28
+ run_as_group
29
+
30
+ input :coverage_ids,
31
+ title: 'Coverage IDs',
32
+ description: 'Comma separated list of Coverage IDs',
33
+ optional: true
34
+
35
+ test from: :coverage_read
36
+ test from: :coverage_validation
37
+ end
38
+ end
@@ -0,0 +1,29 @@
1
+ require_relative '../../read_test'
2
+
3
+ module DaVinciDTRTestKit
4
+ class DeviceRequestReadTest < Inferno::Test
5
+ include DaVinciDTRTestKit::ReadTest
6
+
7
+ title 'Server returns correct DeviceRequest resource from DeviceRequest read interaction'
8
+ description 'A server SHOULD support the DeviceRequest read interaction.'
9
+
10
+ id :device_request_read
11
+ output :device_request_resources
12
+
13
+ def resource_type
14
+ 'DeviceRequest'
15
+ end
16
+
17
+ def device_request_id_list
18
+ return [nil] unless respond_to? :device_request_ids
19
+
20
+ device_request_ids&.split(',')&.map(&:strip)
21
+ end
22
+
23
+ run do
24
+ resources = perform_read_test(device_request_id_list, resource_type)
25
+
26
+ output device_request_resources: resources.to_json
27
+ end
28
+ end
29
+ end