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

#as_json(args = {}) ⇒ Object



49
50
51
# File 'lib/redox/models/visit.rb', line 49

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

#department=(v) ⇒ Object



19
20
21
22
23
# File 'lib/redox/models/visit.rb', line 19

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

#facility=(v) ⇒ Object



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

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

#to_hObject



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

def to_h
  result = super.to_h

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

  result
end

#to_json(args = {}) ⇒ Object



45
46
47
# File 'lib/redox/models/visit.rb', line 45

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