Class: InfernoSuiteGenerator::SpecialIdentifierSearchTest
- Inherits:
-
Inferno::Test
- Object
- Inferno::Test
- InfernoSuiteGenerator::SpecialIdentifierSearchTest
show all
- Extended by:
- Forwardable
- Includes:
- AssertHelpers, SearchTest
- Defined in:
- lib/au_core_test_kit/generators/custom_identifier_search/special_identifier_search_test.rb
Constant Summary
collapse
- SearchTestProperties =
InfernoSuiteGenerator::SearchTestProperties
Instance Method Summary
collapse
Instance Method Details
#all_search_params ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/au_core_test_kit/generators/custom_identifier_search/special_identifier_search_test.rb', line 34
def all_search_params
@all_search_params ||=
patient_id_list.each_with_object({}) do |patient_id, params|
params[patient_id] ||= []
new_params = [search_params_with_values(search_param_names, patient_id)]
new_params.reject! do |n_params|
n_params.any? { |_key, value| value.blank? }
end
params[patient_id].concat(new_params)
end
end
|
#default_search_params(search_param_names, patient_id) ⇒ Object
63
64
65
66
67
68
|
# File 'lib/au_core_test_kit/generators/custom_identifier_search/special_identifier_search_test.rb', line 63
def default_search_params(search_param_names, patient_id)
search_param_names.each_with_object({}) do |name, params|
value = patient_id_param?(name) ? patient_id : nil
params[name] = value
end
end
|
#ensure_special_identifier_prerequisites! ⇒ Object
84
85
86
87
|
# File 'lib/au_core_test_kit/generators/custom_identifier_search/special_identifier_search_test.rb', line 84
def ensure_special_identifier_prerequisites!
conditional_skip_with_msg scratch_resources[:all].empty?, no_resources_skip_message
conditional_skip_with_msg !any_valid_search_params?(all_search_params), unable_to_resolve_params_message
end
|
#get_resource_identifiers(resource, target_identifier) ⇒ Object
70
71
72
|
# File 'lib/au_core_test_kit/generators/custom_identifier_search/special_identifier_search_test.rb', line 70
def get_resource_identifiers(resource, target_identifier)
resource.identifier.filter { |ident| ident.system == target_identifier[:url] }
end
|
89
90
91
92
93
|
# File 'lib/au_core_test_kit/generators/custom_identifier_search/special_identifier_search_test.rb', line 89
def perform_special_identifier_searches
all_search_params.flat_map do |patient_id, params_list|
params_list.flat_map { |params| perform_search_with_system(params, patient_id) }
end
end
|
#run_special_identifier_search_test ⇒ Object
95
96
97
98
99
|
# File 'lib/au_core_test_kit/generators/custom_identifier_search/special_identifier_search_test.rb', line 95
def run_special_identifier_search_test
ensure_special_identifier_prerequisites!
resources_returned = perform_special_identifier_searches
conditional_skip_with_msg resources_returned.empty?, no_resources_skip_message
end
|
#search_param_value(_name, resource, include_system: false) ⇒ Object
74
75
76
77
78
79
80
81
82
|
# File 'lib/au_core_test_kit/generators/custom_identifier_search/special_identifier_search_test.rb', line 74
def search_param_value(_name, resource, include_system: false)
search_value = nil
resource_identifiers = get_resource_identifiers(resource, target_identifier)
if resource_identifiers.length.positive?
resource_identifier = resource_identifiers.first
search_value = include_system ? "#{resource_identifier.system}|#{resource_identifier.value}" : resource_identifier.value.to_s
end
search_value&.gsub(',', '\\,')
end
|
#search_params_with_values(search_param_names, patient_id, include_system: false) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/au_core_test_kit/generators/custom_identifier_search/special_identifier_search_test.rb', line 46
def search_params_with_values(search_param_names, patient_id, include_system: false)
resources = scratch_resources_for_patient(patient_id)
return default_search_params if resources.empty?
resources.each_with_object({}) do |resource, outer_params|
results_from_one_resource = search_param_names.each_with_object({}) do |name, params|
value = search_param_value(name, resource, include_system:)
params[name] = value
end
outer_params.merge!(results_from_one_resource)
return outer_params if outer_params.all? { |_key, value| value.present? }
end
end
|