Class: Inferno::DSL::FHIREvaluation::EvaluationResult

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/dsl/fhir_evaluation/evaluation_result.rb

Overview

The result of a Rule evaluating a data set.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, severity: 'warning', issue_type: 'business-rule', threshold: nil, value: nil, rule: nil) ⇒ EvaluationResult

Returns a new instance of EvaluationResult.



13
14
15
16
17
18
19
20
# File 'lib/inferno/dsl/fhir_evaluation/evaluation_result.rb', line 13

def initialize(message, severity: 'warning', issue_type: 'business-rule', threshold: nil, value: nil, rule: nil)
  @message = message
  @severity = severity
  @issue_type = issue_type
  @threshold = threshold
  @value = value
  @rule = rule
end

Instance Attribute Details

#issue_typeObject

Returns the value of attribute issue_type.



6
7
8
# File 'lib/inferno/dsl/fhir_evaluation/evaluation_result.rb', line 6

def issue_type
  @issue_type
end

#messageObject

Returns the value of attribute message.



6
7
8
# File 'lib/inferno/dsl/fhir_evaluation/evaluation_result.rb', line 6

def message
  @message
end

#ruleObject

Returns the value of attribute rule.



6
7
8
# File 'lib/inferno/dsl/fhir_evaluation/evaluation_result.rb', line 6

def rule
  @rule
end

#severityObject

Returns the value of attribute severity.



6
7
8
# File 'lib/inferno/dsl/fhir_evaluation/evaluation_result.rb', line 6

def severity
  @severity
end

#thresholdObject

Returns the value of attribute threshold.



6
7
8
# File 'lib/inferno/dsl/fhir_evaluation/evaluation_result.rb', line 6

def threshold
  @threshold
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/inferno/dsl/fhir_evaluation/evaluation_result.rb', line 6

def value
  @value
end

Class Method Details

.to_operation_outcome(results) ⇒ Object



54
55
56
57
58
# File 'lib/inferno/dsl/fhir_evaluation/evaluation_result.rb', line 54

def self.to_operation_outcome(results)
  FHIR::OperationOutcome.new({
                               issue: results.map(&:to_oo_issue)
                             })
end

Instance Method Details

#to_oo_issueObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/inferno/dsl/fhir_evaluation/evaluation_result.rb', line 26

def to_oo_issue
  issue = {
    severity:,
    code: issue_type,
    details: { text: message }
  }

  if threshold
    issue[:extension] ||= []
    issue[:extension].push({
                             # TODO: pick real extension for this
                             url: 'https://inferno-framework.github.io/fhir_evaluator/StructureDefinition/operationoutcome-issue-threshold',
                             valueDecimal: threshold
                           })
  end

  if value
    issue[:extension] ||= []
    issue[:extension].push({
                             # TODO: pick real extension for this
                             url: 'https://inferno-framework.github.io/fhir_evaluator/StructureDefinition/operationoutcome-issue-value',
                             valueDecimal: value
                           })
  end

  issue
end

#to_sObject



22
23
24
# File 'lib/inferno/dsl/fhir_evaluation/evaluation_result.rb', line 22

def to_s
  "#{severity.upcase}: #{message}"
end