Sha256: 87d8e7097070a706269c22402cd3a4bba39f4377a2f3011b9d80565292a96d9d

Contents?: true

Size: 1.95 KB

Versions: 142

Compression:

Stored size: 1.95 KB

Contents

# frozen_string_literal: true

module Renalware
  module PrescriptionsHelper
    def patient_prescriptions_path(patient, treatable = nil, params = {})
      treatable ||= patient
      super(patient, params.merge(treatable_type: treatable.class.to_s, treatable_id: treatable.id))
    end

    def new_patient_prescription_path(patient, treatable = nil)
      treatable ||= patient
      super(patient, treatable_type: treatable.class.to_s, treatable_id: treatable.id)
    end

    def patient_medications_prescription_termination_path(patient, prescription, treatable = nil)
      treatable ||= patient
      super(patient, prescription, treatable_type: treatable.class.to_s, treatable_id: treatable.id)
    end

    def new_patient_medications_prescription_termination_path(patient,
                                                              prescription,
                                                              treatable = nil)
      treatable ||= patient
      super(patient, prescription, treatable_type: treatable.class.to_s, treatable_id: treatable.id)
    end

    def highlight_validation_fail(med_object, med_attribute)
      return unless med_object.errors.include?(med_attribute)

      "field_with_errors"
    end

    def validation_fail(prescription)
      prescription.errors.any? ? "show-form" : "content"
    end

    def default_provider(provider)
      provider == "gp" ? "checked" : nil
    end

    def medication_and_route(med_route)
      if med_route.blank?
        "No medication prescribed"
      else
        other_route = "Route: Other (Please specify in notes)"
        safe_join(
          med_route.map do |m|
            route = if m.medication_route.name == other_route
                      m.medication_route.full_name
                    else
                      m.medication_route.name
                    end
            "<li>
                #{m.drug.name} - #{route}
            </li>".html_safe
          end
        )
      end
    end
  end
end

Version data entries

142 entries across 142 versions & 1 rubygems

Version Path
renalware-core-2.0.104 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.103 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.102 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.101 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.100 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.99 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.98 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.97 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.96 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.95 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.94 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.93 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.92 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.91 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.90 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.89 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.88 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.87 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.86 app/helpers/renalware/prescriptions_helper.rb
renalware-core-2.0.85 app/helpers/renalware/prescriptions_helper.rb