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.81 app/models/renalware/renal/profile.rb
renalware-core-2.0.80 app/models/renalware/renal/profile.rb
renalware-core-2.0.79 app/models/renalware/renal/profile.rb
renalware-core-2.0.78 app/models/renalware/renal/profile.rb
renalware-core-2.0.77 app/models/renalware/renal/profile.rb
renalware-core-2.0.76 app/models/renalware/renal/profile.rb
renalware-core-2.0.75 app/models/renalware/renal/profile.rb
renalware-core-2.0.74 app/models/renalware/renal/profile.rb
renalware-core-2.0.73 app/models/renalware/renal/profile.rb
renalware-core-2.0.72 app/models/renalware/renal/profile.rb
renalware-core-2.0.71 app/models/renalware/renal/profile.rb
renalware-core-2.0.70 app/models/renalware/renal/profile.rb
renalware-core-2.0.69 app/models/renalware/renal/profile.rb
renalware-core-2.0.68 app/models/renalware/renal/profile.rb
renalware-core-2.0.67 app/models/renalware/renal/profile.rb
renalware-core-2.0.64 app/models/renalware/renal/profile.rb
renalware-core-2.0.63 app/models/renalware/renal/profile.rb
renalware-core-2.0.62 app/models/renalware/renal/profile.rb
renalware-core-2.0.61 app/models/renalware/renal/profile.rb
renalware-core-2.0.60 app/models/renalware/renal/profile.rb