module Base::Nursing::StudentMedication
  extend ActiveSupport::Concern

  included do
    self.table_name = 'StudentMedicationData'
    self.primary_key = 'StudentMedID'

    alias_attribute :id, :StudentMedID
    alias_attribute :school_id, :SchoolID
    alias_attribute :student_id, :StudentID
    alias_attribute :medication_id, :MEDID
    alias_attribute :notes, :Notes

    after_initialize :initialize_defaults

    private
      def initialize_defaults
        self.school_id = student.school_id unless school_id?
        self.notes = '' unless notes
      end
  end
end
