Class: HealthDataStandards::CQM::Measure

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/health-data-standards/models/cqm/measure.rb

Constant Summary collapse

MSRPOPL =
'MSRPOPL'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_by_measureObject

Finds all measures and groups the sub measures



92
93
94
95
96
97
98
99
# File 'lib/health-data-standards/models/cqm/measure.rb', line 92

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

.categoriesObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/health-data-standards/models/cqm/measure.rb', line 46

def self.categories
  pipeline = []
  pipeline << {'$group' => {_id: "$id", 
                            name: {"$first" => "$name"},
                            description: {"$first" => "$description"},
                            sub_ids: {'$push' => "$sub_id"},
                            subs: {'$push' => {"sub_id" => "$sub_id", "short_subtitle" => "$short_subtitle"}},
                            category: {'$first' => "$category"}}}

  pipeline << {'$group' => {_id: "$category",
                            measures: {'$push' => {"id" => "$_id", 
                                       'name' => "$name",
                                       'description' => "$description",
                                       'subs' => "$subs",
                                       'sub_ids' => "$sub_ids"
                                      }}}}

  pipeline << {'$project' => {'category' => '$_id', 'measures' => 1, '_id' => 0}}
  
  pipeline << {'$sort' => {"category" => 1}}
  Mongoid.default_session.command(aggregate: 'measures', pipeline: pipeline)['result']
end

.installedObject



84
85
86
# File 'lib/health-data-standards/models/cqm/measure.rb', line 84

def self.installed
  Measure.order_by([["id", :asc],["sub_id", :asc]]).to_a
end

Instance Method Details

#all_data_criteriaObject



122
123
124
125
126
127
128
129
130
131
# File 'lib/health-data-standards/models/cqm/measure.rb', line 122

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_modelObject

Returns the hqmf-parser’s ruby implementation of an HQMF document. Rebuild from population_criteria, data_criteria, and measure_period JSON



72
73
74
# File 'lib/health-data-standards/models/cqm/measure.rb', line 72

def as_hqmf_model
  @hqmf ||=  HQMF::Document.from_json(self.hqmf_document)
end

#continuous?Boolean



114
115
116
# File 'lib/health-data-standards/models/cqm/measure.rb', line 114

def continuous?
  population_ids[MSRPOPL]
end

#display_nameObject



101
102
103
# File 'lib/health-data-standards/models/cqm/measure.rb', line 101

def display_name
  "#{self['cms_id']}/#{self['nqf_id']} - #{name}"
end

#is_cv?Boolean



80
81
82
# File 'lib/health-data-standards/models/cqm/measure.rb', line 80

def is_cv?
  ! population_ids[MSRPOPL].nil?
end

#keyObject



76
77
78
# File 'lib/health-data-standards/models/cqm/measure.rb', line 76

def key
  "#{self['id']}#{sub_id}"
end

#measure_idObject



110
111
112
# File 'lib/health-data-standards/models/cqm/measure.rb', line 110

def measure_id
  self['id']
end

#set_idObject



106
107
108
# File 'lib/health-data-standards/models/cqm/measure.rb', line 106

def set_id
  self.hqmf_set_id
end

#titleObject



118
119
120
# File 'lib/health-data-standards/models/cqm/measure.rb', line 118

def title
  self.name
end