Class: QME::MapReduce::MeasureCalculationJob
- Inherits:
-
Resque::JobWithStatus
- Object
- Resque::JobWithStatus
- QME::MapReduce::MeasureCalculationJob
- Defined in:
- lib/qme/map/measure_calculation_job.rb
Overview
A Resque job that allows for measure calculation by a Resque worker. Can be created as follows:
MapReduce::MeasureCalculationJob.create(:measure_id => '0221', :sub_id => 'a', :effective_date => 1291352400, :test_id => xyzzy)
This will return a uuid which can be used to check in on the status of a job. More details on this can be found at the Resque Stats project page.
MeasureCalculationJob will check to see if a measure has been calculated before running the calculation. It does this by creating a QME::QualityReport and asking if it has been calculated. If so, it will complete the job without running the MapReduce job.
When a measure needs calculation, the job will create a QME::MapReduce::Executor and interact with it to calculate the report.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.calculate(options) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/qme/map/measure_calculation_job.rb', line 21 def self.calculate() test_id = ['test_id'] ? BSON::ObjectId(['test_id']) : nil qr = QualityReport.new(['measure_id'], ['sub_id'], 'effective_date' => ['effective_date'], 'test_id' => test_id, 'filters' => ['filters']) if qr.calculated? completed("#{['measure_id']}#{['sub_id']} has already been calculated") if respond_to? :completed else map = QME::MapReduce::Executor.new(['measure_id'], ['sub_id'], 'effective_date' => ['effective_date'], 'test_id' => test_id, 'filters' => ['filters'], 'start_time' => Time.now.to_i) if !qr.patients_cached? tick('Starting MapReduce') if respond_to? :tick map.map_records_into_measure_groups tick('MapReduce complete') if respond_to? :tick end tick('Calculating group totals') if respond_to? :tick result = map.count_records_in_measure_groups completed("#{['measure_id']}#{['sub_id']}: p#{result['population']}, d#{result['denominator']}, n#{result['numerator']}, e#{result['exclusions']}") if respond_to? :completed end end |
Instance Method Details
#perform ⇒ Object
17 18 19 |
# File 'lib/qme/map/measure_calculation_job.rb', line 17 def perform MeasureCalculationJob.calculate() end |