<commit_before>DRUGS = %w(Red Blue Yellow Green Amoxicillin Cephradine Dicloxacillin Metronidazole Penicillin Rifampin Tobramycin Vancomycin)
DRUG_TYPES = %w(Antibiotic ESA Immunosuppressant Peritonitis)


def load_drugs(*names)
  names.each do |name|
    instance_variable_set(:"@#{name.downcase}", create(:drug, :name => name))
  end
end

def load_all_drugs
  load_drugs(DRUGS)
end

def load_drug_types(*names)
  names.each do |dt|
    instance_variable_set(:"@#{dt.downcase}", create(:drug_type, :name => dt))
  end
end

def load_all_drug_types
  load_drug_types(DRUG_TYPES)
end

def set_drug_drug_types(drug,drug_type)
  create(:drug_drug_type, drug_id: drug.id, drug_type_id: drug_type.id)
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 = instance_variable_set(:"@#{drug_name.downcase}", create(:drug, name: drug_name))

    drug_type_names.each do |drug_type_name|
      unless drug_type = DrugType.find_by(name: drug_type_name)
        drug_type = instance_variable_set(:"@#{drug_type_name.downcase}",
          create(:drug_type, name: drug_type_name))
      end
      create(:drug_drug_type, drug_id: drug.id, drug_type_id: drug_type.id)
    end

  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 |mr|
    instance_variable_set(:"@#{mr[0].downcase}", create(:medication_route, name: mr[0], full_name: mr[1]))
  end
end
<commit_msg>Created drugs test helper for rspec.<commit_after>DRUGS = %w(Red Blue Yellow Green Amoxicillin Cephradine Dicloxacillin Metronidazole Penicillin Rifampin Tobramycin Vancomycin)
DRUG_TYPES = %w(Antibiotic ESA Immunosuppressant Peritonitis)


def load_drugs(*names)
  names.each do |name|
    instance_variable_set(:"@#{name.downcase}", create(:drug, :name => name))
  end
end

def load_all_drugs
  load_drugs(DRUGS)
end

def load_drug_types(*names)
  names.each do |dt|
    instance_variable_set(:"@#{dt.downcase}", create(:drug_type, :name => dt))
  end
end

def load_all_drug_types
  load_drug_types(DRUG_TYPES)
end

def set_drug_drug_types(drug,drug_type)
  create(:drug_drug_type, drug_id: drug.id, drug_type_id: drug_type.id)
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 = instance_variable_set(:"@#{drug_name.downcase}", create(:drug, name: drug_name))

    drug_type_names.each do |drug_type_name|
      unless drug_type = DrugType.find_by(name: drug_type_name)
        drug_type = instance_variable_set(:"@#{drug_type_name.downcase}",
          create(:drug_type, name: drug_type_name))
      end
      create(:drug_drug_type, drug_id: drug.id, drug_type_id: drug_type.id)
    end

  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 |mr|
    instance_variable_set(:"@#{mr[0].downcase}", create(:medication_route, name: mr[0], full_name: mr[1]))
  end
end


{'fraction_non_alphanumeric': 0.1403985507246377, 'fraction_numerical': 0.0018115942028985507, 'mean_word_length': 5.573412698412699, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2470818', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1250, 'n_words': 247}