Sha256: 7ecfa83b598b06dc4d6263aed0f7a0d24257d6392774355f5d3f70df7a1f3215

Contents?: true

Size: 890 Bytes

Versions: 43

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true

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.current_drug_ids & drug_ids).any?
          end

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

          private

          def drug_ids
            drug_category.drugs.pluck(: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

43 entries across 43 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.1.0 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.167 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.166 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.165 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.164 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.163 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.162 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.161 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.160 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.159 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.158 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.157 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.156 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.155 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.153 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.152 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.151 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.149 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb
renalware-core-2.0.148 app/models/renalware/pathology/requests/global_rule/prescription_drug_category.rb