class Nursing::Medication < ApplicationRecord
  include Base::Nursing::Medication

  audited

  associations_for legacy: true do |a|
    a.belongs_to :school
  end

  has_many :student_medications, foreign_key: :MEDID, dependent: :restrict_with_error,
    inverse_of: :medication

  validates :name, presence: true
  validates :name, presence: true, length: { maximum: 64 }
  validates :description, length: { maximum: 128 }

  scope :ordered, -> { order(:order) }
end
