quality-measure-engine 1.1.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +12 -0
- data/.travis.yml +16 -0
- data/Gemfile +5 -21
- data/Gemfile.lock +126 -0
- data/LICENSE.txt +13 -0
- data/README.md +23 -44
- data/Rakefile +6 -29
- data/lib/qme/bundle/bundle.rb +34 -0
- data/lib/qme/bundle/importer.rb +69 -0
- data/lib/qme/database_access.rb +7 -11
- data/lib/qme/map/map_reduce_builder.rb +4 -1
- data/lib/qme/map/map_reduce_executor.rb +55 -43
- data/lib/qme/map/measure_calculation_job.rb +24 -23
- data/lib/qme/quality_measure.rb +5 -5
- data/lib/qme/quality_report.rb +37 -19
- data/lib/qme/railtie.rb +7 -0
- data/lib/qme/tasks/bundle.rake +14 -0
- data/lib/qme/version.rb +3 -0
- data/lib/quality-measure-engine.rb +13 -25
- data/quality-measure-engine.gemspec +28 -0
- data/test/fixtures/bundles/just_measure_0002.zip +0 -0
- data/test/fixtures/delayed_backend_mongoid_jobs/queued_job.json +9 -0
- data/test/fixtures/measures/measure_metadata.json +52 -0
- data/test/fixtures/records/barry_berry.json +471 -0
- data/test/fixtures/records/billy_jones_ipp.json +78 -0
- data/test/fixtures/records/jane_jones_numerator.json +120 -0
- data/test/fixtures/records/jill_jones_denominator.json +78 -0
- data/test/simplecov_setup.rb +18 -0
- data/test/test_helper.rb +26 -0
- data/test/unit/qme/map/map_reduce_builder_test.rb +38 -0
- data/test/unit/qme/map/map_reduce_executor_test.rb +56 -0
- data/test/unit/qme/map/measure_calculation_job_test.rb +22 -0
- data/test/unit/qme/quality_measure_test.rb +14 -0
- data/{spec/qme/quality_report_spec.rb → test/unit/qme/quality_report_test.rb} +32 -20
- metadata +91 -115
- data/VERSION +0 -1
- data/js/map_reduce_utils.js +0 -173
- data/js/underscore_min.js +0 -25
- data/lib/qme/ext/record.rb +0 -43
- data/lib/qme/importer/entry.rb +0 -126
- data/lib/qme/importer/generic_importer.rb +0 -117
- data/lib/qme/importer/measure_properties_generator.rb +0 -39
- data/lib/qme/importer/property_matcher.rb +0 -110
- data/lib/qme/measure/database_loader.rb +0 -83
- data/lib/qme/measure/measure_loader.rb +0 -174
- data/lib/qme/measure/properties_builder.rb +0 -184
- data/lib/qme/measure/properties_converter.rb +0 -27
- data/lib/qme/randomizer/patient_randomization_job.rb +0 -47
- data/lib/qme/randomizer/patient_randomizer.rb +0 -250
- data/lib/qme/randomizer/random_patient_creator.rb +0 -47
- data/lib/qme_test.rb +0 -13
- data/lib/tasks/fixtures.rake +0 -91
- data/lib/tasks/measure.rake +0 -110
- data/lib/tasks/mongo.rake +0 -68
- data/lib/tasks/patient_random.rake +0 -45
- data/spec/qme/bundle_spec.rb +0 -37
- data/spec/qme/importer/generic_importer_spec.rb +0 -73
- data/spec/qme/importer/measure_properties_generator_spec.rb +0 -15
- data/spec/qme/importer/property_matcher_spec.rb +0 -174
- data/spec/qme/map/map_reduce_builder_spec.rb +0 -38
- data/spec/qme/map/measures_spec.rb +0 -38
- data/spec/qme/map/patient_mapper_spec.rb +0 -11
- data/spec/qme/measure_loader_spec.rb +0 -12
- data/spec/qme/properties_builder_spec.rb +0 -61
- data/spec/spec_helper.rb +0 -120
- data/spec/validate_measures_spec.rb +0 -21
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,23 +1,7 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
3
|
+
# Specify your gem's dependencies in quality-measure-engine.gemspec
|
4
|
+
gemspec
|
4
5
|
|
5
|
-
gem '
|
6
|
-
gem '
|
7
|
-
gem 'rake'
|
8
|
-
#gem 'pry', :require => true
|
9
|
-
#gem 'health-data-standards', :git => 'https://github.com/projectcypress/health-data-standards.git', :branch => 'develop'
|
10
|
-
gem 'health-data-standards', '1.0.1'
|
11
|
-
|
12
|
-
# does not work with redis 3.0
|
13
|
-
gem 'redis', '~> 2.2.2'
|
14
|
-
|
15
|
-
group :test do
|
16
|
-
gem 'cover_me', '>= 1.0.0.rc5', :platforms => :ruby_19
|
17
|
-
gem 'sinatra'
|
18
|
-
end
|
19
|
-
|
20
|
-
group :build do
|
21
|
-
gem 'yard'
|
22
|
-
gem 'kramdown' # needed by yard
|
23
|
-
end
|
6
|
+
gem 'pry'
|
7
|
+
gem 'pry-nav'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
quality-measure-engine (2.0.0)
|
5
|
+
delayed_job_mongoid (~> 2.0.0)
|
6
|
+
mongoid (~> 3.0.9)
|
7
|
+
moped (~> 1.2.7)
|
8
|
+
rubyzip (~> 0.9.9)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionmailer (3.2.8)
|
14
|
+
actionpack (= 3.2.8)
|
15
|
+
mail (~> 2.4.4)
|
16
|
+
actionpack (3.2.8)
|
17
|
+
activemodel (= 3.2.8)
|
18
|
+
activesupport (= 3.2.8)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
erubis (~> 2.7.0)
|
21
|
+
journey (~> 1.0.4)
|
22
|
+
rack (~> 1.4.0)
|
23
|
+
rack-cache (~> 1.2)
|
24
|
+
rack-test (~> 0.6.1)
|
25
|
+
sprockets (~> 2.1.3)
|
26
|
+
activemodel (3.2.8)
|
27
|
+
activesupport (= 3.2.8)
|
28
|
+
builder (~> 3.0.0)
|
29
|
+
activerecord (3.2.8)
|
30
|
+
activemodel (= 3.2.8)
|
31
|
+
activesupport (= 3.2.8)
|
32
|
+
arel (~> 3.0.2)
|
33
|
+
tzinfo (~> 0.3.29)
|
34
|
+
activeresource (3.2.8)
|
35
|
+
activemodel (= 3.2.8)
|
36
|
+
activesupport (= 3.2.8)
|
37
|
+
activesupport (3.2.8)
|
38
|
+
i18n (~> 0.6)
|
39
|
+
multi_json (~> 1.0)
|
40
|
+
arel (3.0.2)
|
41
|
+
builder (3.0.4)
|
42
|
+
coderay (1.0.8)
|
43
|
+
delayed_job (3.0.3)
|
44
|
+
activesupport (~> 3.0)
|
45
|
+
delayed_job_mongoid (2.0.0)
|
46
|
+
delayed_job (~> 3.0)
|
47
|
+
mongoid (~> 3.0)
|
48
|
+
erubis (2.7.0)
|
49
|
+
hike (1.2.1)
|
50
|
+
i18n (0.6.1)
|
51
|
+
journey (1.0.4)
|
52
|
+
json (1.7.5)
|
53
|
+
mail (2.4.4)
|
54
|
+
i18n (>= 0.4.0)
|
55
|
+
mime-types (~> 1.16)
|
56
|
+
treetop (~> 1.4.8)
|
57
|
+
method_source (0.8.1)
|
58
|
+
mime-types (1.19)
|
59
|
+
minitest (4.1.0)
|
60
|
+
mongoid (3.0.10)
|
61
|
+
activemodel (~> 3.1)
|
62
|
+
moped (~> 1.1)
|
63
|
+
origin (~> 1.0)
|
64
|
+
tzinfo (~> 0.3.22)
|
65
|
+
moped (1.2.7)
|
66
|
+
multi_json (1.3.6)
|
67
|
+
origin (1.0.9)
|
68
|
+
polyglot (0.3.3)
|
69
|
+
pry (0.9.10)
|
70
|
+
coderay (~> 1.0.5)
|
71
|
+
method_source (~> 0.8)
|
72
|
+
slop (~> 3.3.1)
|
73
|
+
pry-nav (0.2.2)
|
74
|
+
pry (~> 0.9.10)
|
75
|
+
rack (1.4.1)
|
76
|
+
rack-cache (1.2)
|
77
|
+
rack (>= 0.4)
|
78
|
+
rack-ssl (1.3.2)
|
79
|
+
rack
|
80
|
+
rack-test (0.6.2)
|
81
|
+
rack (>= 1.0)
|
82
|
+
rails (3.2.8)
|
83
|
+
actionmailer (= 3.2.8)
|
84
|
+
actionpack (= 3.2.8)
|
85
|
+
activerecord (= 3.2.8)
|
86
|
+
activeresource (= 3.2.8)
|
87
|
+
activesupport (= 3.2.8)
|
88
|
+
bundler (~> 1.0)
|
89
|
+
railties (= 3.2.8)
|
90
|
+
railties (3.2.8)
|
91
|
+
actionpack (= 3.2.8)
|
92
|
+
activesupport (= 3.2.8)
|
93
|
+
rack-ssl (~> 1.3.2)
|
94
|
+
rake (>= 0.8.7)
|
95
|
+
rdoc (~> 3.4)
|
96
|
+
thor (>= 0.14.6, < 2.0)
|
97
|
+
rake (0.9.2.2)
|
98
|
+
rdoc (3.12)
|
99
|
+
json (~> 1.4)
|
100
|
+
rubyzip (0.9.9)
|
101
|
+
simplecov (0.7.1)
|
102
|
+
multi_json (~> 1.0)
|
103
|
+
simplecov-html (~> 0.7.1)
|
104
|
+
simplecov-html (0.7.1)
|
105
|
+
slop (3.3.3)
|
106
|
+
sprockets (2.1.3)
|
107
|
+
hike (~> 1.2)
|
108
|
+
rack (~> 1.0)
|
109
|
+
tilt (~> 1.1, != 1.3.0)
|
110
|
+
thor (0.16.0)
|
111
|
+
tilt (1.3.3)
|
112
|
+
treetop (1.4.12)
|
113
|
+
polyglot
|
114
|
+
polyglot (>= 0.3.1)
|
115
|
+
tzinfo (0.3.34)
|
116
|
+
|
117
|
+
PLATFORMS
|
118
|
+
ruby
|
119
|
+
|
120
|
+
DEPENDENCIES
|
121
|
+
minitest (~> 4.1.0)
|
122
|
+
pry
|
123
|
+
pry-nav
|
124
|
+
quality-measure-engine!
|
125
|
+
rails (~> 3.2.8)
|
126
|
+
simplecov (~> 0.7.1)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012 The MITRE Corporation
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -1,14 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Usage
|
4
|
-
=====
|
5
|
-
|
6
|
-
Extracting Measure Data from a HITSP C32
|
7
|
-
----------------------------------------
|
8
|
-
|
9
|
-
Each quality measure will need to extract specific information from a HITSP C32 for calculation. First, for each quality measure, a QME::Importer::GenericImporter should be created by passing in the JSON definition of the quality measure.
|
1
|
+
Quality Measure Engine
|
2
|
+
----------------------
|
10
3
|
|
11
|
-
|
4
|
+
This project is a library designed to calculate clinical quality measures over a given population. Quality measures are described via JSON and provide the details on what information is needed from a patient record to calculate a quality measure. The logic of the measure is described in JavaScript using the MapReduce algorithmic framework.
|
12
5
|
|
13
6
|
Calculating Quality Measures
|
14
7
|
----------------------------
|
@@ -18,7 +11,7 @@ Results of quality measures are represented by QME::QualityReport. This class pr
|
|
18
11
|
Environment
|
19
12
|
===========
|
20
13
|
|
21
|
-
This project currently uses Ruby 1.9.
|
14
|
+
This project currently uses Ruby 1.9.3 and is built using [Bundler](http://gembundler.com/). To get all of the dependencies for the project, first install bundler:
|
22
15
|
|
23
16
|
gem install bundler
|
24
17
|
|
@@ -26,7 +19,7 @@ Then run bundler to grab all of the necessary gems:
|
|
26
19
|
|
27
20
|
bundle install
|
28
21
|
|
29
|
-
The Quality Measure engine relies on a MongoDB [MongoDB](http://www.mongodb.org/) running a minimum of version
|
22
|
+
The Quality Measure engine relies on a MongoDB [MongoDB](http://www.mongodb.org/) running a minimum of version 2.2.* or higher. To get and install Mongo refer to:
|
30
23
|
|
31
24
|
http://www.mongodb.org/display/DOCS/Quickstart
|
32
25
|
|
@@ -46,44 +39,30 @@ QME::QualityReport will kick off background jobs with Resque. For these jobs to
|
|
46
39
|
Testing
|
47
40
|
=======
|
48
41
|
|
49
|
-
This project uses [
|
50
|
-
|
51
|
-
bundle exec rake spec
|
52
|
-
|
53
|
-
The coverage of the test suite is monitored with [cover_me](https://github.com/markbates/cover_me) and can be run with:
|
54
|
-
|
55
|
-
bundle exec rake coverage
|
42
|
+
This project uses [minitest](https://github.com/seattlerb/minitest) for testing. To run the suite, just enter the following:
|
56
43
|
|
57
|
-
|
58
|
-
------------------
|
44
|
+
bundle exec rake test
|
59
45
|
|
60
|
-
|
61
|
-
Debugging JavaScript that is to be run inside of MongoDB can be a bit of a chore, so there is a testing tool that can be run
|
62
|
-
in your browser to aid in troubleshooting.
|
46
|
+
The coverage of the test suite is monitored with [cover_me](https://github.com/markbates/cover_me). You can see the code coverage by looking in the coverage directory after running the test suite
|
63
47
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
bundle exec ruby map_test/map_test.rb
|
68
|
-
|
69
|
-
After running this command, you can open your browser to [http://localhost:4567](http://localhost:4567). This will show you a page
|
70
|
-
of measures to choose from. Once you have selected a measure, it will take you to a page where you can choose the map function you
|
71
|
-
want to test and the effective date you want to run the function with. Once that is selected, you will arrive at the map test page.
|
72
|
-
The map test page provides the ability to load test JSON records from within the project. Once they are loaded, they can be edited
|
73
|
-
in the textarea on the page. Finally, if you click the "run" button, it will execute the map function on the record in the text area
|
74
|
-
and output the results. Since this is executing in a web browser, you can use the JavaScript debugging utilities provided to set
|
75
|
-
breakpoints and inspect variables.
|
48
|
+
Project Practices
|
49
|
+
=================
|
76
50
|
|
77
|
-
|
78
|
-
--------------------
|
51
|
+
Please try to follow our [Coding Style Guides](http://github.com/eedrummer/styleguide). Additionally, we will be using git in a pattern similar to [Vincent Driessen's workflow](http://nvie.com/posts/a-successful-git-branching-model/). While feature branches are encouraged, they are not required to work on the project.
|
79
52
|
|
80
|
-
|
53
|
+
License
|
54
|
+
=======
|
81
55
|
|
82
|
-
|
56
|
+
Copyright 2012 The MITRE Corporation
|
83
57
|
|
84
|
-
|
58
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
59
|
+
you may not use this file except in compliance with the License.
|
60
|
+
You may obtain a copy of the License at
|
85
61
|
|
86
|
-
|
87
|
-
=================
|
62
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
88
63
|
|
89
|
-
|
64
|
+
Unless required by applicable law or agreed to in writing, software
|
65
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
66
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
67
|
+
See the License for the specific language governing permissions and
|
68
|
+
limitations under the License.
|
data/Rakefile
CHANGED
@@ -1,31 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require '
|
3
|
-
require 'resque/tasks'
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rake/testtask'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
load ext
|
10
|
-
end
|
11
|
-
|
12
|
-
RSpec::Core::RakeTask.new do |t|
|
13
|
-
t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
|
14
|
-
t.pattern = 'spec/**/*_spec.rb'
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.test_files = FileList['test/**/*_test.rb']
|
7
|
+
t.verbose = true
|
15
8
|
end
|
16
|
-
|
17
|
-
YARD::Rake::YardocTask.new
|
18
|
-
|
19
|
-
namespace :cover_me do
|
20
|
-
|
21
|
-
task :report do
|
22
|
-
require 'cover_me'
|
23
|
-
CoverMe.complete!
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
task :coverage do
|
29
|
-
Rake::Task['spec'].invoke
|
30
|
-
Rake::Task['cover_me:report'].invoke
|
31
|
-
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module QME
|
2
|
+
module Bundle
|
3
|
+
# Delete a list of collections. By default, this function drops all of collections related to measures and patients.
|
4
|
+
#
|
5
|
+
# @param [Array] collection_names Optionally, an array of collection names to be dropped.
|
6
|
+
def self.drop_collections(db, collection_names=[])
|
7
|
+
collection_names = ["bundles", "records", "measures", "selected_measures", "patient_cache", "query_cache", "system.js"] if collection_names.empty?
|
8
|
+
collection_names.each {|collection| db[collection].drop}
|
9
|
+
end
|
10
|
+
|
11
|
+
# Save a javascript function into Mongo's system.js collection for measure execution.
|
12
|
+
#
|
13
|
+
# @param [String] name The name by which the function will be referred.
|
14
|
+
# @param [String] fn The body of the function being saved.
|
15
|
+
def self.save_system_js_fn(db, name, fn)
|
16
|
+
fn = "function () {\n #{fn} \n }"
|
17
|
+
db['system.js'].find('_id' => name).upsert(
|
18
|
+
{
|
19
|
+
"_id" => name,
|
20
|
+
"value" => Moped::BSON::Code.new(fn)
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
# A utility function for finding files in a bundle. Strip a file path of it's extension and just give the filename.
|
26
|
+
#
|
27
|
+
# @param [String] original A file path.
|
28
|
+
# @param [String] extension A file extension.
|
29
|
+
# @return The filename at the end of the original String path with the extension removed. e.g. "/boo/urns.html" -> "urns"
|
30
|
+
def self.entry_key(original, extension)
|
31
|
+
original.split('/').last.gsub(".#{extension}", '')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module QME
|
2
|
+
module Bundle
|
3
|
+
class Importer
|
4
|
+
include QME::DatabaseAccess
|
5
|
+
|
6
|
+
# Create a new Importer.
|
7
|
+
# @param [String] db_name the name of the database to use
|
8
|
+
def initialize(db_name = nil)
|
9
|
+
determine_connection_information(db_name)
|
10
|
+
@db = get_db
|
11
|
+
end
|
12
|
+
|
13
|
+
# Import a quality bundle into the database. This includes metadata, measures, test patients, supporting JS libraries, and expected results.
|
14
|
+
#
|
15
|
+
# @param [File] zip The bundle zip file.
|
16
|
+
# @param [Boolean] keep_existing If true, delete all current collections related to patients and measures.
|
17
|
+
def import(zip, delete_existing)
|
18
|
+
Bundle.drop_collections(@db) if delete_existing
|
19
|
+
|
20
|
+
# Unpack content from the bundle.
|
21
|
+
bundle_contents = { bundle: nil, measures: {}, patients: {}, extensions: {}, results: {} }
|
22
|
+
Zip::ZipFile.open(zip.path) do |zipfile|
|
23
|
+
zipfile.entries.each do |entry|
|
24
|
+
bundle_contents[:bundle] = zipfile.read(entry.name) if entry.name.include? "bundle"
|
25
|
+
bundle_contents[:measures][Bundle.entry_key(entry.name, "json")] = zipfile.read(entry.name) if entry.name.match /^measures.*\.json$/
|
26
|
+
bundle_contents[:patients][Bundle.entry_key(entry.name, "json")] = zipfile.read(entry.name) if entry.name.match /^patients.*\.json$/ # Only need to import one of the formats
|
27
|
+
bundle_contents[:extensions][Bundle.entry_key(entry.name,"js")] = zipfile.read(entry.name) if entry.name.match /^library_functions/
|
28
|
+
bundle_contents[:results][Bundle.entry_key(entry.name,"json")] = zipfile.read(entry.name) if entry.name.match /^results/
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Store all JS libraries.
|
33
|
+
bundle_contents[:extensions].each do |key, contents|
|
34
|
+
Bundle.save_system_js_fn(@db, key, contents)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Store the bundle metadata.
|
38
|
+
bundle_id = Moped::BSON::ObjectId.new()
|
39
|
+
bundle = JSON.parse(bundle_contents[:bundle])
|
40
|
+
bundle["_id"] = bundle_id
|
41
|
+
@db['bundles'].insert(bundle)
|
42
|
+
|
43
|
+
# Store all measures.
|
44
|
+
bundle_contents[:measures].each do |key, contents|
|
45
|
+
measure_id = Moped::BSON::ObjectId.new()
|
46
|
+
measure = JSON.parse(contents, {:max_nesting => 100})
|
47
|
+
measure['_id'] = measure_id
|
48
|
+
measure['bundle'] = bundle_id
|
49
|
+
@db['measures'].insert(measure)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Store all patients.
|
53
|
+
bundle_id = Moped::BSON::ObjectId(bundle_id.to_s)
|
54
|
+
bundle_contents[:patients].each do |key, contents|
|
55
|
+
patient = JSON.parse(contents, {:max_nesting => 100})
|
56
|
+
patient['bundle'] = bundle_id
|
57
|
+
Record.new(patient).save
|
58
|
+
end
|
59
|
+
|
60
|
+
# Store the expected results into the query and patient caches.
|
61
|
+
bundle_contents[:results].each do |name, contents|
|
62
|
+
collection = name == "by_patient" ? "patient_cache" : "query_cache"
|
63
|
+
contents = JSON.parse(contents, {:max_nesting => 100})
|
64
|
+
contents.each {|document| @db[collection].insert(document)}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/qme/database_access.rb
CHANGED
@@ -10,22 +10,18 @@ module QME
|
|
10
10
|
@db_host = ENV['TEST_DB_HOST'] || 'localhost'
|
11
11
|
@db_port = ENV['TEST_DB_PORT'] ? ENV['TEST_DB_PORT'].to_i : 27017
|
12
12
|
end
|
13
|
-
|
14
|
-
# Directly inject an instance of a database
|
15
|
-
# @param [Mongo::Database] db the database that you would like the object to use
|
16
|
-
def inject_db(db)
|
17
|
-
@db = db
|
18
|
-
end
|
19
13
|
|
20
14
|
# Lazily creates a connection to the database and initializes the
|
21
15
|
# JavaScript environment
|
22
|
-
# @return [
|
16
|
+
# @return [Moped::Session]
|
23
17
|
def get_db
|
24
18
|
if @db == nil
|
25
|
-
@
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
if @db_name==nil || @db_host==nil || @db_port==nil
|
20
|
+
determine_connection_information()
|
21
|
+
end
|
22
|
+
|
23
|
+
@db = Moped::Session.new(["#{@db_host}:#{@db_port}"])
|
24
|
+
@db.use(@db_name)
|
29
25
|
end
|
30
26
|
|
31
27
|
@db
|