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.64 app/models/renalware/hd/patient.rb
renalware-core-2.0.63 app/models/renalware/hd/patient.rb
renalware-core-2.0.62 app/models/renalware/hd/patient.rb
renalware-core-2.0.61 app/models/renalware/hd/patient.rb
renalware-core-2.0.60 app/models/renalware/hd/patient.rb
renalware-core-2.0.58 app/models/renalware/hd/patient.rb
renalware-core-2.0.57 app/models/renalware/hd/patient.rb
renalware-core-2.0.56 app/models/renalware/hd/patient.rb
renalware-core-2.0.55 app/models/renalware/hd/patient.rb
renalware-core-2.0.54 app/models/renalware/hd/patient.rb
renalware-core-2.0.53 app/models/renalware/hd/patient.rb
renalware-core-2.0.52 app/models/renalware/hd/patient.rb
renalware-core-2.0.51 app/models/renalware/hd/patient.rb
renalware-core-2.0.50 app/models/renalware/hd/patient.rb
renalware-core-2.0.48 app/models/renalware/hd/patient.rb
renalware-core-2.0.47 app/models/renalware/hd/patient.rb
renalware-core-2.0.46 app/models/renalware/hd/patient.rb
renalware-core-2.0.45 app/models/renalware/hd/patient.rb
renalware-core-2.0.44 app/models/renalware/hd/patient.rb
renalware-core-2.0.43 app/models/renalware/hd/patient.rb