Sha256: fef2a39667809bf87607842bbabaac298eef5dd7064fb50fcdc80a48477f6b96

Contents?: true

Size: 1012 Bytes

Versions: 4

Compression:

Stored size: 1012 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/clinical"
require "document/base"

module Renalware
  module Clinical
    class DryWeight < ApplicationRecord
      include PatientScope
      include Accountable

      belongs_to :patient, class_name: "Renalware::Clinical::Patient", touch: true
      belongs_to :assessor, class_name: "User", foreign_key: "assessor_id"

      has_paper_trail(
        versions: { class_name: "Renalware::Clinical::Version" },
        on: [:create, :update, :destroy]
      )

      scope :ordered, -> { order(assessed_on: :desc, created_at: :desc) }

      validates :patient, presence: true
      validates :assessor, presence: true
      validates :weight, presence: true, "renalware/patients/weight" => true
      validates :assessed_on, presence: true
      validates :assessed_on, timeliness: { type: :date, allow_blank: false }

      def self.policy_class
        BasePolicy
      end

      def self.latest
        ordered.first
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
renalware-core-2.0.153 app/models/renalware/clinical/dry_weight.rb
renalware-core-2.0.152 app/models/renalware/clinical/dry_weight.rb
renalware-core-2.0.151 app/models/renalware/clinical/dry_weight.rb
renalware-core-2.0.149 app/models/renalware/clinical/dry_weight.rb