Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions lib/ipa_test_kit/reference_resolution_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,14 @@ def validate_reference_resolution(resource, reference, target_profile)
def resource_is_valid_with_target_profile?(resource, target_profile)
return true if target_profile.blank?

# Only need to know if the resource is valid.
# Calling resource_is_valid? causes validation errors to be logged.
validator = find_validator(:default)
validator_response = validator.validate(resource, target_profile)
outcome = validator.operation_outcome_from_hl7_wrapped_response(validator_response)

message_hashes = outcome.issue&.map { |issue| validator.message_hash_from_issue(issue, resource) } || []

message_hashes.concat(validator.additional_validation_messages(resource, target_profile))

validator.filter_messages(message_hashes)

message_hashes.none? { |message_hash| message_hash[:type] == 'error' }
target_profile_with_version =
target_profile.include?('|') ? target_profile : "#{target_profile}|#{metadata.profile_version}"

resource_is_valid?(
resource:,
profile_url: target_profile_with_version,
add_messages_to_runnable: false
)
end
end
end