Sha256: 4fc0bde4d8b105e9676cc4d3a3ad287c290b435e9e3910c3fe3d5e3bda9a0965

Contents?: true

Size: 918 Bytes

Versions: 17

Compression:

Stored size: 918 Bytes

Contents

require_dependency "renalware/hospitals"

module Renalware
  module Hospitals
    class Unit < ApplicationRecord
      extend Enumerize

      belongs_to :hospital_centre, class_name: "Hospitals::Centre"
      has_many :wards,
               class_name: "Hospitals::Ward",
               foreign_key: :hospital_unit_id,
               dependent: :destroy,
               inverse_of: :hospital_unit

      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

      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

17 entries across 17 versions & 1 rubygems

Version Path
renalware-core-2.0.8 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.7 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.5 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.4 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.3 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.2 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.1 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.rc13 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.rc11 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.rc10 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.rc9 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.rc6 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/hospitals/unit.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/hospitals/unit.rb