Sha256: 50b7e3cbddf6a329e17889abc9cfe0d7c752c0137098befdf96237f20d11e01e

Contents?: true

Size: 1.37 KB

Versions: 28

Compression:

Stored size: 1.37 KB

Contents

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

28 entries across 28 versions & 1 rubygems

Version Path
renalware-core-2.0.8 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.7 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.5 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.4 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.3 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.2 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.1 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc13 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc11 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc10 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc9 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc6 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc3 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.rc1 app/models/renalware/pathology/requests/request.rb
renalware-core-2.0.0.pre.beta12 app/models/renalware/pathology/requests/request.rb