Class: Renalware::UKRDC::TreatmentTimeline::HD::ProfileDecorator

Inherits:
DumbDelegator
  • Object
show all
Defined in:
app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb

Overview

Decorates an HD::Profile, adding methods that detect any changes significant enough to warrant generating a new UKRDC Treatment.

Instance Method Summary collapse

Methods inherited from DumbDelegator

#inspect, #public_send, #send, #try, #try!

Constructor Details

#initialize(profile, last_profile: nil) ⇒ ProfileDecorator

Returns a new instance of ProfileDecorator.



11
12
13
14
# File 'app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb', line 11

def initialize(profile, last_profile: nil)
  @last_profile = last_profile
  super(profile)
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
# File 'app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb', line 20

def changed?
  return true if last_profile.blank?

  hd_type_changed? || hospital_unit_changed?
end

#hd_typeObject



16
17
18
# File 'app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb', line 16

def hd_type
  document.dialysis.hd_type
end

#hd_type_changed?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb', line 30

def hd_type_changed?
  last_profile.document.dialysis.hd_type != hd_type
end

#hospital_unit_changed?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb', line 34

def hospital_unit_changed?
  last_profile.hospital_unit_id != hospital_unit_id
end

#unchanged?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb', line 26

def unchanged?
  !changed?
end