Sha256: ea264efa3aa6c88529695f26638d223189978b543fc6a82f06f69f36e84fc341

Contents?: true

Size: 1.53 KB

Versions: 8

Compression:

Stored size: 1.53 KB

Contents

require_dependency "renalware/admissions"

module Renalware
  module Admissions
    class Admission < ApplicationRecord
      include Accountable
      # PatientsRansackHelper adds the :identity_match scope for querying by patient name,
      # local hospital id or NHS number. We use this scope from the filters on the admissions list
      # to enable searching for a patient. *Note* you must join onto the patients table first
      # if calling this scope or using it with ransack, e.g.
      #   Admission.joins(:patient).identity_match("rab rog")

      include PatientsRansackHelper
      extend Enumerize

      acts_as_paranoid

      validates :patient_id, presence: true
      validates :hospital_ward_id, presence: true
      validates :admitted_on, presence: true
      validates :reason_for_admission, presence: true
      validates :admission_type, presence: true

      belongs_to :patient
      belongs_to :hospital_ward, class_name: "Hospitals::Ward"
      belongs_to :summarised_by, class_name: "User"
      belongs_to :modality_at_admission, class_name: "Modalities::Modality"

      enumerize :admission_type, in: %i(unknown routine elective emergency consult transfer)
      enumerize :discharge_destination, in: %i(home other_ward other_hosp itu death other)

      scope :currently_admitted, lambda {
        where(discharged_on: nil)
      }

      scope :discharged_but_missing_a_summary, lambda {
        where("discharge_summary is null or discharge_summary = ?", "")
          .where.not(discharged_on: nil)
      }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc11 app/models/renalware/admissions/admission.rb
renalware-core-2.0.0.pre.rc10 app/models/renalware/admissions/admission.rb
renalware-core-2.0.0.pre.rc9 app/models/renalware/admissions/admission.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/admissions/admission.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/admissions/admission.rb
renalware-core-2.0.0.pre.rc6 app/models/renalware/admissions/admission.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/admissions/admission.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/admissions/admission.rb