Sha256: c9ba6d25ea9bb81c7aa4e20c146847a8239c746e4a200dfb6dae29e6d1c918f1

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

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"
      has_many :prescription_administrations
      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 current_modality_hd?
        return false if current_modality.blank?

        current_modality.description.is_a?(HD::ModalityDescription)
      end

      def __getobj__
        self
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
renalware-core-2.0.153 app/models/renalware/hd/patient.rb
renalware-core-2.0.152 app/models/renalware/hd/patient.rb
renalware-core-2.0.151 app/models/renalware/hd/patient.rb
renalware-core-2.0.149 app/models/renalware/hd/patient.rb
renalware-core-2.0.148 app/models/renalware/hd/patient.rb
renalware-core-2.0.147 app/models/renalware/hd/patient.rb
renalware-core-2.0.146 app/models/renalware/hd/patient.rb
renalware-core-2.0.145 app/models/renalware/hd/patient.rb
renalware-core-2.0.144 app/models/renalware/hd/patient.rb
renalware-core-2.0.143 app/models/renalware/hd/patient.rb
renalware-core-2.0.142 app/models/renalware/hd/patient.rb
renalware-core-2.0.141 app/models/renalware/hd/patient.rb
renalware-core-2.0.140 app/models/renalware/hd/patient.rb
renalware-core-2.0.139 app/models/renalware/hd/patient.rb
renalware-core-2.0.138 app/models/renalware/hd/patient.rb