Sha256: debf49eb31a5f913b6c9d05162b62a5a01f5d050b243410d7e32bb6df2caecff
Contents?: true
Size: 1.45 KB
Versions: 28
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true require_dependency "renalware/medications" module Renalware module Medications module Delivery # For example a home delivery form was printed. class Event < ApplicationRecord include Accountable acts_as_paranoid belongs_to :patient, class_name: "Renalware::Patient" belongs_to :drug_type, class_name: "Drugs::Type" belongs_to :homecare_form, class_name: "Drugs::HomecareForm" has_many( :event_prescriptions, class_name: "Delivery::EventPrescription", dependent: :restrict_with_exception ) has_many( :prescriptions, through: :event_prescriptions, class_name: "Medications::Prescription", dependent: :restrict_with_exception ) validates :patient, presence: true validates :homecare_form, presence: true validates :reference_number, presence: true, if: :printed? validates :prescription_duration, presence: true, if: :printed? validate :renalware_forms_args, on: :update def self.policy_class Renalware::BasePolicy end def renalware_forms_args adapater = Delivery::HomecareFormsAdapter.new(delivery_event: self) args = adapater.build_args unless adapater.valid?(args) errors.add(:base, args.errors.full_messages&.join(", ")) end end end end end end
Version data entries
28 entries across 28 versions & 1 rubygems