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.77 app/models/renalware/admissions/consult.rb
renalware-core-2.0.76 app/models/renalware/admissions/consult.rb
renalware-core-2.0.75 app/models/renalware/admissions/consult.rb
renalware-core-2.0.74 app/models/renalware/admissions/consult.rb
renalware-core-2.0.73 app/models/renalware/admissions/consult.rb
renalware-core-2.0.72 app/models/renalware/admissions/consult.rb
renalware-core-2.0.71 app/models/renalware/admissions/consult.rb
renalware-core-2.0.70 app/models/renalware/admissions/consult.rb
renalware-core-2.0.69 app/models/renalware/admissions/consult.rb
renalware-core-2.0.68 app/models/renalware/admissions/consult.rb
renalware-core-2.0.67 app/models/renalware/admissions/consult.rb
renalware-core-2.0.64 app/models/renalware/admissions/consult.rb
renalware-core-2.0.63 app/models/renalware/admissions/consult.rb
renalware-core-2.0.62 app/models/renalware/admissions/consult.rb
renalware-core-2.0.61 app/models/renalware/admissions/consult.rb
renalware-core-2.0.60 app/models/renalware/admissions/consult.rb
renalware-core-2.0.58 app/models/renalware/admissions/consult.rb
renalware-core-2.0.57 app/models/renalware/admissions/consult.rb
renalware-core-2.0.56 app/models/renalware/admissions/consult.rb
renalware-core-2.0.55 app/models/renalware/admissions/consult.rb