Sha256: d8ebfcad44d002befd89ffbe66c56db8ab387deaf71fc09020aa15871cb5ac06

Contents?: true

Size: 1.46 KB

Versions: 28

Compression:

Stored size: 1.46 KB

Contents

require_dependency "renalware/pathology"

module Renalware
  module Pathology
    module Requests
      class GlobalRuleSetsTable
        def initialize(request_descriptions, clinics, rule_sets)
          @request_descriptions = request_descriptions
          @clinics = clinics
          @rule_sets = rule_sets
        end

        def rows
          @request_descriptions.map do |request_description|
            Row.new(request_description, @clinics, @rule_sets)
          end
        end
      end

      class Row
        attr_reader :request_description

        def initialize(request_description, clinics, rule_sets)
          @request_description = request_description
          @clinics = clinics
          @rule_sets = rule_sets
        end

        def columns
          @clinics.map do |clinic|
            Cell.new(request_description, clinic, @rule_sets)
          end
        end
      end

      class Cell
        attr_reader :request_description, :clinic

        def initialize(request_description, clinic, rule_sets)
          @request_description = request_description
          @clinic = clinic
          @rule_sets = rule_sets
        end

        def rule_sets
          grouped_rule_sets.fetch([request_description.id, clinic.id], [])
        end

        def grouped_rule_sets
          @grouped_rule_sets ||= @rule_sets.group_by do |rule_set|
            [rule_set.request_description_id, rule_set.clinic_id]
          end
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
renalware-core-2.0.8 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.7 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.5 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.4 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.3 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.2 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.1 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc13 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc11 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc10 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc9 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc6 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc3 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.rc1 app/models/renalware/pathology/requests/global_rule_sets_table.rb
renalware-core-2.0.0.pre.beta12 app/models/renalware/pathology/requests/global_rule_sets_table.rb