Sha256: 8f751c2ba41841373271bddac03ccc13b398cc6cfb6ed375c382a91485afc3da

Contents?: true

Size: 1.05 KB

Versions: 75

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/ukrdc"
module Renalware
  module UKRDC
    module TreatmentTimeline
      module HD
        # Decorates an HD::Profile, adding methods that detect any changes significant enough
        # to warrant generating a new UKRDC Treatment.
        class ProfileDecorator < DumbDelegator
          def initialize(profile, last_profile: nil)
            @last_profile = last_profile
            super(profile)
          end

          def hd_type
            document.dialysis.hd_type
          end

          def changed?
            return true if last_profile.blank?

            hd_type_changed? || hospital_unit_changed?
          end

          def unchanged?
            !changed?
          end

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

          def hospital_unit_changed?
            last_profile.hospital_unit_id != hospital_unit_id
          end

          private

          attr_reader :last_profile
        end
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
renalware-core-2.0.104 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.103 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.102 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.101 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.100 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.99 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.98 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.97 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.96 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.95 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.94 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.93 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.92 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.91 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.90 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb