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

from_response, from_response_inflected, #insurances, #to_json

Instance Method Details

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



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

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



48
49
50
51
52
# File 'lib/redox/models/transaction.rb', line 48

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

#add_performer(**kwargs) ⇒ Object



54
55
56
57
58
# File 'lib/redox/models/transaction.rb', line 54

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

#as_json(args) ⇒ Object



70
71
72
# File 'lib/redox/models/transaction.rb', line 70

def as_json(args)
  self.to_h
end

#to_hObject



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

def to_h
  result = super.to_h

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

  result
end