Class: DaVinciCRDTestKit::CoverageInformationSystemActionValidationTest
- Inherits:
-
Inferno::Test
- Object
- Inferno::Test
- DaVinciCRDTestKit::CoverageInformationSystemActionValidationTest
show all
- Includes:
- ServerHookRequestValidation, TestHelper
- Defined in:
- lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb
Instance Method Summary
collapse
Methods included from TestHelper
#parse_json, #verify_at_least_one_test_passes
#client_test?, #server_test?
#appointment_book_context_check, #bundle_entries_check, #check_patient_scope_requirement, #common_context_fields, #context_optional_fields_by_hook, #context_required_fields_by_hook, #context_selections_check, #context_user_types_by_hook, #context_validate_optional_fields, #encounter_start_or_discharge_context_check, #fhir_auth_fields_valid?, #fhir_authorization_required_fields, #hook_optional_fields, #hook_request_context_check, #hook_request_fhir_auth_check, #hook_request_optional_fields_check, #hook_request_prefetch_check, #hook_request_required_fields_check, #hook_required_fields, #hook_specific_context_check, #hook_user_type_check, #id_only_fields_check, #json_parse, #no_error_validation, #optional_field_resource_types, #order_dispatch_context_check, #order_select_or_sign_context_check, #parse_fhir_bundle_from_context, #query_and_validate_id_field, #request_number, #resource_reference_check, #status_check, #structure_definition_map, #valid_id_format?, #valid_reference_format?, #valid_url?, #validate_hash_fields, #validate_prefetch_coverage, #validate_prefetch_resource, #validate_presence_and_type
Instance Method Details
#collect_extensions_id(extensions, url, *properties) ⇒ Object
79
80
81
82
83
|
# File 'lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb', line 79
def collect_extensions_id(extensions, url, *properties)
extensions.map do |extension|
find_extension_value(extension, url, *properties)
end
end
|
#coverage_info_system_action_check(coverage_info_system_action) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb', line 93
def coverage_info_system_action_check(coverage_info_system_action)
type = coverage_info_system_action['type']
assert type, '`type` field is missing.'
assert type == 'update', "`type` must be `update`, but was `#{type}`"
resource = FHIR.from_contents(coverage_info_system_action['resource'].to_json)
profile_url = structure_definition_map[resource.resourceType]
assert_valid_resource(resource:, profile_url:)
grouped_coverage_info = extract_and_group_coverage_info(resource)
multiple_extensions_conformance_check(grouped_coverage_info, resource)
end
|
89
90
91
|
# File 'lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb', line 89
def different_coverage_conformance_error_msg(resource_ref, id_name)
"#{resource_ref}: extensions referencing differing coverage SHALL have distinct #{id_name}."
end
|
#extract_and_group_coverage_info(resource) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb', line 40
def extract_and_group_coverage_info(resource)
resource.extension.each_with_object({}) do |extension, grouped_extensions|
next unless extension.url == 'http://hl7.org/fhir/us/davinci-crd/StructureDefinition/ext-coverage-information'
coverage_key = find_extension_value(extension, 'coverage', 'valueReference', 'reference')
grouped_extensions[coverage_key] ||= []
grouped_extensions[coverage_key] << extension
end
end
|
#find_extension_value(extension, url, *properties) ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb', line 29
def find_extension_value(extension, url, *properties)
found_extension = extension.extension.find { |ext| ext.url == url }
return nil unless found_extension
properties.reduce(found_extension) do |current, prop|
return current unless current.respond_to?(prop)
current.send(prop)
end
end
|
#hook_name ⇒ Object
25
26
27
|
# File 'lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb', line 25
def hook_name
config.options[:hook_name]
end
|
For the same coverage, ensure coverage-assertion-ids and satisfied-pa-ids are the same. For different coverages, ensure coverage-assertion-ids and satisfied-pa-ids are distinct.
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb', line 52
def multiple_extensions_conformance_check(grouped_coverage_info, resource)
resource_ref = "#{resource.resourceType}/#{resource.id}"
assertion_ids_across_coverages = Set.new
pa_ids_across_coverages = Set.new
grouped_coverage_info.each do |coverage, extensions|
coverage_assertion_ids = collect_extensions_id(extensions, 'coverage-assertion-id', 'valueString').uniq
satisfied_pa_ids = collect_extensions_id(extensions, 'satisfied-pa-id', 'valueString').uniq.compact
assert coverage_assertion_ids.length == 1,
same_coverage_conformance_error_msg(resource_ref, coverage, 'coverage-assertion-ids')
assert satisfied_pa_ids.length <= 1,
same_coverage_conformance_error_msg(resource_ref, coverage, 'satisfied-pa-ids')
assertion_id = coverage_assertion_ids.first
assert !assertion_ids_across_coverages.include?(assertion_id),
different_coverage_conformance_error_msg(resource_ref, 'coverage-assertion-ids')
assertion_ids_across_coverages.add(assertion_id)
pa_id = satisfied_pa_ids.first
next unless pa_id
assert !pa_ids_across_coverages.include?(pa_id),
different_coverage_conformance_error_msg(resource_ref, 'satisfied-pa-ids')
pa_ids_across_coverages.add(pa_id)
end
end
|
85
86
87
|
# File 'lib/davinci_crd_test_kit/server_tests/coverage_information_system_action_validation_test.rb', line 85
def same_coverage_conformance_error_msg(resource_ref, coverage, id_name)
"#{resource_ref}: extension has multiple repetitions of coverage `#{coverage}` with different #{id_name}."
end
|