Class: Redox::Models::Visit

Inherits:
Model show all
Defined in:
lib/redox/models/visit.rb

Constant Summary collapse

DEFAULT_LOCATION =
{
  Department: nil,
  Facility: nil
}

Constants inherited from AbstractModel

AbstractModel::HIGH_LEVEL_KEYS

Instance Method Summary collapse

Methods inherited from Model

#initialize

Methods inherited from AbstractModel

from_response, from_response_inflected

Constructor Details

This class inherits a constructor from Redox::Models::Model

Instance Method Details

#add_equipment(description: nil, code: nil) ⇒ Object



38
39
40
41
42
# File 'lib/redox/models/visit.rb', line 38

def add_equipment(description: nil, code: nil)
  self[:Equipment] ||= []
  self[:Equipment] << { Description: description, Code: code }
  self
end

#as_json(args = {}) ⇒ Object



62
63
64
# File 'lib/redox/models/visit.rb', line 62

def as_json(args = {})
  self.to_h.dig('Visit')
end

#department=(v) ⇒ Object



26
27
28
29
30
# File 'lib/redox/models/visit.rb', line 26

def department=(v)
  self[:Location] ||= DEFAULT_LOCATION
  self[:Location][:Department] = v
  self
end

#facility=(v) ⇒ Object



32
33
34
35
36
# File 'lib/redox/models/visit.rb', line 32

def facility=(v)
  self[:Location] ||= DEFAULT_LOCATION
  self[:Location][:Facility] = v
  self
end

#to_hObject



48
49
50
51
52
53
54
55
56
# File 'lib/redox/models/visit.rb', line 48

def to_h
  result = super.to_h

  %w[VisitDateTime DischargeDateTime].each do |k|
    result[key][k] = Redox::Models.format_datetime(result[key][k])
  end

  result
end

#to_json(args = {}) ⇒ Object



58
59
60
# File 'lib/redox/models/visit.rb', line 58

def to_json(args = {})
  self.to_h.to_json
end