Sha256: 17050a33f3d33e8553e729f5a850a0de9ca9c96427f50018740fa95ba77bcdcd

Contents?: true

Size: 589 Bytes

Versions: 9

Compression:

Stored size: 589 Bytes

Contents

require_dependency "renalware/drugs"

module Renalware
  module Drugs
    class Drug < ApplicationRecord
      acts_as_paranoid

      has_and_belongs_to_many :drug_types,
                              class_name: "Type",
                              association_foreign_key: :drug_type_id
      scope :ordered, -> { order(:name) }

      validates :name, presence: true

      def self.for(code)
        joins(:drug_types).where(drug_types: { code: code.to_s })
      end

      def display_type
        "Standard Drug"
      end

      def to_s
        name
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta12 app/models/renalware/drugs/drug.rb
renalware-core-2.0.0.pre.beta11 app/models/renalware/drugs/drug.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/drugs/drug.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/drugs/drug.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/drugs/drug.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/drugs/drug.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/drugs/drug.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/drugs/drug.rb
renalware-core-2.0.0.pre.beta4 app/models/renalware/drugs/drug.rb