lib/qme/map/map_reduce_builder.rb in quality-measure-engine-0.2.0 vs lib/qme/map/map_reduce_builder.rb in quality-measure-engine-0.8.0
- old
+ new
@@ -29,22 +29,13 @@
# collection of the current database (used by the Rails Web application).
def init_js_frameworks
result = ''
result << 'if (typeof(map)=="undefined") {'
result << "\n"
- Dir.glob(File.join(File.dirname(__FILE__), '../../../js/*.js')).each do |js_file|
- result << File.read(js_file)
- result << "\n"
- end
- Dir.glob(File.join('./js/*.js')).each do |js_file|
- result << File.read(js_file)
- result << "\n"
- end
@db['bundles'].find.each do |bundle|
(bundle['extensions'] || []).each do |ext|
- result << ext
- result << "\n"
+ result << "#{ext}();\n"
end
end
result << "}\n"
result
end
@@ -87,11 +78,22 @@
# Get the reduce function for the measure, this is a simple
# wrapper for the reduce utility function specified in
# map-reduce-utils.js
# @return [String] the reduce function
- def reduce_function
- 'function (key, values) { return reduce(key, values);};'
+ def finalize_function
+ reduce =
+ "function (key, value) {
+ var patient = value;
+ patient.measure_id = \"#{@measure_def['id']}\";\n"
+ if @measure_def['sub_id']
+ reduce += " patient.sub_id = \"#{@measure_def['sub_id']}\";\n"
+ end
+
+ reduce += "patient.effective_date = #{@params['effective_date']};
+ return patient;}"
+
+ reduce
end
end
end
\ No newline at end of file