Sha256: aabd35113fb3bbe50c91cd574965a47635e086561df7e4d902b5c6221f5295cc

Contents?: true

Size: 1.8 KB

Versions: 114

Compression:

Stored size: 1.8 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/transplants"

module Renalware
  module Transplants
    class WaitListRegistrationPresenter < SimpleDelegator
      delegate :uk_transplant_centre,
               :transplant,
               :organs,
               :crf,
               to: :document
      delegate :status,
               :status_updated_on,
               to: :uk_transplant_centre, prefix: true, allow_nil: true
      delegate :highest,
               :latest,
               to: :crf, prefix: true, allow_nil: true
      delegate :recorded_on,
               :result,
               to: :crf_highest, prefix: true, allow_nil: true
      delegate :recorded_on,
               :result,
               to: :crf_latest, prefix: true, allow_nil: true
      delegate :blood_group,
               :nb_of_previous_grafts,
               to: :transplant, prefix: true, allow_nil: true
      delegate :transplant_type,
               to: :organs,
               prefix: true, allow_nil: true
      delegate :hospital_identifier,
               :age,
               :sex,
               :current_modality,
               to: :patient,
               prefix: true, allow_nil: true

      def uk_transplant_centre_summary
        return if uk_transplant_centre_status.blank?

        "#{uk_transplant_centre_status} (#{I18n.l(uk_transplant_centre_status_updated_on)})"
      end

      def hd_hospital_unit_code
        Renalware::HD.cast_patient(patient).hd_profile&.hospital_unit&.unit_code
      end

      def esrf_date
        Renalware::Renal.cast_patient(patient).profile&.esrf_on
      end

      def dol
        entered_on && (Time.zone.today - entered_on).to_i
      end

      def sens
        return if crf_latest_result.blank?

        crf_latest_result.to_i > 60 ? "Sens" : "Unsens"
      end
    end
  end
end

Version data entries

114 entries across 114 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.1.0 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.167 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.166 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.165 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.164 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.163 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.162 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.161 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.160 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.159 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.158 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.157 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.156 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.155 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.153 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.152 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.151 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.149 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.148 app/presenters/renalware/transplants/wait_list_registration_presenter.rb