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.1.1 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.1.0 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.167 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.166 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.165 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.164 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.163 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.162 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.161 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.160 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.159 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.158 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.157 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.156 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.155 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.153 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.152 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.151 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.149 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb
renalware-core-2.0.148 app/models/renalware/ukrdc/treatment_timeline/hd/profile_decorator.rb