Sha256: 4bcaef5e594331464430e22ea3b773a1a84eea9e388d3d6e58205645b386fa4b

Contents?: true

Size: 1.15 KB

Versions: 62

Compression:

Stored size: 1.15 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

62 entries across 62 versions & 1 rubygems

Version Path
renalware-core-2.0.33 app/models/renalware/admissions/consult.rb
renalware-core-2.0.32 app/models/renalware/admissions/consult.rb
renalware-core-2.0.31 app/models/renalware/admissions/consult.rb
renalware-core-2.0.30 app/models/renalware/admissions/consult.rb
renalware-core-2.0.28 app/models/renalware/admissions/consult.rb
renalware-core-2.0.27 app/models/renalware/admissions/consult.rb
renalware-core-2.0.26 app/models/renalware/admissions/consult.rb
renalware-core-2.0.25 app/models/renalware/admissions/consult.rb
renalware-core-2.0.24 app/models/renalware/admissions/consult.rb
renalware-core-2.0.23 app/models/renalware/admissions/consult.rb
renalware-core-2.0.22 app/models/renalware/admissions/consult.rb
renalware-core-2.0.21 app/models/renalware/admissions/consult.rb
renalware-core-2.0.20 app/models/renalware/admissions/consult.rb
renalware-core-2.0.18 app/models/renalware/admissions/consult.rb
renalware-core-2.0.17 app/models/renalware/admissions/consult.rb
renalware-core-2.0.16 app/models/renalware/admissions/consult.rb
renalware-core-2.0.15 app/models/renalware/admissions/consult.rb
renalware-core-2.0.14 app/models/renalware/admissions/consult.rb
renalware-core-2.0.13 app/models/renalware/admissions/consult.rb
renalware-core-2.0.12 app/models/renalware/admissions/consult.rb