Sha256: 7298067442d8f860e56e5effb3f2f16e114894cff831e097dfeca6aeed3d1f98

Contents?: true

Size: 1.8 KB

Versions: 29

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

29 entries across 29 versions & 1 rubygems

Version Path
renalware-core-2.0.46 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.45 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.44 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.43 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.42 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.41 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.40 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.39 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.38 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.37 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.36 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.35 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.34 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.33 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.32 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.31 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.30 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.28 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.27 app/presenters/renalware/transplants/wait_list_registration_presenter.rb
renalware-core-2.0.26 app/presenters/renalware/transplants/wait_list_registration_presenter.rb