Skip to content

Commit

Permalink
initial validation
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnaden committed May 10, 2024
1 parent 769b41d commit e79cae8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/davinci_pas_test_kit/pas_bundle_validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,20 @@ def evaluate_fhirpath_expression(resource, expression)

logger = Logger.new($stdout)
begin
validator_url = ENV.fetch('VALIDATOR_URL') # 'https://inferno.healthit.gov/validatorapi/'
validator_url = 'http://localhost:6789' # 'https://inferno.healthit.gov/validatorapi/'
path = "#{validator_url}/evaluate?path=#{expression}"

response = Faraday.post(path, resource.to_json, 'Content-Type' => 'application/json')
if response.status.to_s.start_with? '2'
result = JSON.parse(response.body)
return result.map { |entry| entry.dig('element', 'reference') if entry['type'] == 'Reference' }.compact
else
logger.error "External validator failed: #{response.status}"
logger.error "External evaluator failed: #{response.status}"
raise 'fhirpath service not available'
end
rescue Faraday::Error => e
logger.error "HTTP request failed: #{e.message}"
raise 'fhirpath service not available'
end

[]
Expand Down

0 comments on commit e79cae8

Please sign in to comment.