quality-measure-engine 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32ed387902a54660adf12e524588392b5e329437
4
- data.tar.gz: deaefc5e9b3fdf34cc27f3e132bc62c1019f995b
3
+ metadata.gz: 35e476899eb214e4601ce6d61c96bbb2e9dbbd7a
4
+ data.tar.gz: f4d5ac3ac53c4e6fcbd39d4237799443274368a0
5
5
  SHA512:
6
- metadata.gz: 2fc390d8e5251f5e00b4517359381d17025593351099db2826dd4ba8757600df49c5700dae74a960434aa1e22137547091b6fbe974c619f8d549b1c71f450ef0
7
- data.tar.gz: 76aea2d8f2ad3b5da238be7a83bdc39309ce607d4390683278fdab8964f085ed962c49c05d228d4fb81440b164215d6221c66df93a5d76b25eec3c7548c446d7
6
+ metadata.gz: 9e0eac215433503529b1ad7eaf3c0adea2f212e5f5ceec48097064374edca2d34355ecc367e452688cbe56b98a68c88a6bd8e1a35560724ff59a9756bd9b6177
7
+ data.tar.gz: 866b367b2d0a978294854ffc125ef7e70628bfefc49038decabc88abd867c4bfe3c27e4e096c333364bb3f9fb684f8571ed6c00349fb0f5a77ebf8fd19ee7888
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- quality-measure-engine (3.0.1)
4
+ quality-measure-engine (3.0.2)
5
5
  delayed_job_mongoid (~> 2.0.0)
6
6
  mongoid (~> 3.1.4)
7
7
  moped (~> 1.5.1)
@@ -19,13 +19,13 @@ module QME
19
19
 
20
20
  @measure_id = measure_id
21
21
  @sub_id =sub_id
22
-
22
+
23
23
  @parameter_values = parameter_values
24
24
  q_filter = {hqmf_id: @measure_id,sub_id: @sub_id}
25
25
  if @parameter_values.keys.index("bundle_id")
26
26
  q_filter["bundle_id"] == @parameter_values['bundle_id']
27
27
  @bundle_id = @parameter_values['bundle_id']
28
- end
28
+ end
29
29
  @measure_def = QualityMeasure.where(q_filter).first
30
30
  end
31
31
 
@@ -34,8 +34,8 @@ module QME
34
34
 
35
35
  filters = @parameter_values["filters"]
36
36
 
37
-
38
- match = {'value.measure_id' => @measure_id,
37
+
38
+ match = {'value.measure_id' => @measure_id,
39
39
  'value.sub_id' => @sub_id,
40
40
  'value.effective_date' => @parameter_values['effective_date'],
41
41
  'value.test_id' => @parameter_values['test_id'],
@@ -53,8 +53,8 @@ module QME
53
53
  end
54
54
  if (filters['providers'] && filters['providers'].size > 0)
55
55
  providers = filters['providers'].map { |pv| {'providers' => Moped::BSON::ObjectId(pv) } }
56
- pipeline.concat [{'$project' => {'value' => 1, 'providers' => "$value.provider_performances.provider_id"}},
57
- {'$unwind' => '$providers'},
56
+ pipeline.concat [{'$project' => {'value' => 1, 'providers' => "$value.provider_performances.provider_id"}},
57
+ {'$unwind' => '$providers'},
58
58
  {'$match' => {'$or' => providers}},
59
59
  {'$group' => {"_id" => "$_id", "value" => {"$first" => "$value"}}}]
60
60
  end
@@ -74,32 +74,32 @@ module QME
74
74
  end
75
75
 
76
76
 
77
- #Calculate all of the supoplemental data elements
77
+ #Calculate all of the supoplemental data elements
78
78
  def calculate_supplemental_data_elements
79
79
 
80
- match = {'value.measure_id' => @measure_id,
80
+ match = {'value.measure_id' => @measure_id,
81
81
  'value.sub_id' => @sub_id,
82
82
  'value.effective_date' => @parameter_values['effective_date'],
83
83
  'value.test_id' => @parameter_values['test_id'],
84
- 'value.manual_exclusion' => {'$in' => [nil, false]}}
85
-
84
+ 'value.manual_exclusion' => {'$in' => [nil, false]}}
85
+
86
86
  keys = @measure_def.population_ids.keys - [QME::QualityReport::OBSERVATION, "stratification"]
87
87
  supplemental_data = Hash[*keys.map{|k| [k,{QME::QualityReport::RACE => {},
88
88
  QME::QualityReport::ETHNICITY => {},
89
89
  QME::QualityReport::SEX => {},
90
90
  QME::QualityReport::PAYER => {}}]}.flatten]
91
-
91
+
92
92
  keys.each do |pop_id|
93
93
  _match = match.clone
94
94
  _match["value.#{pop_id}"] = {"$gt" => 0}
95
95
  SUPPLEMENTAL_DATA_ELEMENTS.each_pair do |supp_element,location|
96
- group1 = {"$group" => { "_id" => { "id" => "$_id", "val" => location}}}
96
+ group1 = {"$group" => { "_id" => { "id" => "$_id", "val" => location}}}
97
97
  group2 = {"$group" => {"_id" => "$_id.val", "val" =>{"$sum" => 1} }}
98
98
  pipeline = [{"$match" =>_match},group1,group2]
99
99
  aggregate = get_db.command(:aggregate => 'patient_cache', :pipeline => pipeline)
100
100
 
101
101
  v = {}
102
- (aggregate["result"] || []).each do |entry|
102
+ (aggregate["result"] || []).each do |entry|
103
103
  code = entry["_id"].nil? ? "UNK" : entry["_id"]
104
104
  v[code] = entry["val"]
105
105
  end
@@ -119,8 +119,8 @@ module QME
119
119
  pipeline = build_query
120
120
 
121
121
  pipeline << {'$group' => {
122
- "_id" => "$value.measure_id", # we don't really need this, but Mongo requires that we group
123
- QME::QualityReport::POPULATION => {"$sum" => "$value.#{QME::QualityReport::POPULATION}"},
122
+ "_id" => "$value.measure_id", # we don't really need this, but Mongo requires that we group
123
+ QME::QualityReport::POPULATION => {"$sum" => "$value.#{QME::QualityReport::POPULATION}"},
124
124
  QME::QualityReport::DENOMINATOR => {"$sum" => "$value.#{QME::QualityReport::DENOMINATOR}"},
125
125
  QME::QualityReport::NUMERATOR => {"$sum" => "$value.#{QME::QualityReport::NUMERATOR}"},
126
126
  QME::QualityReport::ANTINUMERATOR => {"$sum" => "$value.#{QME::QualityReport::ANTINUMERATOR}"},
@@ -135,7 +135,7 @@ module QME
135
135
  raise RuntimeError, "Aggregation Failed"
136
136
  elsif aggregate['result'].size !=1
137
137
  aggregate['result'] =[{"defaults" => true,
138
- QME::QualityReport::POPULATION => 0,
138
+ QME::QualityReport::POPULATION => 0,
139
139
  QME::QualityReport::DENOMINATOR => 0,
140
140
  QME::QualityReport::NUMERATOR =>0,
141
141
  QME::QualityReport::ANTINUMERATOR => 0,
@@ -151,7 +151,7 @@ module QME
151
151
 
152
152
 
153
153
  if @measure_def.continuous_variable
154
- aggregated_value = calculate_cv_aggregation
154
+ aggregated_value = calculate_cv_aggregation
155
155
  result[QME::QualityReport::OBSERVATION] = aggregated_value
156
156
  end
157
157
 
@@ -167,8 +167,8 @@ module QME
167
167
 
168
168
  end
169
169
 
170
- # This method calculates the aggregated value for a CV measure. It extracts all
171
- # the values for patients in the MSRPOPL and uses the aggregator to combine those
170
+ # This method calculates the aggregated value for a CV measure. It extracts all
171
+ # the values for patients in the MSRPOPL and uses the aggregator to combine those
172
172
  # values into an aggregated value. The currently supported aggregators are:
173
173
  # MEDIAN
174
174
  # MEAN
@@ -193,17 +193,17 @@ module QME
193
193
  # This method runs the MapReduce job for the measure which will create documents
194
194
  # in the patient_cache collection. These documents will state the measure groups
195
195
  # that the record belongs to, such as numerator, etc.
196
- def map_records_into_measure_groups
196
+ def map_records_into_measure_groups(prefilter={})
197
197
  measure = Builder.new(get_db(), @measure_def, @parameter_values)
198
198
  get_db().command(:mapreduce => 'records',
199
199
  :map => measure.map_function,
200
200
  :reduce => "function(key, values){return values;}",
201
- :out => {:reduce => 'patient_cache', :sharded => true},
201
+ :out => {:reduce => 'patient_cache', :sharded => true},
202
202
  :finalize => measure.finalize_function,
203
- :query => {:test_id => @parameter_values['test_id']})
203
+ :query => prefilter)
204
204
  QME::ManualExclusion.apply_manual_exclusions(@measure_id,@sub_id)
205
205
  end
206
-
206
+
207
207
  # This method runs the MapReduce job for the measure and a specific patient.
208
208
  # This will create a document in the patient_cache collection. This document
209
209
  # will state the measure groups that the record belongs to, such as numerator, etc.
@@ -212,13 +212,13 @@ module QME
212
212
  get_db().command(:mapreduce => 'records',
213
213
  :map => measure.map_function,
214
214
  :reduce => "function(key, values){return values;}",
215
- :out => {:reduce => 'patient_cache', :sharded => true},
215
+ :out => {:reduce => 'patient_cache', :sharded => true},
216
216
  :finalize => measure.finalize_function,
217
217
  :query => {:medical_record_number => patient_id, :test_id => @parameter_values["test_id"]})
218
218
  QME::ManualExclusion.apply_manual_exclusions(@measure_id,@sub_id)
219
219
 
220
220
  end
221
-
221
+
222
222
  # This method runs the MapReduce job for the measure and a specific patient.
223
223
  # This will *not* create a document in the patient_cache collection, instead the
224
224
  # result is returned directly.
@@ -227,14 +227,14 @@ module QME
227
227
  result = get_db().command(:mapreduce => 'records',
228
228
  :map => measure.map_function,
229
229
  :reduce => "function(key, values){return values;}",
230
- :out => {:inline => true},
231
- :raw => true,
230
+ :out => {:inline => true},
231
+ :raw => true,
232
232
  :query => {:medical_record_number => patient_id, :test_id => @parameter_values["test_id"]})
233
233
 
234
234
  raise result['err'] if result['ok']!=1
235
235
  result['results'][0]['value']
236
236
  end
237
-
237
+
238
238
 
239
239
  end
240
240
  end
@@ -4,7 +4,7 @@ module QME
4
4
  #
5
5
  # Delayed::Job.enqueue QME::MapRedude::MeasureCalculationJob.new(quality_report, :effective_date => 1291352400, :test_id => xyzzy)
6
6
  #
7
- # MeasureCalculationJob will check to see if a measure has been calculated before running the calculation. It will do this by
7
+ # MeasureCalculationJob will check to see if a measure has been calculated before running the calculation. It will do this by
8
8
  # checking the status of the quality report that this calculation job was created with.
9
9
  #
10
10
  # When a measure needs calculation, the job will create a QME::MapReduce::Executor and interact with it to calculate
@@ -17,21 +17,21 @@ module QME
17
17
  @options = options
18
18
  @options.merge! @quality_report.attributes
19
19
  end
20
-
20
+
21
21
  def perform
22
22
 
23
23
  if !@quality_report.calculated?
24
24
  map = QME::MapReduce::Executor.new(@quality_report.measure_id,@quality_report.sub_id, @options.merge('start_time' => Time.now.to_i))
25
25
  if !@quality_report.patients_cached?
26
26
  tick('Starting MapReduce')
27
- map.map_records_into_measure_groups
27
+ map.map_records_into_measure_groups(@options['prefilter'])
28
28
  tick('MapReduce complete')
29
29
  end
30
-
30
+
31
31
  tick('Calculating group totals')
32
32
  result = map.count_records_in_measure_groups
33
33
  @quality_report.result=result
34
- # backwards compatibility with previous q cahce users. Should be reomved going foward
34
+ # backwards compatibility with previous q cahce users. Should be reomved going foward
35
35
  # and provide a means to update existing results to the newer format
36
36
  result.attributes.each_pair do |k,v|
37
37
  unless k.to_s == "_id"
@@ -58,7 +58,7 @@ module QME
58
58
  end
59
59
 
60
60
  def enqueue(job)
61
- @quality_report.status = {"state" => "queued", "log" => ["Queued at #{Time.now}"], "job_id" => job.id}
61
+ @quality_report.status = {"state" => "queued", "log" => ["Queued at #{Time.now}"], "job_id" => job.id}
62
62
  @quality_report.save
63
63
  end
64
64
 
@@ -96,10 +96,10 @@ module QME
96
96
  :failed
97
97
  else
98
98
  :running
99
- end
99
+ end
100
100
  end
101
101
  end
102
102
  end
103
103
  end
104
104
  end
105
- end
105
+ end
data/lib/qme/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module QME
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quality-measure-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Hadley
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-04-04 00:00:00.000000000 Z
15
+ date: 2014-05-15 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: moped