class Nursing::ScreeningDecorator < ApplicationDecorator
  def age
    return if student.date_of_birth.blank?

    screen = object.date.year * 12 + object.date.month
    age = student.date_of_birth.year * 12 + student.date_of_birth.month
    (screen - age) / 12
  end

  def bmi
    return unless height? && weight?

    (weight.to_f / height.to_f**2 * 703.to_f).round(2)
  end

  def date
    l(object.date) if object.date
  end

  def hearing_label
    return if hearing.nil?

    hearing ? 'Passed' : 'Failed'
  end

  def sight_label
    return if sight.nil?

    sight ? 'Passed' : 'Failed'
  end
end
