Sha256: 42c89f5a3d27d2e4dc17032abe762ce0c383421389a5b7fa9d90adb4fad8e8a2

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

require_dependency "renalware/hospitals"

module Renalware
  module Hospitals
    class Unit < ApplicationRecord
      extend Enumerize

      belongs_to :hospital_centre, class_name: "Hospitals::Centre"

      validates :hospital_centre, presence: true
      validates :unit_code, presence: true
      validates :name, presence: true
      validates :renal_registry_code, presence: true
      validates :unit_type, presence: true
      validates :number_of_hd_stations, numericality: { allow_blank: true, only_integer: true }

      enumerize :unit_type, in: %i(hospital satellite home)

      scope :ordered, -> { order(:name) }
      scope :hd_sites, -> { where(is_hd_site: true) }

      def self.policy_class
        BasePolicy
      end

      def to_s
        "#{name} (#{unit_code})"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta8 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/hospitals/unit.rb