Sha256: ef478ffa6a674d90288facf28f6c65664dc8cfacb37203c73e61084e7d44873e
Contents?: true
Size: 914 Bytes
Versions: 64
Compression:
Stored size: 914 Bytes
Contents
# frozen_string_literal: true require_dependency "renalware/hospitals" module Renalware module Hospitals class Centre < ApplicationRecord has_many( :units, class_name: "Hospitals::Unit", foreign_key: :hospital_centre_id, dependent: :restrict_with_exception ) scope :ordered, -> { order(:name) } scope :active, -> { where(active: true) } scope :performing_transplant, -> { active.where(is_transplant_site: true) } scope :with_hd_sites, -> { where(id: Unit.hd_sites.pluck(:hospital_centre_id)) } validates :code, presence: true validates :name, presence: true def hd_sites units.hd_sites.ordered end def self.policy_class BasePolicy end def to_s if location.present? "#{name} (#{location})" else name end end end end end
Version data entries
64 entries across 64 versions & 1 rubygems