Sha256: bc6000f4d79fd3b82146ffc53bb3db2f25dbaca4f9a65e42e199f8d6450c7469

Contents?: true

Size: 1.2 KB

Versions: 32

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/medications"

module Renalware
  module Medications
    class PrescriptionPresenter < DumbDelegator
      delegate :drug_types, to: :drug
      delegate :local_patient_id, :age, :sex, :current_modality, to: :patient, prefix: true

      def patient_name
        patient.to_s
      end

      def patient_current_modality_name
        return unless patient_current_modality

        patient_current_modality.description.to_s
      end

      def route_code
        medication_route.other? ? route_description : medication_route.code
      end

      def drug_type_names
        drug_types.map(&:name).join(", ")
      end

      def provider
        ::I18n.t(super, scope: "enums.provider")
      end

      def dose
        "#{dose_amount} #{translated_dose_unit}"
      end

      def administer_on_hd?
        administer_on_hd ? "Yes" : "No"
      end

      def to_s
        [
          drug,
          "DOSE #{dose}",
          route_code,
          frequency
        ].compact.join(" - ")
      end

      private

      def translated_dose_unit
        ::I18n.t(dose_unit, scope: "enumerize.renalware.medications.prescription.dose_unit")
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
renalware-core-2.0.159 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.158 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.157 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.156 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.155 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.153 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.152 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.151 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.149 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.148 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.147 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.146 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.145 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.144 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.143 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.142 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.141 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.140 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.139 app/presenters/renalware/medications/prescription_presenter.rb
renalware-core-2.0.138 app/presenters/renalware/medications/prescription_presenter.rb