Sha256: 3734c199c42640548cf8cd0eea7542f3cbc897760775bf370bbcab0887f7dfb8

Contents?: true

Size: 856 Bytes

Versions: 28

Compression:

Stored size: 856 Bytes

Contents

require_dependency "renalware/pathology/requests"

module Renalware
  module Pathology
    module Requests
      class GlobalRule
        class PrescriptionDrugCategory < GlobalRule
          validate :drug_category_present

          def observation_required_for_patient?(patient, _date)
            (patient.drugs.map(&:id) & drug_ids).any?
          end

          def to_s
            "prescribed drugs include #{drug_category.name}"
          end

          private

          def drug_ids
            drug_category.drugs.map(&:id)
          end

          def drug_category
            DrugCategory.find_by(id: param_id)
          end

          def drug_category_present
            return if drug_category.present?
            errors.add(:param_id, "param_id must be the id of a DrugCategory")
          end
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta11 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.0.pre.beta4 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb