Class: FHIR::StructureDefinitionFinding

Inherits:
Object
  • Object
show all
Defined in:
lib/fhir_models/fhir_ext/structure_definition_finding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute.



9
10
11
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 9

def attribute
  @attribute
end

#messageObject

Returns the value of attribute message.



10
11
12
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 10

def message
  @message
end

#pathObject

Returns the value of attribute path.



8
9
10
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 8

def path
  @path
end

#profileIdAObject

Returns the value of attribute profileIdA.



5
6
7
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 5

def profileIdA
  @profileIdA
end

#profileIdBObject

Returns the value of attribute profileIdB.



6
7
8
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 6

def profileIdB
  @profileIdB
end

#resourceTypeObject

This is not an official FHIR Resource type. It is a data structure used for reporting.



4
5
6
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 4

def resourceType
  @resourceType
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 7

def status
  @status
end

#valueAObject

Returns the value of attribute valueA.



11
12
13
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 11

def valueA
  @valueA
end

#valueBObject

Returns the value of attribute valueB.



12
13
14
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 12

def valueB
  @valueB
end

Instance Method Details

#cloneObject



41
42
43
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 41

def clone
  from_json(to_json)
end

#error(path, attribute, message, value_a, value_b) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 56

def error(path, attribute, message, value_a, value_b)
  obj = clone
  obj.status = 'ERROR'
  obj.path = path
  obj.attribute = attribute
  obj.message = message
  obj.valueA = value_a
  obj.valueB = value_b
  obj
end

#from_json(json) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 22

def from_json(json)
  obj = FHIR::StructureDefinitionFinding.new
  if json.is_a? String
    begin
      if json.encoding.names.include? 'UTF-8'
        json.gsub!("\xEF\xBB\xBF".force_encoding('UTF-8'), '') # remove UTF-8 BOM
      end
      hash = JSON.parse(json)
      hash.each do |key, value|
        obj.send("#{key}=".to_sym, value) if value
      end
    rescue => e
      FHIR.logger.error "Failed to parse JSON: #{e.message}"
      return nil
    end
  end
  obj
end

#to_jsonObject



18
19
20
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 18

def to_json
  JSON.pretty_unparse(as_json)
end

#to_sObject



14
15
16
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 14

def to_s
  "#{resourceType},#{profileIdA},#{profileIdB},#{path},#{attribute},#{status},#{message},#{valueA},#{valueB}"
end

#warning(path, attribute, message, value_a, value_b) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/fhir_models/fhir_ext/structure_definition_finding.rb', line 45

def warning(path, attribute, message, value_a, value_b)
  obj = clone
  obj.status = 'WARNING'
  obj.path = path
  obj.attribute = attribute
  obj.message = message
  obj.valueA = value_a
  obj.valueB = value_b
  obj
end