Sha256: 32bf0c13f6b4d74649eb504c6faba9b26dc109cfcd9175c7c7756be9c65fb6f8
Contents?: true
Size: 1.5 KB
Versions: 13
Compression:
Stored size: 1.5 KB
Contents
# # A presenter which, for a patient, displays any HD preferences (for example when or where they # have HD) that do not match their current HD profile. # require_dependency "renalware/hd" module Renalware module HD class UnmetPreferencesPresenter include ActionView::Helpers COMMON_ATTRIBUTES = %i(schedule_definition other_schedule hospital_unit).freeze delegate(*COMMON_ATTRIBUTES, to: :hd_preference_set, prefix: :preferred, allow_nil: true) delegate(*COMMON_ATTRIBUTES, to: :hd_profile, prefix: :current, allow_nil: true) delegate(:notes, :entered_on, to: :hd_preference_set) delegate(:to_s, :to_param, :hd_profile, :hd_preference_set, to: :patient) def initialize(patient) @patient = patient end # Returns the HD::PreferenceSet setting if it differs from that in the HD::Profile # If the preference is unmet, wrap in a <b> tag. Yield the value so the template # has a chance to format it before it is wrapped. def preferred(attribute) value = public_send(:"preferred_#{attribute}") value = yield(value) if block_given? return value if preference_satisfied?(attribute) content_tag(:b, value) end def preference_satisfied?(attribute) preferred = public_send(:"preferred_#{attribute}") current = public_send(:"current_#{attribute}") return true if preferred.blank? || preferred == current false end private attr_reader :patient end end end
Version data entries
13 entries across 13 versions & 1 rubygems