Sha256: cf8aaeb7608570be293943ac692cca91f6d7a538b0ebfcede0fe5c054ba518a3

Contents?: true

Size: 1.99 KB

Versions: 16

Compression:

Stored size: 1.99 KB

Contents

# frozen_string_literal: true

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

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

      # This maps to a PG enum
      enum pre_post_hd: {
        pre: "pre",
        post: "post"
      }

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

      has_paper_trail 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 :overhydration, presence: true, numeric_inclusion: { in: -20..20 }
      validates :volume_of_distribution, presence: true, numeric_inclusion: { in: 5..150 }
      validates :total_body_water, presence: true, numeric_inclusion: { in: 0..150 }
      validates :extracellular_water, presence: true, numeric_inclusion: { in: 0..150 }
      validates :intracellular_water, presence: true, numeric_inclusion: { in: 0..150 }
      validates :lean_tissue_index, presence: true, numeric_inclusion: { in: 0..150 }
      validates :fat_tissue_index, presence: true, numeric_inclusion: { in: 0..150 }
      validates :lean_tissue_mass, presence: true, numeric_inclusion: { in: 0..150 }
      validates :fat_tissue_mass, presence: true, numeric_inclusion: { in: 0..150 }
      validates :adipose_tissue_mass, presence: true, numeric_inclusion: { in: 0..100 }
      validates :body_cell_mass, presence: true, numeric_inclusion: { in: 0..150 }
      validates :quality_of_reading, presence: true, numeric_inclusion: { in: 50..100 }
      validates :assessed_on, presence: true, timeliness: { type: :date, allow_blank: false }
      validates :weight, "renalware/patients/weight" => true
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
renalware-core-2.0.148 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.147 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.146 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.145 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.144 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.143 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.142 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.141 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.140 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.139 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.138 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.137 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.136 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.135 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.134 app/models/renalware/clinical/body_composition.rb
renalware-core-2.0.133 app/models/renalware/clinical/body_composition.rb