Sha256: 2366e2458a0b5d9db2e286cb8da360a7c66a92bfc5ebb225ae798673bcaa9e0f

Contents?: true

Size: 1.16 KB

Versions: 30

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/admissions"

module Renalware
  module Admissions
    class Consult < ApplicationRecord
      include Accountable
      extend Enumerize
      include PatientsRansackHelper
      validates :patient_id, presence: true
      validates :started_on, presence: true
      validates :description, presence: true
      # Currently #consult_type is a string and we are not sure what should be in there
      # Migrated consults may not have a type so only enforce it creation of new ones.
      validates :consult_type, presence: true, on: :create
      validates :other_site_or_ward, presence: {
        if: ->(consult) { consult.consult_site_id.blank? && consult.hospital_ward_id.blank? }
      }

      belongs_to :patient, touch: true
      belongs_to :consult_site, class_name: "Admissions::ConsultSite"
      belongs_to :hospital_ward, class_name: "Hospitals::Ward"
      belongs_to :seen_by, class_name: "User"

      enumerize :transfer_priority, in: %i(unknown necessary desirable potential unnecessary)
      enumerize :aki_risk, in: %i(yes no unknown)

      scope :active, -> { where(ended_on: nil) }
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
renalware-core-2.0.108 app/models/renalware/admissions/consult.rb
renalware-core-2.0.106 app/models/renalware/admissions/consult.rb
renalware-core-2.0.105 app/models/renalware/admissions/consult.rb
renalware-core-2.0.104 app/models/renalware/admissions/consult.rb
renalware-core-2.0.103 app/models/renalware/admissions/consult.rb
renalware-core-2.0.102 app/models/renalware/admissions/consult.rb
renalware-core-2.0.101 app/models/renalware/admissions/consult.rb
renalware-core-2.0.100 app/models/renalware/admissions/consult.rb
renalware-core-2.0.99 app/models/renalware/admissions/consult.rb
renalware-core-2.0.98 app/models/renalware/admissions/consult.rb
renalware-core-2.0.97 app/models/renalware/admissions/consult.rb
renalware-core-2.0.96 app/models/renalware/admissions/consult.rb
renalware-core-2.0.95 app/models/renalware/admissions/consult.rb
renalware-core-2.0.94 app/models/renalware/admissions/consult.rb
renalware-core-2.0.93 app/models/renalware/admissions/consult.rb
renalware-core-2.0.92 app/models/renalware/admissions/consult.rb
renalware-core-2.0.91 app/models/renalware/admissions/consult.rb
renalware-core-2.0.90 app/models/renalware/admissions/consult.rb
renalware-core-2.0.89 app/models/renalware/admissions/consult.rb
renalware-core-2.0.88 app/models/renalware/admissions/consult.rb