Sha256: 9954bd257a572ba0b360c3d493c69709cd87b30b8cbbdbfcc9b0612b4004b102
Contents?: true
Size: 888 Bytes
Versions: 69
Compression:
Stored size: 888 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.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
69 entries across 69 versions & 1 rubygems