davinci_crd_test_kit 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/lib/davinci_crd_test_kit/card_responses/companions_prerequisites.json +58 -0
  4. data/lib/davinci_crd_test_kit/card_responses/create_update_coverage_information.json +20 -0
  5. data/lib/davinci_crd_test_kit/card_responses/external_reference.json +21 -0
  6. data/lib/davinci_crd_test_kit/card_responses/instructions.json +14 -0
  7. data/lib/davinci_crd_test_kit/card_responses/launch_smart_app.json +21 -0
  8. data/lib/davinci_crd_test_kit/card_responses/propose_alternate_request.json +71 -0
  9. data/lib/davinci_crd_test_kit/card_responses/request_form_completion.json +227 -0
  10. data/lib/davinci_crd_test_kit/cards_validation.rb +234 -0
  11. data/lib/davinci_crd_test_kit/client_fhir_api_group.rb +762 -0
  12. data/lib/davinci_crd_test_kit/client_hook_request_validation.rb +15 -0
  13. data/lib/davinci_crd_test_kit/client_hooks_group.rb +706 -0
  14. data/lib/davinci_crd_test_kit/client_tests/appointment_book_receive_request_test.rb +71 -0
  15. data/lib/davinci_crd_test_kit/client_tests/client_display_cards_attest.rb +48 -0
  16. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_create_test.rb +40 -0
  17. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_read_test.rb +39 -0
  18. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_search_test.rb +232 -0
  19. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_update_test.rb +40 -0
  20. data/lib/davinci_crd_test_kit/client_tests/client_fhir_api_validation_test.rb +60 -0
  21. data/lib/davinci_crd_test_kit/client_tests/decode_auth_token_test.rb +40 -0
  22. data/lib/davinci_crd_test_kit/client_tests/encounter_discharge_receive_request_test.rb +68 -0
  23. data/lib/davinci_crd_test_kit/client_tests/encounter_start_receive_request_test.rb +68 -0
  24. data/lib/davinci_crd_test_kit/client_tests/hook_request_optional_fields_test.rb +41 -0
  25. data/lib/davinci_crd_test_kit/client_tests/hook_request_required_fields_test.rb +40 -0
  26. data/lib/davinci_crd_test_kit/client_tests/hook_request_valid_context_test.rb +63 -0
  27. data/lib/davinci_crd_test_kit/client_tests/hook_request_valid_prefetch_test.rb +151 -0
  28. data/lib/davinci_crd_test_kit/client_tests/order_dispatch_receive_request_test.rb +79 -0
  29. data/lib/davinci_crd_test_kit/client_tests/order_select_receive_request_test.rb +76 -0
  30. data/lib/davinci_crd_test_kit/client_tests/order_sign_receive_request_test.rb +79 -0
  31. data/lib/davinci_crd_test_kit/client_tests/retrieve_jwks_test.rb +65 -0
  32. data/lib/davinci_crd_test_kit/client_tests/token_header_test.rb +34 -0
  33. data/lib/davinci_crd_test_kit/client_tests/token_payload_test.rb +61 -0
  34. data/lib/davinci_crd_test_kit/crd_client_suite.rb +156 -0
  35. data/lib/davinci_crd_test_kit/crd_jwks.json +59 -0
  36. data/lib/davinci_crd_test_kit/crd_options.rb +9 -0
  37. data/lib/davinci_crd_test_kit/crd_server_suite.rb +115 -0
  38. data/lib/davinci_crd_test_kit/ext/inferno_core/runnable.rb +22 -0
  39. data/lib/davinci_crd_test_kit/hook_request_field_validation.rb +410 -0
  40. data/lib/davinci_crd_test_kit/jwks.rb +25 -0
  41. data/lib/davinci_crd_test_kit/jwt_helper.rb +74 -0
  42. data/lib/davinci_crd_test_kit/mock_service_response.rb +421 -0
  43. data/lib/davinci_crd_test_kit/routes/cds-services.json +74 -0
  44. data/lib/davinci_crd_test_kit/routes/cds_services_discovery_handler.rb +18 -0
  45. data/lib/davinci_crd_test_kit/routes/hook_request_endpoint.rb +93 -0
  46. data/lib/davinci_crd_test_kit/routes/jwk_set_endpoint_handler.rb +15 -0
  47. data/lib/davinci_crd_test_kit/server_appointment_book_group.rb +173 -0
  48. data/lib/davinci_crd_test_kit/server_discovery_group.rb +59 -0
  49. data/lib/davinci_crd_test_kit/server_encounter_discharge_group.rb +144 -0
  50. data/lib/davinci_crd_test_kit/server_encounter_start_group.rb +144 -0
  51. data/lib/davinci_crd_test_kit/server_hook_request_validation.rb +15 -0
  52. data/lib/davinci_crd_test_kit/server_hooks_group.rb +69 -0
  53. data/lib/davinci_crd_test_kit/server_order_dispatch_group.rb +173 -0
  54. data/lib/davinci_crd_test_kit/server_order_select_group.rb +169 -0
  55. data/lib/davinci_crd_test_kit/server_order_sign_group.rb +198 -0
  56. data/lib/davinci_crd_test_kit/server_required_card_response_validation_group.rb +23 -0
  57. data/lib/davinci_crd_test_kit/server_tests/additional_orders_validation_test.rb +70 -0
  58. data/lib/davinci_crd_test_kit/server_tests/card_optional_fields_validation_test.rb +47 -0
  59. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_across_hooks_validation_test.rb +32 -0
  60. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_received_test.rb +58 -0
  61. data/lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb +121 -0
  62. data/lib/davinci_crd_test_kit/server_tests/create_or_update_coverage_info_response_validation_test.rb +72 -0
  63. data/lib/davinci_crd_test_kit/server_tests/discovery_endpoint_test.rb +88 -0
  64. data/lib/davinci_crd_test_kit/server_tests/discovery_services_validation_test.rb +65 -0
  65. data/lib/davinci_crd_test_kit/server_tests/external_reference_card_across_hooks_validation_test.rb +28 -0
  66. data/lib/davinci_crd_test_kit/server_tests/external_reference_card_validation_test.rb +36 -0
  67. data/lib/davinci_crd_test_kit/server_tests/form_completion_response_validation_test.rb +79 -0
  68. data/lib/davinci_crd_test_kit/server_tests/instructions_card_received_across_hooks_test.rb +25 -0
  69. data/lib/davinci_crd_test_kit/server_tests/instructions_card_received_test.rb +28 -0
  70. data/lib/davinci_crd_test_kit/server_tests/launch_smart_app_card_validation_test.rb +38 -0
  71. data/lib/davinci_crd_test_kit/server_tests/propose_alternate_request_card_validation_test.rb +65 -0
  72. data/lib/davinci_crd_test_kit/server_tests/service_call_test.rb +86 -0
  73. data/lib/davinci_crd_test_kit/server_tests/service_request_context_validation_test.rb +30 -0
  74. data/lib/davinci_crd_test_kit/server_tests/service_request_optional_fields_validation_test.rb +41 -0
  75. data/lib/davinci_crd_test_kit/server_tests/service_request_required_fields_validation_test.rb +43 -0
  76. data/lib/davinci_crd_test_kit/server_tests/service_response_validation_test.rb +82 -0
  77. data/lib/davinci_crd_test_kit/suggestion_actions_validation.rb +123 -0
  78. data/lib/davinci_crd_test_kit/tags.rb +8 -0
  79. data/lib/davinci_crd_test_kit/test_helper.rb +23 -0
  80. data/lib/davinci_crd_test_kit/urls.rb +52 -0
  81. data/lib/davinci_crd_test_kit/version.rb +3 -0
  82. data/lib/davinci_crd_test_kit.rb +2 -0
  83. metadata +170 -0
@@ -0,0 +1,173 @@
1
+ require_relative 'server_tests/service_call_test'
2
+ require_relative 'server_tests/service_request_required_fields_validation_test'
3
+ require_relative 'server_tests/service_request_context_validation_test'
4
+ require_relative 'server_tests/service_request_optional_fields_validation_test'
5
+ require_relative 'server_tests/service_response_validation_test'
6
+ require_relative 'server_tests/card_optional_fields_validation_test'
7
+ require_relative 'server_tests/external_reference_card_validation_test'
8
+ require_relative 'server_tests/launch_smart_app_card_validation_test'
9
+ require_relative 'server_tests/instructions_card_received_test'
10
+ require_relative 'server_tests/coverage_information_system_action_received_test'
11
+ require_relative 'server_tests/coverage_information_system_action_validation_test'
12
+ require_relative 'server_tests/form_completion_response_validation_test'
13
+ require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
14
+
15
+ module DaVinciCRDTestKit
16
+ class ServerOrderDispatchGroup < Inferno::TestGroup
17
+ title 'order-dispatch'
18
+ id :crd_server_order_dispatch
19
+ description %(
20
+ This group of tests invokes the order-dispatch hook and ensures that
21
+ the user-provided requests are valid as per the requirements described
22
+ in the [CRD IG section on order-dispatch hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-dispatch)
23
+ and the [CDS Hooks specification section on order-dispatch context](https://cds-hooks.hl7.org/hooks/order-dispatch/2023SepSTU1Ballot/order-dispatch/).
24
+ It also ensures that the contents of the server's response are valid as per the requirements described in
25
+ the [CRD IG section on order-dispatch hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-dispatch)
26
+ and the [CDS Hooks section on CDS Service Response](https://cds-hooks.hl7.org/2.0/#cds-service-response).
27
+
28
+ The [CRD IG section on order-dispatch hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-dispatch)
29
+ states that "servers SHALL, at minimum, support returning and processing the Coverage Information
30
+ system action for all invocations of this hook."
31
+
32
+ This group includes tests to validate the following CRD response types:
33
+ - [Coverage Information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#coverage-information)
34
+ - [Create or update coverage information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#create-or-update-coverage-information)\
35
+ - optional
36
+ - [External Reference](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#external-reference) - optional
37
+ - [Instructions](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#instructions) - optional
38
+ - [Launch SMART application](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#launch-smart-application) -
39
+ optional
40
+ - [Request form completion](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#request-form-completion) -
41
+ optional
42
+ )
43
+
44
+ config options: { hook_name: 'order-dispatch' }
45
+ run_as_group
46
+
47
+ test from: :crd_service_call_test,
48
+ config: {
49
+ inputs: {
50
+ service_ids: {
51
+ name: :order_dispatch_service_ids,
52
+ title: 'Service id for the service that invokes `order-dispatch` hook'
53
+ },
54
+ service_request_bodies: {
55
+ name: :order_dispatch_request_bodies,
56
+ title: 'Request bodies collection to use to invoke the `order-dispatch` hook'
57
+ }
58
+ }
59
+ }
60
+
61
+ test from: :crd_service_request_required_fields_validation,
62
+ config: {
63
+ outputs: {
64
+ contexts: {
65
+ name: :order_dispatch_contexts
66
+ }
67
+ }
68
+ }
69
+ test from: :crd_service_request_context_validation,
70
+ config: {
71
+ inputs: {
72
+ contexts: {
73
+ name: :order_dispatch_contexts
74
+ }
75
+ }
76
+ }
77
+ test from: :crd_service_request_optional_fields_validation
78
+ test from: :crd_service_response_validation,
79
+ config: {
80
+ outputs: {
81
+ valid_cards: {
82
+ name: :order_dispatch_valid_cards
83
+ },
84
+ valid_system_actions: {
85
+ name: :order_dispatch_valid_system_actions
86
+ }
87
+ }
88
+ }
89
+ test from: :crd_card_optional_fields_validation,
90
+ config: {
91
+ inputs: {
92
+ valid_cards: {
93
+ name: :order_dispatch_valid_cards
94
+ }
95
+ },
96
+ outputs: {
97
+ valid_cards_with_links: {
98
+ name: :order_dispatch_valid_cards_with_links
99
+ },
100
+ valid_cards_with_suggestions: {
101
+ name: :order_dispatch_valid_cards_with_suggestions
102
+ }
103
+ }
104
+ }
105
+ test from: :crd_external_reference_card_validation,
106
+ config: {
107
+ inputs: {
108
+ valid_cards_with_links: {
109
+ name: :order_dispatch_valid_cards_with_links
110
+ }
111
+ }
112
+ }
113
+ test from: :crd_launch_smart_app_card_validation,
114
+ config: {
115
+ inputs: {
116
+ valid_cards_with_links: {
117
+ name: :order_dispatch_valid_cards_with_links
118
+ }
119
+ }
120
+ }
121
+ test from: :crd_valid_instructions_card_received,
122
+ config: {
123
+ inputs: {
124
+ valid_cards: {
125
+ name: :order_dispatch_valid_cards
126
+ }
127
+ }
128
+ }
129
+ test from: :crd_coverage_info_system_action_received,
130
+ config: {
131
+ inputs: {
132
+ valid_system_actions: {
133
+ name: :order_dispatch_valid_system_actions
134
+ }
135
+ },
136
+ outputs: {
137
+ coverage_info: {
138
+ name: :order_dispatch_coverage_info
139
+ }
140
+ }
141
+ }
142
+ test from: :crd_coverage_info_system_action_validation,
143
+ config: {
144
+ inputs: {
145
+ coverage_info: {
146
+ name: :order_dispatch_coverage_info
147
+ }
148
+ }
149
+ }
150
+ test from: :crd_request_form_completion_response_validation,
151
+ config: {
152
+ inputs: {
153
+ valid_system_actions: {
154
+ name: :order_dispatch_valid_system_actions
155
+ },
156
+ valid_cards_with_suggestions: {
157
+ name: :order_dispatch_valid_cards_with_suggestions
158
+ }
159
+ }
160
+ }
161
+ test from: :crd_create_or_update_coverage_info_response_validation,
162
+ config: {
163
+ inputs: {
164
+ valid_system_actions: {
165
+ name: :order_dispatch_valid_system_actions
166
+ },
167
+ valid_cards_with_suggestions: {
168
+ name: :order_dispatch_valid_cards_with_suggestions
169
+ }
170
+ }
171
+ }
172
+ end
173
+ end
@@ -0,0 +1,169 @@
1
+ require_relative 'server_tests/service_call_test'
2
+ require_relative 'server_tests/service_request_required_fields_validation_test'
3
+ require_relative 'server_tests/service_request_context_validation_test'
4
+ require_relative 'server_tests/service_request_optional_fields_validation_test'
5
+ require_relative 'server_tests/service_response_validation_test'
6
+ require_relative 'server_tests/card_optional_fields_validation_test'
7
+ require_relative 'server_tests/external_reference_card_validation_test'
8
+ require_relative 'server_tests/launch_smart_app_card_validation_test'
9
+ require_relative 'server_tests/instructions_card_received_test'
10
+ require_relative 'server_tests/propose_alternate_request_card_validation_test'
11
+ require_relative 'server_tests/additional_orders_validation_test'
12
+ require_relative 'server_tests/form_completion_response_validation_test'
13
+ require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
14
+
15
+ module DaVinciCRDTestKit
16
+ class ServerOrderSelectGroup < Inferno::TestGroup
17
+ title 'order-select'
18
+ id :crd_server_order_select
19
+ description %(
20
+ This group of tests invokes the order-select hook and ensures that
21
+ the user-provided requests are valid as per the requirements described
22
+ in the [CRD IG section on order-select hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-select)
23
+ and the [CDS Hooks specification section on order-select context](https://cds-hooks.hl7.org/hooks/order-select/2023SepSTU1Ballot/order-select/).
24
+ It also ensures that the contents of the server's response are valid as per the requirements described in
25
+ the [CRD IG section on order-select hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-select)
26
+ and the [CDS Hooks section on CDS Service Response](https://cds-hooks.hl7.org/2.0/#cds-service-response).
27
+
28
+ This group includes tests to validate the following CRD response types:
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
+ - optional
31
+ - [Create or update coverage information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#create-or-update-coverage-information)\
32
+ - optional
33
+ - [External Reference](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#external-reference) - optional
34
+ - [Instructions](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#instructions) - optional
35
+ - [Launch SMART application](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#launch-smart-application) -
36
+ optional
37
+ - [Propose alternate request](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#propose-alternate-request) -
38
+ optional
39
+ - [Request form completion](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#request-form-completion) -
40
+ optional
41
+ )
42
+
43
+ config options: { hook_name: 'order-select' }
44
+ run_as_group
45
+
46
+ test from: :crd_service_call_test,
47
+ config: {
48
+ inputs: {
49
+ service_ids: {
50
+ name: :order_select_service_ids,
51
+ title: 'Service id for the service that invokes `order-select` hook'
52
+ },
53
+ service_request_bodies: {
54
+ name: :order_select_request_bodies,
55
+ title: 'Request bodies collection to use to invoke the `order-select` hook'
56
+ }
57
+ }
58
+ }
59
+ test from: :crd_service_request_required_fields_validation,
60
+ config: {
61
+ outputs: {
62
+ contexts: {
63
+ name: :order_select_contexts
64
+ }
65
+ }
66
+ }
67
+ test from: :crd_service_request_context_validation,
68
+ config: {
69
+ inputs: {
70
+ contexts: {
71
+ name: :order_select_contexts
72
+ }
73
+ }
74
+ }
75
+ test from: :crd_service_request_optional_fields_validation
76
+ test from: :crd_service_response_validation,
77
+ config: {
78
+ outputs: {
79
+ valid_cards: {
80
+ name: :order_select_valid_cards
81
+ },
82
+ valid_system_actions: {
83
+ name: :order_select_valid_system_actions
84
+ }
85
+ }
86
+ }
87
+ test from: :crd_card_optional_fields_validation,
88
+ config: {
89
+ inputs: {
90
+ valid_cards: {
91
+ name: :order_select_valid_cards
92
+ }
93
+ },
94
+ outputs: {
95
+ valid_cards_with_links: {
96
+ name: :order_select_valid_cards_with_links
97
+ },
98
+ valid_cards_with_suggestions: {
99
+ name: :order_select_valid_cards_with_suggestions
100
+ }
101
+ }
102
+ }
103
+ test from: :crd_external_reference_card_validation,
104
+ config: {
105
+ inputs: {
106
+ valid_cards_with_links: {
107
+ name: :order_select_valid_cards_with_links
108
+ }
109
+ }
110
+ }
111
+ test from: :crd_launch_smart_app_card_validation,
112
+ config: {
113
+ inputs: {
114
+ valid_cards_with_links: {
115
+ name: :order_select_valid_cards_with_links
116
+ }
117
+ }
118
+ }
119
+ test from: :crd_valid_instructions_card_received,
120
+ config: {
121
+ inputs: {
122
+ valid_cards: {
123
+ name: :order_select_valid_cards
124
+ }
125
+ }
126
+ }
127
+ test from: :crd_propose_alternate_request_card_validation,
128
+ config: {
129
+ inputs: {
130
+ valid_cards_with_suggestions: {
131
+ name: :order_select_valid_cards_with_suggestions
132
+ },
133
+ contexts: {
134
+ name: :order_select_contexts
135
+ }
136
+ }
137
+ }
138
+ test from: :crd_additional_orders_card_validation,
139
+ config: {
140
+ inputs: {
141
+ valid_cards_with_suggestions: {
142
+ name: :order_select_valid_cards_with_suggestions
143
+ }
144
+ }
145
+ }
146
+ test from: :crd_request_form_completion_response_validation,
147
+ config: {
148
+ inputs: {
149
+ valid_system_actions: {
150
+ name: :order_select_valid_system_actions
151
+ },
152
+ valid_cards_with_suggestions: {
153
+ name: :order_select_valid_cards_with_suggestions
154
+ }
155
+ }
156
+ }
157
+ test from: :crd_create_or_update_coverage_info_response_validation,
158
+ config: {
159
+ inputs: {
160
+ valid_system_actions: {
161
+ name: :order_select_valid_system_actions
162
+ },
163
+ valid_cards_with_suggestions: {
164
+ name: :order_select_valid_cards_with_suggestions
165
+ }
166
+ }
167
+ }
168
+ end
169
+ end
@@ -0,0 +1,198 @@
1
+ require_relative 'server_tests/service_call_test'
2
+ require_relative 'server_tests/service_request_required_fields_validation_test'
3
+ require_relative 'server_tests/service_request_context_validation_test'
4
+ require_relative 'server_tests/service_request_optional_fields_validation_test'
5
+ require_relative 'server_tests/service_response_validation_test'
6
+ require_relative 'server_tests/card_optional_fields_validation_test'
7
+ require_relative 'server_tests/external_reference_card_validation_test'
8
+ require_relative 'server_tests/launch_smart_app_card_validation_test'
9
+ require_relative 'server_tests/instructions_card_received_test'
10
+ require_relative 'server_tests/coverage_information_system_action_received_test'
11
+ require_relative 'server_tests/coverage_information_system_action_validation_test'
12
+ require_relative 'server_tests/propose_alternate_request_card_validation_test'
13
+ require_relative 'server_tests/additional_orders_validation_test'
14
+ require_relative 'server_tests/form_completion_response_validation_test'
15
+ require_relative 'server_tests/create_or_update_coverage_info_response_validation_test'
16
+
17
+ module DaVinciCRDTestKit
18
+ class ServerOrderSignGroup < Inferno::TestGroup
19
+ title 'order-sign'
20
+ id :crd_server_order_sign
21
+ description %(
22
+ This group of tests invokes the order-sign hook and ensures that
23
+ the user-provided requests are valid as per the requirements described
24
+ in the [CRD IG section on order-sign hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-sign)
25
+ and the [CDS Hooks specification section on order-sign context](https://cds-hooks.hl7.org/hooks/order-sign/2023SepSTU1Ballot/order-sign/).
26
+ It also ensures that the contents of the server's response are valid as per the requirements described in
27
+ the [CRD IG section on order-sign hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-sign)
28
+ and the [CDS Hooks section on CDS Service Response](https://cds-hooks.hl7.org/2.0/#cds-service-response).
29
+
30
+ The [CRD IG section on order-sign hook](https://hl7.org/fhir/us/davinci-crd/STU2/hooks.html#order-sign)
31
+ states that "servers SHALL, at minimum, support returning and processing the Coverage Information
32
+ system action for all invocations of this hook."
33
+
34
+ This group includes tests to validate the following CRD response types:
35
+ - [additional orders as companions/prerequisites](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#identify-additional-orders-as-companionsprerequisites-for-current-order)\
36
+ - optional
37
+ - [Coverage Information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#coverage-information)
38
+ - [Create or update coverage information](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#create-or-update-coverage-information)\
39
+ - optional
40
+ - [External Reference](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#external-reference) - optional
41
+ - [Instructions](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#instructions) - optional
42
+ - [Launch SMART application](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#launch-smart-application) -
43
+ optional
44
+ - [Propose alternate request](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#propose-alternate-request) -
45
+ optional
46
+ - [Request form completion](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#request-form-completion) -
47
+ optional
48
+ )
49
+
50
+ config options: { hook_name: 'order-sign' }
51
+ run_as_group
52
+
53
+ test from: :crd_service_call_test,
54
+ config: {
55
+ inputs: {
56
+ service_ids: {
57
+ name: :order_sign_service_ids,
58
+ title: 'Service id for the service that invokes `order-sign` hook'
59
+ },
60
+ service_request_bodies: {
61
+ name: :order_sign_request_bodies,
62
+ title: 'Request bodies collection to use to invoke the `order-sign` hook'
63
+ }
64
+ }
65
+ }
66
+
67
+ test from: :crd_service_request_required_fields_validation,
68
+ config: {
69
+ outputs: {
70
+ contexts: {
71
+ name: :order_sign_contexts
72
+ }
73
+ }
74
+ }
75
+ test from: :crd_service_request_context_validation,
76
+ config: {
77
+ inputs: {
78
+ contexts: {
79
+ name: :order_sign_contexts
80
+ }
81
+ }
82
+ }
83
+ test from: :crd_service_request_optional_fields_validation
84
+ test from: :crd_service_response_validation,
85
+ config: {
86
+ outputs: {
87
+ valid_cards: {
88
+ name: :order_sign_valid_cards
89
+ },
90
+ valid_system_actions: {
91
+ name: :order_sign_valid_system_actions
92
+ }
93
+ }
94
+ }
95
+ test from: :crd_card_optional_fields_validation,
96
+ config: {
97
+ inputs: {
98
+ valid_cards: {
99
+ name: :order_sign_valid_cards
100
+ }
101
+ },
102
+ outputs: {
103
+ valid_cards_with_links: {
104
+ name: :order_sign_valid_cards_with_links
105
+ },
106
+ valid_cards_with_suggestions: {
107
+ name: :order_sign_valid_cards_with_suggestions
108
+ }
109
+ }
110
+ }
111
+ test from: :crd_external_reference_card_validation,
112
+ config: {
113
+ inputs: {
114
+ valid_cards_with_links: {
115
+ name: :order_sign_valid_cards_with_links
116
+ }
117
+ }
118
+ }
119
+ test from: :crd_launch_smart_app_card_validation,
120
+ config: {
121
+ inputs: {
122
+ valid_cards_with_links: {
123
+ name: :order_sign_valid_cards_with_links
124
+ }
125
+ }
126
+ }
127
+ test from: :crd_valid_instructions_card_received,
128
+ config: {
129
+ inputs: {
130
+ valid_cards: {
131
+ name: :order_sign_valid_cards
132
+ }
133
+ }
134
+ }
135
+ test from: :crd_coverage_info_system_action_received,
136
+ config: {
137
+ inputs: {
138
+ valid_system_actions: {
139
+ name: :order_sign_valid_system_actions
140
+ }
141
+ },
142
+ outputs: {
143
+ coverage_info: {
144
+ name: :order_sign_coverage_info
145
+ }
146
+ }
147
+ }
148
+ test from: :crd_coverage_info_system_action_validation,
149
+ config: {
150
+ inputs: {
151
+ coverage_info: {
152
+ name: :order_sign_coverage_info
153
+ }
154
+ }
155
+ }
156
+ test from: :crd_propose_alternate_request_card_validation,
157
+ config: {
158
+ inputs: {
159
+ valid_cards_with_suggestions: {
160
+ name: :order_sign_valid_cards_with_suggestions
161
+ },
162
+ contexts: {
163
+ name: :order_sign_contexts
164
+ }
165
+ }
166
+ }
167
+ test from: :crd_additional_orders_card_validation,
168
+ config: {
169
+ inputs: {
170
+ valid_cards_with_suggestions: {
171
+ name: :order_sign_valid_cards_with_suggestions
172
+ }
173
+ }
174
+ }
175
+ test from: :crd_request_form_completion_response_validation,
176
+ config: {
177
+ inputs: {
178
+ valid_system_actions: {
179
+ name: :order_sign_valid_system_actions
180
+ },
181
+ valid_cards_with_suggestions: {
182
+ name: :order_sign_valid_cards_with_suggestions
183
+ }
184
+ }
185
+ }
186
+ test from: :crd_create_or_update_coverage_info_response_validation,
187
+ config: {
188
+ inputs: {
189
+ valid_system_actions: {
190
+ name: :order_sign_valid_system_actions
191
+ },
192
+ valid_cards_with_suggestions: {
193
+ name: :order_sign_valid_cards_with_suggestions
194
+ }
195
+ }
196
+ }
197
+ end
198
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'server_tests/external_reference_card_across_hooks_validation_test'
2
+ require_relative 'server_tests/instructions_card_received_across_hooks_test'
3
+ require_relative 'server_tests/coverage_information_system_action_across_hooks_validation_test'
4
+
5
+ module DaVinciCRDTestKit
6
+ class ServerRequiredCardResponseValidationGroup < Inferno::TestGroup
7
+ title 'Required Card Response Validation'
8
+ description %(
9
+ This group contains tests to verify the presence and validity of required response types
10
+ across all hooks invoked. As per the [Da Vinci CRD Implementation Guide](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#potential-crd-response-types),
11
+ CRD Servers SHALL, at minimum, demonstrate an ability to return the following response types:
12
+ - Coverage Information System Action
13
+ - External Reference Card
14
+ - Instructions Card
15
+ )
16
+ id :crd_server_required_card_response_validation
17
+ run_as_group
18
+
19
+ test from: :crd_external_reference_card_across_hooks_validation
20
+ test from: :crd_valid_instructions_card_received_across_hooks
21
+ test from: :crd_coverage_info_system_action_across_hooks_validation
22
+ end
23
+ end
@@ -0,0 +1,70 @@
1
+ require_relative '../test_helper'
2
+ require_relative '../suggestion_actions_validation'
3
+
4
+ module DaVinciCRDTestKit
5
+ class AdditionalOrdersValidationTest < Inferno::Test
6
+ include DaVinciCRDTestKit::TestHelper
7
+ include DaVinciCRDTestKit::SuggestionActionsValidation
8
+
9
+ title 'Valid Additional Orders as companions/prerequisites cards received'
10
+ id :crd_additional_orders_card_validation
11
+ description %(
12
+ This test validates that an [Additional Orders as companions/prerequisites](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#identify-additional-orders-as-companionsprerequisites-for-current-order)
13
+ card was received. It does so by:
14
+ - Filtering cards with the following criteria:
15
+ - For each suggestion in the card's suggestions array, all actions have a type of 'create'
16
+ and the action's resource type is one of the expected types: CommunicationRequest, Device,
17
+ DeviceRequest, Medication, MedicationRequest, NutritionOrder, ServiceRequest, or VisionPrescription.
18
+ - Then, for each valid Additional Orders card retrieved, verifying that each action within the
19
+ card's suggestions complies with their respective profiles as specified in the
20
+ [CRD IG section on Additional Orders as companions/prerequisites](https://hl7.org/fhir/us/davinci-crd/STU2/cards.html#identify-additional-orders-as-companionsprerequisites-for-current-order):
21
+ - [crd-profile-communicationrequest](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-communicationrequest.html)
22
+ - [crd-profile-device](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-device.html)
23
+ - [crd-profile-deviceRequest](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-devicerequest.html)
24
+ - [us-core-medication](http://hl7.org/fhir/us/core/STU3.1.1/StructureDefinition-us-core-medication.html)
25
+ - [crd-profile-medicationRequest](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-medicationrequest.html)
26
+ - [crd-profile-nutritionOrder](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-nutritionorder.html)
27
+ - [crd-profile-serviceRequest](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-servicerequest.html)
28
+ - [crd-profile-visionPrescription](https://hl7.org/fhir/us/davinci-crd/STU2/StructureDefinition-profile-visionprescription.html).
29
+
30
+ The test will skip if no Additional Orders cards are found.
31
+ )
32
+
33
+ optional
34
+ input :valid_cards_with_suggestions
35
+
36
+ EXPECTED_RESOURCE_TYPES = %w[
37
+ CommunicationRequest Device DeviceRequest Medication
38
+ MedicationRequest NutritionOrder ServiceRequest
39
+ VisionPrescription
40
+ ].freeze
41
+
42
+ def hook_name
43
+ config.options[:hook_name]
44
+ end
45
+
46
+ def additional_orders_card?(card)
47
+ card['suggestions'].all? do |suggestion|
48
+ actions = suggestion['actions']
49
+ actions&.all? do |action|
50
+ action['type'] == 'create' && action_resource_type_check(action, EXPECTED_RESOURCE_TYPES)
51
+ end
52
+ end
53
+ end
54
+
55
+ run do
56
+ parsed_cards = parse_json(valid_cards_with_suggestions)
57
+ additional_orders_cards = parsed_cards.filter { |card| additional_orders_card?(card) }
58
+ skip_if additional_orders_cards.blank?,
59
+ "#{hook_name} hook response does not contain an Additional Orders as companions/prerequisites card."
60
+
61
+ additional_orders_cards.each do |card|
62
+ card['suggestions'].each do |suggestion|
63
+ actions_check(suggestion['actions'])
64
+ end
65
+ end
66
+
67
+ no_error_validation('Some Additional Orders as companions/prerequisites cards are not valid.')
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,47 @@
1
+ require_relative '../test_helper'
2
+ require_relative '../cards_validation'
3
+
4
+ module DaVinciCRDTestKit
5
+ class CardOptionalFieldsValidationTest < Inferno::Test
6
+ include DaVinciCRDTestKit::TestHelper
7
+ include DaVinciCRDTestKit::CardsValidation
8
+
9
+ title 'Cards contain valid optional fields'
10
+ id :crd_card_optional_fields_validation
11
+ description %(
12
+ This test checks for the presence and validity of optional fields in a card,
13
+ but only if the card's required fields are valid. As specified in the
14
+ [CDS Hooks specification section on Card Attributes](https://cds-hooks.hl7.org/2.0/#card-attributes),
15
+ the optional fields include `uuid`, `detail`, `suggestions`, `overrideReasons`, and `links`.
16
+
17
+ Additionally, the test validates the presence of the conditional field `selectionBehavior`
18
+ only if the `suggestions` field is present.
19
+ )
20
+ optional
21
+ input :valid_cards
22
+ output :valid_cards_with_links, :valid_cards_with_suggestions
23
+
24
+ def cards_with_suggestions
25
+ @cards_with_suggestions ||= []
26
+ end
27
+
28
+ def cards_with_links
29
+ @cards_with_links ||= []
30
+ end
31
+
32
+ run do
33
+ parsed_cards = parse_json(valid_cards)
34
+ parsed_cards.each do |card|
35
+ if valid_card_with_optionals?(card)
36
+ cards_with_links << card if card['links']
37
+ cards_with_suggestions << card if card['suggestions']
38
+ end
39
+ end
40
+
41
+ output valid_cards_with_links: cards_with_links.to_json
42
+ output valid_cards_with_suggestions: cards_with_suggestions.to_json
43
+
44
+ no_error_validation('Some cards with valid required fields have invalid optional fields.')
45
+ end
46
+ end
47
+ end