class Notification::Nursing::PanJob
  include Sidekiq::Worker

  def perform(id)
    log = Nursing::Log.find(id)

    details = "Author: #{log.author.full_name}\nStudent: #{log.student.full_name}\nComplaint: "
    details += "#{log.decorate.complaint_description}\nTreatment: #{log.treatment}"

    log.author.pan_messages.create(
      school: log.school,
      date: Time.zone.now,
      recipients: [log.family_user],
      subject: 'New Medical Log',
      body: details
    )
  end
end
