Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jhlee-mitre committed Jan 3, 2025
1 parent 2a13c5c commit 696e2e3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 57 deletions.
6 changes: 2 additions & 4 deletions lib/inferno/dsl/fhir_evaluation/evaluator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
require_relative 'evaluation_context'
require_relative 'evaluation_result'
require_relative 'dataset_loader'
require_relative 'rules/all_references_resolve'
require_relative 'rules/all_resources_reachable'

module Inferno
module DSL
Expand All @@ -19,10 +21,6 @@ def initialize(ig) # rubocop:disable Naming/MethodParameterName
def evaluate(data, config = Config.new)
context = EvaluationContext.new(@ig, data, config)

Dir.glob(File.join(__dir__, 'rules', '*.rb')).each do |file|
require_relative file
end

active_rules = []
config.data['Rule'].each do |rulename, rule_details|
active_rules << rulename if rule_details['Enabled']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ class AllResourcesReachable < Rule

def check(context)
@config = context.config
# TODO: add some customizable configurations for this rule:
# - whether it should be checked at all
# - determine the base/root resource
# - which types/resources to ignore
# TODO: for the customizable configurations, use the config settings below:
# config.Rule.AllResourcesReachable.CheckedAtAll: true/false
# config.Rule.AllResourcesReachable.RunOnlyBaseResource: true/false
# config.Rule.AllResourcesReachable.IgnoreType: - value
# TODO: can come up with a "connectedness metric" to see how well-connected the data set is

# every resource is either making a resolvable reference or is referenced
util = Inferno::Utils::EvaluatorUtil
Expand Down
44 changes: 0 additions & 44 deletions lib/inferno/utils/evaluator_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,6 @@ def self.extract_ids_references(resources)
extractor.extract_ids_references(resources)
end

def self.validate_resource(resource)
wrapped_resource = {
# IG in cliContext is optional, since HL7 Validator automatically
# finds matching profiles for the resource in the loaded IGs
# If the valiator doesn't find its matching profile, the operation will fail.
cliContext: {
sv: '4.0.1',
# ig: [
# "hl7.fhir.us.core#4.0.0"
# ],
locale: 'en'
},
filesToValidate: [
{
fileName: "#{resource.resourceType}/#{resource.id}.json",
fileContent: resource.to_json,
fileType: 'json'
}
],
# sessionId may reuse Inferno's or be autogenerated by the validator.
sessionId: '32fc25cf-020e-4492-ace5-03fe904d22e0'
}
request_body = wrapped_resource.to_json

response = Faraday.new(
ENV.fetch('FHIR_RESOURCE_VALIDATOR_URL'),
request: { timeout: 600 }
).post('validate', request_body, content_type: 'application/json')

unless response.status == 200
raise StandardError,
"Error occurred in the validator. Http response: #{response.status}"
end

err_flg = false
JSON.parse(response.body)['outcomes'].any? do |outcome|
outcome['issues'].any? do |issue|
err_flg = true if %w[ERROR FATAL].include?(issue['level'])
end
end

err_flg
end

class ReferenceExtractor
def initialize
@resource_type_ids = Hash.new { |h, k| h[k] = [] }
Expand Down

0 comments on commit 696e2e3

Please sign in to comment.