Sha256: 3c5dd113c6346967d1da1bfc07468575255fdfb02ba393cf0f612d186b2ada8d

Contents?: true

Size: 1.2 KB

Versions: 35

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/hd"
require "document/base"

module Renalware
  module HD
    class Profile < ApplicationRecord
      include Document::Base
      include PatientScope
      include Accountable
      include Supersedeable

      belongs_to :patient, touch: true
      belongs_to :hospital_unit, class_name: "Hospitals::Unit"
      belongs_to :dialysate
      belongs_to :prescriber, class_name: "User", foreign_key: "prescriber_id"
      belongs_to :named_nurse, class_name: "User", foreign_key: "named_nurse_id"
      belongs_to :transport_decider, class_name: "User", foreign_key: "transport_decider_id"
      belongs_to :schedule_definition, foreign_key: "schedule_definition_id"

      has_document class_name: "Renalware::HD::ProfileDocument"
      has_paper_trail class_name: "Renalware::HD::Version"

      validates :patient, presence: true
      validates :prescriber, presence: true

      delegate :hospital_centre, to: :hospital_unit, allow_nil: true

      scope :ordered, -> { order(deactivated_at: :desc) }
      scope :dialysing_at_unit, ->(unit_id) { where(hospital_unit_id: unit_id) }

      def self.policy_class
        BasePolicy
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.46 app/models/renalware/hd/profile.rb
renalware-core-2.0.45 app/models/renalware/hd/profile.rb
renalware-core-2.0.44 app/models/renalware/hd/profile.rb
renalware-core-2.0.43 app/models/renalware/hd/profile.rb
renalware-core-2.0.42 app/models/renalware/hd/profile.rb
renalware-core-2.0.41 app/models/renalware/hd/profile.rb
renalware-core-2.0.40 app/models/renalware/hd/profile.rb
renalware-core-2.0.39 app/models/renalware/hd/profile.rb
renalware-core-2.0.38 app/models/renalware/hd/profile.rb
renalware-core-2.0.37 app/models/renalware/hd/profile.rb
renalware-core-2.0.36 app/models/renalware/hd/profile.rb
renalware-core-2.0.35 app/models/renalware/hd/profile.rb
renalware-core-2.0.34 app/models/renalware/hd/profile.rb
renalware-core-2.0.33 app/models/renalware/hd/profile.rb
renalware-core-2.0.32 app/models/renalware/hd/profile.rb
renalware-core-2.0.31 app/models/renalware/hd/profile.rb
renalware-core-2.0.30 app/models/renalware/hd/profile.rb
renalware-core-2.0.28 app/models/renalware/hd/profile.rb
renalware-core-2.0.27 app/models/renalware/hd/profile.rb
renalware-core-2.0.26 app/models/renalware/hd/profile.rb