class HealthDataStandards::CQM::Measure
Constants
- MSRPOPL
Public Class Methods
all_by_measure()
click to toggle source
Finds all measures and groups the sub measures @return Array - This returns an Array of Hashes. Each Hash will represent a top level measure with an ID, name, and category.
It will also have an array called subs containing hashes with an ID and name for each sub-measure.
# File lib/health-data-standards/models/cqm/measure.rb, line 117 def self.all_by_measure reduce = 'function(obj,prev) { if (obj.sub_id != null) prev.subs.push({id : obj.id + obj.sub_id, name : obj.subtitle}); }' self.moped_session.command( :group=> {:ns=>"measures", :key => {:id=>1, :name=>1, :category=>1}, :initial => {:subs => []}, "$reduce" => reduce})["retval"] end
categories(measure_properties = [])
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 55 def self.categories(measure_properties = []) measure_properties = Array(measure_properties).map(&:to_s) | %w( name description nqf_id cms_id hqmf_id continuous_variable episode_of_care ) pipeline = [] pipeline << {'$group' => measure_properties.inject({ '_id' => "$id", 'subs' => {'$push' => {"sub_id" => "$sub_id", "short_subtitle" => "$short_subtitle"}}, 'sub_ids' => {'$push' => "$sub_id"}, 'category' => {'$first' => "$category"} }) do |h, prop| h[prop] = {"$first" => "$#{prop}"} h end } pipeline << {'$group' => { _id: "$category", measures: { '$push' => measure_properties.inject({ 'id' => "$_id", 'hqmf_id' => "$_id", 'subs' => "$subs", 'sub_ids' => "$sub_ids" }) do |h, prop| h[prop] = "$#{prop}" h end } }} pipeline << {'$project' => {'category' => '$_id', 'measures' => 1, '_id' => 0}} pipeline << {'$sort' => {"category" => 1}} Mongoid.default_client.command(aggregate: 'measures', pipeline: pipeline).documents[0]["result"] end
installed()
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 109 def self.installed Measure.order_by([["id", :asc],["sub_id", :asc]]).to_a end
Public Instance Methods
all_data_criteria()
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 147 def all_data_criteria return @crit if @crit @crit = [] self.data_criteria.each do |dc| dc.each_pair do |k,v| @crit << HQMF::DataCriteria.from_json(k,v) end end @crit end
as_hqmf_model()
click to toggle source
Returns the hqmf-parser's ruby implementation of an HQMF
document. Rebuild from population_criteria, data_criteria, and measure_period JSON
# File lib/health-data-standards/models/cqm/measure.rb, line 97 def as_hqmf_model @hqmf ||= HQMF::Document.from_json(self.hqmf_document) end
build_pre_filters!()
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 184 def build_pre_filters! dc = self.data_criteria.inject({}) do |all_dc, single_dc| key = single_dc.keys.first value = single_dc.values.first all_dc[key] = value all_dc end dc.each_pair do |criteria_name, data_criteria| if data_criteria['definition'] == 'patient_characteristic_birthdate' if data_criteria_in_population?(self.ipp_id, criteria_name) prefilter = Prefilter.new(record_field: 'birthdate', effective_time_based: true) if data_criteria['temporal_references'] data_criteria['temporal_references'].each do |tr| if tr['type'] == 'SBS' && tr['reference'] == 'MeasurePeriod' years = nil if tr['range']['high'] prefilter.comparison = '$gte' years = tr['range']['high']['value'].to_i elsif tr['range']['low'] prefilter.comparison = '$lte' years = tr['range']['low']['value'].to_i end prefilter.effective_time_offset = 1 + years self.prefilters << prefilter end end end end end end end
continuous?()
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 139 def continuous? population_ids[MSRPOPL] end
display_name()
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 126 def display_name "#{self['cms_id']}/#{self['nqf_id']} - #{name}" end
ipp_id()
click to toggle source
For submeasures, this will return something like IPP_1
# File lib/health-data-standards/models/cqm/measure.rb, line 176 def ipp_id ipp_hqmf_id = self.population_ids['IPP'] pop_id, pop_criteria = hqmf_document['population_criteria'].find do |population_id, population_criteria| population_criteria['hqmf_id'] == ipp_hqmf_id end pop_id end
is_cv?()
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 105 def is_cv? ! population_ids[MSRPOPL].nil? end
key()
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 101 def key "#{self['id']}#{sub_id}" end
measure_id()
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 135 def measure_id self['id'] end
prefilter_query!(effective_time)
click to toggle source
Builds the query hash to pass to MongoDB Calling this method will create Prefilters if they do not exist on the measure
# File lib/health-data-standards/models/cqm/measure.rb, line 161 def prefilter_query!(effective_time) self.build_pre_filters! if self.prefilters.empty? if self.prefilters.count == 1 self.prefilters.first.build_query_hash(effective_time) else self.prefilters.inject({}) do |query, pf| query.merge(pf.build_query_hash(effective_time)) do |key, new_val, old_val| new_val.merge(old_val) end end end end
set_id()
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 131 def set_id self.hqmf_set_id end
title()
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 143 def title self.name end
Private Instance Methods
criteria_in_precondition?(preconditions, criteria_name)
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 224 def criteria_in_precondition?(preconditions, criteria_name) preconditions.any? do |precondition| (precondition['reference'] == criteria_name) || (precondition['preconditions'] && criteria_in_precondition?(precondition['preconditions'], criteria_name)) end end
data_criteria_in_population?(population_id, criteria_name)
click to toggle source
# File lib/health-data-standards/models/cqm/measure.rb, line 220 def data_criteria_in_population?(population_id, criteria_name) criteria_in_precondition?(self.hqmf_document['population_criteria'][population_id]['preconditions'], criteria_name) end