quality-measure-engine 3.0.3 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,6 @@ module QME
19
19
  end
20
20
 
21
21
  def perform
22
-
23
22
  if !@quality_report.calculated?
24
23
  map = QME::MapReduce::Executor.new(@quality_report.measure_id,@quality_report.sub_id, @options.merge('start_time' => Time.now.to_i))
25
24
  if !@quality_report.patients_cached?
@@ -42,6 +41,7 @@ module QME
42
41
  completed("#{@measure_id}#{@sub_id}: p#{result[QME::QualityReport::POPULATION]}, d#{result[QME::QualityReport::DENOMINATOR]}, n#{result[QME::QualityReport::NUMERATOR]}, excl#{result[QME::QualityReport::EXCLUSIONS]}, excep#{result[QME::QualityReport::EXCEPTIONS]}")
43
42
  QME::QualityReport.queue_staged_rollups(@quality_report.measure_id,@quality_report.sub_id,@quality_report.effective_date)
44
43
  end
44
+ @quality_report
45
45
  end
46
46
 
47
47
  def completed(message)
@@ -1,5 +1,5 @@
1
1
  module QME
2
-
2
+
3
3
  class QualityReportResult
4
4
  include Mongoid::Document
5
5
  include Mongoid::Timestamps
@@ -20,14 +20,15 @@ module QME
20
20
  # A class that allows you to create and obtain the results of running a
21
21
  # quality measure against a set of patient records.
22
22
  class QualityReport
23
-
23
+
24
24
  include Mongoid::Document
25
25
  include Mongoid::Timestamps
26
+ include Mongoid::Attributes::Dynamic
26
27
  store_in collection: 'query_cache'
27
28
 
28
29
  field :nqf_id, type: String
29
30
  field :npi, type: String
30
- field :calculation_time, type: Time
31
+ field :calculation_time, type: Time
31
32
  field :status, type: Hash, default: {"state" => "unknown", "log" => []}
32
33
  field :measure_id, type: String
33
34
  field :sub_id, type: String
@@ -56,8 +57,8 @@ module QME
56
57
  POSTAL_CODE = 'POSTAL_CODE'
57
58
  PAYER = 'PAYER'
58
59
 
59
-
60
-
60
+
61
+
61
62
  # Removes the cached results for the patient with the supplied id and
62
63
  # recalculates as necessary
63
64
  def self.update_patient_results(id)
@@ -66,12 +67,12 @@ module QME
66
67
 
67
68
  # drop any cached measure result calculations for the modified patient
68
69
  QME::PatientCache.where('value.medical_record_id' => id).destroy()
69
-
70
+
70
71
  # get a list of cached measure results for a single patient
71
72
  sample_patient = QME::PatientCache.where({}).first
72
73
  if sample_patient
73
74
  cached_results = QME::PatientCache.where({'value.patient_id' => sample_patient['value']['patient_id']})
74
-
75
+
75
76
  # for each cached result (a combination of measure_id, sub_id, effective_date and test_id)
76
77
  cached_results.each do |measure|
77
78
  # recalculate patient_cache value for modified patient
@@ -81,13 +82,13 @@ module QME
81
82
  map.map_record_into_measure_groups(id)
82
83
  end
83
84
  end
84
-
85
+
85
86
  # remove the query totals so they will be recalculated using the new results for
86
87
  # the modified patient
87
88
  self.destroy_all
88
89
  end
89
90
 
90
-
91
+
91
92
 
92
93
 
93
94
  def self.find_or_create(measure_id, sub_id, parameter_values)
@@ -101,11 +102,13 @@ module QME
101
102
  def self.queue_staged_rollups(measure_id,sub_id,effective_date)
102
103
  query = Mongoid.default_session["rollup_buffer"].find({measure_id: measure_id, sub_id: sub_id, effective_date: effective_date})
103
104
  query.each do |options|
104
- QME::QualityReport.enque_job(options,:rollup)
105
+ if QME::QualityReport.where("_id" => options["quality_report_id"]).count == 1
106
+ QME::QualityReport.enque_job(options,:rollup)
107
+ end
105
108
  end
106
109
  query.remove_all
107
110
  end
108
-
111
+
109
112
  # Determines whether the quality report has been calculated for the given
110
113
  # measure and parameters
111
114
  # @return [true|false]
@@ -116,14 +119,14 @@ module QME
116
119
  # Determines whether the patient mapping for the quality report has been
117
120
  # completed
118
121
  def patients_cached?
119
- !QME::QualityReport.where({measure_id: self.measure_id,sub_id:self.sub_id, effective_date: self.effective_date,"status.state" => "completed" }).first.nil?
122
+ !QME::QualityReport.where({measure_id: self.measure_id,sub_id:self.sub_id, effective_date: self.effective_date, test_id: self.test_id, "status.state" => "completed" }).first.nil?
120
123
  end
121
-
124
+
122
125
 
123
126
  # Determines whether the patient mapping for the quality report has been
124
- # queued up by another quality report or if it is currently running
127
+ # queued up by another quality report or if it is currently running
125
128
  def calculation_queued_or_running?
126
- !QME::QualityReport.where({measure_id: self.measure_id,sub_id:self.sub_id, effective_date: self.effective_date }).nin("status.state" =>["unknown","stagged"]).first.nil?
129
+ !QME::QualityReport.where({measure_id: self.measure_id,sub_id:self.sub_id, effective_date: self.effective_date, test_id: self.test_id }).nin("status.state" =>["unknown","stagged"]).first.nil?
127
130
  end
128
131
 
129
132
  # Kicks off a background job to calculate the measure
@@ -132,11 +135,11 @@ module QME
132
135
 
133
136
  options = {'quality_report_id' => self.id}
134
137
  options.merge! parameters || {}
135
-
138
+
136
139
  if self.status["state"] == "completed" && !options["recalculate"]
137
140
  return self
138
141
  end
139
-
142
+
140
143
  self.status["state"] = "queued"
141
144
  if (asynchronous)
142
145
  options[:asynchronous] = true
@@ -156,7 +159,7 @@ module QME
156
159
  mcj.perform
157
160
  end
158
161
  end
159
-
162
+
160
163
  def patient_results
161
164
  ex = QME::MapReduce::Executor.new(self.measure_id,self.sub_id, self.attributes)
162
165
  QME::PatientCache.where(patient_cache_matcher)
@@ -170,7 +173,7 @@ module QME
170
173
  def self.normalize_filters(filters)
171
174
  filters.each {|key, value| value.sort_by! {|v| (v.is_a? Hash) ? "#{v}" : v} if value.is_a? Array} unless filters.nil?
172
175
  end
173
-
176
+
174
177
  def patient_result(patient_id = nil)
175
178
  query = patient_cache_matcher
176
179
  if patient_id
@@ -181,7 +184,7 @@ module QME
181
184
 
182
185
 
183
186
  def patient_cache_matcher
184
- match = {'value.measure_id' => self.measure_id,
187
+ match = {'value.measure_id' => self.measure_id,
185
188
  'value.sub_id' => self.sub_id,
186
189
  'value.effective_date' => self.effective_date,
187
190
  'value.test_id' => test_id,
@@ -215,7 +218,7 @@ module QME
215
218
  # a new QR object which would then go to the db and see if the calculation was performed or
216
219
  # not yet and then return the results. Now that QR objects are persisted you need to go through
217
220
  # the find_or_create by method to ensure that duplicate entries are not being created. Protecting
218
- # this method causes an exception to be thrown for anyone attempting to use this version of QME with the
221
+ # this method causes an exception to be thrown for anyone attempting to use this version of QME with the
219
222
  # sematics of the older version to highlight the issue.
220
223
  def initialize(attrs = nil)
221
224
  super(attrs)
@@ -225,4 +228,4 @@ module QME
225
228
  Delayed::Job.enqueue(QME::MapReduce::MeasureCalculationJob.new(options), {queue: queue})
226
229
  end
227
230
  end
228
- end
231
+ end
@@ -1,3 +1,3 @@
1
1
  module QME
2
- VERSION = "3.0.3"
2
+ VERSION = "3.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quality-measure-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.1.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Marc Hadley
@@ -12,104 +13,118 @@ authors:
12
13
  autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
- date: 2014-08-27 00:00:00.000000000 Z
16
+ date: 2014-09-17 00:00:00.000000000 Z
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
18
19
  name: moped
19
20
  requirement: !ruby/object:Gem::Requirement
21
+ none: false
20
22
  requirements:
21
- - - "~>"
23
+ - - ~>
22
24
  - !ruby/object:Gem::Version
23
25
  version: 2.0.0
24
26
  type: :runtime
25
27
  prerelease: false
26
28
  version_requirements: !ruby/object:Gem::Requirement
29
+ none: false
27
30
  requirements:
28
- - - "~>"
31
+ - - ~>
29
32
  - !ruby/object:Gem::Version
30
33
  version: 2.0.0
31
34
  - !ruby/object:Gem::Dependency
32
35
  name: mongoid
33
36
  requirement: !ruby/object:Gem::Requirement
37
+ none: false
34
38
  requirements:
35
- - - "~>"
39
+ - - ~>
36
40
  - !ruby/object:Gem::Version
37
41
  version: 4.0.0
38
42
  type: :runtime
39
43
  prerelease: false
40
44
  version_requirements: !ruby/object:Gem::Requirement
45
+ none: false
41
46
  requirements:
42
- - - "~>"
47
+ - - ~>
43
48
  - !ruby/object:Gem::Version
44
49
  version: 4.0.0
45
50
  - !ruby/object:Gem::Dependency
46
51
  name: rubyzip
47
52
  requirement: !ruby/object:Gem::Requirement
53
+ none: false
48
54
  requirements:
49
- - - "~>"
55
+ - - ~>
50
56
  - !ruby/object:Gem::Version
51
57
  version: 0.9.9
52
58
  type: :runtime
53
59
  prerelease: false
54
60
  version_requirements: !ruby/object:Gem::Requirement
61
+ none: false
55
62
  requirements:
56
- - - "~>"
63
+ - - ~>
57
64
  - !ruby/object:Gem::Version
58
65
  version: 0.9.9
59
66
  - !ruby/object:Gem::Dependency
60
67
  name: delayed_job_mongoid
61
68
  requirement: !ruby/object:Gem::Requirement
69
+ none: false
62
70
  requirements:
63
- - - "~>"
71
+ - - ~>
64
72
  - !ruby/object:Gem::Version
65
73
  version: 2.1.0
66
74
  type: :runtime
67
75
  prerelease: false
68
76
  version_requirements: !ruby/object:Gem::Requirement
77
+ none: false
69
78
  requirements:
70
- - - "~>"
79
+ - - ~>
71
80
  - !ruby/object:Gem::Version
72
81
  version: 2.1.0
73
82
  - !ruby/object:Gem::Dependency
74
83
  name: minitest
75
84
  requirement: !ruby/object:Gem::Requirement
85
+ none: false
76
86
  requirements:
77
- - - "~>"
87
+ - - ~>
78
88
  - !ruby/object:Gem::Version
79
89
  version: 5.4.0
80
90
  type: :development
81
91
  prerelease: false
82
92
  version_requirements: !ruby/object:Gem::Requirement
93
+ none: false
83
94
  requirements:
84
- - - "~>"
95
+ - - ~>
85
96
  - !ruby/object:Gem::Version
86
97
  version: 5.4.0
87
98
  - !ruby/object:Gem::Dependency
88
99
  name: simplecov
89
100
  requirement: !ruby/object:Gem::Requirement
101
+ none: false
90
102
  requirements:
91
- - - "~>"
103
+ - - ~>
92
104
  - !ruby/object:Gem::Version
93
105
  version: 0.9.0
94
106
  type: :development
95
107
  prerelease: false
96
108
  version_requirements: !ruby/object:Gem::Requirement
109
+ none: false
97
110
  requirements:
98
- - - "~>"
111
+ - - ~>
99
112
  - !ruby/object:Gem::Version
100
113
  version: 0.9.0
101
114
  - !ruby/object:Gem::Dependency
102
115
  name: rails
103
116
  requirement: !ruby/object:Gem::Requirement
117
+ none: false
104
118
  requirements:
105
- - - "~>"
119
+ - - ~>
106
120
  - !ruby/object:Gem::Version
107
121
  version: 4.1.5
108
122
  type: :development
109
123
  prerelease: false
110
124
  version_requirements: !ruby/object:Gem::Requirement
125
+ none: false
111
126
  requirements:
112
- - - "~>"
127
+ - - ~>
113
128
  - !ruby/object:Gem::Version
114
129
  version: 4.1.5
115
130
  description: A library for running clinical quality measures
@@ -119,8 +134,8 @@ executables: []
119
134
  extensions: []
120
135
  extra_rdoc_files: []
121
136
  files:
122
- - ".gitignore"
123
- - ".travis.yml"
137
+ - .gitignore
138
+ - .travis.yml
124
139
  - Gemfile
125
140
  - Gemfile.lock
126
141
  - LICENSE.txt
@@ -167,26 +182,27 @@ files:
167
182
  - test/unit/qme/quality_report_test.rb
168
183
  homepage: http://www.projectpophealth.org
169
184
  licenses: []
170
- metadata: {}
171
185
  post_install_message:
172
186
  rdoc_options: []
173
187
  require_paths:
174
188
  - lib
175
189
  required_ruby_version: !ruby/object:Gem::Requirement
190
+ none: false
176
191
  requirements:
177
- - - ">="
192
+ - - ! '>='
178
193
  - !ruby/object:Gem::Version
179
194
  version: '0'
180
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
+ none: false
181
197
  requirements:
182
- - - ">="
198
+ - - ! '>='
183
199
  - !ruby/object:Gem::Version
184
200
  version: '0'
185
201
  requirements: []
186
202
  rubyforge_project:
187
- rubygems_version: 2.2.2
203
+ rubygems_version: 1.8.23
188
204
  signing_key:
189
- specification_version: 4
205
+ specification_version: 3
190
206
  summary: This library can run JavaScript based clinical quality measures on a repository
191
207
  of patients stored in MongoDB
192
208
  test_files:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 2ac3f8a80c26556684d7f21bd6201e5265b256eb
4
- data.tar.gz: b8379f12837783c518639ebadb3d21fe7e07546f
5
- SHA512:
6
- metadata.gz: fb88b3fecf9ce6d5cee8f489195ed8e02b5d2a91f8549dd97a417af732d4225aadad6c0d0f1a5fd331736140d19d23821aee251b1f47ae40ee3f56b18334f589
7
- data.tar.gz: 5da3dd5bc12ee8383df188b97d1dfefadd23591daee55674bed0ae2da4ec6a29209c36e3eac2310d6a4e206146bdbec3162f4a35922dbd2881753bdb286bc44c