Sha256: 72d3b109d0832f5661f6c1a369501b877bbd492ad658fe4b97034716dff820a0
Contents?: true
Size: 1.44 KB
Versions: 31
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true require_dependency "renalware/pathology/requests" module Renalware module Pathology module Requests class Request < ApplicationRecord include Accountable TEMPLATES = %w(crs manual).freeze belongs_to :patient, class_name: "::Renalware::Pathology::Patient", touch: true belongs_to :clinic, class_name: "::Renalware::Clinics::Clinic" belongs_to :consultant, class_name: "::Renalware::Pathology::Consultant" has_and_belongs_to_many :request_descriptions, class_name: "::Renalware::Pathology::RequestDescription" has_and_belongs_to_many :patient_rules, class_name: "::Renalware::Pathology::Requests::PatientRule" validates :patient, presence: true validates :clinic, presence: true validates :consultant, presence: true validates :template, presence: true validates :template, inclusion: { in: TEMPLATES, allow_nil: false } def print_form save end def has_global_requests? request_descriptions.any? end def has_patient_requests? patient_rules.any? end def has_tests_required? has_global_requests? || has_patient_requests? end def requested_on created_at.to_date end alias_method :printed_on, :requested_on end end end end
Version data entries
31 entries across 31 versions & 1 rubygems