Sha256: ef8c4d8a05000c267644030df172cab59ba8990e8875c35baf95de5d553fd1c0

Contents?: true

Size: 1.28 KB

Versions: 51

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/renal"
require "document/base"

module Renalware
  module Renal
    class Profile < ApplicationRecord
      include Document::Base
      extend Enumerize

      has_paper_trail class_name: "Renalware::Renal::Version", on: [:create, :update, :destroy]

      belongs_to :patient, touch: true
      belongs_to :prd_description
      has_one :address_at_diagnosis, as: :addressable, class_name: "Address"

      has_document class_name: "Renalware::Renal::ProfileDocument"

      validates :patient, presence: true, uniqueness: true
      validates :esrf_on, timeliness: { type: :date, allow_nil: true }, allow_blank: true
      validates :first_seen_on,
                timeliness: {
                  type: :date,
                  allow_nil: true
                },
                allow_blank: true
      validates :comorbidities_updated_on,
                timeliness: {
                  type: :date,
                  allow_nil: true
                },
                allow_blank: true

      accepts_nested_attributes_for :address_at_diagnosis, reject_if: Address.reject_if_blank

      enumerize :modality_at_esrf, in: %i(HD PD Tx CM)

      def to_s
        [I18n.l(esrf_on), prd_description].compact.join(" ")
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
renalware-core-2.0.101 app/models/renalware/renal/profile.rb
renalware-core-2.0.100 app/models/renalware/renal/profile.rb
renalware-core-2.0.99 app/models/renalware/renal/profile.rb
renalware-core-2.0.98 app/models/renalware/renal/profile.rb
renalware-core-2.0.97 app/models/renalware/renal/profile.rb
renalware-core-2.0.96 app/models/renalware/renal/profile.rb
renalware-core-2.0.95 app/models/renalware/renal/profile.rb
renalware-core-2.0.94 app/models/renalware/renal/profile.rb
renalware-core-2.0.93 app/models/renalware/renal/profile.rb
renalware-core-2.0.92 app/models/renalware/renal/profile.rb
renalware-core-2.0.91 app/models/renalware/renal/profile.rb
renalware-core-2.0.90 app/models/renalware/renal/profile.rb
renalware-core-2.0.89 app/models/renalware/renal/profile.rb
renalware-core-2.0.88 app/models/renalware/renal/profile.rb
renalware-core-2.0.87 app/models/renalware/renal/profile.rb
renalware-core-2.0.86 app/models/renalware/renal/profile.rb
renalware-core-2.0.85 app/models/renalware/renal/profile.rb
renalware-core-2.0.84 app/models/renalware/renal/profile.rb
renalware-core-2.0.83 app/models/renalware/renal/profile.rb
renalware-core-2.0.82 app/models/renalware/renal/profile.rb