Skip to content

Commit

Permalink
Code cleanup address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
emichaud998 committed Oct 26, 2023
1 parent 4c4780f commit ed21123
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions lib/carin_for_blue_button_test_kit/carin_search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,25 +178,16 @@ def run_include_search(search_params, param_value)
paths.each do |path|
values_found = resolve_path(resource.source_hash, path)

values_found.each do |reference|
reference_found = find_included_resource(reference, returned_resources_all)

# If at least one reference is not found, set reference_bool to false and do not change back to true for any other found references
if !reference_found
reference_bool = false
end
end
reference_bool = values_found.all? { |reference| find_included_resource(reference, returned_resources_all) }

match_found = (values_found.length > 0)

break if match_found
end
assert match_found, "Returned resource did not match the search parameter"
assert reference_bool, "Returned resource did not include the _include resource parameter"
return
else
values_found = []
reference_bool = true

paths.each do |path|
values_found += resolve_path(resource.source_hash, path)
Expand Down Expand Up @@ -229,15 +220,10 @@ def find_included_resource(reference, returned_resources_all)

referenced_resources = returned_resources_all.select{|item| item.resourceType == referenced_resource_type}

assert referenced_resources.present?, "No " + referenced_resource_type + " resources were included in the search results"
assert referenced_resources.present?, "No #{referenced_resource_type} resources were included in the search results"

reference_found = false
referenced_resources.each do |referenced_resource|
reference_found = is_reference_match?(referenced_resource_id, referenced_resource.id)
break if reference_found
end
referenced_resources.any? { |referenced_resource| is_reference_match?(referenced_resource_id, referenced_resource.id) }

return reference_found
end

def is_reference_match? (reference, local_reference)
Expand Down

0 comments on commit ed21123

Please sign in to comment.