Sha256: 26d121bd42c584cff65a90ec9dcd160f44b520a42881d3a54bc28c15718fe838

Contents?: true

Size: 861 Bytes

Versions: 4

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/hd"

module Renalware
  module HD
    class PreferenceSet < ApplicationRecord
      include PatientScope
      include Accountable

      belongs_to :patient, touch: true
      belongs_to :hospital_unit, class_name: "Hospitals::Unit"
      belongs_to :schedule_definition, foreign_key: "schedule_definition_id"

      has_paper_trail(
        versions: { class_name: "Renalware::HD::Version" },
        on: [:create, :update, :destroy]
      )

      validates :patient, presence: true
      validates :entered_on, timeliness: { type: :date, allow_blank: true }

      delegate :hospital_centre, to: :hospital_unit, allow_nil: true

      def preferred_schedule
        other_schedule || schedule_definition&.to_s
      end

      def self.policy_class
        BasePolicy
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
renalware-core-2.0.153 app/models/renalware/hd/preference_set.rb
renalware-core-2.0.152 app/models/renalware/hd/preference_set.rb
renalware-core-2.0.151 app/models/renalware/hd/preference_set.rb
renalware-core-2.0.149 app/models/renalware/hd/preference_set.rb