<commit_before>module Renalware
  class Medication < ActiveRecord::Base
    attr_accessor :drug_select

    acts_as_paranoid

    has_paper_trail class_name: 'Renalware::MedicationVersion'

    belongs_to :patient
    belongs_to :drug, class_name: "Renalware::Drugs::Drug"
    belongs_to :treatable, polymorphic: true
    belongs_to :medication_route

    validates :patient, presence: true
    validates :treatable, presence: true
    validates :drug, presence: true
    validates :dose, presence: true
    validates :medication_route, presence: true
    validates :frequency, presence: true
    validates :start_date, presence: true
    validates :provider, presence: true

    enum provider: Provider.codes

    scope :ordered, -> { order(default_search_order) }

    def self.default_search_order
      "start_date desc"
    end

    def formatted
      [].tap { |ary|
        ary << drug.name if drug.present?
        ary << dose
        ary << medication_route.name if medication_route.present?
        ary << frequency
        ary << start_date
      }.compact.join(', ')
    end

    def self.peritonitis
      self.new(treatable_type: 'Renalware::PeritonitisEpisode')
    end

    def self.exit_site
      self.new(treatable_type: 'Renalware::ExitSiteInfection')
    end

  end
end<commit_msg>Formatting<commit_after>module Renalware
  class Medication < ActiveRecord::Base
    attr_accessor :drug_select

    acts_as_paranoid

    has_paper_trail class_name: 'Renalware::MedicationVersion'

    belongs_to :patient
    belongs_to :drug, class_name: "Renalware::Drugs::Drug"
    belongs_to :treatable, polymorphic: true
    belongs_to :medication_route

    validates :patient, presence: true
    validates :treatable, presence: true
    validates :drug, presence: true
    validates :dose, presence: true
    validates :medication_route, presence: true
    validates :frequency, presence: true
    validates :start_date, presence: true
    validates :provider, presence: true

    enum provider: Provider.codes

    scope :ordered, -> { order(default_search_order) }

    def self.default_search_order
      "start_date desc"
    end

    def self.peritonitis
      self.new(treatable_type: 'Renalware::PeritonitisEpisode')
    end

    def self.exit_site
      self.new(treatable_type: 'Renalware::ExitSiteInfection')
    end

    def formatted
      [].tap { |ary|
        ary << drug.name if drug.present?
        ary << dose
        ary << medication_route.name if medication_route.present?
        ary << frequency
        ary << start_date
      }.compact.join(', ')
    end
  end
end
{'fraction_non_alphanumeric': 0.08538461538461538, 'fraction_numerical': 0.0, 'mean_word_length': 3.236156351791531, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7639656', 'n_tokens_mistral': 851, 'n_tokens_neox': 781, 'n_words': 195}