Sha256: a52a55974126aaba35db62307d02f3555d111ad3ca464f5ef8075428015b7a48

Contents?: true

Size: 808 Bytes

Versions: 35

Compression:

Stored size: 808 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/pathology/requests"

module Renalware
  module Pathology
    module Requests
      class GlobalRule
        class PrescriptionDrugType < GlobalRule
          validate :drug_type_present

          def observation_required_for_patient?(patient, _date)
            patient.drugs.flat_map(&:drug_types).include?(drug_type)
          end

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

          private

          def drug_type
            @drug_type ||= Drugs::Type.find_by(id: param_id)
          end

          def drug_type_present
            return if drug_type.present?
            errors.add(:param_id, "param_id must be the id of a DrugType")
          end
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.46 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.45 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.44 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.43 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.42 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.41 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.40 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.39 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.38 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.37 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.36 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.35 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.34 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.33 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.32 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.31 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.30 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.28 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.27 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb
renalware-core-2.0.26 app/models/renalware/pathology/requests/global_rule/prescription_drug_type.rb