Class: Redox::Models::Transaction

Inherits:
AbstractModel show all
Defined in:
lib/redox/models/transaction.rb

Constant Summary

Constants inherited from AbstractModel

AbstractModel::HIGH_LEVEL_KEYS

Instance Method Summary collapse

Methods inherited from AbstractModel

add_helpers, from_response, from_response_inflected, get_inflected_class, #insurances, #to_json

Instance Method Details

#add_medication(ndc_code: nil, quantity: nil, magnitude: nil, unit: nil, description: nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/redox/models/transaction.rb', line 34

def add_medication(ndc_code: nil, quantity: nil, magnitude: nil, unit: nil, description: nil)
  self[:NDC] = { Code: ndc_code, Description: description }
  self[:Extensions] = {
    'ndc-quantity' => {
      integer: quantity&.to_s
    },
    'ndc-units-measure' => {
      coding: {
        code: magnitude&.to_s,
        display: unit
      }
    }
  }
  self
end

#add_ordering_provider(**kwargs) ⇒ Object



50
51
52
53
54
# File 'lib/redox/models/transaction.rb', line 50

def add_ordering_provider(**kwargs)
  self[:OrderingProviders] ||= []
  self[:OrderingProviders] << OrderingProvider.new(kwargs)
  self
end

#add_performer(**kwargs) ⇒ Object



56
57
58
59
60
# File 'lib/redox/models/transaction.rb', line 56

def add_performer(**kwargs)
  self[:Performers] ||= []
  self[:Performers] << OrderingProvider.new(kwargs)
  self
end

#as_json(_args) ⇒ Object



72
73
74
# File 'lib/redox/models/transaction.rb', line 72

def as_json(_args)
  to_h
end

#to_hObject



62
63
64
65
66
67
68
69
70
# File 'lib/redox/models/transaction.rb', line 62

def to_h
  result = super.to_h

  %w[EndDateTime DateTimeOfService].each do |k|
    result[k] = Redox::Models.format_datetime(result[k])
  end

  result
end