Sha256: fafb8562646eda267033a27e6189e9cf9031bd527ed76021b36cee499563eb5a

Contents?: true

Size: 1.32 KB

Versions: 35

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/problems"

module Renalware
  module Problems
    class Problem < ApplicationRecord
      include PatientScope
      include Accountable

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

      belongs_to :patient, touch: true
      has_many :notes, dependent: :destroy

      scope :ordered, -> { order(position: :asc) }
      scope :with_notes, -> { includes(:notes) }
      scope :with_patient, -> { includes(:patient) }

      validates :patient, presence: true
      validates :description, presence: true

      def self.with_archived
        with_deleted
      end

      def self.current
        all.with_notes
      end

      def self.archived
        only_deleted.with_notes
      end

      def archived?
        deleted?
      end

      def archived_at
        deleted_at
      end

      def archived_on
        deleted_at.to_date
      end

      def created_on
        created_at.to_date
      end

      def updated_on
        updated_at.to_date
      end

      def self.reject_if_proc
        proc { |attrs| attrs[:description].blank? }
      end

      def full_description
        description
      end

      def formatted
        "#{full_description}, #{date}"
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.113 app/models/renalware/problems/problem.rb
renalware-core-2.0.112 app/models/renalware/problems/problem.rb
renalware-core-2.0.111 app/models/renalware/problems/problem.rb
renalware-core-2.0.110 app/models/renalware/problems/problem.rb
renalware-core-2.0.109 app/models/renalware/problems/problem.rb
renalware-core-2.0.108 app/models/renalware/problems/problem.rb
renalware-core-2.0.106 app/models/renalware/problems/problem.rb
renalware-core-2.0.105 app/models/renalware/problems/problem.rb
renalware-core-2.0.104 app/models/renalware/problems/problem.rb
renalware-core-2.0.103 app/models/renalware/problems/problem.rb
renalware-core-2.0.102 app/models/renalware/problems/problem.rb
renalware-core-2.0.101 app/models/renalware/problems/problem.rb
renalware-core-2.0.100 app/models/renalware/problems/problem.rb
renalware-core-2.0.99 app/models/renalware/problems/problem.rb
renalware-core-2.0.98 app/models/renalware/problems/problem.rb
renalware-core-2.0.97 app/models/renalware/problems/problem.rb
renalware-core-2.0.96 app/models/renalware/problems/problem.rb
renalware-core-2.0.95 app/models/renalware/problems/problem.rb
renalware-core-2.0.94 app/models/renalware/problems/problem.rb
renalware-core-2.0.93 app/models/renalware/problems/problem.rb