Sha256: a26cc7b5a175e96576dd8cfad7e80773b6f8ac9c7d558489c90b2cb7d51ea0c9

Contents?: true

Size: 1.23 KB

Versions: 15

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Renalware
  module DrugsHelper
    def drug_select_options
      options_for_select(
        Drugs::Type
          .all
          .reject { |dt| dt.name == "Peritonitis" }
          .map { |dt| [dt.name, dt.name.downcase] }
      )
    end

    # Now that we have a drug_types.colour column e.g. '#aaa' we can use here.
    # Where the drug belongs to 2 drug types, we need to be sure to choose the colour of the most
    # clinically significant drug type - eg 'ESA' wins over 'My other drug type'.
    # This should be done by ordering a drugs types and taking the one with the highest value
    # in the #weighting column - i.e. ESA will have a a large value in this column to ensure it
    # trumps other types and its colour is used.
    def drug_types_colour_tag(drug_types)
      drug_names = drug_types.map(&:name)
      return "esa" if drug_names.include?("ESA")
      return "immunosuppressant" if drug_names.include?("Immunosuppressant")

      "other"
    end

    def drug_types_tag(drug_type)
      if drug_type.map(&:name).include?("ESA")
        "ESA"
      elsif drug_type.map(&:name).include?("Immunosuppressant")
        "Immunosuppressant"
      else
        "Standard"
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/helpers/renalware/drugs_helper.rb
renalware-core-2.1.0 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.167 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.166 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.165 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.164 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.163 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.162 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.161 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.160 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.159 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.158 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.157 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.156 app/helpers/renalware/drugs_helper.rb
renalware-core-2.0.155 app/helpers/renalware/drugs_helper.rb