Sha256: 9a938ffb1ee3d7964e7a3eb671c50ae76ca6b24acb5d4ab6f0a179b2a5c6a5c5

Contents?: true

Size: 998 Bytes

Versions: 45

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/hd"

module Renalware
  module HD
    class Patient < ActiveType::Record[Renalware::Patient]
      has_one :hd_profile, class_name: "Profile"
      has_one :hd_preference_set, class_name: "PreferenceSet"
      has_many :hd_sessions, class_name: "Session"
      scope :with_profile, lambda {
        includes(hd_profile: :hospital_unit)
        .joins(<<-SQL)
          LEFT OUTER JOIN hd_profiles ON hd_profiles.patient_id = patients.id
          LEFT OUTER JOIN hospital_units ON hd_profiles.hospital_unit_id = hospital_units.id
        SQL
        .where("hd_profiles.deactivated_at is NULL")
      }

      def treated?
        modality_descriptions.exists?(type: "Renalware::HD::ModalityDescription")
      end

      def has_ever_been_on_hd?
        @has_ever_been_on_hd ||=
          modality_descriptions.exists?(type: "Renalware::HD::ModalityDescription")
      end

      def __getobj__
        self
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
renalware-core-2.0.42 app/models/renalware/hd/patient.rb
renalware-core-2.0.41 app/models/renalware/hd/patient.rb
renalware-core-2.0.40 app/models/renalware/hd/patient.rb
renalware-core-2.0.39 app/models/renalware/hd/patient.rb
renalware-core-2.0.38 app/models/renalware/hd/patient.rb
renalware-core-2.0.37 app/models/renalware/hd/patient.rb
renalware-core-2.0.36 app/models/renalware/hd/patient.rb
renalware-core-2.0.35 app/models/renalware/hd/patient.rb
renalware-core-2.0.34 app/models/renalware/hd/patient.rb
renalware-core-2.0.33 app/models/renalware/hd/patient.rb
renalware-core-2.0.32 app/models/renalware/hd/patient.rb
renalware-core-2.0.31 app/models/renalware/hd/patient.rb
renalware-core-2.0.30 app/models/renalware/hd/patient.rb
renalware-core-2.0.28 app/models/renalware/hd/patient.rb
renalware-core-2.0.27 app/models/renalware/hd/patient.rb
renalware-core-2.0.26 app/models/renalware/hd/patient.rb
renalware-core-2.0.25 app/models/renalware/hd/patient.rb
renalware-core-2.0.24 app/models/renalware/hd/patient.rb
renalware-core-2.0.23 app/models/renalware/hd/patient.rb
renalware-core-2.0.22 app/models/renalware/hd/patient.rb