Class: Inferno::Terminology::Tasks::ValidateCode

Inherits:
Object
  • Object
show all
Includes:
Inferno::Terminology::TerminologyValidation
Defined in:
lib/inferno/terminology/tasks/validate_code.rb

Constant Summary

Constants included from Inferno::Terminology::TerminologyValidation

Inferno::Terminology::TerminologyValidation::PREPROCESS_FUNCS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inferno::Terminology::TerminologyValidation

#validate_code, #validators_repo

Constructor Details

#initialize(code:, system:, valueset:) ⇒ ValidateCode

Returns a new instance of ValidateCode.



13
14
15
16
17
# File 'lib/inferno/terminology/tasks/validate_code.rb', line 13

def initialize(code:, system:, valueset:)
  @code = code
  @system = system
  @value_set_url = valueset
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



11
12
13
# File 'lib/inferno/terminology/tasks/validate_code.rb', line 11

def code
  @code
end

#systemObject (readonly)

Returns the value of attribute system.



11
12
13
# File 'lib/inferno/terminology/tasks/validate_code.rb', line 11

def system
  @system
end

#value_set_urlObject (readonly)

Returns the value of attribute value_set_url.



11
12
13
# File 'lib/inferno/terminology/tasks/validate_code.rb', line 11

def value_set_url
  @value_set_url
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/inferno/terminology/tasks/validate_code.rb', line 19

def run
  Inferno::Terminology::Loader.load_validators
  code_display = self.system ? "#{self.system}|#{code}" : code.to_s
  if validate_code(code:, system: self.system, value_set_url:)
    in_system = 'is in'
    symbol = "\u2713".encode('utf-8').to_s.green
  else
    in_system = 'is not in'
    symbol = 'X'.red
  end
  system_checked = value_set_url || self.system

  Inferno.logger.info "#{symbol} #{code_display} #{in_system} #{system_checked}"
end