Sha256: 1e6ea36c8f3ff18b2827202dd4f45c15291f21ee197ed6e2b016905ff63b25b8
Contents?: true
Size: 1.44 KB
Versions: 56
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::Renal::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
56 entries across 56 versions & 1 rubygems