Sha256: 7cb8ed64d02089d52c741a039ecd63a81dee8dc54f4c7898a6b1e422d06d09bd

Contents?: true

Size: 1.13 KB

Versions: 9

Compression:

Stored size: 1.13 KB

Contents

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

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

      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
      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

9 entries across 9 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta12 app/models/renalware/renal/profile.rb
renalware-core-2.0.0.pre.beta11 app/models/renalware/renal/profile.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/renal/profile.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/renal/profile.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/renal/profile.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/renal/profile.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/renal/profile.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/renal/profile.rb
renalware-core-2.0.0.pre.beta4 app/models/renalware/renal/profile.rb