Sha256: a00c0b9cdf1528bd6ec1f32c3a3ef7580c749d7389c17ae2032ad7867a405f1d

Contents?: true

Size: 1.5 KB

Versions: 16

Compression:

Stored size: 1.5 KB

Contents

module HealthDataStandards
  module CQM
    class QueryCache
      include Mongoid::Document
      include Mongoid::Timestamps
      store_in collection: 'query_cache'

      field :calculation_date, type: Time
      field :status, type: Hash
      field :measure_id, type: String
      field :sub_id, type: String
      field :population_ids, type: Hash
      field :effective_date, type: Integer
      field :IPP, type: Integer
      field :DENOM, type: Integer
      field :NUMER, type: Integer
      field :NUMEX, type: Integer
      field :antinumerator, type: Integer
      field :DENEX, type: Integer
      field :DENEXCEP, type: Integer
      field :MSRPOPL, type: Integer
      field :MSRPOPLEX, type: Integer
      field :OBSERV, type: Float
      field :supplemental_data, type: Hash

      def self.aggregate_measure(measure_id, effective_date, filters=nil, test_id=nil)
        query_hash = {'effective_date' => effective_date, 'measure_id' => measure_id,
                      'test_id' => test_id}
        if filters
          query_hash.merge!(filters)
        end
        cache_entries = self.where(query_hash)
        aggregate_count = AggregateCount.new(measure_id)
        cache_entries.each do |cache_entry|
          aggregate_count.add_entry(cache_entry)
        end
        aggregate_count
      end

      def is_stratification?
        population_ids.has_key?('stratification') || population_ids.has_key?('STRAT')
      end

      def is_cv?
        population_ids.has_key?('MSRPOPL')
      end


    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
health-data-standards-4.3.5 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.3.4 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.3.3 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.3.2 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.3.1 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.3.0 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.2.0 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.1.0 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.0.6 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.0.5 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.0.4 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.0.3 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.0.2 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.0.1 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-4.0.0 lib/health-data-standards/models/cqm/query_cache.rb
health-data-standards-3.7.0 lib/health-data-standards/models/cqm/query_cache.rb