Sha256: 21c7fdba6d8e06ec09e08d446c08a281b53829dfd0a268dab2b5952f63e4f844
Contents?: true
Size: 1.32 KB
Versions: 158
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true module DrugsSpecHelper def load_drugs(*names) names.each do |name| drug = create(:drug, name: name) instance_variable_set(:"@#{name.downcase}", drug) end end # { 'Amoxicillin' => ['Antibiotic', 'Peritonitis'], 'Penicillin' => ['Foo', ...] } def load_drugs_by_type(drugs_by_type) drugs_by_type.each do |drug_name, drug_type_names| drug = assign_drug(drug_name) drug_type_names.each { |name| assign_drug_type(drug, name) } end end def load_med_routes medication_routes = { "PO" => "Per Oral", "IV" => "Intravenous", "SC" => "Subcutaneous", "IM" => "Intramuscular", "Other" => "Other (Refer to notes)" } medication_routes.map do |code, name| route = create(:medication_route, code: code, name: name) instance_variable_set(:"@#{code.downcase}", route) end end private def assign_drug(name) drug = create(:drug, name: name) instance_variable_set(:"@#{name.downcase}", drug) end def assign_drug_type(drug, name) drug_type = Renalware::Drugs::Type.find_by(code: name.downcase) if drug_type.blank? drug_type = create(:drug_type, code: name.downcase, name: name) instance_variable_set(:"@#{name.downcase}", drug_type) end drug.drug_types << drug_type end end
Version data entries
158 entries across 158 versions & 1 rubygems