diff --git a/.gitignore b/.gitignore index 226fa9a..98109f1 100755 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,8 @@ coverage/ public/assets spec/javascripts/generated/* log/ -spec/generated \ No newline at end of file +spec/generated +.idea +monitoring/nagios-config/ +monitoring/nagios-nrpe-server-config/ +generate_nagios3_config.sh~ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..25b5b81 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: ruby +rvm: + - 1.9.3 +branches: + only: + - master +services: + - mongodb +notifications: + email: false +script: bundle exec rake test:units test:functionals test:integration diff --git a/Gemfile b/Gemfile index 9a0e18a..488cda6 100755 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,6 @@ -source :rubygems - -gem 'rails' - -# Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' +source 'https://rubygems.org' +gem 'rails', '=3.2.13' # Gems used only for assets and not required # in production environments by default. group :assets do @@ -13,38 +9,44 @@ group :assets do gem 'uglifier' end -gem 'jquery-rails' +gem 'daemons' +gem 'jquery-rails', '=1.0.19' gem 'sprockets' -gem 'bson_ext', :platforms => :mri -gem "mongoid" +gem 'webrick', '1.3.1' + +gem 'mongoid' gem 'mongoid_rails_migrations' + gem 'simple_form' + gem 'multipart-post' gem 'delayed_job' -gem 'delayed_job_mongoid', :git => 'https://github.com/collectiveidea/delayed_job_mongoid.git' -gem 'hquery-patient-api', :git => 'http://github.com/hquery/patientapi.git', :tag => 'V0.2' +gem 'delayed_job_mongoid' + +gem 'hquery-patient-api', :git => 'https://github.com/scoophealth/patientapi.git', :branch => 'master' + +gem 'coderay' + gem 'devise' gem 'cancan' gem 'pry' gem 'kramdown' gem 'jasmine', :group => [:development, :test] gem 'headless', :group => [:development, :test] -gem 'coderay' -gem 'quality-measure-engine', :git => 'http://github.com/pophealth/quality-measure-engine.git', :branch => 'develop' - +gem 'parallel' # To use debugger # gem 'ruby-debug19', :require => 'ruby-debug' group :test do # Pretty printed test output + gem 'minitest', '< 5.0.0' gem 'turn', :require => false - gem 'cover_me', '>= 1.0.0.rc6' - gem 'minitest' + gem 'cover_me', '>= 1.0.0.rc6', :platforms => :ruby + gem 'factory_girl' gem 'fakeweb' + gem 'mocha', :require => false gem 'therubyracer', :platforms => :ruby gem 'therubyrhino', :platforms => :jruby - gem 'factory_girl' - gem 'mocha', :require => false end diff --git a/Gemfile.lock b/Gemfile.lock index fb4bac3..1ad8d7a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,304 +1,299 @@ GIT - remote: http://github.com/hquery/patientapi.git - revision: e26c6c7e0679987f2afbb5e4a7693fd025c0d61f - tag: V0.2 + remote: https://github.com/scoophealth/patientapi.git + revision: 8cfb50a53396180b652737f406d5cc2d9e5e3cb5 + branch: master specs: - hquery-patient-api (0.1.0) - -GIT - remote: http://github.com/pophealth/quality-measure-engine.git - revision: 6573859d0d8ca8d76e6dc2f0d4d15181c8457c61 - branch: develop - specs: - quality-measure-engine (1.0.4) - mongo (~> 1.3) - nokogiri (~> 1.4.4) - resque (~> 1.15.0) - resque-status (~> 0.2.3) - rubyzip (~> 0.9.4) - -GIT - remote: https://github.com/collectiveidea/delayed_job_mongoid.git - revision: c8816d7eecb3e2ba61b878d45b90625a63cbc0d4 - specs: - delayed_job_mongoid (1.0.7) - delayed_job (~> 3.0.0.pre) - mongoid (>= 2.0) + hquery-patient-api (1.0.5) GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - actionmailer (3.1.3) - actionpack (= 3.1.3) - mail (~> 2.3.0) - actionpack (3.1.3) - activemodel (= 3.1.3) - activesupport (= 3.1.3) + actionmailer (3.2.13) + actionpack (= 3.2.13) + mail (~> 2.5.3) + actionpack (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) builder (~> 3.0.0) erubis (~> 2.7.0) - i18n (~> 0.6) - rack (~> 1.3.5) - rack-cache (~> 1.1) - rack-mount (~> 0.8.2) + journey (~> 1.0.4) + rack (~> 1.4.5) + rack-cache (~> 1.2) rack-test (~> 0.6.1) - sprockets (~> 2.0.3) - activemodel (3.1.3) - activesupport (= 3.1.3) + sprockets (~> 2.2.1) + activemodel (3.2.13) + activesupport (= 3.2.13) builder (~> 3.0.0) - i18n (~> 0.6) - activerecord (3.1.3) - activemodel (= 3.1.3) - activesupport (= 3.1.3) - arel (~> 2.2.1) + activerecord (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) + arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.1.3) - activemodel (= 3.1.3) - activesupport (= 3.1.3) - activesupport (3.1.3) + activeresource (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) + activesupport (3.2.13) + i18n (= 0.6.1) multi_json (~> 1.0) - ansi (1.4.1) - arel (2.2.1) - bcrypt-ruby (3.0.1) - bcrypt-ruby (3.0.1-java) - bcrypt-ruby (3.0.1-x86-mingw32) - bson (1.5.2) - bson (1.5.2-java) - bson_ext (1.5.2) - bson (= 1.5.2) - builder (3.0.0) - cancan (1.6.7) - childprocess (0.2.3) - ffi (~> 1.0.6) - coderay (1.0.4) - coffee-rails (3.1.1) + ansi (1.4.3) + arel (3.0.3) + bcrypt-ruby (3.1.1) + builder (3.0.4) + cancan (1.6.10) + childprocess (0.3.9) + ffi (~> 1.0, >= 1.0.11) + coderay (1.0.9) + coffee-rails (3.2.2) coffee-script (>= 2.2.0) - railties (~> 3.1.0) + railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.1.3) - configatron (2.9.0) + coffee-script-source (1.6.3) + configatron (2.13.0) yamler (>= 0.1.0) - cover_me (1.2.0) + cover_me (1.1.2) configatron hashie - daemons (1.0.10) - delayed_job (3.0.0.pre4) + daemons (1.1.9) + delayed_job (3.0.5) activesupport (~> 3.0) - daemons (= 1.0.10) - devise (1.5.2) + delayed_job_mongoid (2.0.0) + delayed_job (~> 3.0) + mongoid (~> 3.0) + devise (2.2.4) bcrypt-ruby (~> 3.0) - orm_adapter (~> 0.0.3) - warden (~> 1.1) - diff-lcs (1.1.3) + orm_adapter (~> 0.1) + railties (~> 3.1) + warden (~> 1.2.1) + diff-lcs (1.2.4) erubis (2.7.0) - execjs (1.2.12) + execjs (1.4.0) multi_json (~> 1.0) - factory_girl (2.3.2) - activesupport + factory_girl (4.2.0) + activesupport (>= 3.0.0) fakeweb (1.3.0) - ffi (1.0.11) - ffi (1.0.11-java) - hashie (1.2.0) - headless (0.2.2) - hike (1.2.1) - i18n (0.6.0) - jasmine (1.1.2) - jasmine-core (>= 1.1.0) - rack (>= 1.1) + ffi (1.9.0) + hashie (2.0.5) + headless (1.0.1) + hike (1.2.3) + i18n (0.6.1) + jasmine (1.3.2) + jasmine-core (~> 1.3.1) + rack (~> 1.0) rspec (>= 1.3.1) selenium-webdriver (>= 0.1.3) - jasmine-core (1.1.0) + jasmine-core (1.3.1) + journey (1.0.4) jquery-rails (1.0.19) railties (~> 3.0) thor (~> 0.14) - json (1.4.6) - json (1.4.6-java) - kramdown (0.13.3) - libv8 (3.3.10.4) - macaddr (1.5.0) - systemu (>= 2.4.0) - mail (2.3.0) - i18n (>= 0.4.0) + json (1.8.1) + kramdown (1.1.0) + libv8 (3.11.8.17) + mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.1) - method_source (0.6.7) - ruby_parser (>= 2.3.1) - mime-types (1.17.2) - minitest (2.9.1) - mocha (0.10.0) + method_source (0.8.1) + mime-types (1.25.1) + minitest (4.7.5) + mocha (0.14.0) metaclass (~> 0.0.1) - mongo (1.5.2) - bson (= 1.5.2) - mongoid (2.3.4) - activemodel (~> 3.1) - mongo (~> 1.3) + mongoid (3.1.4) + activemodel (~> 3.2) + moped (~> 1.4) + origin (~> 1.0) tzinfo (~> 0.3.22) - mongoid_rails_migrations (0.0.14) - activesupport (>= 3.0.0) + mongoid_rails_migrations (1.0.1) + activesupport (>= 3.2.0) bundler (>= 1.0.0) - rails (>= 3.0.0) - railties (>= 3.0.0) - multi_json (1.0.4) - multipart-post (1.1.4) - nokogiri (1.4.7) - nokogiri (1.4.7-java) - weakling (>= 0.0.3) - nokogiri (1.4.7-x86-mingw32) - orm_adapter (0.0.5) - polyglot (0.3.3) - pry (0.9.6) - coderay (>= 0.9.8) - method_source (>= 0.6.5) - ruby_parser (>= 2.0.5) - slop (~> 2.1.0) - pry (0.9.6-java) - coderay (>= 0.9.8) - method_source (>= 0.6.5) - ruby_parser (>= 2.0.5) - slop (~> 2.1.0) - spoon (>= 0.0.1) - pry (0.9.6-x86-mingw32) - coderay (>= 0.9.8) - method_source (>= 0.6.5) - ruby_parser (>= 2.0.5) - slop (~> 2.1.0) - win32console (>= 1.3.0) - rack (1.3.5) - rack-cache (1.1) + rails (>= 3.2.0) + railties (>= 3.2.0) + moped (1.5.0) + multi_json (1.10.1) + multipart-post (1.2.0) + origin (1.1.0) + orm_adapter (0.4.0) + parallel (1.0.0) + polyglot (0.3.5) + pry (0.9.12.2) + coderay (~> 1.0.5) + method_source (~> 0.8) + slop (~> 3.4) + rack (1.4.5) + rack-cache (1.2) rack (>= 0.4) - rack-mount (0.8.3) - rack (>= 1.0.0) - rack-protection (1.1.4) + rack-ssl (1.3.4) rack - rack-ssl (1.3.2) - rack - rack-test (0.6.1) + rack-test (0.6.2) rack (>= 1.0) - rails (3.1.3) - actionmailer (= 3.1.3) - actionpack (= 3.1.3) - activerecord (= 3.1.3) - activeresource (= 3.1.3) - activesupport (= 3.1.3) + rails (3.2.13) + actionmailer (= 3.2.13) + actionpack (= 3.2.13) + activerecord (= 3.2.13) + activeresource (= 3.2.13) + activesupport (= 3.2.13) bundler (~> 1.0) - railties (= 3.1.3) - railties (3.1.3) - actionpack (= 3.1.3) - activesupport (= 3.1.3) + railties (= 3.2.13) + railties (3.2.13) + actionpack (= 3.2.13) + activesupport (= 3.2.13) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) - thor (~> 0.14.6) - rake (0.9.2.2) - rdoc (3.11) + thor (>= 0.14.6, < 2.0) + rake (10.3.2) + rdoc (3.12.2) json (~> 1.4) - redis (2.2.2) - redis-namespace (1.1.0) - redis (< 3.0.0) - redisk (0.2.2) - redis (>= 0.1.1) - redis-namespace (>= 0.1.0) - resque (1.15.0) - json (~> 1.4.6) - redis-namespace (>= 0.10.0) - sinatra (>= 0.9.2) - vegas (~> 0.1.2) - resque-status (0.2.4) - redisk (>= 0.2.1) - resque (>= 1.3.1) - uuid (>= 2.0.2) - rspec (2.7.0) - rspec-core (~> 2.7.0) - rspec-expectations (~> 2.7.0) - rspec-mocks (~> 2.7.0) - rspec-core (2.7.1) - rspec-expectations (2.7.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.7.0) - ruby_parser (2.3.1) - sexp_processor (~> 3.0) - rubyzip (0.9.5) - sass (3.1.11) - sass-rails (3.1.5) - actionpack (~> 3.1.0) - railties (~> 3.1.0) - sass (~> 3.1.10) - tilt (~> 1.3.2) - selenium-webdriver (2.15.0) - childprocess (>= 0.2.1) - ffi (~> 1.0.9) - multi_json (~> 1.0.4) + ref (1.0.5) + rspec (2.14.0) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + rspec-core (2.14.2) + rspec-expectations (2.14.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.1) + rubyzip (0.9.9) + sass (3.2.9) + sass-rails (3.2.6) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) + selenium-webdriver (2.33.0) + childprocess (>= 0.2.5) + multi_json (~> 1.0) rubyzip - sexp_processor (3.0.9) - simple_form (1.5.2) + websocket (~> 1.0.4) + simple_form (2.1.0) actionpack (~> 3.0) activemodel (~> 3.0) - sinatra (1.3.1) - rack (~> 1.3, >= 1.3.4) - rack-protection (~> 1.1, >= 1.1.2) - tilt (~> 1.3, >= 1.3.3) - slop (2.1.0) - spoon (0.0.1) - sprockets (2.0.3) + slop (3.4.5) + sprockets (2.2.2) hike (~> 1.2) + multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - systemu (2.4.2) - therubyracer (0.9.9) - libv8 (~> 3.3.10) - therubyrhino (1.73.0) - thor (0.14.6) - tilt (1.3.3) - treetop (1.4.10) + therubyracer (0.11.4) + libv8 (~> 3.11.8.12) + ref + thor (0.19.1) + tilt (1.4.1) + treetop (1.4.15) + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) + polyglot (>= 0.3.1) polyglot (>= 0.3.1) - turn (0.8.3) + turn (0.9.6) ansi - tzinfo (0.3.31) - uglifier (1.2.0) + tzinfo (0.3.41) + uglifier (2.1.1) execjs (>= 0.3.0) - multi_json (>= 1.0.2) - uuid (2.3.4) - macaddr (~> 1.0) - vegas (0.1.8) - rack (>= 1.0.0) - warden (1.1.0) + multi_json (~> 1.0, >= 1.0.2) + warden (1.2.1) rack (>= 1.0) - weakling (0.0.4-java) - win32console (1.3.0-x86-mingw32) + webrick (1.3.1) + websocket (1.0.7) yamler (0.1.0) PLATFORMS - java ruby - x86-mingw32 DEPENDENCIES - bson_ext cancan coderay coffee-rails cover_me (>= 1.0.0.rc6) + daemons delayed_job - delayed_job_mongoid! + delayed_job_mongoid devise factory_girl fakeweb headless hquery-patient-api! jasmine - jquery-rails + jquery-rails (= 1.0.19) kramdown - minitest + minitest (< 5.0.0) mocha mongoid mongoid_rails_migrations multipart-post + parallel pry - quality-measure-engine! - rails + rails (= 3.2.13) sass-rails simple_form sprockets @@ -306,3 +301,4 @@ DEPENDENCIES therubyrhino turn uglifier + webrick (= 1.3.1) diff --git a/HUB-Test-Plan.md b/HUB-Test-Plan.md new file mode 100644 index 0000000..084a302 --- /dev/null +++ b/HUB-Test-Plan.md @@ -0,0 +1,42 @@ +##SCOOPHEALTH Infrastructure Testing Methodology + +#Infrastructure Overview + +There are 4 major components in the SCOOPHEALTH infrastructure. These consist of the: + + - Importer Library (health-data-standards) + - Endpoint (query-gateway) + - Patient API (patientapi) + - Hub (query-composer) + +## Importer Library +The health-data-standards ([HDS]) library used by SCOOPHEALTH is a fork of [Project Cypress] which is still undergoing rapid development. The SCOOPHEALTH fork was made on Nov 15, 2012. Since then the major changes to the SCOOPHEALTH fork have been migration from Ruby 1.9.2 to 1.9.3 and the addition of E2E importer code. + +The health-data-standards library uses the Ruby Gem "minitest" to support test-driven development (TDD) and a mock-object framework. The E2E importer has extensive unit testing of all the sections of the E2E document. These tests are ran against test patient data, verifying that known information is imported correctly. This makes refactoring of the HDS E2E importer code much easier and ensures that code changes required for consistency with changing E2E document specifications are made. + +## Endpoint +Ongoing [endpoint] code development is taking place in the Scoophealth fork of [query-gateway]. Visitors to the hquery site are now advised to use the Scoophealth fork for updated code. Major changes include migration from Ruby 1.9.2 to 1.9.3 and mongoid 2.0 to mongoid 3.0.6 (for consistentancy with health-data-standards). The query-gateway code also uses the "minitest" framework which makes refactoring and tracking of the evolving E2E standard easier. Testing consists of 1) functional testing to verify that E2E test patient documents can be loaded into the MongoDB records collection and that information from the patient records can be retrieved successfully, and 2) integration testing of the E2E importer verifying that data loaded into the database can be retrieved using Javascript methods provided by the patientapi library. Each section of the E2E document imported by the HDS E2E importer is tested. All code relevant to E2E has 100% code coverage. Test scripts based on PDC and scoophealth queries are ran to ensure that output remains consistent with past results. + +## Patient API +The SCOOPHEALTH [patientapi] library code is a fork of the [pophealth-patientapi] branch which was forked from the [hquery-patientapi] code base. The hquery codebase is no longer updated and the pophealth code base is updated infrequently. The scoophealth fork tracks any changes relevant to E2E. The primary difference from the pophealth codebase is support for regular expressions in coded values and the addition of tests specific to E2E documents. All "minitest"-based tests performed on imported CDA documents are also executed against E2E documents and the results are compared with expected E2E test patient information. + +## Hub +The [hub] code is a fork of [query-composer]. The hquery site now redirects visitors to the scoophealth fork for updated code. Major changes to the code relate to migration from Ruby 1.9.2 to 1.9.3, mongoid from 2.3.4 to 3.1.4, and rails from 3.1.3 to 3.2.7. The query-composer code has extensive "minitest" code coverage based on functional testing of the Rails controllers, unit tests of hub functionality, and integration tests of query aggregation and user access control. None of these tests are specific to E2E because once the data is stored in the endpoint database in a format queryable by the patientapi, the details of which importer was used to obtain the data is hidden. + +[HDS]:https://github.com/scoophealth/health-data-standards "health-data-standards" + +[Project Cypress]: http://projectcypress.org/ + +[Endpoint]: https://github.com/hquery/query-gateway "scoop query-gateway" + +[query-gateway]: https://github.com/hquery/query-gateway "hquery gateway" + +[patientapi]: https://github.com/scoophealth/patientapi "Patient API" + +[pophealth-patientapi]: https://github.com/pophealth/patientapi "Pophealth patientapi" + +[hquery-patientapi]: https://github.com/pophealth/patientapi "hquery patientapi" + +[hub]: https://github.com/scoophealth/query-composer "scoop query-composer" + +[query-composer]: https://github.com/hquery/query-composer "hquery query-composer" diff --git a/README.md b/README.md index d76b432..df73b8e 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -hQuery +hQuery [![travis](https://secure.travis-ci.org/scoophealth/query-composer.png?branch=master)](http://travis-ci.org/scoophealth/query-composer) ========= The query composer is a web based application that provides the front end for creating, managing, and executing queries. @@ -14,14 +14,37 @@ hQuery will also run on Windows, however, there are some minor limitations to fu Dependencies ------------ -* Ruby = 1.9.2 -* Rails 3.1 -* MongoDB >= 1.8.1 +* Ruby = 1.9.3 +* Rails 3.2.7 +* MongoDB >= 2.4.1 +* Webrick = 1.3.1 added to eliminate nuisance messages in log regarding: + WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true + + Based on information gotten from http://stackoverflow.com/questions/9612618/warn-could-not-determine-content-length-of-response-body-set-content-length-of adding Webrick explicitly to Gemfile (even though it is the version already being used) resolves the problem. + +Dependencies on old gems (to be remedied in future) +--------------------------------------------------- +* rails 3.2.7 (later versions of rails escape single and double quotes with ' and \" which causes mongoid queries to fail) +* jquery-rails 1.0.19 and jQuery UI 1.8.16 +* minitest < 5.0.0 + +Browser Issue with Firefox +-------------------------- +When using the visual Query Builder in Firefox (but not with Chrome or IE), there is an issue with popups containing the message: + +"This web page is being redirected to a new location. Would you like to resend the form data you have typed to the new location?" + +This message will continue to popup until "Cancel" is entered. The builder works OK despite this irritating message. + +To eliminate these warnings from Firefox, the following configuration change can be applied (from https://support.mozilla.org/en-US/questions/792131 ): + +* Type in your firefox url : about:config +* Then toggle the following option : network.http.prompt-temp-redirect to false Install Instructions -------------------- - Once you get a copy of the hQuery code from GitHub (http://github.com/hQuery), + Once you get a copy of the hQuery code from GitHub (https://github.com/scoophealth), these are step-by-step instructions to get hQuery installed on your local machine. These steps are the steps required to get both the Query Composer and Query Gateway up and running @@ -48,7 +71,7 @@ Install Instructions ###Common setup requirements for OSX and LINUX - install ruby 1.9.2 or later + install ruby 1.9.3 or later install bundler 1.0.14 or later @@ -65,8 +88,8 @@ First you will need to install XCode see: [http://developer.apple.com/technologi Open a terminal and run bash < <(curl -s https://rvm.beginrescueend.com/install/rvm) - rvm install 1.9.2 - rvm use 1.9.2 + rvm install 1.9.3 + rvm use 1.9.3 ####LINUX @@ -76,8 +99,8 @@ Open a terminal and run apt-get install build-essential curl file zlib1g-dev libreadline5-dev libxml2-dev libsqlite3-dev gem install rvm /var/lib/gems/1.8/bin/rvm-install - rvm install 1.9.2 - rvm use 1.9.2 + rvm install 1.9.3 + rvm use 1.9.3 ###Getting Ruby Directly Ruby can also be installed directly from the following without the use of RVM. @@ -96,8 +119,8 @@ Open a terminal and run [http://railsinstaller.org/](http://railsinstaller.org/) - Packages included in version 2.0.0 are: - Ruby 1.9.2-p290 + Packages included are (outdated information): + Ruby 1.9.2 Rails 3.1 Bundler 1.0.18 Git 1.7.6 @@ -124,12 +147,12 @@ d) Install the ruby dev kit, also available at [http://rubyinstaller.org/downloa ruby dk.rb init - 5. Veryify the new file config.yml contains a reference to Ruby192 + 5. Verify the new file config.yml contains a reference to Ruby192 6. run ruby dk.rb install - 7. Next you will want to run pi.bat in the postinstall directory + 7. Next you will want to run pi.bat in the post install directory ###1j. JRuby @@ -160,7 +183,7 @@ command in the terminal once ruby has been installed. ###Getting the latest released version -See: [http://github.com/hquery/](http://github.com/hquery/) +See: [https://github.com/scoophealth](https://github.com/scoophealth) Getting the latest source code (skip to "Installing Mongo" if you are using the latest stable release) @@ -214,7 +237,7 @@ run: bundle exec script/delayed_job start sbundle exec rails server -p 3001 -In a browser open the URL: http://localhost:3000/queries/ +In a browser open the URL: https://localhost:3000/queries/ ###7w. WINDOWS - Starting the Application @@ -250,20 +273,31 @@ Finish starting the application by running the following: Run the following in a different terminal: bundle exec rails server -p 3001 - In a browser open the URL: http://localhost:3000/queries/ + In a browser open the URL: https://localhost:3000/queries/ -###8. Adding a User Account +###8. Adding an Administrative User Account When the application opens, you should be presented with a login page. You should see a sign up Link, click it. Fill out the form to create a user. -Next you need to approve the user and set the user as an admin +Next you need to approve the user and set the user as an admin. In the root of the query-composer project run the command: bundle exec rake hquery:users:grant_admin USER_ID= where <USERNAME> is replaced with the username for the user you just created. +###9. Adding a Non-administrative User Account + +When the application opens, the user will be presented with a login page. +They will see a sign up Link which they should click. +They then need to fill out the form to create their user account. +Next you need to approve the user. +In the root of the query-composer project run the command: + + bundle exec rake hquery:users:approve USER_ID= + +where <USERNAME> is replaced with the username for the user account that is being approved. License ------- diff --git a/app/assets/javascripts/scheduled_jobs.js.coffee b/app/assets/javascripts/scheduled_jobs.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/scheduled_jobs.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/scheduled_jobs.css.scss b/app/assets/stylesheets/scheduled_jobs.css.scss new file mode 100644 index 0000000..3b0e189 --- /dev/null +++ b/app/assets/stylesheets/scheduled_jobs.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the scheduled_jobs controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 344aefd..7b6844e 100755 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -31,7 +31,7 @@ def disable end def approve - user = User.first(:conditions => {:username => params[:username]}) + user = User.where(username: params[:username]).first if user user.update_attribute(:approved, true) render :text => "true" diff --git a/app/controllers/queries_controller.rb b/app/controllers/queries_controller.rb index a0b981a..1165656 100755 --- a/app/controllers/queries_controller.rb +++ b/app/controllers/queries_controller.rb @@ -37,7 +37,7 @@ def edit @query.map = "function map(patient) {\r\n \r\n}" end if (@query.reduce.nil?) - @query.reduce = "function reduce(key, values) {\r\n \r\n}" + @query.reduce = "function reduce(key, values) {\r\n return Array.sum(values); \r\n}" end end @@ -74,7 +74,7 @@ def result def execute endpoint_ids = params[:endpoint_ids] if (endpoint_ids && !endpoint_ids.empty?) - endpoint_ids = endpoint_ids.map! {|id| BSON::ObjectId(id)} + endpoint_ids = endpoint_ids.map! {|id| Moped::BSON::ObjectId(id)} endpoints = Endpoint.criteria.for_ids(endpoint_ids) notify = params[:notification] @@ -89,6 +89,28 @@ def execute end end + + def execute_batch + endpoint_ids = params[:endpoint_ids] + + if (endpoint_ids && !endpoint_ids.empty?) + endpoint_ids = endpoint_ids.map! {|id| Moped::BSON::ObjectId(id)} + endpoints = Endpoint.criteria.for_ids(endpoint_ids) + + notify = params[:notification] + + current_user.queries.each do |eachQuery| + # execute the query, and pass in the endpoints and if the user should be notified by email when execution completes + eachQuery.execute(endpoints, notify) + end + + redirect_to :action => 'index' + else + flash[:alert] = "Cannot execute a query if no endpoints are provided." + redirect_to :action => 'index' + end + end + def cancel execution = @query.executions.find(params[:execution_id]) execution.results.find(params[:result_id]).cancel diff --git a/app/controllers/scheduled_jobs_controller.rb b/app/controllers/scheduled_jobs_controller.rb new file mode 100644 index 0000000..508cf21 --- /dev/null +++ b/app/controllers/scheduled_jobs_controller.rb @@ -0,0 +1,103 @@ +require 'cud_actions' +#require 'parallel' + +class ScheduledJobsController < ActionController::Base + include CudActions + + creates_updates_destroys :query + + def parse_array(string) + parray = string[1..-2].gsub!(/[^0-9A-Za-z(), -]/, '').split(',') + parray.each do |element| + element.strip! + end + return parray + end + + # Model constraints: + # usernames are required to be unique in the user model, + # a query must have a title, + # an endpoint must have a name. + # Query titles and descriptions do not have to be unique; A combination + # of title, description and username is more likely to be unique but for + # convenience only description and username are currently implemented. + def batch_query + render nothing: true + + # logger.info "params: " + params.inspect + # + # endpoints_all = Endpoint.all + # logger.info "List of all endpoints:" + # endpoints_all.each do |endpoint| + # logger.info ' name: ' + endpoint[:name] + ', url: ' + endpoint[:base_url] + # end + + # Select endpoints using array of endpoint names; + # Unfortunately, they are not necessarily unique + endpoint_names = params[:endpoint_names] + logger.info 'param endpoint_names:' + endpoint_names.inspect + selected_endpoints = [] + if endpoint_names + parse_array(endpoint_names).each do |endpoint_name| + match_ep = Endpoint.find_by_name(endpoint_name) + if match_ep + logger.info endpoint_name.to_s + ' matches: ' + match_ep[:name].inspect + selected_endpoints.push(match_ep) + else + logger.info 'WARNING: ' + endpoint_name.to_s + ' has no match!' + end + end + end + # logger.info 'selected endpoings: ' + selected_endpoints.inspect + + + # users = User.all + # users.each do |user| + # logger.info 'username: ' + user[:username] + # end + + # queries_all = Query.all + # logger.info "List of all queries:" + # queries_all.each do |query| + # logger.info ' title: ' + query[:title] + ', desc: ' + query[:description] + # end + + # Select query using array of query descriptions; + # Unfortunately, they are not necessarily unique + #query_titles = params[:query_titles] + username = params[:username] + current_user = User.find_by_username(username) + if current_user + query_descriptions = params[:query_descriptions] + # logger.info 'param query_descriptions:' + query_descriptions.inspect + selected_queries = [] + if query_descriptions + parse_array(query_descriptions).each do |query_desc| + match_query = current_user.queries.find_by_description(query_desc) + if match_query + logger.info query_desc + ' matches: ' + match_query[:description].inspect + selected_queries.push(match_query) + else + logger.info 'WARNING: ' + query_desc + ' has no match!' + end + end + end + end + # logger.info 'selected queries: ' + selected_queries.inspect + + if selected_endpoints && !selected_endpoints.empty? && + selected_queries && !selected_queries.empty? + notify = params[:notification] + selected_queries.each do |eachQuery| + #Parallel.each(selected_queries, :in_threads=>15) do |eachQuery| + # execute the query, and pass in the endpoints and if the user should be notified by email when execution completes + # logger.info 'title: ' + eachQuery[:title].inspect + # logger.info 'desc: ' + eachQuery[:description].inspect + # logger.info 'user_id: ' + eachQuery[:user_id].inspect + eachQuery.execute(selected_endpoints, notify) + end + else + flash[:alert] = 'Cannot execute a query if no endpoints are provided.' + end + end +end diff --git a/app/helpers/code_system_helper.rb b/app/helpers/code_system_helper.rb new file mode 100644 index 0000000..e31a242 --- /dev/null +++ b/app/helpers/code_system_helper.rb @@ -0,0 +1,60 @@ +module CodeSystemHelper + # General helpers for working with codes and code systems + # Based on abandoned code from quality-measure-engine (1.0.4) + # http://github.com/pophealth/quality-measure-engine.git + # revision: 6573859d0d8ca8d76e6dc2f0d4d15181c8457c61 + # branch: develop + class CodeSysHelper + CODE_SYSTEMS = { + '2.16.840.1.113883.6.1' => 'LOINC', + '2.16.840.1.113883.6.96' => 'SNOMED-CT', + '2.16.840.1.113883.6.12' => 'CPT', + #'2.16.840.1.113883.3.88.12.80.32' => 'CPT', + '2.16.840.1.113883.6.88' => 'RxNorm', + '2.16.840.1.113883.6.103' => 'ICD-9-CM', + '2.16.840.1.113883.6.104' => 'ICD-9-CM', + '2.16.840.1.113883.6.90' => 'ICD-10-CM', + '2.16.840.1.113883.6.14' => 'HCPCS', + '2.16.840.1.113883.6.59' => 'CVX', + '2.16.840.1.113883.6.238' => 'CDC-RE', + '2.16.840.1.113883.5.83' => 'HITSP C80 Observation Status', + '2.16.840.1.113883.3.26.1.1' => 'NCI Thesaurus', + '2.16.840.1.113883.3.88.12.80.20' => 'FDA', + '2.16.840.1.113883.5.14' => 'HL7 ActStatus', + '2.16.840.1.113883.6.259' => 'HL7 Healthcare Service Location', + '2.16.840.1.113883.5.4' => 'HL7 Act Code', + '2.16.840.1.113883.1.11.18877' => 'HL7 Relationship Code', + '2.16.840.1.113883.6.238' => 'CDC Race', + '2.16.840.1.113883.5.1105' => 'HC-DIN', + '2.16.840.1.113883.6.63' => 'FDDC', + '2.16.840.1.113883.6.73' => 'whoATC', + '2.16.840.1.113883.6.42' => 'ICD9', + '2.16.840.1.113883.3.1818.10.2.8.2' => 'PITO AllergyClinicalStatus', + '2.16.840.1.113883.2.20.3.78' => 'ObservationInterpretation', + '2.16.840.1.113883.2.20.5.1' => 'pCLOCD', + '2.16.840.1.113883.3.3068.10.6.3' => 'ObservationType-CA-Pending' + } + + # Returns the name of a code system given an oid + # @param [String] oid of a code system + # @return [String] the name of the code system as described in the measure definition JSON + def self.code_system_for(oid) + CODE_SYSTEMS[oid] || "Unknown" + end + + # Returns the oid for a code system given a codesystem name + # @param [String] the name of the code system + # @return [String] the oid of the code system + def self.oid_for_code_system(code_system) + CODE_SYSTEMS.invert[code_system] + end + + # Returns the whole map of OIDs to code systems + # @terurn [Hash] oids as keys, code system names as values + def self.code_systems + CODE_SYSTEMS + end + end + + +end \ No newline at end of file diff --git a/app/helpers/endpoints_helper.rb b/app/helpers/endpoints_helper.rb index 2cb658d..859e241 100755 --- a/app/helpers/endpoints_helper.rb +++ b/app/helpers/endpoints_helper.rb @@ -1,10 +1,14 @@ +require 'parallel' + module EndpointsHelper def fetch_endpoint_statuses @endpoint_server_statuses = {} - @endpoints.each do |endpoint| + #@endpoints.each do |endpoint| + Parallel.each(@endpoints, :in_threads=>10) do |endpoint| url = endpoint.status_url begin - response = Net::HTTP.start(url.host, url.port) do |http| + #use ssl + response = Net::HTTP.start(url.host, url.port, :use_ssl => USE_SSL_CLIENT, :key => CLIENT_KEY, :cert => CLIENT_CERT) do |http| headers = {} headers['Accept'] = 'application/atom+xml' http.get(url.path, headers) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 038dbbf..c8239cf 100755 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -1,7 +1,7 @@ module QueriesHelper def jsonify(value) begin - if value.class == Hash || value.class == Array || value.class == BSON::OrderedHash + if value.class == Hash || value.class == Array || value.class == Moped::BSON::OrderedHash JSON.pretty_generate(value) else value diff --git a/app/helpers/scheduled_jobs_helper.rb b/app/helpers/scheduled_jobs_helper.rb new file mode 100644 index 0000000..c3b616b --- /dev/null +++ b/app/helpers/scheduled_jobs_helper.rb @@ -0,0 +1,2 @@ +module ScheduledJobsHelper +end diff --git a/app/models/.gitkeep b/app/models/.gitkeep deleted file mode 100755 index e69de29..0000000 diff --git a/app/models/base_query.rb b/app/models/base_query.rb index 4148d75..eaf83fc 100644 --- a/app/models/base_query.rb +++ b/app/models/base_query.rb @@ -1,6 +1,6 @@ class BaseQuery include Mongoid::Document - store_in :queries + store_in collection: 'queries' field :title, type: String field :description, type: String @@ -12,5 +12,10 @@ class BaseQuery field :generated, type: Boolean validates_presence_of :title + + def self.find_by_description(desc) + where(description: desc).first + end + end diff --git a/app/models/endpoint.rb b/app/models/endpoint.rb index 2fe648c..68e26f4 100755 --- a/app/models/endpoint.rb +++ b/app/models/endpoint.rb @@ -35,12 +35,13 @@ def check url = submit_url begin check_time = Time.now - - response = Net::HTTP.start(url.host, url.port) do |http| + + #use ssl + response = Net::HTTP.start(url.host, url.port, :use_ssl => USE_SSL_CLIENT, :key => CLIENT_KEY, :cert => CLIENT_CERT) do |http| headers = {} - if last_check - headers['If-Modified-Since'] = last_check.to_formatted_s(:rfc822) - end + #if last_check + # headers['If-Modified-Since'] = last_check.to_formatted_s(:rfc822) + #end headers['Accept'] = 'application/atom+xml' http.get(url.path, headers) end @@ -66,7 +67,8 @@ def update_results(atom_feed) parsed_feed.entries.each do |atom_entry| query_url = atom_entry.id.try(:content) query_update_time = atom_entry.updated.try(:content) - result = active_results_for_this_endpoint.where(:query_url => query_url, :updated_at.lt => query_update_time).first + #result = active_results_for_this_endpoint.where(:query_url => query_url, :updated_at.lt => query_update_time).first + result = active_results_for_this_endpoint.where(:query_url => query_url).first if result result.check() if (result.status == Result::COMPLETE) @@ -86,4 +88,9 @@ def get_execution result def active_results_for_this_endpoint results.any_in(status: [Result::RUNNING, Result::QUEUED]) end -end \ No newline at end of file + + def self.find_by_name(name) + where(name: name).first + end + +end diff --git a/app/models/execution.rb b/app/models/execution.rb index 141079f..1e236dc 100755 --- a/app/models/execution.rb +++ b/app/models/execution.rb @@ -47,8 +47,8 @@ def cancel # = Aggregation = # =============== def aggregate - - response = Result.collection.map_reduce(self.map_fn(), _reduce(), :raw => true, :out => {:inline => true}, :query => {:execution_id => id}) + #response = Result.collection.map_reduce(self.map_fn(), _reduce(), :raw => true, :out => {:inline => true}, :query => {:execution_id => id}) + response = Result.where(execution_id: id).map_reduce(self.map_fn(), self.query.reduce).out(inline: true).raw() results = response['results'] if results self.aggregate_result = {} @@ -101,7 +101,7 @@ def prettify_generated_result(result) pretty_key = "Results" if pretty_key.empty? pretty_result['_id'] = pretty_key pretty_result['value'] = pretty_values - + return pretty_result end @@ -161,7 +161,7 @@ def map_fn private - def _reduce + def _reduce_deprecated #unwrapped reduce method; its output datatype must match the values datatype exactly "function(k,v){ var iter = function(x){ diff --git a/app/models/query.rb b/app/models/query.rb index 12dd9ba..cec3ef0 100755 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -27,12 +27,12 @@ def generate_map_reduce if (self.generated?) map_function = "" map_template = ActionView::Base.new(QueryComposer::Application.paths['app/views']) - map_template = map_template.render(:template => "queries/builder/_map_function.js.erb", locals: { :query_structure => self.query_structure }) + map_template = map_template.render(:template => "queries/builder/_map_function", :handlers => [:erb], :formats => [:js], locals: { :query_structure => self.query_structure }) self.map = prettify_generated_function(map_template) reduce_function = "" reduce_template = ActionView::Base.new(QueryComposer::Application.paths['app/views']) - reduce_template = reduce_template.render(:template => "queries/builder/_reduce_function.js.erb", locals: { :query_structure => self.query_structure }) + reduce_template = reduce_template.render(:template => "queries/builder/_reduce_function", :handlers => [:erb], :formats => [:js], locals: { :query_structure => self.query_structure }) self.reduce = prettify_generated_function(reduce_template) end end @@ -83,5 +83,4 @@ def prettify_generated_function function return pretty_function end - end \ No newline at end of file diff --git a/app/models/result.rb b/app/models/result.rb index f0e001a..0c5d75a 100755 --- a/app/models/result.rb +++ b/app/models/result.rb @@ -29,9 +29,12 @@ def cancel def check logger.debug("Checking query url #{query_url}") url = URI.parse(query_url) - response = Net::HTTP.start(url.host, url.port) do |http| - http.get(url.path, 'If-Modified-Since' => updated_at.to_formatted_s(:rfc822), - 'Accept' => 'application/json') + + #use ssl + response = Net::HTTP.start(url.host, url.port, :use_ssl => USE_SSL_CLIENT, :key => CLIENT_KEY, :cert => CLIENT_CERT) do |http| + #http.get(url.path, 'If-Modified-Since' => updated_at.to_formatted_s(:rfc822), + # 'Accept' => 'application/json') + http.get(url.path, 'Accept' => 'application/json') end case response @@ -52,7 +55,7 @@ def check self.status = query_status save! else - self.update_attribute(:created_at, Time.now) + self.update_attribute(:created_at, Time.now) end end when Net::HTTPNotModified @@ -65,11 +68,12 @@ def check def fetch_result url = URI.parse(self.result_url) - response = Net::HTTP.start(url.host, url.port) do |http| + #use ssl + response = Net::HTTP.start(url.host, url.port, :use_ssl => USE_SSL_CLIENT, :key => CLIENT_KEY, :cert => CLIENT_CERT) do |http| http.get(url.path, 'Accept' => 'application/json') end self.value = JSON.parse(response.body) self.status = COMPLETE save! end -end \ No newline at end of file +end diff --git a/app/models/user.rb b/app/models/user.rb index bb38df4..82b7c9b 100755 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ class User include Mongoid::Document # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable - devise :database_authenticatable, :registerable,:recoverable, :rememberable, :trackable, :validatable,:authentication_keys => [:username] + devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :authentication_keys => [:username] has_many :queries has_many :library_functions @@ -13,6 +13,7 @@ class User field :email, type: String field :company, type: String field :company_url, type: String + field :encrypted_password, :type => String field :agree_license, type: Boolean @@ -31,6 +32,21 @@ class User validates :email, presence: true, length: {minimum: 3, maximum: 254}, format: {with: /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i} validates :username, :presence => true, length: {minimum: 3, maximum: 254} + # Trackable + field :current_sign_in_at, :type => Time + field :remember_created_at, :type => Time + field :last_sign_in_at, :type => Time + field :current_sign_in_ip, :type => String + field :last_sign_in_ip, :type => String + field :sign_in_count, :type => Integer + + :remember_created_at + :sign_in_count + :current_sign_in_at + :last_sign_in_at + :current_sign_in_ip + :last_sign_in_ip + def active_for_authentication? super && approved? && !disabled? end @@ -40,10 +56,10 @@ def active_for_authentication? # ========== def self.find_by_username(username) - User.first(:conditions => {:username => username}) + where(username: username).first end def self.find_by_email(email) - User.first(:conditions => {:email => email}) + where(email: email).first end # ============= diff --git a/app/views/code_sets/_form.html.erb b/app/views/code_sets/_form.html.erb index a6dfb62..967576d 100644 --- a/app/views/code_sets/_form.html.erb +++ b/app/views/code_sets/_form.html.erb @@ -27,7 +27,7 @@ - <% code_set_list = [ "" ] + QME::Importer::CodeSystemHelper.code_systems.values.uniq %> + <% code_set_list = [ "" ] + CodeSystemHelper::CodeSysHelper.code_systems.values.uniq %> Codes diff --git a/app/views/code_sets/edit.html.erb b/app/views/code_sets/edit.html.erb index fd4bd15..c2f43ca 100644 --- a/app/views/code_sets/edit.html.erb +++ b/app/views/code_sets/edit.html.erb @@ -8,7 +8,7 @@
-<%= render :partial=>"code_sets/form.html" %> +<%= render :partial=>"code_sets/form", formats => [:html] %>
diff --git a/app/views/code_sets/index.html.erb b/app/views/code_sets/index.html.erb index 1a48deb..8bde2b2 100644 --- a/app/views/code_sets/index.html.erb +++ b/app/views/code_sets/index.html.erb @@ -15,7 +15,7 @@

Type

Coded Concepts

-<%= render :partial=> "code_sets/entry.html" %> +<%= render :partial=> "code_sets/entry", formats => [:html] %>
diff --git a/app/views/code_sets/index2.html.erb b/app/views/code_sets/index2.html.erb index 0313fdf..4a2fca5 100644 --- a/app/views/code_sets/index2.html.erb +++ b/app/views/code_sets/index2.html.erb @@ -16,7 +16,7 @@ - <%= render :partial=> "code_sets/entry2.html", :collection => @code_sets %> + <%= render :partial=> "code_sets/entry2", :formats => [:html], :collection => @code_sets %>
diff --git a/app/views/code_sets/new.html.erb b/app/views/code_sets/new.html.erb index fd4bd15..c2f43ca 100644 --- a/app/views/code_sets/new.html.erb +++ b/app/views/code_sets/new.html.erb @@ -8,7 +8,7 @@
-<%= render :partial=>"code_sets/form.html" %> +<%= render :partial=>"code_sets/form", formats => [:html] %>
diff --git a/app/views/endpoints/_endpoint_statuses.html.erb b/app/views/endpoints/_endpoint_statuses.html.erb index beead66..de2ed62 100755 --- a/app/views/endpoints/_endpoint_statuses.html.erb +++ b/app/views/endpoints/_endpoint_statuses.html.erb @@ -17,7 +17,7 @@ <%= link_to endpoint.name, endpoint_path(endpoint.id) %> <%= @endpoint_server_statuses[endpoint.id]['backend_status'] %> - <%= button_to '×', endpoint, :class=>"btn alert", confirm: 'Are you sure you wish to delete this endpoint?', method: :delete, title:"×" if current_user.admin? %> + <%= button_to '×', endpoint, :class=>"btn alert", :data => {:confirm => 'Are you sure you wish to delete this endpoint?'}, method: :delete, title:"×" if current_user.admin? %> <% end %> \ No newline at end of file diff --git a/app/views/library_functions/index.html.erb b/app/views/library_functions/index.html.erb index cd0cd24..5d0b9eb 100755 --- a/app/views/library_functions/index.html.erb +++ b/app/views/library_functions/index.html.erb @@ -21,7 +21,7 @@ <%= link_to library_function.name, library_function %> <%= link_to 'Edit', edit_library_function_path(library_function), :class=> "btn tbbtn" %> - <%= link_to '×', library_function, confirm: 'Are you sure?', method: :delete, :class=> "btn alert" %> + <%= link_to '×', library_function, :data => { :confirm => 'Are you sure?'}, method: :delete, :class=> "btn alert" %> <% end %> diff --git a/app/views/queries/_execute_all_popup.html.erb b/app/views/queries/_execute_all_popup.html.erb new file mode 100644 index 0000000..7dca954 --- /dev/null +++ b/app/views/queries/_execute_all_popup.html.erb @@ -0,0 +1,53 @@ +<% content_for :head do -%> + +<% end -%> + +
+ <%= simple_form_for :query, :url => url_for(:controller => 'queries', :action => 'execute_batch'), :method => 'post', :html => {id: 'execute-all-popup-form'} do |f| %> +

Notification:

+ <%= check_box_tag "notification", true, false %> Send email notification when query completes +

Endpoints:

+ + + + + + + + + + + <% for endpoint in endpoints %> + + + + + + <% end %> + +
TitleUrl
<%= check_box_tag "endpoint_ids[]", endpoint.id, endpoints.length == 1 ? true : false %><%= endpoint.name %><%= endpoint.base_url %>
+ <% end %> +
diff --git a/app/views/queries/_execution_results.html.erb b/app/views/queries/_execution_results.html.erb index 1d5bd20..e3f9dd5 100755 --- a/app/views/queries/_execution_results.html.erb +++ b/app/views/queries/_execution_results.html.erb @@ -13,7 +13,7 @@ execution.results.each do |result| %> - <%= result.endpoint.base_url %> + <%= result.endpoint && result.endpoint.base_url %> <%= result.status %><%= result.error_msg if result.status == Result::FAILED %> <%= result.result_url %> diff --git a/app/views/queries/_query_details.html.erb b/app/views/queries/_query_details.html.erb index 58b8a50..5f5f8fe 100755 --- a/app/views/queries/_query_details.html.erb +++ b/app/views/queries/_query_details.html.erb @@ -14,8 +14,8 @@ <% else %> Mode - <%= f.radio_button :generated, true, :checked => true %> Graphical Builder - <%= f.radio_button :generated, false, :checked => false %> Handwritten JavaScript (Advanced) + <%= f.radio_button :generated, true, :checked => false %> Graphical Builder + <%= f.radio_button :generated, false, :checked => true %> Handwritten JavaScript (Advanced) <% end %> diff --git a/app/views/queries/builder/_reduce_function.js.erb b/app/views/queries/builder/_reduce_function.js.erb index 23a213b..c350444 100644 --- a/app/views/queries/builder/_reduce_function.js.erb +++ b/app/views/queries/builder/_reduce_function.js.erb @@ -20,13 +20,12 @@ function reduce(key, values) { rereduced = false ); - while(values.hasNext()) { - var _val = values.next(); - result.sum('target_pop', _val); - result.sum('filtered_pop', _val); - result.sum('unfound_pop', _val); - result.sum('total_pop', _val); - _val.rereduced = true; + for (var i in values) { + result.sum('target_pop', values[i]); + result.sum('filtered_pop', values[i]); + result.sum('unfound_pop', values[i]); + result.sum('total_pop', values[i]); + values[i].rereduced = true; result.rereduced = true; } } else if (key.type == 'group') { @@ -36,18 +35,17 @@ function reduce(key, values) { end initial_values = '' if (selections.length > 0) - initial_values = selections.join(",\n") + initial_values = selections.join(',\n') end %> - + result = new reducer.Value( { - <%= initial_values %> + <%= raw initial_values %> }, rereduced = false ); - while(values.hasNext()) { - var _val = values.next(); + for (var i in values) { <% aggregates = [] query_structure['extract']['selections'].each do |select| # TODO - We need to decide on a default action when no aggregate is defined. For now, we'll just sum. @@ -55,17 +53,17 @@ function reduce(key, values) { select['aggregation'] << 'sum' end select['aggregation'].each do |aggregate| - aggregates << "result.#{aggregate}('#{select['title']}', _val);" + aggregates << "result.#{aggregate}('#{select['title']}', values[i]);" end end aggregation = aggregates.join("\n") %> - <%= aggregation %> + <%= raw aggregation %> result.rereduced = true; - _val.rereduced = true; + values[i].rereduced = true; } } return result; -} \ No newline at end of file +} diff --git a/app/views/queries/index.html.erb b/app/views/queries/index.html.erb index 2f8eafb..cd2cdbc 100755 --- a/app/views/queries/index.html.erb +++ b/app/views/queries/index.html.erb @@ -17,7 +17,7 @@ Status <% end %> - <% @queries.each do |query| %> + <% @queries.asc(:description).each do |query| %> <%= link_to query.title, query_path(query.id) %> <%= query.description %> @@ -37,15 +37,21 @@ <% end %> <% end %> - <%= button_to '×', {:action=>'destroy', :id=>query.id}, :class=>"btn alert", :method=>:delete, :confirm=>'Are you sure you wish to delete the query ' + query.title %> + <%= button_to '×', {:action=>'destroy', :id=>query.id}, :class=>"btn alert", :method=>:delete, :data => {:confirm=>'Are you sure you wish to delete the query ' + query.title} %> <% end %> + <%= render partial: 'execute_all_popup', locals: { endpoints: Endpoint.all, button_id: 'execute-all-button' } %> + <%= link_to(new_query_path, class: "btn primary m") do %>Add Query<% end %> -
-
-
-
+ <% if !current_user.admin %> + + <% end %> + +
+
+
+
diff --git a/app/views/scheduled_jobs/batch_query.html.erb b/app/views/scheduled_jobs/batch_query.html.erb new file mode 100644 index 0000000..56fc0b4 --- /dev/null +++ b/app/views/scheduled_jobs/batch_query.html.erb @@ -0,0 +1,2 @@ +

ScheduledJobs#batch_query

+

Find me in app/views/scheduled_jobs/batch_query.html.erb

diff --git a/cert/README b/cert/README new file mode 100644 index 0000000..2992b3d --- /dev/null +++ b/cert/README @@ -0,0 +1,51 @@ +# Change into the query-composer root directory. Make a cert subdirectory. +cd $HOME/query-composer && mkdir cert && cd cert +# +# Generate a self-signed certificate. You need to answer some questions. +# Most of them can be answered arbitrarily but it is important that the +# Common Name be accurate. For development and test purposes you can +# use something like *.localdomain to cover all hosts in localdomain. +# I used: +# Country Name (2 letter code) [GB]:CA +# State or Province Name (full name): British Columbia +# Locality Name (eg, city): Victoria +# Organization Name (eg, company): University of Victoria +# Organizational Unit Name (eg, section): Island Medical Program +# Common Name (eg, your name or your server's hostname): *.localdomain +# Email Address: scoophealth@googlegroups.com +# +# This will generate the certificate and key in a file named server.pem: +openssl req -new -x509 -keyout server.pem -out server.pem -nodes -days 365 +# +# Copy the self-signed certificate to query-gateway/cert/ca +# [The location and name can be changed but must match +# the entries in query-gateway/script/secure_rails.] +mkdir ca && cp server.pem ca/LeadLab_root_cert_TEST.pem && rm server.pem +# +# Note: We used *.localdomain for the "Common Name" when prompted +# for that information. For this to work, you will need an /etc/hosts +# file that maps IP addresses to entries in the localdomain. For instance, +# $ cat /etc/hosts +# 127.0.0.1 localhost localhost.localdomain +# 127.0.1.1 query-composer query-composer.localdomain +# 192.168.52.100 mysql-host mysql-host.localdomain +# 192.168.52.101 query-gateway0 query-gateway0.localdomain +# 192.168.52.102 query-composer query-composer.localdomain +# 192.168.52.103 query-gateway1 query-gateway1.localdomain +# +# Now find the hash of the self-signed certificate +# $ openssl x509 -hash -noout -in ../cert/ca/LeadLab_root_cert_TEST.pem +# +# 962a3564 +# +# Create a symbolic link from the self-signed certicate to a file in +# /etc/ssl/certs with name matching the hash with suffix '.0'. +# +# /etc/ssl/certs/962a3564.0 ->/home/vagrant/query-composer/cert/ca/LeadLab_root_cert_TEST.pem +# +# For this particular self-signed certificate's hash, I did this: +# $ sudo ln -s /home/vagrant/query-composer/cert/ca/LeadLab_root_cert_TEST.pem /etc/ssl/certs/962a3564.0 +# +# To start up the SSL secured version of query-gateway on port 3002 use: +# $ bundle exec script/delayed_job start +# $ bundle exec rails server -p 3002 diff --git a/cert/ca/LeadLab_root_cert_TEST.pem b/cert/ca/LeadLab_root_cert_TEST.pem new file mode 100644 index 0000000..5af6e59 --- /dev/null +++ b/cert/ca/LeadLab_root_cert_TEST.pem @@ -0,0 +1,36 @@ +-----BEGIN PRIVATE KEY----- +MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBANEKAbCsoweaNzb1 +An3rPTlF/8lypAz6zReIML6dBrquO/R1fHYrs1qdQCOf8rY3mFU+FCloSFIITiF+ +NeqsVzGAFwRbT2HIwCiWMepLvjumLxCPSfUZiz+yhgXjNnNLu4m+YzDlFJCmMDV+ +m0Q0ViKFyPzPINGVI0xtPFTKX1fpAgMBAAECgYBsdQepdfjkUeRB9F9Fm87ZL3Nm +Pr/VKC9O/U9lJq2+H/ZlgKuB2GynIB2OHkfcuP2lhJ8LWNrlDQAUqpoo1yApUydz +u98QLFw7+7V5B8igC+mxjImc9XGdWtB+/sAQk3aQuEMLskmpvZHkCgzIWylvRvmb +ATBFvethNnqRC5PrgQJBAPZvYoDub4nm9Lyb+7Pc8ZSKmmltngbYEFXhrld21WIn +wL95ZeiJqyleZxsXth86fSWd+Fgv8KmYYrw7DMjIibkCQQDZJwyy1tibX6nTaou5 +TYBVAvlTuYA5iVOh1Q/a9T/Ko/4/dX8lm/Lm7MrMRxqIGok1IIexNhsfloN/TUew +XJexAkArozupIw+jNr99qo1eozAwIn8HTj7ebWIvIwBxQny0nd92yHNwQviJIctW +M9OvIfdJMvjn/M076t0JAdfYshIZAkA4wy9blDN8sc3nmKM7ZdnU3vkjfIra/12g +INyLJK5vHtz345O/1frxiBYevbtetmkFPSKbHQSMBkELRr0liZ6RAkBzhur1fRhr +RjJR38o684Z4Sx0iflyWFVe/08EVXBqCaj6Bb9/unQmYC+dWhmJqAOUS/FiaEmvC +EaE6hG7QkARE +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDVDCCAr2gAwIBAgIJAOWAnoqQBfNbMA0GCSqGSIb3DQEBBQUAMIHCMQswCQYD +VQQGEwJDQTEZMBcGA1UECAwQQnJpdGlzaCBDb2x1bWJpYTERMA8GA1UEBwwIVmlj +dG9yaWExHzAdBgNVBAoMFlVuaXZlcnNpdHkgb2YgVmljdG9yaWExHzAdBgNVBAsM +FklzbGFuZCBNZWRpY2FsIFByb2dyYW0xFjAUBgNVBAMMDSoubG9jYWxkb21haW4x +KzApBgkqhkiG9w0BCQEWHHNjb29waGVhbHRoQGdvb2dsZWdyb3Vwcy5jb20wHhcN +MTMwODI4MjAwMjEwWhcNMTQwODI4MjAwMjEwWjCBwjELMAkGA1UEBhMCQ0ExGTAX +BgNVBAgMEEJyaXRpc2ggQ29sdW1iaWExETAPBgNVBAcMCFZpY3RvcmlhMR8wHQYD +VQQKDBZVbml2ZXJzaXR5IG9mIFZpY3RvcmlhMR8wHQYDVQQLDBZJc2xhbmQgTWVk +aWNhbCBQcm9ncmFtMRYwFAYDVQQDDA0qLmxvY2FsZG9tYWluMSswKQYJKoZIhvcN +AQkBFhxzY29vcGhlYWx0aEBnb29nbGVncm91cHMuY29tMIGfMA0GCSqGSIb3DQEB +AQUAA4GNADCBiQKBgQDRCgGwrKMHmjc29QJ96z05Rf/JcqQM+s0XiDC+nQa6rjv0 +dXx2K7NanUAjn/K2N5hVPhQpaEhSCE4hfjXqrFcxgBcEW09hyMAoljHqS747pi8Q +j0n1GYs/soYF4zZzS7uJvmMw5RSQpjA1fptENFYihcj8zyDRlSNMbTxUyl9X6QID +AQABo1AwTjAdBgNVHQ4EFgQUltQ6g39ZWulvvY/kTFqqQnJGXY0wHwYDVR0jBBgw +FoAUltQ6g39ZWulvvY/kTFqqQnJGXY0wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B +AQUFAAOBgQB6V+HzYlW9qgu/xliFIu1EjJmLGOtBf4aRkdg6gSaxDB84SggoKKG0 +YzrTuYN9vv70zqGTDc76FKQSjuSugnmn6eCKkTi9/9Xvc0ZMdT3Hr3KQfgseTEpA +URHghVEJCn1s1OmW8Eb/I99FbhN6L8sibl9eWBSUZffTKiIJY3JX0g== +-----END CERTIFICATE----- diff --git a/cert/old/README.cert b/cert/old/README.cert new file mode 100644 index 0000000..315971b --- /dev/null +++ b/cert/old/README.cert @@ -0,0 +1,16 @@ +mkdir ca +# Generate 4096-bit long RSA key for our root CA +openssl genrsa -out ca/LeadLab_root_cert_TEST.pem 4096 +# Create a self-signed root CA certificate +openssl req -new -x509 -days 1826 -key ca/LeadLab_root_cert_TEST.pem -out ca/LeadLab_root_cert_TEST.crt +# Create a subordinate CA used for actual signing +openssl genrsa -out composer.key 4096 +# Request a certificate for this subordinate CA +openssl req -new -key composer.key -out composer.csr +# Process request for the subordinate CA and get it signed by the root CA +openssl x509 -req -days 730 -in composer.csr -CA ca/LeadLab_root_cert_TEST.crt -CAkey ca/LeadLab_root_cert_TEST.pem -set_serial 5342365815382548354816354178354176 -out composer.crt +# Make client credentials +openssl genrsa -out client.key 4096 +openssl req -new -key client.key -out client.csr +openssl x509 -req -days 730 -in client.csr -CA ca/LeadLab_root_cert_TEST.crt -CAkey ca/LeadLab_root_cert_TEST.pem -set_serial 5342365815382548354816354178354177 -out client.crt + diff --git a/cert/old/comp-cert b/cert/old/comp-cert new file mode 100755 index 0000000..c3703f5 --- /dev/null +++ b/cert/old/comp-cert @@ -0,0 +1,7 @@ +rm ./composer.crt +rm ./composer.csr +rm ./composer.key +openssl genrsa -out composer.key 4096 +openssl req -new -key composer.key -out composer.csr +openssl x509 -req -days 300 -in composer.csr -CA ./ca/LeadLab_root_cert_TEST.pem -CAkey ./ca/LeadLab_root_cert_TEST.key -set_serial 5342365815382548354816354178354176 -out composer.crt + diff --git a/config/environment.rb b/config/environment.rb index e2b79db..11ac8fb 100755 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,6 @@ # Load the rails application require File.expand_path('../application', __FILE__) +require File.expand_path('../../config/ssl_config', __FILE__) # Initialize the rails application QueryComposer::Application.initialize! @@ -16,4 +17,4 @@ ActionMailer::Base.default_url_options = { :host => "localhost", # TODO: This should be localhost in test.rb but a real host for production env :port => 3000 -} \ No newline at end of file +} diff --git a/config/environments/development.rb b/config/environments/development.rb index 35cd16e..f4e9db8 100755 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -9,6 +9,8 @@ # Log error messages when you accidentally call methods on nil. config.whiny_nils = true + config.log_level = :info #:debug + # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 0a204a4..399e79b 100755 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,8 +1,9 @@ -# Use this hook to configure devise mailer, warden hooks and so forth. The first -# four configuration values can also be set straight in your models. +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. Devise.setup do |config| # ==> Mailer Configuration - # Configure the e-mail address which will be shown in DeviseMailer. + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class with default "from" parameter. config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" # Configure the class responsible to send e-mails. @@ -36,10 +37,25 @@ # to authenticate or find a user. Default is :email. config.case_insensitive_keys = [ :email ] + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [ :email ] + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. # config.params_authenticatable = true - # Tell if authentication through HTTP Basic Auth is enabled. False by default. + # Tell if authentication through HTTP Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:token]` will + # enable it only for token authentication. The supported strategies are: + # :database = Support basic authentication with authentication key + password + # :token = Support basic authentication with token authentication key + # :token_options = Support token authentication with options as defined in + # http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html # config.http_authenticatable = false # If http headers should be returned for AJAX requests. True by default. @@ -48,22 +64,51 @@ # The realm used in Http Basic Authentication. "Application" by default. # config.http_authentication_realm = "Application" + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # :http_auth and :token_auth by adding those symbols to the array below. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing :skip => :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + # ==> Configuration for :database_authenticatable # For bcrypt, this is the cost for hashing the password and defaults to 10. If # using other encryptors, it sets how many times you want the password re-encrypted. - config.stretches = 10 + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. + config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password. - # config.pepper = "ca090303f7746d096fb3349512c5a211a12e95db385e225d5682c0e580ae7e1e79c808b433724421627ff68e6b2bdb189ed95d0a43f570c97fc2787c06090754" + # config.pepper = "72e0710c83b5b04cb896d5ce09f319ec651d9adc2f927aa1fd2085d437f313dae2e8aaa90005583b66dc943dff07379b40dff579d032cf3e9809f1d72a3dd014" # ==> Configuration for :confirmable - # The time you want to give your user to confirm his account. During this time - # he will be able to access your application without confirming. Default is 0.days - # When confirm_within is zero, the user won't be able to sign in without confirming. - # You can use this to let your user access some features of your application - # without confirming the account, but blocking it after a certain period - # (ie 2 days). - # config.confirm_within = 2.days + # A period that the user is allowed to access the website even without + # confirming his account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming his account, + # access will be blocked just in the third day. Default is 0.days, meaning + # the user cannot access the website without confirming his account. + # config.allow_unconfirmed_access_for = 2.days + + # A period that the user is allowed to confirm their account before their + # token becomes invalid. For example, if set to 3.days, the user can confirm + # their account within 3 days after the mail was sent, but on the fourth day + # their account can't be confirmed with the token any more. + # Default is nil, meaning there is no restriction on how long a user can take + # before confirming their account. + # config.confirm_within = 3.days + + # If true, requires any email changes to be confirmed (exactly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed new email is stored in + # unconfirmed email column, and copied to email column on successful confirmation. + config.reconfirmable = true # Defines which key will be used when confirming an account # config.confirmation_keys = [ :email ] @@ -72,32 +117,30 @@ # The time the user will be remembered without asking for credentials again. # config.remember_for = 2.weeks - # If true, a valid remember token can be re-used between multiple browsers. - # config.remember_across_browsers = true - # If true, extends the user's remember period when remembered via cookie. # config.extend_remember_period = false - # If true, uses the password salt as remember token. This should be turned - # to false if you are not using database authenticatable. - config.use_salt_as_remember_token = true - # Options to be passed to the created cookie. For instance, you can set # :secure => true in order to force SSL only cookies. - # config.cookie_options = {} + # config.rememberable_options = {} # ==> Configuration for :validatable - # Range for password length. Default is 6..128. - # config.password_length = 6..128 + # Range for password length. Default is 8..128. + config.password_length = 8..128 - # Regex to use to validate the email address - # config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i + # Email regex used to validate email formats. It simply asserts that + # one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + # config.email_regexp = /\A[^@]+@[^@]+\z/ # ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this # time the user will be asked for credentials again. Default is 30 minutes. # config.timeout_in = 30.minutes + # If true, expires auth token on session timeout. + # config.expire_auth_token_on_timeout = false + # ==> Configuration for :lockable # Defines which strategy will be used to lock an account. # :failed_attempts = Locks an account after a number of failed attempts to sign in. @@ -129,24 +172,22 @@ # Time interval you can reset your password with a reset password key. # Don't put a too small interval or your users won't have the time to # change their passwords. - config.reset_password_within = 2.hours + config.reset_password_within = 6.hours # ==> Configuration for :encryptable # Allow you to use another encryption algorithm besides bcrypt (default). You can use # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) # and :restful_authentication_sha1 (then you should set stretches to 10, and copy - # REST_AUTH_SITE_KEY to pepper) + # REST_AUTH_SITE_KEY to pepper). + # + # Require the `devise-encryptable` gem when using anything other than bcrypt # config.encryptor = :sha512 # ==> Configuration for :token_authenticatable # Defines name of the authentication token params key # config.token_authentication_key = :auth_token - # If true, authentication through token does not store user in session and needs - # to be supplied on each request. Useful if you are using the token as API token. - # config.stateless_token = false - # ==> Scopes configuration # Turn scoped views on. Before rendering "sessions/new", it will first check for # "users/sessions/new". It's turned off by default because it's slower if you @@ -157,9 +198,8 @@ # devise role declared in your routes (usually :user). # config.default_scope = :user - # Configure sign_out behavior. - # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). - # The default is true, which means any logout action will sign out all active scopes. + # Set this configuration to false if you want /users/sign_out to sign out + # only the current scope. By default, Devise signs out all scopes. # config.sign_out_all_scopes = true # ==> Navigation configuration @@ -170,12 +210,11 @@ # If you have any extra navigational formats, like :iphone or :mobile, you # should add them to the navigational formats lists. # - # The :"*/*" and "*/*" formats below is required to match Internet - # Explorer requests. - # config.navigational_formats = [:"*/*", "*/*", :html] + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ["*/*", :html] - # The default HTTP method used to sign out a resource. Default is :get. - # config.sign_out_via = :get + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :get # ==> OmniAuth # Add a new OmniAuth provider. Check the wiki for more information on setting @@ -187,8 +226,21 @@ # change the failure app, you can configure them inside the config.warden block. # # config.warden do |manager| - # manager.failure_app = AnotherApp # manager.intercept_401 = false # manager.default_strategies(:scope => :user).unshift :some_external_strategy # end + + # ==> Mountable engine configurations + # When using Devise inside an engine, let's call it `MyEngine`, and this engine + # is mountable, there are some extra configurations to be taken into account. + # The following options are available, assuming the engine is mounted as: + # + # mount MyEngine, at: "/my_engine" + # + # The router that invoked `devise_for`, in the example above, would be: + # config.router_name = :my_engine + # + # When using omniauth, Devise cannot automatically set Omniauth path, + # so you need to do it manually. For the users scope, it would be: + # config.omniauth_path_prefix = "/my_engine/users/auth" end diff --git a/config/initializers/mongo.rb b/config/initializers/mongo.rb index 3b5e6c4..241af4b 100755 --- a/config/initializers/mongo.rb +++ b/config/initializers/mongo.rb @@ -1,6 +1,6 @@ -require 'mongo' +#require 'mongo' -host = ENV['TEST_DB_HOST'] || 'localhost' -conn = Mongo::Connection.new(host, 27017) +#host = ENV['TEST_DB_HOST'] || 'localhost' +#conn = Mongo::Connection.new(host, 27017) -MONGO_DB = conn["hquery-composer-#{Rails.env}"] +#MONGO_DB = conn["hquery-composer-#{Rails.env}"] diff --git a/config/initializers/ssl_config.rb b/config/initializers/ssl_config.rb new file mode 100644 index 0000000..3339c37 --- /dev/null +++ b/config/initializers/ssl_config.rb @@ -0,0 +1 @@ +include SslConfig diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 25022e1..d01f375 100755 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -1,50 +1,59 @@ -# Additional translations at http://github.com/plataformatec/devise/wiki/I18n +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n en: + devise: + confirmations: + confirmed: "Your account was successfully confirmed. You are now signed in." + send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes." + failure: + already_authenticated: "You are already signed in." + inactive: "Your account was not activated yet." + invalid: "Invalid email or password." + invalid_token: "Invalid authentication token." + locked: "Your account is locked." + not_found_in_database: "Invalid email or password." + timeout: "Your session expired, please sign in again to continue." + unauthenticated: "You need to sign in or sign up before continuing." + unconfirmed: "You have to confirm your account before continuing." + mailer: + confirmation_instructions: + subject: "Confirmation instructions" + reset_password_instructions: + subject: "Reset password instructions" + unlock_instructions: + subject: "Unlock Instructions" + omniauth_callbacks: + failure: "Could not authenticate you from %{kind} because \"%{reason}\"." + success: "Successfully authenticated from %{kind} account." + passwords: + no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." + send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." + updated: "Your password was changed successfully. You are now signed in." + updated_not_active: "Your password was changed successfully." + registrations: + destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon." + signed_up: "Welcome! You have signed up successfully." + signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." + signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." + signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account." + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address." + updated: "You updated your account successfully." + sessions: + signed_in: "Signed in successfully." + signed_out: "Signed out successfully." + unlocks: + send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes." + send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes." + unlocked: "Your account has been unlocked successfully. Please sign in to continue." errors: messages: + already_confirmed: "was already confirmed, please try signing in" + confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" expired: "has expired, please request a new one" not_found: "not found" - already_confirmed: "was already confirmed, please try signing in" not_locked: "was not locked" not_saved: one: "1 error prohibited this %{resource} from being saved:" other: "%{count} errors prohibited this %{resource} from being saved:" - - devise: - failure: - already_authenticated: 'You are already signed in.' - unauthenticated: 'You need to sign in or sign up before continuing.' - unconfirmed: 'You have to confirm your account before continuing.' - locked: 'Your account is locked.' - invalid: 'Invalid email or password.' - invalid_token: 'Invalid authentication token.' - timeout: 'Your session expired, please sign in again to continue.' - inactive: 'Your account was not activated yet.' - sessions: - signed_in: 'Signed in successfully.' - signed_out: 'Signed out successfully.' - passwords: - send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' - updated: 'Your password was changed successfully. You are now signed in.' - confirmations: - send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' - confirmed: 'Your account was successfully confirmed. You are now signed in.' - registrations: - signed_up: 'Welcome! You have signed up successfully.' - inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.' - updated: 'You updated your account successfully.' - destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.' - unlocks: - send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' - unlocked: 'Your account was successfully unlocked. You are now signed in.' - omniauth_callbacks: - success: 'Successfully authorized from %{kind} account.' - failure: 'Could not authorize you from %{kind} because "%{reason}".' - mailer: - confirmation_instructions: - subject: 'Confirmation instructions' - reset_password_instructions: - subject: 'Reset password instructions' - unlock_instructions: - subject: 'Unlock Instructions' diff --git a/config/mongoid.yml b/config/mongoid.yml index 53ef4bd..35a4d1a 100755 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -1,15 +1,80 @@ development: - host: localhost - database: hquery-composer-development + # Configure available database sessions. (required) + sessions: + # Defines the default session. (required) + default: + # Defines the name of the default database that Mongoid can connect to. + # (required). + database: query_composer_development + # Provides the hosts the default session can connect to. Must be an array + # of host:port pairs. (required) + hosts: + - localhost:27017 + options: + # Change whether the session persists in safe mode by default. + # (default: false) + # safe: false + # Change the default consistency model to :eventual or :strong. + # :eventual will send reads to secondaries, :strong sends everything + # to master. (default: :eventual) + # consistency: :eventual + + # How many times Moped should attempt to retry an operation after + # failure. (default: 30) + # max_retries: 30 + + # The time in seconds that Moped should wait before retrying an + # operation on failure. (default: 1) + # retry_interval: 1 + # Configure Mongoid specific options. (optional) + options: + # Configuration for whether or not to allow access to fields that do + # not have a field definition on the model. (default: true) + # allow_dynamic_fields: true + + # Enable the identity map, needed for eager loading. (default: false) + # identity_map_enabled: false + + # Includes the root model name in json serialization. (default: false) + # include_root_in_json: false + + # Include the _type field in serializaion. (default: false) + # include_type_for_serialization: false + + # Preload all models in development, needed when models use + # inheritance. (default: false) + # preload_models: false + + # Protect id and type from mass assignment. (default: true) + # protect_sensitive_fields: true + + # Raise an error when performing a #find and the document is not found. + # (default: true) + # raise_not_found_error: true + + # Raise an error when defining a scope with the same name as an + # existing method. (default: false) + # scope_overwrite_exception: false + + # Skip the database version check, used when connecting to a db without + # admin access. (default: false) + # skip_version_check: false + + # User Active Support's time zone in conversions. (default: true) + # use_activesupport_time_zone: true + + # Ensure all times are UTC in the app side. (default: false) + # use_utc: false test: - host: <%= ENV['TEST_DB_HOST'] || 'localhost' %> - database: hquery-composer-test - -# set these environment variables on your prod server -production: - host: <%= ENV['MONGOID_HOST'] %> - port: <%= ENV['MONGOID_PORT'] %> - username: <%= ENV['MONGOID_USERNAME'] %> - password: <%= ENV['MONGOID_PASSWORD'] %> - database: <%= ENV['MONGOID_DATABASE'] %> \ No newline at end of file + sessions: + default: + database: query_composer_test + hosts: + - localhost:27017 + options: + consistency: :strong + # In the test environment we lower the retries and retry interval to + # low amounts for fast failures. + max_retries: 1 + retry_interval: 0 diff --git a/config/routes.rb b/config/routes.rb index 59ae62f..57a772f 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ QueryComposer::Application.routes.draw do + post "scheduled_jobs/batch_query", :constraints => {:ip => /127.0.0.1/} + devise_for :users get "admin/users" @@ -30,6 +32,9 @@ get 'edit_code' get 'result' end + collection do + post 'execute_batch' + end end diff --git a/config/ssl_config.rb b/config/ssl_config.rb new file mode 100644 index 0000000..f6c784e --- /dev/null +++ b/config/ssl_config.rb @@ -0,0 +1,45 @@ +module SslConfig + #contains constants for certificate used for SSL + # + USE_SSL_SERVER = true # encrypt browser access to hub + #SERVER_KEY_PATH_ = "cert/composer.key" + #SERVER_CERT_PATH_ = "cert/composer.crt" + SERVER_KEY_PATH_ = "cert/ca/LeadLab_root_cert_TEST.pem" + SERVER_CERT_PATH_ = "cert/ca/LeadLab_root_cert_TEST.pem" + # + USE_SSL_CLIENT = false # don't use SSL to access endpoints + #CLIENT_KEY_PATH = "cert/client.key" + #CLIENT_CERT_PATH = "cert/client.crt" + CLIENT_KEY_PATH = "cert/ca/LeadLab_root_cert_TEST.pem" + CLIENT_CERT_PATH = "cert/ca/LeadLab_root_cert_TEST.pem" + # + #SERVER_KEY_ = OpenSSL::PKey::RSA.new(File.open(SERVER_KEY_PATH_).read) + #SERVER_CERT_ = OpenSSL::X509::Certificate.new(File.open(SERVER_CERT_PATH_).read) + # + CLIENT_KEY = OpenSSL::PKey::RSA.new(File.open(CLIENT_KEY_PATH).read) + CLIENT_CERT = OpenSSL::X509::Certificate.new(File.open(CLIENT_CERT_PATH).read) + + def self.getUseSslServer + USE_SSL_SERVER + end + + def self.getUseSslClient + USE_SSL_CLIENT + end + + def self.getServerKeyPath + SERVER_KEY_PATH_ + end + + def self.getServerCertPath + SERVER_CERT_PATH_ + end + + def self.getClientKeyPath + CLIENT_KEY_PATH + end + + def self.getClientCertPath + CLIENT_CERT_PATH + end +end diff --git a/doc/controllers.png b/doc/controllers.png new file mode 100644 index 0000000..005e69b Binary files /dev/null and b/doc/controllers.png differ diff --git a/doc/controllers_without_engines.png b/doc/controllers_without_engines.png new file mode 100644 index 0000000..b5be852 Binary files /dev/null and b/doc/controllers_without_engines.png differ diff --git a/doc/full_models.png b/doc/full_models.png new file mode 100644 index 0000000..c279dfa Binary files /dev/null and b/doc/full_models.png differ diff --git a/lib/gateway_utils.rb b/lib/gateway_utils.rb index 3844ad7..efe306b 100644 --- a/lib/gateway_utils.rb +++ b/lib/gateway_utils.rb @@ -65,7 +65,8 @@ def submit(endpoint) query_url = endpoint.submit_url request = query_request(full_map(query), full_reduce(query), build_library_functions(query), query.filter, query_url) begin - Net::HTTP.start(query_url.host, query_url.port) do |http| + #use ssl + Net::HTTP.start(query_url.host, query_url.port, :use_ssl => USE_SSL_CLIENT, :key => CLIENT_KEY, :cert => CLIENT_CERT) do |http| response = http.request(request) if response.code == '201' query_url = response['Location'] @@ -79,4 +80,4 @@ def submit(endpoint) end query_url end -end \ No newline at end of file +end diff --git a/lib/tasks/.gitkeep b/lib/tasks/.gitkeep deleted file mode 100755 index e69de29..0000000 diff --git a/lib/tasks/cover_me.rake b/lib/tasks/cover_me.rake index 31856cf..e73ae71 100755 --- a/lib/tasks/cover_me.rake +++ b/lib/tasks/cover_me.rake @@ -1,10 +1,11 @@ namespace :cover_me do - + + desc "Generates and opens code coverage report." task :report do require 'cover_me' CoverMe.complete! end - + end task :test do diff --git a/monitoring/README-nagios.txt b/monitoring/README-nagios.txt new file mode 100644 index 0000000..97d0fd6 --- /dev/null +++ b/monitoring/README-nagios.txt @@ -0,0 +1,159 @@ +This README documents local Nagios configuration modifications used to +monitor the PDC network. When a new endpoint is added, items 3 and 7 +need to be reviewed. + +1. Updates required in /etc/nagios3/conf.d/contacts_nagios2.cfg + +a) Add the following contact information +define contact{ + contact_name derek + alias derek + service_notification_period 24x7 + host_notification_period 24x7 + service_notification_options w,u,c,r + host_notification_options d,r + service_notification_commands notify-service-by-email + host_notification_commands notify-host-by-email + email derek.roberts@gmail.com + } + +define contact{ + contact_name fieran + alias fieran + service_notification_period 24x7 + host_notification_period 24x7 + service_notification_options w,u,c,r + host_notification_options d,r + service_notification_commands notify-service-by-email + host_notification_commands notify-host-by-email + email fieranmason@gmail.com + } + +define contact{ + contact_name simon + alias simon + service_notification_period 24x7 + host_notification_period 24x7 + service_notification_options w,u,c,r + host_notification_options d,r + service_notification_commands notify-service-by-email + host_notification_commands notify-host-by-email + email simon.diemert@gmail.com + } + +b) Modify the members entry of the admins contactgroup in +/etc/nagios3/conf.d/contacts_nagios2.cfg to: + + members fieran,simon,derek + + +2. Add file /etc/nagios3/conf.d/noping-host.cfg. This file is exactly +the same as /etc/nagios3/conf.d/generic-host_nagios2.cfg except that +the line with check_command is commented out: + +Change line: + check_command check-host-alive +to: + ;check_command check-host-alive + +The normal check-host-alive command uses ping but the endpoint servers +are behind a firewall so they do not respond to ping. Instead, each +endpoint has an entry similar to the following: + +define host{ + use noping-host + host_name pdc-nnn + check_command check_alive_pdcnnn + } + +The check_alive_pdcnnn uses the Nagios plugin check_http to determine +whether the endpoint's query-gateway is responding to http requests. +If it is, then the endpoint is considered UP. + +3. Each endpoint will have a configuration file similar to +/etc/nagios3/conf.d/pdc-nnn.cfg with one "define host" entry like that +described above and multiple "define service" commands. These +configuration files are auto-generated. + +4. Create a configuration file for the hub by copying +/etc/nagios3/conf.d/localhost_nagios2.cfg to pdchub.cfg. Replace all +references to localhost with the DNS name of the hub, for instance +pdchub.uvic.ca, and replace the localhost IP address of 127.0.0.1 with +the correct IP address for the PDC hub. This step is not necessary if +Nagios runs on the same host as the hub software. + +5. Add to /etc/nagios3/conf.d/timeperiods_nagios2.cfg the following +timeperiod definition. This entry is needed because Tomcat will not +run on the Oscar endpoints during times when the Oscar database is +being reloaded with the most recent MySQL dump available. + +-------------(start)------------- +# Period when Tomcat server on Oscar EMR endpoints should be running +define timeperiod{ + timeperiod_name importhours + alias E2E Import Hours + sunday 09:30-22:00 + monday 09:30-22:00 + tuesday 09:30-22:00 + wednesday 09:30-22:00 + thursday 09:30-22:00 + friday 09:30-22:00 + saturday 09:30-22:00 + } +-------------( end )------------- + +6. Add to /etc/nagios3/conf.d/services_nagios2.cfg the following: + +-------------(start)------------- +# generic service for Tomcat checks ("use importhours-service,generic-service") +define service { + name importhours-service + check_period importhours + register 0 +} +-------------( end )------------- + +7. Append to /etc/nagios3/commands.cfg the commands used for host and +service checks. They are autogenerated and will have the general +form: + +# commands to check endpoint pdc-NNN +define command{ + command_name check_alive_pdcNNN + command_line $USER1$/check_nrpe -H 142.104.90.75 -c check_alive_pdcNNN +} + +define command{ + command_name diskspace_pdcNNN + command_line $USER1$/check_nrpe -H 142.104.90.75 -c check_diskspace_pdcNNN +} + +define command{ + command_name import_pdcNNN + command_line $USER1$/check_nrpe -H 142.104.90.75 -c check_import_pdcNNN +} + +define command{ + command_name load_pdcNNN + command_line $USER1$/check_nrpe -H 142.104.90.75 -c check_load_pdcNNN +} + +define command{ + command_name processes_pdcNNN + command_line $USER1$/check_nrpe -H 142.104.90.75 -c check_processes_pdcNNN +} + +define command{ + command_name swap_pdcNNN + command_line $USER1$/check_nrpe -H 142.104.90.75 -c check_swap_pdcNNN +} + +define command{ + command_name tomcat_pdcNNN + command_line $USER1$/check_nrpe -H 142.104.90.75 -c check_tomcat_pdcNNN +} + +define command{ + command_name users_pdcNNN + command_line $USER1$/check_nrpe -H 142.104.90.75 -c check_users_pdcNNN +} diff --git a/monitoring/check_service_pdc.template b/monitoring/check_service_pdc.template new file mode 100644 index 0000000..3b645a7 --- /dev/null +++ b/monitoring/check_service_pdc.template @@ -0,0 +1,37 @@ +#!/bin/bash +# Expect two lines of output from call to web server +URL="http://localhost:ep_port/sysinfo/ep_check" +TMPFILE=`/bin/tempfile -p_PDC_` +CMD=`/usr/bin/curl -sSf $URL > $TMPFILE 2>&1` +STATUS=$? +if [ $STATUS -ne 0 ]; then + /bin/echo "UNKNOWN - For $URL got $(cat $TMPFILE)" + /bin/rm $TMPFILE + exit 3 +fi +# first line should be Nagios message +NAGIOSMSG=`/usr/bin/head -1 $TMPFILE` +# second line should be Nagios status code +STATUSSTR=`/bin/cat $TMPFILE | /usr/bin/head -2 | /usr/bin/tail -1` +/bin/rm $TMPFILE +NAGIOSSTATUS=-1 +if [ "$STATUSSTR" == "Status Code: 0" ]; then + NAGIOSSTATUS=0 +fi +if [ "$STATUSSTR" == "Status Code: 1" ]; then + NAGIOSSTATUS=1 +fi +if [ "$STATUSSTR" == "Status Code: 2" ]; then + NAGIOSSTATUS=2 +fi +if [ "$STATUSSTR" == "Status Code: 3" ]; then + NAGIOSSTATUS=3 +fi +if [ "$NAGIOSSTATUS" -ge 0 -a "$NAGIOSSTATUS" -le 3 ]; then + echo $NAGIOSMSG + exit $NAGIOSSTATUS +else + # shouldn't get here unless there was a completely unexpected response + /bin/echo "UNKNOWN - Unexpected response from \"$URL\". Return status $STATUS" + exit 3 +fi diff --git a/monitoring/commands_cfg.prefix b/monitoring/commands_cfg.prefix new file mode 100644 index 0000000..e2cabf1 --- /dev/null +++ b/monitoring/commands_cfg.prefix @@ -0,0 +1,50 @@ +############################################################################### +# COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS +############################################################################### + + +################################################################################ +# NOTIFICATION COMMANDS +################################################################################ + + +# 'notify-host-by-email' command definition +define command{ + command_name notify-host-by-email + command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ + } + +# 'notify-service-by-email' command definition +define command{ + command_name notify-service-by-email + command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ + } + + + + + +################################################################################ +# HOST CHECK COMMANDS +################################################################################ + +# On Debian, check-host-alive is being defined from within the +# nagios-plugins-basic package + +################################################################################ +# PERFORMANCE DATA COMMANDS +################################################################################ + + +# 'process-host-perfdata' command definition +define command{ + command_name process-host-perfdata + command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /var/lib/nagios3/host-perfdata.out + } + + +# 'process-service-perfdata' command definition +define command{ + command_name process-service-perfdata + command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /var/lib/nagios3/service-perfdata.out + } diff --git a/monitoring/generate_nagios3_config.sh b/monitoring/generate_nagios3_config.sh new file mode 100755 index 0000000..a97e8e5 --- /dev/null +++ b/monitoring/generate_nagios3_config.sh @@ -0,0 +1,203 @@ +#!/bin/sh +# +# Endpoint ids and corresponding checks (Oscar) +ep_ids_oscar="0 1 2 3 4 5 6 7 8 9 11" +ep_checks_oscar="diskspace import load processes swap tomcat users" +# Endpoint ids and corresponding checks (Osler) +ep_ids_osler="" +ep_checks_osler="diskspace load processes swap users" + +print_info() { + echo + echo "Hub NRPE server monitoring configuration:" + echo "----------------------------" + echo "WARNING: Don't change any NRPE command or plugin that the Nagios host" + echo "expects to find present on the NRPE server while Nagios is running." + echo "Otherwise, there is likely to be a flood of alerts." + echo "NRPE commands are written into ./nagios-nrpe-server-config/nrpe_local.cfg." + echo "Use this to replace /etc/nagios/nrpe_local.cfg after checking correctness." + echo "The plugins are written into ./nagios-nrpe-server-config/plugins. Move the" + echo "plugins to /usr/local/lib/nagios once they have been checked for correctness." + echo "The script verify_nrpe.sh will assist in checking the generated files." + echo "Reload nrpe configuration on the hub using" + echo " 'sudo service nagios-nrpe-server reload'" + echo + echo "Nagios host configuration:" + echo "-------------------------" + echo "Nagios commands are written into ./nagios-config/commands.cfg." + echo "They should be verified carefully and then copied to" + echo "/etc/nagios3/commands.cfg on the Nagios host." + echo "Endpoint specific Nagios configuration files are in" + echo "./nagios-config/conf.d/pdc-XXX.cfg. They should be" + echo "verifed carefully and then copied to /etc/nagios3/conf.d/." + echo "The script verify_nagios.sh will assist in checking the generated files." + echo "The generated Nagios configuration should then be checked using" + echo " '/usr/sbin/nagios3 -v /etc/nagios3/nagios.cfg'" + echo "If there are no errors or warnings, it should be safe to execute" + echo " 'sudo service nagios3 restart'" + echo +} + +# remove and rebuild Nagios configuration and hub NRPE server configuration +/bin/rm -rf nagios-config && /bin/mkdir -p nagios-config/conf.d +/bin/rm -rf nagios-nrpe-server-config && /bin/mkdir -p nagios-nrpe-server-config/plugins + +# The function service_description provides a description of +# the service defined in configuration files named +# /etc/nagios3/conf.d/pdc-XXX.cfg on the Nagios host. +# The description is used to provide a informative label +# for the service check on the Nagios services web page. +# Requires one input parameter specifying the service check. +service_description() { + if [ "diskspace" = $1 ]; then + echo " service_description Disk Space" + elif [ "import" = $1 ]; then + echo " service_description Current E2E Import" + elif [ "load" = $1 ]; then + echo " service_description Current Load" + elif [ "processes" = $1 ]; then + echo " service_description Total Processes" + elif [ "swap" = $1 ]; then + echo " service_description Swap Usage" + elif [ "tomcat" = $1 ]; then + echo " service_description Tomcat Process" + elif [ "users" = $1 ]; then + echo " service_description Current Users" + else + echo $2 + fi +} + +generate_endpoint_header() { + echo "# Custom services specific to this host are added here, but services" + echo "# defined in nagios2-common_services.cfg may also apply." + echo +} + +# The function generate_host_definition provides the host definition +# in the configuration files /etc/nagios3/conf.d/pdc-XXX.cfg on the +# Nagios host. +# Requires one input parameter specifying the host id +generate_host_definition() { + ep_id=$1 + echo + echo "# commands to check endpoint pdc-$ep_id" + echo "define host {" + echo " use noping-host" + echo " host_name pdc-$ep_id" + echo " check_command check_alive_pdc$ep_id" + echo "}" +} + +# The function generate_host_service_definition provides the service +# definition in the configuration files /etc/nagios3/conf.d/pdc-XXX.cfg on +# the Nagios host. +# Requires two input parameters specifying the host id and service checked. +generate_host_service_definition() { + ep_id=$1 + echo "define service {" + if [ "tomcat" = $2 ]; then + echo " use importhours-service,generic-service" + else + echo " use generic-service" + fi + echo " host_name pdc-$ep_id" + service_description $2 + echo " check_command $2_pdc$ep_id" + echo "}" +} + +# The function generate_nagios_command_definition specifies +# the host commands in /etc/nagios3/commands.cfg on the Nagios host. +# Requires two input parameters specifying the host id and the +# service that nagios is checking. The check_alive service +# is special because it determines whether the query-gateway +# is responding to http requests at the endpoint. When it +# doesn't respond the host endpoint is considered DOWN. +generate_nagios_command_definition() { + ep_id=$1 + if [ "alive" = "$2" ]; then + echo + echo "# commands to check endpoint pdc-$ep_id" + echo "define command{" + echo " command_name check_alive_pdc$ep_id" + echo " command_line \$USER1\$/check_nrpe -H 142.104.90.75 -c check_alive_pdc$ep_id" + echo "}" + else + echo "define command{" + echo " command_name $2_pdc$ep_id" + echo " command_line \$USER1\$/check_nrpe -H 142.104.90.75 -c check_$2_pdc$ep_id" + echo "}" + fi +} + +# The function generate_service_host_plugin generates the +# endpoint service plugin called by the NRPE server on the hub. +# The plugins are kept in /usr/local/lib/nagios on the hub. +# Requires two input parameters, the endpoint id and the +# endpoint service being checked. +generate_service_host_plugin() { + ep_id=$1 + ep_port=`/usr/bin/expr 10300 + $1` + /bin/sed "s/ep_port/$ep_port/;s/ep_check/$2/" ./check_service_pdc.template > ./nagios-nrpe-server-config/plugins/check_"$2"_"pdc$ep_id".sh + chmod +x ./nagios-nrpe-server-config/plugins/check_"$2"_"pdc$ep_id".sh +} + +# The function generate_nrpe_command specifies commands that the +# NRPE server can execute on the hub with the add of plugins. +# Requires two input parameters, the endpoint id and the +# endpoint service being checked. +generate_nrpe_command() { + ep_id=$1 + echo command[check_"$2"_"pdc$ep_id"]=/usr/local/lib/nagios/check_"$2"_"pdc$ep_id".sh +} + +# The function generate_alive_command specifies the commands that the NRPE server can +# execute on the hub using check_http to determine whether the query-gateway is running +# at an endpoint. +# Requires one input parameter specifying the endpoint id. +generate_alive_command() { + ep_id=$1 + ep_port=`/usr/bin/expr 10300 + $1` + echo "# pdc$ep_id checks" + echo command[check_alive_"pdc$ep_id"]=/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -p $ep_port +} + + +cp ./nrpe_local_cfg.prefix ./nagios-nrpe-server-config/nrpe_local.cfg +cp ./commands_cfg.prefix ./nagios-config/commands.cfg + +# generate oscar configuration and plugins +for id in $ep_ids_oscar +do + ep_id=`/usr/bin/expr 1000 + $id | cut -d1 -f2-` + generate_endpoint_header > ./nagios-config/conf.d/pdc-$ep_id.cfg + generate_host_definition $ep_id >> ./nagios-config/conf.d/pdc-$ep_id.cfg + generate_nagios_command_definition $ep_id "alive" >> ./nagios-config/commands.cfg + generate_alive_command $ep_id >> ./nagios-nrpe-server-config/nrpe_local.cfg + for check in $ep_checks_oscar + do + generate_host_service_definition $ep_id $check >> ./nagios-config/conf.d/pdc-$ep_id.cfg + generate_nagios_command_definition $ep_id $check >> ./nagios-config/commands.cfg + generate_service_host_plugin $ep_id $check # writes file directly + generate_nrpe_command $ep_id $check >> ./nagios-nrpe-server-config/nrpe_local.cfg + done +done +# generate osler configuration and plugins +for id in $ep_ids_osler +do + ep_id=`/usr/bin/expr 1000 + $id | cut -d1 -f2-` + generate_endpoint_header > ./nagios-config/conf.d/pdc-$ep_id.cfg + generate_host_definition $ep_id >> ./nagios-config/conf.d/pdc-$ep_id.cfg + generate_nagios_command_definition $ep_id "alive" >> ./nagios-config/commands.cfg + generate_alive_command $ep_id >> ./nagios-nrpe-server-config/nrpe_local.cfg + for check in $ep_checks_osler + do + generate_host_service_definition $ep_id $check >> ./nagios-config/conf.d/pdc-$ep_id.cfg + generate_nagios_command_definition $ep_id $check >> ./nagios-config/commands.cfg + generate_service_host_plugin $ep_id $check # writes file directly + generate_nrpe_command $ep_id $check >> ./nagios-nrpe-server-config/nrpe_local.cfg + done +done + +print_info diff --git a/monitoring/nagios-nrpe-server.md b/monitoring/nagios-nrpe-server.md new file mode 100644 index 0000000..3fa92b0 --- /dev/null +++ b/monitoring/nagios-nrpe-server.md @@ -0,0 +1,8 @@ +The local configuration is stored in /etc/nagios/nagios_local.cnf to make +it easier to find non-default behaviour. + +Changes made to nagios_local.cnf do not take effect until nagios-nrpe-server is restarted or the following command is issued: + +$ sudo service nagios-nrpe-server reload + +The PDC specific command definitions execute plugins stored in /usr/local/lib/nagios. diff --git a/monitoring/nrpe_command.template b/monitoring/nrpe_command.template new file mode 100644 index 0000000..05e2c8d --- /dev/null +++ b/monitoring/nrpe_command.template @@ -0,0 +1,9 @@ +# pdc_epid checks +command[check_alive_pdc_epid]=/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -p ep_port +command[check_diskspace_pdc_epid]=/usr/local/lib/nagios/check_diskspace_pdc_epid.sh +command[check_import_pdc_epid]=/usr/local/lib/nagios/check_import_pdc_epid.sh +command[check_load_pdc_epid]=/usr/local/lib/nagios/check_load_pdc_epid.sh +command[check_processes_pdc_epid]=/usr/local/lib/nagios/check_processes_pdc_epid.sh +command[check_swap_pdc_epid]=/usr/local/lib/nagios/check_swap_pdc_epid.sh +command[check_tomcat_pdc_epid]=/usr/local/lib/nagios/check_tomcat_pdc_epid.sh +command[check_users_pdc_epid]=/usr/local/lib/nagios/check_users_pdc_epid.sh diff --git a/monitoring/nrpe_local_cfg.prefix b/monitoring/nrpe_local_cfg.prefix new file mode 100644 index 0000000..f689d9c --- /dev/null +++ b/monitoring/nrpe_local_cfg.prefix @@ -0,0 +1,42 @@ +###################################### +# Do any local nrpe configuration here +###################################### +# +# ALLOWED HOST ADDRESSES +# This is an optional comma-delimited list of IP address or hostnames +# that are allowed to talk to the NRPE daemon. Network addresses with a bit mask +# (i.e. 192.168.1.0/24) are also supported. Hostname wildcards are not currently +# supported. +# +# Note: The daemon only does rudimentary checking of the client's IP +# address. I would highly recommend adding entries in your /etc/hosts.allow +# file to allow only the specified host to connect to the port +# you are running this daemon on. +# +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +allowed_hosts=127.0.0.1,142.104.90.77 + +# COMMAND DEFINITIONS +# Command definitions that this daemon will run. Definitions +# are in the following format: +# +# command[]= +# +# When the daemon receives a request to return the results of +# it will execute the command specified by the argument. +# +# Unlike Nagios, the command line cannot contain macros - it must be +# typed exactly as it should be executed. +# +# Note: Any plugins that are used in the command lines must reside +# on the machine that this daemon is running on! The examples below +# assume that you have plugins installed in a /usr/local/lib/nagios +# directory. Also note that you will have to modify the definitions below +# to match the argument format the plugins expect. Remember, these are +# examples only! + +# The following commands use hardcoded arguments... + +command[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -e + diff --git a/monitoring/verify_nagios.sh b/monitoring/verify_nagios.sh new file mode 100755 index 0000000..331608a --- /dev/null +++ b/monitoring/verify_nagios.sh @@ -0,0 +1,18 @@ +#!/bin/sh +cd nagios-config +echo "Differencing generated commands.cfg and /etc/nagios3/commands.cfg" +echo "Begin diff..." +diff -bB commands.cfg /etc/nagios3/commands.cfg +echo "End diff" +cd conf.d +echo "Differencing generated endpoint specific configuration and those in" +echo "/etc/nagios3/conf.d/pdc-XXX.cfg" +echo "Begin diffs..." +for i in * ; do diff -bB $i /etc/nagios3/conf.d/$i ; done +echo "End diffs" +echo "If all the differences shown are expected it should be safe to copy" +echo "the generated files into their proper location and then to execute" +echo " /usr/sbin/nagios3 -v /etc/nagios3/nagios.cfg" +echo "If there are no errors or warnings restart Nagios with the new" +echo "configuration by executing" +echo " sudo service nagios3 restart" diff --git a/monitoring/verify_nrpe.sh b/monitoring/verify_nrpe.sh new file mode 100755 index 0000000..113f237 --- /dev/null +++ b/monitoring/verify_nrpe.sh @@ -0,0 +1,14 @@ +#!/bin/sh +cd nagios-nrpe-server-config +echo "Differencing generated nrpe_local.cfg and /etc/nagios/nrpe_local.cfg" +echo "Begin diff..." +diff -bB nrpe_local.cfg /etc/nagios/nrpe_local.cfg +echo "End diff" +cd plugins +echo "Differencing generated plugins and those in /usr/local/lib/nagios/" +echo "Begin diffs..." +for i in * ; do diff -bB $i /usr/local/lib/nagios/$i ; done +echo "End diffs" +echo "If all the differences shown are expected it should be safe to copy" +echo "the generated files into their proper location and then to execute" +echo " sudo service nagios-nrpe-server reload" diff --git a/public/patientapi/files.html b/public/patientapi/files.html index 1264c28..9af1b54 100644 --- a/public/patientapi/files.html +++ b/public/patientapi/files.html @@ -212,8 +212,12 @@

Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -234,6 +238,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -263,7 +269,7 @@

    File Index

    -

    tmp\patient.js

    +

    tmp/patient.js

    @@ -278,7 +284,7 @@

    tmp\patient.js

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    \ No newline at end of file diff --git a/public/patientapi/index.html b/public/patientapi/index.html index 119d7d9..4632901 100644 --- a/public/patientapi/index.html +++ b/public/patientapi/index.html @@ -212,8 +212,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -234,6 +238,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -349,12 +355,24 @@

    hQuery.Encounter


    +
    +

    hQuery.Facility

    + a Facility +
    +
    +

    hQuery.Fulfillment

    Fulfillment - information about when and who fulfilled an order for the medication

    + +
    +

    hQuery.Immunization

    represents a immunization entry for a patient. @@ -415,6 +433,12 @@

    hQuery.Person


    +
    +

    hQuery.PhysicalQuantity

    + PhysicalQuantity - a representation of a physical quantity +
    +
    +

    hQuery.Pregnancy

    @@ -480,7 +504,7 @@

    hQuery.TypeOfMedication
    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    \ No newline at end of file diff --git a/public/patientapi/symbols/__hasProp.html b/public/patientapi/symbols/__hasProp.html index 9769c2c..cf29267 100644 --- a/public/patientapi/symbols/__hasProp.html +++ b/public/patientapi/symbols/__hasProp.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -361,7 +367,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:26 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/_global_.html b/public/patientapi/symbols/_global_.html index a6bf542..e257ced 100644 --- a/public/patientapi/symbols/_global_.html +++ b/public/patientapi/symbols/_global_.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -388,7 +394,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:26 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Actor.html b/public/patientapi/symbols/hQuery.Actor.html index 569b011..f73e7c9 100644 --- a/public/patientapi/symbols/hQuery.Actor.html +++ b/public/patientapi/symbols/hQuery.Actor.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -497,7 +503,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:26 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Address.html b/public/patientapi/symbols/hQuery.Address.html index 0285496..0430828 100644 --- a/public/patientapi/symbols/hQuery.Address.html +++ b/public/patientapi/symbols/hQuery.Address.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -593,7 +599,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:26 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.AdministrationTiming.html b/public/patientapi/symbols/hQuery.AdministrationTiming.html index 88b7053..67141e2 100644 --- a/public/patientapi/symbols/hQuery.AdministrationTiming.html +++ b/public/patientapi/symbols/hQuery.AdministrationTiming.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -517,7 +523,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Allergy.html b/public/patientapi/symbols/hQuery.Allergy.html index 7713e14..6c562b7 100644 --- a/public/patientapi/symbols/hQuery.Allergy.html +++ b/public/patientapi/symbols/hQuery.Allergy.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    @@ -347,7 +353,7 @@

    <inner>   -
    - hQuery.Allergy() + hQuery.Allergy(_super)
    @@ -427,6 +433,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -507,7 +524,7 @@

    <inner> - Allergy() + Allergy(json)
    @@ -519,6 +536,17 @@

    +
    +
    Parameters:
    + +
    + json + +
    +
    + +
    + @@ -694,7 +722,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.CauseOfDeath.html b/public/patientapi/symbols/hQuery.CauseOfDeath.html index 56c32fc..b905179 100644 --- a/public/patientapi/symbols/hQuery.CauseOfDeath.html +++ b/public/patientapi/symbols/hQuery.CauseOfDeath.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -511,7 +517,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.CodedEntry.html b/public/patientapi/symbols/hQuery.CodedEntry.html index c88b8fd..bf5c227 100644 --- a/public/patientapi/symbols/hQuery.CodedEntry.html +++ b/public/patientapi/symbols/hQuery.CodedEntry.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -342,6 +348,15 @@

    + +   + +
    endDate() +
    +
    Date and time at which the coded entry ended
    + + +   @@ -354,18 +369,109 @@

      -
    id() + -
    Unique identifier for this coded entry
    +
    Returns true if any of this entry codes match a code in the supplied codeSet.
      -
    includesCodeFrom(codeSet) + +
    Determines whether the entry specifies a time range or not
    + + + + +   + + +
    Determines whether a coded entry contains sufficient information (code and at least + one time stamp) to be usable
    + + + + +   + + +
    + + + + +   + + +
    Indicates the reason an entry was negated.
    + + + + +   + +
    reason() +
    +
    Explains the reason for an entry.
    + + + + +   + + +
    Returns true if any of this entry codes match a code in the supplied codeSet.
    + + + + +   + +
    setTimestamp(timestamp) +
    +
    Adjust the start and end times of this event to the supplied timestamp
    + + + + +   + + -
    Returns true if any of this entry's codes match a code in the supplied codeSet.
    +
    Date and time at which the coded entry started
    + + + + +   + +
    status() +
    +
    Status for this coded entry
    + + + + +   + + +
    Status for this coded entry
    + + + + +   + + +
    Tries to find a single point in time for this entry.
    @@ -378,6 +484,15 @@

    + +   + +
    values() +
    +
    Returns the values of the result.
    + + + @@ -494,15 +609,15 @@


    - +
    - {String} - freeTextType() + {Date} + endDate()
    - A free text description of the type of coded entry + Date and time at which the coded entry ended
    @@ -517,7 +632,7 @@

    Returns:
    -
    {String}
    +
    {Date}
    @@ -526,15 +641,15 @@


    - +
    {String} - id() + freeTextType()
    - Unique identifier for this coded entry + A free text description of the type of coded entry
    @@ -566,7 +681,7 @@

    - Returns true if any of this entry's codes match a code in the supplied codeSet. + Returns true if any of this entry codes match a code in the supplied codeSet.
    @@ -599,6 +714,375 @@

    +
    + + +
    + + {boolean} + isTimeRange() + +
    +
    + Determines whether the entry specifies a time range or not + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {boolean}
    + +
    + + + + +
    + + +
    + + {boolean} + isUsable() + +
    +
    + Determines whether a coded entry contains sufficient information (code and at least + one time stamp) to be usable + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {boolean}
    + +
    + + + + +
    + + +
    + + {Boolean} + negationInd() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Boolean} whether the entry was negated
    + +
    + + + + +
    + + +
    + + {hQuery.CodedValue} + negationReason() + +
    +
    + Indicates the reason an entry was negated. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {hQuery.CodedValue} Used to indicate reason an immunization was not administered.
    + +
    + + + + +
    + + +
    + + {hQuery.CodedValue} + reason() + +
    +
    + Explains the reason for an entry. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {hQuery.CodedValue} Used to explain the rationale for a given entry.
    + +
    + + + + +
    + + +
    + + {boolean} + regex_includesCodeFrom(codeSet) + +
    +
    + Returns true if any of this entry codes match a code in the supplied codeSet. + + +
    + + + + +
    +
    Parameters:
    + +
    + {Object} codeSet + +
    +
    a hash with code system names as keys and an array of codes (provided as regular expressions) as values
    + +
    + + + + + +
    +
    Returns:
    + +
    {boolean}
    + +
    + + + + +
    + + +
    + + + setTimestamp(timestamp) + +
    +
    + Adjust the start and end times of this event to the supplied timestamp + + +
    + + + + +
    +
    Parameters:
    + +
    + timestamp + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {Date} + startDate() + +
    +
    + Date and time at which the coded entry started + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Date}
    + +
    + + + + +
    + + +
    + + {String} + status() + +
    +
    + Status for this coded entry + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {String}
    + +
    + + + + +
    + + +
    + + {Hash} + statusCode() + +
    +
    + Status for this coded entry + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Hash} keys are code systems, values are arrays of codes
    + +
    + + + + +
    + + +
    + + {Date} + timeStamp() + +
    +
    + Tries to find a single point in time for this entry. Will first return date if it is present, + then fall back to startDate and finally endDate + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Date}
    + +
    + + + +
    @@ -631,6 +1115,39 @@

    +
    + + +
    + + {Array} + values() + +
    +
    + Returns the values of the result. This will return an array that contains + PhysicalQuantity or CodedValue objects depending on the result type. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Array} containing either PhysicalQuantity and/or CodedValues
    + +
    + + + + @@ -645,7 +1162,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.CodedEntryList.html b/public/patientapi/symbols/hQuery.CodedEntryList.html index ddfdeab..89fdb15 100644 --- a/public/patientapi/symbols/hQuery.CodedEntryList.html +++ b/public/patientapi/symbols/hQuery.CodedEntryList.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -299,7 +305,7 @@

     
    @@ -337,13 +343,68 @@

      -
    match(codeSet, start, end) +
    concat(otherEntries) +
    +
    Return a new list of entries that is the result of concatenating the passed in entries with this list
    + + + + +   + +
    match(codeSet, start, end, includeNegated) +
    +
    Return the number of entries that match the + supplied code set where those entries occur between the supplied time bounds
    + + + + +   + + +
    Push the supplied entry onto this list if it is usable
    + + + + +   + +
    regex_match(codeSet, start, end, includeNegated)
    Return the number of entries that match the supplied code set where those entries occur between the supplied time bounds
    + +   + +
    withNegation(codeSet) +
    +
    Filter entries based on negation
    + + + + +   + + +
    Filter entries based on negation
    + + + + +   + +
    withStatuses(statuses, includeUndefined) +
    +
    Match entries with the specified statuses
    + + + @@ -361,7 +422,7 @@

    - hQuery.CodedEntryList() + hQuery.CodedEntryList(_super)
    @@ -373,6 +434,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -415,13 +487,56 @@

    +
    + + +
    + + {CodedEntryList} + concat(otherEntries) + +
    +
    + Return a new list of entries that is the result of concatenating the passed in entries with this list + + +
    + + + + +
    +
    Parameters:
    + +
    + otherEntries + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    {CodedEntryList} the set of concatenated entries
    + +
    + + + +
    - {Array[CodedEntry]} - match(codeSet, start, end) + {CodedEntryList} + match(codeSet, start, end, includeNegated)
    @@ -455,6 +570,235 @@

    the end of the period during which the entry must occur, a null value will match all times
    +
    + {boolean} includeNegated + +
    +
    whether the returned list of entries should include those that have been negated
    + + + + + + + +
    +
    Returns:
    + +
    {CodedEntryList} the matching entries
    + +
    + + + + +
    + + +
    + + + pushIfUsable(a) + +
    +
    + Push the supplied entry onto this list if it is usable + + +
    + + + + +
    +
    Parameters:
    + +
    + {CodedEntry} a + +
    +
    coded entry that should be added to the list if it is usable
    + +
    + + + + + + + + +
    + + +
    + + {CodedEntryList} + regex_match(codeSet, start, end, includeNegated) + +
    +
    + Return the number of entries that match the + supplied code set where those entries occur between the supplied time bounds + + +
    + + + + +
    +
    Parameters:
    + +
    + {Object} codeSet + +
    +
    a hash with code system names as keys and an array of codes (provided as regular expressions) as values
    + +
    + {Date} start + +
    +
    the start of the period during which the entry must occur, a null value will match all times
    + +
    + {Date} end + +
    +
    the end of the period during which the entry must occur, a null value will match all times
    + +
    + {boolean} includeNegated + +
    +
    whether the returned list of entries should include those that have been negated
    + +
    + + + + + +
    +
    Returns:
    + +
    {CodedEntryList} the matching entries + TODO - decide on what to do with includeNegated parameter
    + +
    + + + + +
    + + +
    + + {CodedEntryList} + withNegation(codeSet) + +
    +
    + Filter entries based on negation + + +
    + + + + +
    +
    Parameters:
    + +
    + {Object} codeSet + +
    +
    a hash with code system names as keys and an array of codes as values
    + +
    + + + + + +
    +
    Returns:
    + +
    {CodedEntryList} negated entries
    + +
    + + + + +
    + + +
    + + {CodedEntryList} + withoutNegation() + +
    +
    + Filter entries based on negation + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CodedEntryList} non-negated entries
    + +
    + + + + +
    + + +
    + + {CodedEntryList} + withStatuses(statuses, includeUndefined) + +
    +
    + Match entries with the specified statuses + + +
    + + + + +
    +
    Parameters:
    + +
    + statuses + +
    +
    + +
    + includeUndefined + +
    +
    +
    @@ -464,7 +808,7 @@

    Returns:
    -
    {Array[CodedEntry]} the matching entries
    +
    {CodedEntryList} the matching entries
    @@ -485,7 +829,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.CodedValue.html b/public/patientapi/symbols/hQuery.CodedValue.html index da66fce..ee30b69 100644 --- a/public/patientapi/symbols/hQuery.CodedValue.html +++ b/public/patientapi/symbols/hQuery.CodedValue.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -360,6 +366,24 @@

    + + <static>   + +
    hQuery.CodedValue.normalize(val) +
    +
    + + + + +   + +
    regex_includedIn(codeSet) +
    +
    Returns true if the contained code and codeSystemName match a code in the supplied codeSet.
    + + + @@ -555,6 +579,85 @@

    +
    + + +
    <static> + + + hQuery.CodedValue.normalize(val) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + val + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {boolean} + regex_includedIn(codeSet) + +
    +
    + Returns true if the contained code and codeSystemName match a code in the supplied codeSet. + + +
    + + + + +
    +
    Parameters:
    + +
    + {Object} codeSet + +
    +
    a hash with code system names as keys and an array of codes (provided as regular expressions) as values
    + +
    + + + + + +
    +
    Returns:
    + +
    {boolean}
    + +
    + + + + @@ -569,7 +672,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Condition.html b/public/patientapi/symbols/hQuery.Condition.html index 772915e..fd7880a 100644 --- a/public/patientapi/symbols/hQuery.Condition.html +++ b/public/patientapi/symbols/hQuery.Condition.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -304,7 +310,7 @@

     
    @@ -375,6 +381,15 @@

    + +   + + +
    Ordinality
    + + +   @@ -393,13 +408,22 @@

    + +   + + +
    This is a description of the level of the severity of the condition.
    + + +
    -
    Methods borrowed from class hQuery.CodedEntry:
    date, freeTextType, id, includesCodeFrom, type
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, type, values
    @@ -414,7 +438,7 @@

    - hQuery.Condition() + hQuery.Condition(_super)
    @@ -426,6 +450,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -607,6 +642,38 @@

    +
    + + +
    + + {CodedValue} + ordinality() + +
    +
    + Ordinality + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CodedValue}
    + +
    + + + +
    @@ -671,6 +738,38 @@

    +
    + + +
    + + {CodedValue} + severity() + +
    +
    + This is a description of the level of the severity of the condition. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CodedValue}
    + +
    + + + + @@ -685,7 +784,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.DateRange.html b/public/patientapi/symbols/hQuery.DateRange.html index 1688b25..1db39f5 100644 --- a/public/patientapi/symbols/hQuery.DateRange.html +++ b/public/patientapi/symbols/hQuery.DateRange.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -497,7 +503,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.DoseRestriction.html b/public/patientapi/symbols/hQuery.DoseRestriction.html index e359240..7e8ee49 100644 --- a/public/patientapi/symbols/hQuery.DoseRestriction.html +++ b/public/patientapi/symbols/hQuery.DoseRestriction.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -497,7 +503,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Encounter.html b/public/patientapi/symbols/hQuery.Encounter.html index b3fb2e4..ef1407c 100644 --- a/public/patientapi/symbols/hQuery.Encounter.html +++ b/public/patientapi/symbols/hQuery.Encounter.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -301,11 +307,11 @@

     
    An Encounter is an interaction, regardless of the setting, between a patient and a practitioner who is vested with primary responsibility for diagnosing, evaluating, -or treating the patient's condition.
    +or treating the patients condition.

    @@ -329,6 +335,15 @@

    + +   + + +
    Date and time at which the patient was admitted for the encounter
    + + +   @@ -341,16 +356,25 @@

      -
    dischargeDisp() +
    + +   + + +
    Date and time at which the patient was discharged for the encounter
    + + + <inner>   -
    Encounter() +
    Encounter(json)
    @@ -359,7 +383,7 @@

      -
    encounterDuration() +
    @@ -368,7 +392,25 @@

      -
    facility() + +
    + + + + +   + + +
    + + + + +   + +
    @@ -392,13 +434,31 @@

    + +   + + +
    + + + + +   + + +
    + + +
    -
    Methods borrowed from class hQuery.CodedEntry:
    date, freeTextType, id, includesCodeFrom, type
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, type, values
    @@ -413,13 +473,13 @@

    - hQuery.Encounter() + hQuery.Encounter(_super)
    An Encounter is an interaction, regardless of the setting, between a patient and a practitioner who is vested with primary responsibility for diagnosing, evaluating, -or treating the patient's condition. It may include visits, appointments, as well +or treating the patients condition. It may include visits, appointments, as well as non face-to-face interactions. It is also a contact between a patient and a practitioner who has primary responsibility for assessing and treating the patient at a given contact, exercising independent judgment. @@ -430,6 +490,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -449,6 +520,38 @@

    Method Detail

    + +
    + + {Date} + admitTime() + +
    +
    + Date and time at which the patient was admitted for the encounter + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Date}
    + +
    + + + + +
    +
    @@ -482,11 +585,11 @@


    - +
    {String} - dischargeDisp() + dischargeDisposition()
    @@ -512,13 +615,45 @@

    +
    + + +
    + + {Date} + dischargeTime() + +
    +
    + Date and time at which the patient was discharged for the encounter + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Date}
    + +
    + + + +
    <inner> - Encounter() + Encounter(json)
    @@ -530,6 +665,17 @@

    +
    +
    Parameters:
    + +
    + json + +
    +
    + +
    + @@ -539,11 +685,11 @@


    - +
    - {hQuery.DateRange} - encounterDuration() + {hQuery.Organization} + facility()
    @@ -562,7 +708,7 @@

    Returns:
    -
    {hQuery.DateRange}
    +
    {hQuery.Organization}
    @@ -571,11 +717,61 @@


    - +
    - {hQuery.Organization} - facility() + + facilityArrival() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + facilityDeparture() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + {Integer} + lengthOfStay()
    @@ -594,7 +790,7 @@

    Returns:
    -
    {hQuery.Organization}
    +
    {Integer}
    @@ -665,6 +861,70 @@

    +
    + + +
    + + {CodedValue} + transferFrom() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CodedValue}
    + +
    + + + + +
    + + +
    + + {CodedValue} + transferTo() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CodedValue}
    + +
    + + + + @@ -679,7 +939,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Facility.html b/public/patientapi/symbols/hQuery.Facility.html new file mode 100644 index 0000000..71762b2 --- /dev/null +++ b/public/patientapi/symbols/hQuery.Facility.html @@ -0,0 +1,452 @@ + + + + + + + JsDoc Reference - hQuery.Facility + + + + + + + + + + + + + +
    + +

    + + Class hQuery.Facility +

    + + +

    + + + + a Facility + + +
    Defined in: patient.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      +
    + hQuery.Facility(_super) +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <inner>   +
    Facility(json) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + hQuery.Facility(_super) +
    + +
    + + +
    + + + + + +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    <inner> + + + Facility(json) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + json + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT) +
    + + diff --git a/public/patientapi/symbols/hQuery.Fulfillment.html b/public/patientapi/symbols/hQuery.Fulfillment.html index 179e3d7..82d31a7 100644 --- a/public/patientapi/symbols/hQuery.Fulfillment.html +++ b/public/patientapi/symbols/hQuery.Fulfillment.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -429,7 +435,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.FunctionalStatus.html b/public/patientapi/symbols/hQuery.FunctionalStatus.html new file mode 100644 index 0000000..80478f9 --- /dev/null +++ b/public/patientapi/symbols/hQuery.FunctionalStatus.html @@ -0,0 +1,558 @@ + + + + + + + JsDoc Reference - hQuery.FunctionalStatus + + + + + + + + + + + + + +
    + +

    + + Class hQuery.FunctionalStatus +

    + + +

    + +
    Extends + hQuery.CodedEntry.
    + + + + + +
    Defined in: patient.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    This class can be used to represnt a functional status for a patient.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <inner>   + +
    +
      +
    source() +
    +
    A coded value.
    +
      +
    type() +
    +
    Either "condition" or "result"
    +
    + + + +
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, values
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + hQuery.FunctionalStatus(_super) +
    + +
    + This class can be used to represnt a functional status for a patient. Currently, +it is not a very close representation of functional status as it is represented +in the HL7 CCD, HITSP C32 or Consolidated CDA. + +In the previously mentioned specifications, functional status may represented +using either a condition or result. Having "mixed" types of entries in a section +is currently not well supported in the existing Record class + +Additionally, there is a mismatch between the data needed to calculate Stage 2 +Meaningful Use Quailty Measures and the data contained in patient summary +standards. The CQMs are checking to see if a functional status represented by +a result was patient supplied. Right now, results do not have a source, and +even if we were to use Provider as a source, it would need to be extended +to support patients. + +To avoid this, the patient sumamry style functional status has been "flattened" +into this class. This model supports the information needed to calculate +Stage 2 MU CQMs. If importers are created from C32 or CCDA, the information +can be stored here, but it will be a lossy transformation. + +
    + + + + + +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    <inner> + + + FunctionalStatus(json) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + json + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {hQuery.CodedValue} + source() + +
    +
    + A coded value. Like a code for patient supplied. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {hQuery.CodedValue}
    + +
    + + + + +
    + + +
    + + {String} + type() + +
    +
    + Either "condition" or "result" + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {String}
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT) +
    + + diff --git a/public/patientapi/symbols/hQuery.Immunization.html b/public/patientapi/symbols/hQuery.Immunization.html index 1803d7c..6273a46 100644 --- a/public/patientapi/symbols/hQuery.Immunization.html +++ b/public/patientapi/symbols/hQuery.Immunization.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    @@ -406,7 +412,7 @@

    -
    Methods borrowed from class hQuery.CodedEntry:
    date, freeTextType, id, includesCodeFrom, type
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, type, values
    @@ -421,7 +427,7 @@

    - hQuery.Immunization() + hQuery.Immunization(_super)
    @@ -433,6 +439,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -698,7 +715,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Informant.html b/public/patientapi/symbols/hQuery.Informant.html index 4baf6e1..963b23e 100644 --- a/public/patientapi/symbols/hQuery.Informant.html +++ b/public/patientapi/symbols/hQuery.Informant.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -512,7 +518,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Language.html b/public/patientapi/symbols/hQuery.Language.html index 0647156..8069547 100644 --- a/public/patientapi/symbols/hQuery.Language.html +++ b/public/patientapi/symbols/hQuery.Language.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    @@ -359,7 +365,7 @@

    -
    Methods borrowed from class hQuery.CodedEntry:
    date, freeTextType, id, includesCodeFrom, type
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, type, values
    @@ -374,7 +380,7 @@

    - hQuery.Language() + hQuery.Language(_super)
    @@ -386,6 +392,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -517,7 +534,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Medication.html b/public/patientapi/symbols/hQuery.Medication.html index fbdf784..5cb394c 100644 --- a/public/patientapi/symbols/hQuery.Medication.html +++ b/public/patientapi/symbols/hQuery.Medication.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    @@ -335,6 +341,15 @@

    + +   + + +
    The duration over which this medication has been active.
    + + +   @@ -425,10 +440,28 @@

    + +   + + +
    + + + + +   + +
    isPRN() +
    +
    + + + <inner>   -
    - hQuery.Medication() + hQuery.Medication(_super)
    @@ -558,6 +591,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -600,6 +644,38 @@

    +
    + + +
    + + {Hash} + cumulativeMedicationDuration() + +
    +
    + The duration over which this medication has been active. For example, 5 days. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Hash} with two keys: unit and scalar
    + +
    + + + +
    @@ -922,13 +998,77 @@

    +
    + + +
    + + {Boolean} + isLongTerm() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Boolean}
    + +
    + + + + +
    + + +
    + + {Boolean} + isPRN() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Boolean}
    + +
    + + + +
    <inner> - Medication() + Medication(json)
    @@ -940,6 +1080,17 @@

    +
    +
    Parameters:
    + +
    + json + +
    +
    + +
    + @@ -1289,7 +1440,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.MedicationInformation.html b/public/patientapi/symbols/hQuery.MedicationInformation.html index cd5ce63..f5fec87 100644 --- a/public/patientapi/symbols/hQuery.MedicationInformation.html +++ b/public/patientapi/symbols/hQuery.MedicationInformation.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -606,7 +612,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.NoImmunization.html b/public/patientapi/symbols/hQuery.NoImmunization.html index 81195d6..ea500d9 100644 --- a/public/patientapi/symbols/hQuery.NoImmunization.html +++ b/public/patientapi/symbols/hQuery.NoImmunization.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    NoImmunzation as defined by value set 2.16.840.1.113883.1.11.19717 The terms come from Health Level Seven (HL7) Version 3.0 Vocabulary and are managed by HL7 @@ -415,7 +421,7 @@

    -
    Methods borrowed from class hQuery.CodedEntry:
    date, freeTextType, id, includesCodeFrom, type
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, type, values
    @@ -430,7 +436,7 @@

    - hQuery.NoImmunization() + hQuery.NoImmunization(_super)
    @@ -444,6 +450,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -756,7 +773,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.OrderInformation.html b/public/patientapi/symbols/hQuery.OrderInformation.html index b21e8ac..ecea83b 100644 --- a/public/patientapi/symbols/hQuery.OrderInformation.html +++ b/public/patientapi/symbols/hQuery.OrderInformation.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -599,7 +605,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Organization.html b/public/patientapi/symbols/hQuery.Organization.html index 1191212..a4e6895 100644 --- a/public/patientapi/symbols/hQuery.Organization.html +++ b/public/patientapi/symbols/hQuery.Organization.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -593,7 +599,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Patient.html b/public/patientapi/symbols/hQuery.Patient.html index b67543b..37f5983 100644 --- a/public/patientapi/symbols/hQuery.Patient.html +++ b/public/patientapi/symbols/hQuery.Patient.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    @@ -362,6 +368,24 @@

    + +   + + +
    + + + + +   + + +
    + + +   @@ -407,6 +431,24 @@

    + +   + +
    expired() +
    +
    + + + + +   + + +
    + + +   @@ -443,6 +485,15 @@

    + +   + + +
    + + +   @@ -518,7 +569,7 @@

      -
    socialhistories() +
    @@ -563,7 +614,7 @@

    - hQuery.Patient() + hQuery.Patient(_super)
    @@ -575,6 +626,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -724,7 +786,71 @@

    Returns:
    -
    {Date} containing the patient's birthdate
    +
    {Date} containing the patients birthdate
    + +
    + + + + +
    + + +
    + + {hQuery.CodedEntryList} + careGoals() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {hQuery.CodedEntryList} A list of CareGoal objects
    + +
    + + + + +
    + + +
    + + {Boolean} + clinicalTrialParticipant() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Boolean} returns true if the patient participated in a clinical trial
    @@ -893,6 +1019,70 @@

    +
    + + +
    + + {Boolean} + expired() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Boolean} returns true if the patient has died
    + +
    + + + + +
    + + +
    + + {hQuery.CodedEntryList} + functionalStatuses() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {hQuery.CodedEntryList} A list of FunctionalStatus objects
    + +
    + + + +
    @@ -1032,6 +1222,38 @@

    +
    + + +
    + + {hQuery.CodedEntryList} + medicalEquipment() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {hQuery.CodedEntryList} A list of MedicalEquipment objects
    + +
    + + + +
    @@ -1285,11 +1507,11 @@


    - +
    {hQuery.CodedEntryList} - socialhistories() + socialHistories()
    @@ -1393,7 +1615,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Person.html b/public/patientapi/symbols/hQuery.Person.html index f8f49e0..2a8079c 100644 --- a/public/patientapi/symbols/hQuery.Person.html +++ b/public/patientapi/symbols/hQuery.Person.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -634,7 +640,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.PhysicalQuantity.html b/public/patientapi/symbols/hQuery.PhysicalQuantity.html new file mode 100644 index 0000000..3c46c66 --- /dev/null +++ b/public/patientapi/symbols/hQuery.PhysicalQuantity.html @@ -0,0 +1,509 @@ + + + + + + + JsDoc Reference - hQuery.PhysicalQuantity + + + + + + + + + + + + + +
    + +

    + + Class hQuery.PhysicalQuantity +

    + + +

    + + + + PhysicalQuantity - a representation of a physical quantity + + +
    Defined in: patient.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <inner>   + +
    +
      +
    scalar() +
    +
    +
      +
    units() +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + hQuery.PhysicalQuantity() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    <inner> + + + PhysicalQuantity(json) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + json + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + scalar() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + units() + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT) +
    + + diff --git a/public/patientapi/symbols/hQuery.Pregnancy.html b/public/patientapi/symbols/hQuery.Pregnancy.html index 7db5004..7a0bcd2 100644 --- a/public/patientapi/symbols/hQuery.Pregnancy.html +++ b/public/patientapi/symbols/hQuery.Pregnancy.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    This includes information about the patients current and past pregnancy status The Coded Entry code system should be SNOMED-CT
    @@ -339,7 +345,7 @@

    <inner>   -
    - hQuery.Pregnancy() + hQuery.Pregnancy(_super)
    @@ -379,6 +385,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -434,7 +451,7 @@

    <inner> - Pregnancy() + Pregnancy(json)
    @@ -446,6 +463,17 @@

    +
    +
    Parameters:
    + +
    + json + +
    +
    + +
    + @@ -467,7 +495,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Procedure.html b/public/patientapi/symbols/hQuery.Procedure.html index 12d11b4..79f70cc 100644 --- a/public/patientapi/symbols/hQuery.Procedure.html +++ b/public/patientapi/symbols/hQuery.Procedure.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    This represents all interventional, surgical, diagnostic, or therapeutic procedures or treatments pertinent to the patient.
    @@ -327,6 +333,24 @@

    + +   + + +
    + + + + +   + + +
    Ordinality
    + + +   @@ -339,7 +363,7 @@

    <inner>   -
    Procedure() +
    Procedure(json)
    @@ -354,13 +378,22 @@

    + +   + +
    source() +
    +
    + + +
    -
    Methods borrowed from class hQuery.CodedEntry:
    date, freeTextType, id, includesCodeFrom, type
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, type, values
    @@ -375,7 +408,7 @@

    - hQuery.Procedure() + hQuery.Procedure(_super)
    @@ -388,6 +421,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -407,6 +451,70 @@

    Method Detail

    + +
    + + {Date} + incisionTime() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {Date} The actual or intended start of an incision.
    + +
    + + + + +
    + + +
    + + {CodedValue} + ordinality() + +
    +
    + Ordinality + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CodedValue}
    + +
    + + + + +
    +
    @@ -443,7 +551,7 @@

    <inner> - Procedure() + Procedure(json)
    @@ -455,6 +563,17 @@

    +
    +
    Parameters:
    + +
    + json + +
    +
    + +
    + @@ -495,6 +614,38 @@

    +
    + + +
    + + {hQuery.CodedValue} + source() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {hQuery.CodedValue} A SNOMED code indicating where the procedure was performed.
    + +
    + + + + @@ -509,7 +660,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Provider.html b/public/patientapi/symbols/hQuery.Provider.html index aa04ef5..f49cdeb 100644 --- a/public/patientapi/symbols/hQuery.Provider.html +++ b/public/patientapi/symbols/hQuery.Provider.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -716,7 +722,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Result.html b/public/patientapi/symbols/hQuery.Result.html index e351657..8981224 100644 --- a/public/patientapi/symbols/hQuery.Result.html +++ b/public/patientapi/symbols/hQuery.Result.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    Observations generated by laboratories, imaging procedures, and other procedures.
    @@ -356,7 +362,7 @@

    <inner>   -
    Result() +
    Result(json)
    @@ -373,31 +379,13 @@

    - -   - -
    status() -
    -
    A status from the HL7 ActStatusNormal vocabulary
    - - - - -   - -
    value() -
    -
    Returns the value of the result.
    - - -
    -
    Methods borrowed from class hQuery.CodedEntry:
    date, freeTextType, id, includesCodeFrom, type
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, type, values
    @@ -412,7 +400,7 @@

    - hQuery.Result() + hQuery.Result(_super)
    @@ -427,6 +415,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -546,7 +545,7 @@

    <inner> - Result() + Result(json)
    @@ -558,6 +557,17 @@

    +
    +
    Parameters:
    + +
    + json + +
    +
    + +
    + @@ -599,64 +609,6 @@

    -
    - - -
    - - {String} - status() - -
    -
    - A status from the HL7 ActStatusNormal vocabulary - - -
    - - - - - - - - -
    -
    Returns:
    - -
    {String}
    - -
    - - - - -
    - - -
    - - - value() - -
    -
    - Returns the value of the result. This will return an object. The properties of this - object are dependent on the type of result. - - -
    - - - - - - - - - - - @@ -671,7 +623,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Scalar.html b/public/patientapi/symbols/hQuery.Scalar.html index 8b73e14..2741e9d 100644 --- a/public/patientapi/symbols/hQuery.Scalar.html +++ b/public/patientapi/symbols/hQuery.Scalar.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -497,7 +503,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Status.html b/public/patientapi/symbols/hQuery.Status.html index f5987a4..b70a32c 100644 --- a/public/patientapi/symbols/hQuery.Status.html +++ b/public/patientapi/symbols/hQuery.Status.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    Status as defined by value set 2.16.840.1.113883.5.14, the ActStatus vocabulary maintained by HL7
    @@ -432,7 +438,7 @@

    -
    Methods borrowed from class hQuery.CodedEntry:
    date, freeTextType, id, includesCodeFrom, type
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, type, values
    @@ -447,7 +453,7 @@

    - hQuery.Status() + hQuery.Status(_super)
    @@ -460,6 +466,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -766,7 +783,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.StatusOfMedication.html b/public/patientapi/symbols/hQuery.StatusOfMedication.html index 6490f6d..f133ee3 100644 --- a/public/patientapi/symbols/hQuery.StatusOfMedication.html +++ b/public/patientapi/symbols/hQuery.StatusOfMedication.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -300,7 +306,7 @@

     
    StatusOfMedication as defined by value set 2.16.840.1.113883.1.11.20.7 The terms come from SNOMED and are managed by HL7
    @@ -378,7 +384,7 @@

    -
    Methods borrowed from class hQuery.CodedEntry:
    date, freeTextType, id, includesCodeFrom, type
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, type, values
    @@ -393,7 +399,7 @@

    - hQuery.StatusOfMedication() + hQuery.StatusOfMedication(_super)
    @@ -406,6 +412,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -590,7 +607,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Supports.html b/public/patientapi/symbols/hQuery.Supports.html index 2fd6ea3..7b5023d 100644 --- a/public/patientapi/symbols/hQuery.Supports.html +++ b/public/patientapi/symbols/hQuery.Supports.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -634,7 +640,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.Telecom.html b/public/patientapi/symbols/hQuery.Telecom.html index e7ad487..201cba1 100644 --- a/public/patientapi/symbols/hQuery.Telecom.html +++ b/public/patientapi/symbols/hQuery.Telecom.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -594,7 +600,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/hQuery.TypeOfMedication.html b/public/patientapi/symbols/hQuery.TypeOfMedication.html index c1508a0..c12c8c1 100644 --- a/public/patientapi/symbols/hQuery.TypeOfMedication.html +++ b/public/patientapi/symbols/hQuery.TypeOfMedication.html @@ -217,8 +217,12 @@

    Classes

  • hQuery.Encounter
  • +
  • hQuery.Facility
  • +
  • hQuery.Fulfillment
  • +
  • hQuery.FunctionalStatus
  • +
  • hQuery.Immunization
  • hQuery.Informant
  • @@ -239,6 +243,8 @@

    Classes

  • hQuery.Person
  • +
  • hQuery.PhysicalQuantity
  • +
  • hQuery.Pregnancy
  • hQuery.Procedure
  • @@ -301,7 +307,7 @@

     
    TypeOfMedication as defined by value set 2.16.840.1.113883.3.88.12.3221.8.19 which pulls two values from SNOMED to describe whether a medication is @@ -362,7 +368,7 @@

    -
    Methods borrowed from class hQuery.CodedEntry:
    date, freeTextType, id, includesCodeFrom, type
    +
    Methods borrowed from class hQuery.CodedEntry:
    date, endDate, freeTextType, includesCodeFrom, isTimeRange, isUsable, negationInd, negationReason, reason, regex_includesCodeFrom, setTimestamp, startDate, status, statusCode, timeStamp, type, values
    @@ -377,7 +383,7 @@

    - hQuery.TypeOfMedication() + hQuery.TypeOfMedication(_super)
    @@ -391,6 +397,17 @@

    +
    +
    Parameters:
    + +
    + _super + +
    +
    + +
    + @@ -511,7 +528,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Oct 28 2011 09:44:47 GMT-0400 (EDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 26 2015 12:15:27 GMT-0700 (PDT)
    diff --git a/public/patientapi/symbols/src/tmp_patient.js.html b/public/patientapi/symbols/src/tmp_patient.js.html index a4ba231..4148c70 100644 --- a/public/patientapi/symbols/src/tmp_patient.js.html +++ b/public/patientapi/symbols/src/tmp_patient.js.html @@ -8,1875 +8,3467 @@
      1 /**
       2 @namespace scoping into the hquery namespace
       3 */
    -  4 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -  5   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -  6   function ctor() { this.constructor = child; }
    -  7   ctor.prototype = parent.prototype;
    -  8   child.prototype = new ctor;
    -  9   child.__super__ = parent.prototype;
    - 10   return child;
    - 11 };
    - 12 this.hQuery || (this.hQuery = {});
    - 13 /**
    - 14 Converts a a number in UTC Seconds since the epoch to a date.
    - 15 @param {number} utcSeconds seconds since the epoch in UTC
    - 16 @returns {Date}
    - 17 @function
    - 18 @exports dateFromUtcSeconds as hQuery.dateFromUtcSeconds
    - 19 */
    +  4 
    +  5 var __hasProp = {}.hasOwnProperty,
    +  6   __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; },
    +  7   __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
    +  8 
    +  9 this.hQuery || (this.hQuery = {});
    + 10 
    + 11 /**
    + 12 Converts a a number in UTC Seconds since the epoch to a date.
    + 13 @param {number} utcSeconds seconds since the epoch in UTC
    + 14 @returns {Date}
    + 15 @function
    + 16 @exports dateFromUtcSeconds as hQuery.dateFromUtcSeconds
    + 17 */
    + 18 
    + 19 
      20 hQuery.dateFromUtcSeconds = function(utcSeconds) {
      21   return new Date(utcSeconds * 1000);
      22 };
    - 23 /**
    - 24 @class Scalar - a representation of a unit and value
    - 25 @exports Scalar as hQuery.Scalar
    - 26 */
    - 27 hQuery.Scalar = (function() {
    - 28   function Scalar(json) {
    - 29     this.json = json;
    - 30   }
    - 31   Scalar.prototype.unit = function() {
    - 32     return this.json['unit'];
    - 33   };
    - 34   Scalar.prototype.value = function() {
    - 35     return this.json['value'];
    - 36   };
    - 37   return Scalar;
    - 38 })();
    - 39 /**
    - 40 @class A code with its corresponding code system
    - 41 @exports CodedValue as hQuery.CodedValue
    - 42 */
    - 43 hQuery.CodedValue = (function() {
    - 44   /**
    - 45   @param {String} c value of the code
    - 46   @param {String} csn name of the code system that the code belongs to
    - 47   @constructs
    - 48   */  function CodedValue(c, csn) {
    - 49     this.c = c;
    - 50     this.csn = csn;
    - 51   }
    - 52   /**
    - 53   @returns {String} the code
    - 54   */
    - 55   CodedValue.prototype.code = function() {
    - 56     return this.c;
    - 57   };
    - 58   /**
    - 59   @returns {String} the code system name
    - 60   */
    - 61   CodedValue.prototype.codeSystemName = function() {
    - 62     return this.csn;
    - 63   };
    - 64   /**
    - 65   Returns true if the contained code and codeSystemName match a code in the supplied codeSet.
    - 66   @param {Object} codeSet a hash with code system names as keys and an array of codes as values
    - 67   @returns {boolean}
    - 68   */
    - 69   CodedValue.prototype.includedIn = function(codeSet) {
    - 70     var code, codeSystemName, codes, _i, _len;
    - 71     for (codeSystemName in codeSet) {
    - 72       codes = codeSet[codeSystemName];
    - 73       if (this.csn === codeSystemName) {
    - 74         for (_i = 0, _len = codes.length; _i < _len; _i++) {
    - 75           code = codes[_i];
    - 76           if (code === this.c) {
    - 77             return true;
    - 78           }
    - 79         }
    - 80       }
    - 81     }
    - 82     return false;
    - 83   };
    - 84   return CodedValue;
    - 85 })();
    - 86 /**
    - 87 Status as defined by value set 2.16.840.1.113883.5.14,
    - 88 the ActStatus vocabulary maintained by HL7
    - 89 
    - 90 @class Status
    - 91 @augments hQuery.CodedEntry
    - 92 @exports Status as hQuery.Status
    - 93 */
    - 94 hQuery.Status = (function() {
    - 95   var ABORTED, ACTIVE, CANCELLED, COMPLETED, HELD, NEW, NORMAL, NULLIFIED, OBSOLETE, SUSPENDED;
    - 96   __extends(Status, hQuery.CodedValue);
    - 97   function Status() {
    - 98     Status.__super__.constructor.apply(this, arguments);
    - 99   }
    -100   NORMAL = "normal";
    -101   ABORTED = "aborted";
    -102   ACTIVE = "active";
    -103   CANCELLED = "cancelled";
    -104   COMPLETED = "completed";
    -105   HELD = "held";
    -106   NEW = "new";
    -107   SUSPENDED = "suspended";
    -108   NULLIFIED = "nullified";
    -109   OBSOLETE = "obsolete";
    -110   Status.prototype.isNormal = function() {
    -111     return this.c === NORMAL;
    -112   };
    -113   Status.prototype.isAborted = function() {
    -114     return this.c === ABORTED;
    -115   };
    -116   Status.prototype.isActive = function() {
    -117     return this.c === ACTIVE;
    + 23 
    + 24 /**
    + 25 @class Scalar - a representation of a unit and value
    + 26 @exports Scalar as hQuery.Scalar
    + 27 */
    + 28 
    + 29 
    + 30 hQuery.Scalar = (function() {
    + 31 
    + 32   Scalar.name = 'Scalar';
    + 33 
    + 34   function Scalar(json) {
    + 35     this.json = json;
    + 36   }
    + 37 
    + 38   Scalar.prototype.unit = function() {
    + 39     return this.json['unit'];
    + 40   };
    + 41 
    + 42   Scalar.prototype.value = function() {
    + 43     return this.json['value'];
    + 44   };
    + 45 
    + 46   return Scalar;
    + 47 
    + 48 })();
    + 49 
    + 50 /**
    + 51 @class PhysicalQuantity - a representation of a physical quantity
    + 52 @exports PhysicalQuantity as hQuery.PhysicalQuantity
    + 53 */
    + 54 
    + 55 
    + 56 hQuery.PhysicalQuantity = (function() {
    + 57 
    + 58   PhysicalQuantity.name = 'PhysicalQuantity';
    + 59 
    + 60   function PhysicalQuantity(json) {
    + 61     this.json = json;
    + 62   }
    + 63 
    + 64   PhysicalQuantity.prototype.units = function() {
    + 65     return this.json['units'];
    + 66   };
    + 67 
    + 68   PhysicalQuantity.prototype.scalar = function() {
    + 69     return parseFloat(this.json['scalar']);
    + 70   };
    + 71 
    + 72   return PhysicalQuantity;
    + 73 
    + 74 })();
    + 75 
    + 76 /**
    + 77 @class A code with its corresponding code system
    + 78 @exports CodedValue as hQuery.CodedValue
    + 79 */
    + 80 
    + 81 
    + 82 hQuery.CodedValue = (function() {
    + 83 
    + 84   CodedValue.name = 'CodedValue';
    + 85 
    + 86   /**
    + 87   @param {String} c value of the code
    + 88   @param {String} csn name of the code system that the code belongs to
    + 89   @constructs
    + 90   */
    + 91 
    + 92 
    + 93   function CodedValue(c, csn) {
    + 94     this.c = c;
    + 95     this.csn = csn;
    + 96   }
    + 97 
    + 98   /**
    + 99   @returns {String} the code
    +100   */
    +101 
    +102 
    +103   CodedValue.prototype.code = function() {
    +104     return this.c;
    +105   };
    +106 
    +107   /**
    +108   @returns {String} the code system name
    +109   */
    +110 
    +111 
    +112   CodedValue.prototype.codeSystemName = function() {
    +113     return this.csn;
    +114   };
    +115 
    +116   CodedValue.normalize = function(val) {
    +117     return String(val).toLowerCase();
     118   };
    -119   Status.prototype.isCancelled = function() {
    -120     return this.c === CANCELLED;
    -121   };
    -122   Status.prototype.isCompleted = function() {
    -123     return this.c === COMPLETED;
    -124   };
    -125   Status.prototype.isHeld = function() {
    -126     return this.c === HELD;
    -127   };
    -128   Status.prototype.isNew = function() {
    -129     return this.c === NEW;
    -130   };
    -131   Status.prototype.isSuspended = function() {
    -132     return this.c === SUSPENDED;
    -133   };
    -134   Status.prototype.isNullified = function() {
    -135     return this.c === NULLIFIED;
    -136   };
    -137   Status.prototype.isObsolete = function() {
    -138     return this.c === OBSOLETE;
    -139   };
    -140   return Status;
    -141 })();
    -142 /**
    -143 @class an Address for a person or organization
    -144 @exports Address as hQuery.Address
    -145 */
    -146 hQuery.Address = (function() {
    -147   function Address(json) {
    -148     this.json = json;
    -149   }
    -150   /**
    -151   @returns {Array[String]} the street addresses
    -152   */
    -153   Address.prototype.street = function() {
    -154     return this.json['streetAddress'];
    -155   };
    -156   /**
    -157   @returns {String} the city
    -158   */
    -159   Address.prototype.city = function() {
    -160     return this.json['city'];
    -161   };
    -162   /**
    -163   @returns {String} the State
    -164   */
    -165   Address.prototype.state = function() {
    -166     return this.json['stateOrProvince'];
    +119 
    +120   /**
    +121   Returns true if the contained code and codeSystemName match a code in the supplied codeSet.
    +122   @param {Object} codeSet a hash with code system names as keys and an array of codes as values
    +123   @returns {boolean}
    +124   */
    +125 
    +126 
    +127   CodedValue.prototype.includedIn = function(codeSet) {
    +128     var c1, c2, code, codeSystemName, codes, _i, _len;
    +129     for (codeSystemName in codeSet) {
    +130       codes = codeSet[codeSystemName];
    +131       if (this.csn === codeSystemName) {
    +132         for (_i = 0, _len = codes.length; _i < _len; _i++) {
    +133           code = codes[_i];
    +134           c1 = hQuery.CodedValue.normalize(code);
    +135           c2 = hQuery.CodedValue.normalize(this.c);
    +136           if (c1 === c2) {
    +137             return true;
    +138           }
    +139         }
    +140       }
    +141     }
    +142     return false;
    +143   };
    +144 
    +145   /**
    +146   Returns true if the contained code and codeSystemName match a code in the supplied codeSet.
    +147   @param {Object} codeSet a hash with code system names as keys and an array of codes (provided as regular expressions) as values
    +148   @returns {boolean}
    +149   */
    +150 
    +151 
    +152   CodedValue.prototype.regex_includedIn = function(codeSet) {
    +153     var code, codeSystemName, codes, regex, _i, _len;
    +154     for (codeSystemName in codeSet) {
    +155       codes = codeSet[codeSystemName];
    +156       if (this.csn === codeSystemName) {
    +157         for (_i = 0, _len = codes.length; _i < _len; _i++) {
    +158           code = codes[_i];
    +159           regex = RegExp(code, "i");
    +160           if (regex.test(this.c)) {
    +161             return true;
    +162           }
    +163         }
    +164       }
    +165     }
    +166     return false;
     167   };
    -168   /**
    -169   @returns {String} the postal code
    -170   */
    -171   Address.prototype.postalCode = function() {
    -172     return this.json['zip'];
    -173   };
    -174   return Address;
    -175 })();
    -176 /**
    -177 @class An object that describes a means to contact an entity.  This is used to represent
    -178 phone numbers, email addresses,  instant messaging accounts etc.
    -179 @exports Telecom as hQuery.Telecom
    +168 
    +169   return CodedValue;
    +170 
    +171 })();
    +172 
    +173 /**
    +174 Status as defined by value set 2.16.840.1.113883.5.14,
    +175 the ActStatus vocabulary maintained by HL7
    +176 
    +177 @class Status
    +178 @augments hQuery.CodedEntry
    +179 @exports Status as hQuery.Status
     180 */
    -181 hQuery.Telecom = (function() {
    -182   function Telecom(json) {
    -183     this.json = json;
    -184   }
    -185   /**
    -186   @returns {String} the type of telecom entry, phone, sms, email ....
    -187   */
    -188   Telecom.prototype.type = function() {
    -189     return this.json['type'];
    -190   };
    -191   /**
    -192   @returns {String} the value of the entry -  the actual phone number , email address , ....
    -193   */
    -194   Telecom.prototype.value = function() {
    -195     return this.json['value'];
    -196   };
    -197   /**
    -198   @returns {String} the use of the entry. Is it a home, office, .... type of contact
    -199   */
    -200   Telecom.prototype.use = function() {
    -201     return this.json['use'];
    -202   };
    -203   /**
    -204   @returns {Boolean} is this a preferred form of contact
    -205   */
    -206   Telecom.prototype.preferred = function() {
    -207     return this.json['preferred'];
    -208   };
    -209   return Telecom;
    -210 })();
    -211 /**
    -212 @class an object that describes a person.  includes a persons name, addresses, and contact information
    -213 @exports Person as hQuery.Person
    -214 */
    -215 hQuery.Person = (function() {
    -216   function Person(json) {
    -217     this.json = json;
    -218   }
    -219   /**
    -220    @returns {String} the given name of the person
    -221   */
    -222   Person.prototype.given = function() {
    -223     return this.json['first'];
    +181 
    +182 
    +183 hQuery.Status = (function(_super) {
    +184   var ABORTED, ACTIVE, CANCELLED, COMPLETED, HELD, NEW, NORMAL, NULLIFIED, OBSOLETE, SUSPENDED;
    +185 
    +186   __extends(Status, _super);
    +187 
    +188   Status.name = 'Status';
    +189 
    +190   function Status() {
    +191     return Status.__super__.constructor.apply(this, arguments);
    +192   }
    +193 
    +194   NORMAL = "normal";
    +195 
    +196   ABORTED = "aborted";
    +197 
    +198   ACTIVE = "active";
    +199 
    +200   CANCELLED = "cancelled";
    +201 
    +202   COMPLETED = "completed";
    +203 
    +204   HELD = "held";
    +205 
    +206   NEW = "new";
    +207 
    +208   SUSPENDED = "suspended";
    +209 
    +210   NULLIFIED = "nullified";
    +211 
    +212   OBSOLETE = "obsolete";
    +213 
    +214   Status.prototype.isNormal = function() {
    +215     return this.c === NORMAL;
    +216   };
    +217 
    +218   Status.prototype.isAborted = function() {
    +219     return this.c === ABORTED;
    +220   };
    +221 
    +222   Status.prototype.isActive = function() {
    +223     return this.c === ACTIVE;
     224   };
    -225   /**
    -226    @returns {String} the last/family name of the person
    -227   */
    -228   Person.prototype.last = function() {
    -229     return this.json['last'];
    -230   };
    -231   /**
    -232    @returns {String} the display name of the person
    -233   */
    -234   Person.prototype.name = function() {
    -235     if (this.json['name']) {
    -236       return this.json['name'];
    -237     } else {
    -238       return this.json['first'] + ' ' + this.json['last'];
    -239     }
    +225 
    +226   Status.prototype.isCancelled = function() {
    +227     return this.c === CANCELLED;
    +228   };
    +229 
    +230   Status.prototype.isCompleted = function() {
    +231     return this.c === COMPLETED;
    +232   };
    +233 
    +234   Status.prototype.isHeld = function() {
    +235     return this.c === HELD;
    +236   };
    +237 
    +238   Status.prototype.isNew = function() {
    +239     return this.c === NEW;
     240   };
    -241   /**
    -242    @returns {Array} an array of {@link hQuery.Address} objects associated with the patient
    -243   */
    -244   Person.prototype.addresses = function() {
    -245     var address, list, _i, _len, _ref;
    -246     list = [];
    -247     if (this.json['addresses']) {
    -248       _ref = this.json['addresses'];
    -249       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -250         address = _ref[_i];
    -251         list.push(new hQuery.Address(address));
    -252       }
    -253     }
    -254     return list;
    -255   };
    -256   /**
    -257   @returns {Array} an array of {@link hQuery.Telecom} objects associated with the person
    -258   */
    -259   Person.prototype.telecoms = function() {
    -260     var tel, _i, _len, _ref, _results;
    -261     _ref = this.json['telecoms'];
    -262     _results = [];
    -263     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -264       tel = _ref[_i];
    -265       _results.push(new hQuery.Telecom(tel));
    -266     }
    -267     return _results;
    -268   };
    -269   return Person;
    -270 })();
    -271 /**
    -272 @class an actor is either a person or an organization
    -273 @exports Actor as hQuery.Actor
    -274 */
    -275 hQuery.Actor = (function() {
    -276   function Actor(json) {
    -277     this.json = json;
    -278   }
    -279   Actor.prototype.person = function() {
    -280     if (this.json['person']) {
    -281       return new hQuery.Person(this.json['person']);
    -282     }
    -283   };
    -284   Actor.prototype.organization = function() {
    -285     if (this.json['organization']) {
    -286       return new hQuery.Organization(this.json['organization']);
    -287     }
    +241 
    +242   Status.prototype.isSuspended = function() {
    +243     return this.c === SUSPENDED;
    +244   };
    +245 
    +246   Status.prototype.isNullified = function() {
    +247     return this.c === NULLIFIED;
    +248   };
    +249 
    +250   Status.prototype.isObsolete = function() {
    +251     return this.c === OBSOLETE;
    +252   };
    +253 
    +254   return Status;
    +255 
    +256 })(hQuery.CodedValue);
    +257 
    +258 /**
    +259 @class an Address for a person or organization
    +260 @exports Address as hQuery.Address
    +261 */
    +262 
    +263 
    +264 hQuery.Address = (function() {
    +265 
    +266   Address.name = 'Address';
    +267 
    +268   function Address(json) {
    +269     this.json = json;
    +270   }
    +271 
    +272   /**
    +273   @returns {Array[String]} the street addresses
    +274   */
    +275 
    +276 
    +277   Address.prototype.street = function() {
    +278     return this.json['street'];
    +279   };
    +280 
    +281   /**
    +282   @returns {String} the city
    +283   */
    +284 
    +285 
    +286   Address.prototype.city = function() {
    +287     return this.json['city'];
     288   };
    -289   return Actor;
    -290 })();
    -291 /**
    -292 @class an Organization
    -293 @exports Organization as hQuery.Organization
    -294 */
    -295 hQuery.Organization = (function() {
    -296   function Organization(json) {
    -297     this.json = json;
    -298   }
    +289 
    +290   /**
    +291   @returns {String} the State
    +292   */
    +293 
    +294 
    +295   Address.prototype.state = function() {
    +296     return this.json['state'];
    +297   };
    +298 
     299   /**
    -300   @returns {String} the id for the organization
    +300   @returns {String} the postal code
     301   */
    -302   Organization.prototype.organizationId = function() {
    -303     return this.json['organizationId'];
    -304   };
    -305   /**
    -306   @returns {String} the name of the organization
    -307   */
    -308   Organization.prototype.organizationName = function() {
    -309     return this.json['organizationName'];
    -310   };
    -311   /**
    -312   @returns {Array} an array of {@link hQuery.Address} objects associated with the organization
    -313   */
    -314   Organization.prototype.addresses = function() {
    -315     var address, list, _i, _len, _ref;
    -316     list = [];
    -317     if (this.json['addresses']) {
    -318       _ref = this.json['addresses'];
    -319       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -320         address = _ref[_i];
    -321         list.push(new hQuery.Address(address));
    -322       }
    -323     }
    -324     return list;
    -325   };
    -326   /**
    -327   @returns {Array} an array of {@link hQuery.Telecom} objects associated with the organization
    -328   */
    -329   Organization.prototype.telecoms = function() {
    -330     var tel, _i, _len, _ref, _results;
    -331     _ref = this.json['telecoms'];
    -332     _results = [];
    -333     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -334       tel = _ref[_i];
    -335       _results.push(new hQuery.Telecom(tel));
    -336     }
    -337     return _results;
    -338   };
    -339   return Organization;
    -340 })();
    -341 /**
    -342 @class represents a DateRange in the form of hi and low date values.
    -343 @exports DateRange as hQuery.DateRange
    -344 */
    -345 hQuery.DateRange = (function() {
    -346   function DateRange(json) {
    -347     this.json = json;
    -348   }
    -349   DateRange.prototype.hi = function() {
    -350     if (this.json['hi']) {
    -351       return hQuery.dateFromUtcSeconds(this.json['hi']);
    -352     }
    -353   };
    -354   DateRange.prototype.low = function() {
    -355     return hQuery.dateFromUtcSeconds(this.json['low']);
    -356   };
    -357   return DateRange;
    -358 })();
    -359 /**
    -360 @class Class used to describe an entity that is providing some form of information.  This does not mean that they are
    -361 providing any treatment just that they are providing information.
    -362 @exports Informant as hQuery.Informant
    -363 */
    -364 hQuery.Informant = (function() {
    -365   function Informant(json) {
    -366     this.json = json;
    -367   }
    -368   /**
    -369   an array of hQuery.Person objects as points of contact
    -370   @returns {Array}
    -371   */
    -372   Informant.prototype.contacts = function() {
    -373     var contact, _i, _len, _ref, _results;
    -374     _ref = this.json['contacts'];
    -375     _results = [];
    -376     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -377       contact = _ref[_i];
    -378       _results.push(new hQuery.Person(contact));
    -379     }
    -380     return _results;
    -381   };
    -382   /**
    -383    @returns {hQuery.Organization} the organization providing the information
    -384   */
    -385   Informant.prototype.organization = function() {
    -386     return new hQuery.Organization(this.json['organization']);
    -387   };
    -388   return Informant;
    -389 })();
    -390 /**
    -391 @class
    -392 @exports CodedEntry as hQuery.CodedEntry
    -393 */
    -394 hQuery.CodedEntry = (function() {
    -395   function CodedEntry(json) {
    -396     this.json = json;
    -397   }
    -398   /**
    -399   Date and time at which the coded entry took place
    -400   @returns {Date}
    +302 
    +303 
    +304   Address.prototype.postalCode = function() {
    +305     return this.json['zip'];
    +306   };
    +307 
    +308   return Address;
    +309 
    +310 })();
    +311 
    +312 /**
    +313 @class An object that describes a means to contact an entity.  This is used to represent
    +314 phone numbers, email addresses,  instant messaging accounts etc.
    +315 @exports Telecom as hQuery.Telecom
    +316 */
    +317 
    +318 
    +319 hQuery.Telecom = (function() {
    +320 
    +321   Telecom.name = 'Telecom';
    +322 
    +323   function Telecom(json) {
    +324     this.json = json;
    +325   }
    +326 
    +327   /**
    +328   @returns {String} the type of telecom entry, phone, sms, email ....
    +329   */
    +330 
    +331 
    +332   Telecom.prototype.type = function() {
    +333     return this.json['type'];
    +334   };
    +335 
    +336   /**
    +337   @returns {String} the value of the entry -  the actual phone number , email address , ....
    +338   */
    +339 
    +340 
    +341   Telecom.prototype.value = function() {
    +342     return this.json['value'];
    +343   };
    +344 
    +345   /**
    +346   @returns {String} the use of the entry. Is it a home, office, .... type of contact
    +347   */
    +348 
    +349 
    +350   Telecom.prototype.use = function() {
    +351     return this.json['use'];
    +352   };
    +353 
    +354   /**
    +355   @returns {Boolean} is this a preferred form of contact
    +356   */
    +357 
    +358 
    +359   Telecom.prototype.preferred = function() {
    +360     return this.json['preferred'];
    +361   };
    +362 
    +363   return Telecom;
    +364 
    +365 })();
    +366 
    +367 /**
    +368 @class an object that describes a person.  includes a persons name, addresses, and contact information
    +369 @exports Person as hQuery.Person
    +370 */
    +371 
    +372 
    +373 hQuery.Person = (function() {
    +374 
    +375   Person.name = 'Person';
    +376 
    +377   function Person(json) {
    +378     this.json = json;
    +379   }
    +380 
    +381   /**
    +382    @returns {String} the given name of the person
    +383   */
    +384 
    +385 
    +386   Person.prototype.given = function() {
    +387     return this.json['first'];
    +388   };
    +389 
    +390   /**
    +391    @returns {String} the last/family name of the person
    +392   */
    +393 
    +394 
    +395   Person.prototype.last = function() {
    +396     return this.json['last'];
    +397   };
    +398 
    +399   /**
    +400    @returns {String} the display name of the person
     401   */
    -402   CodedEntry.prototype.date = function() {
    -403     return hQuery.dateFromUtcSeconds(this.json['time']);
    -404   };
    -405   /**
    -406   An Array of CodedValues which describe what kind of coded entry took place
    -407   @returns {Array}
    -408   */
    -409   CodedEntry.prototype.type = function() {
    -410     return hQuery.createCodedValues(this.json['codes']);
    -411   };
    +402 
    +403 
    +404   Person.prototype.name = function() {
    +405     if (this.json['name']) {
    +406       return this.json['name'];
    +407     } else {
    +408       return this.json['first'] + ' ' + this.json['last'];
    +409     }
    +410   };
    +411 
     412   /**
    -413   A free text description of the type of coded entry
    -414   @returns {String}
    -415   */
    -416   CodedEntry.prototype.freeTextType = function() {
    -417     return this.json['description'];
    -418   };
    -419   /**
    -420   Unique identifier for this coded entry
    -421   @returns {String}
    -422   */
    -423   CodedEntry.prototype.id = function() {
    -424     return this.json['id'];
    -425   };
    -426   /**
    -427   Returns true if any of this entry's codes match a code in the supplied codeSet.
    -428   @param {Object} codeSet a hash with code system names as keys and an array of codes as values
    -429   @returns {boolean}
    -430   */
    -431   CodedEntry.prototype.includesCodeFrom = function(codeSet) {
    -432     var codedValue, _i, _len, _ref;
    -433     _ref = this.type();
    -434     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -435       codedValue = _ref[_i];
    -436       if (codedValue.includedIn(codeSet)) {
    -437         return true;
    -438       }
    -439     }
    -440     return false;
    -441   };
    -442   return CodedEntry;
    -443 })();
    -444 /**
    -445 @class Represents a list of hQuery.CodedEntry instances. Offers utility methods for matching
    -446 entries based on codes and date ranges
    -447 @exports CodedEntryList as hQuery.CodedEntryList
    -448 */
    -449 hQuery.CodedEntryList = (function() {
    -450   __extends(CodedEntryList, Array);
    -451   function CodedEntryList() {
    -452     this.push.apply(this, arguments);
    -453   }
    -454   /**
    -455   Return the number of entries that match the
    -456   supplied code set where those entries occur between the supplied time bounds
    -457   @param {Object} codeSet a hash with code system names as keys and an array of codes as values
    -458   @param {Date} start the start of the period during which the entry must occur, a null value will match all times
    -459   @param {Date} end the end of the period during which the entry must occur, a null value will match all times
    -460   @return {Array[CodedEntry]} the matching entries
    -461   */
    -462   CodedEntryList.prototype.match = function(codeSet, start, end) {
    -463     var afterStart, beforeEnd, entry, matchingEntries, _i, _len;
    -464     matchingEntries = [];
    -465     for (_i = 0, _len = this.length; _i < _len; _i++) {
    -466       entry = this[_i];
    -467       afterStart = !start || entry.date() >= start;
    -468       beforeEnd = !end || entry.date() <= end;
    -469       if (afterStart && beforeEnd && entry.includesCodeFrom(codeSet)) {
    -470         matchingEntries.push(entry);
    -471       }
    -472     }
    -473     return matchingEntries;
    +413    @returns {Array} an array of {@link hQuery.Address} objects associated with the patient
    +414   */
    +415 
    +416 
    +417   Person.prototype.addresses = function() {
    +418     var address, list, _i, _len, _ref;
    +419     list = [];
    +420     if (this.json['addresses']) {
    +421       _ref = this.json['addresses'];
    +422       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +423         address = _ref[_i];
    +424         list.push(new hQuery.Address(address));
    +425       }
    +426     }
    +427     return list;
    +428   };
    +429 
    +430   /**
    +431   @returns {Array} an array of {@link hQuery.Telecom} objects associated with the person
    +432   */
    +433 
    +434 
    +435   Person.prototype.telecoms = function() {
    +436     var tel, _i, _len, _ref, _results;
    +437     _ref = this.json['telecoms'];
    +438     _results = [];
    +439     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +440       tel = _ref[_i];
    +441       _results.push(new hQuery.Telecom(tel));
    +442     }
    +443     return _results;
    +444   };
    +445 
    +446   return Person;
    +447 
    +448 })();
    +449 
    +450 /**
    +451 @class an actor is either a person or an organization
    +452 @exports Actor as hQuery.Actor
    +453 */
    +454 
    +455 
    +456 hQuery.Actor = (function() {
    +457 
    +458   Actor.name = 'Actor';
    +459 
    +460   function Actor(json) {
    +461     this.json = json;
    +462   }
    +463 
    +464   Actor.prototype.person = function() {
    +465     if (this.json['person']) {
    +466       return new hQuery.Person(this.json['person']);
    +467     }
    +468   };
    +469 
    +470   Actor.prototype.organization = function() {
    +471     if (this.json['organization']) {
    +472       return new hQuery.Organization(this.json['organization']);
    +473     }
     474   };
    -475   return CodedEntryList;
    -476 })();
    -477 /**
    -478 @private
    -479 @function
    -480 
    -481 */
    -482 hQuery.createCodedValues = function(jsonCodes) {
    -483   var code, codeSystem, codedValues, codes, _i, _len;
    -484   codedValues = [];
    -485   for (codeSystem in jsonCodes) {
    -486     codes = jsonCodes[codeSystem];
    -487     for (_i = 0, _len = codes.length; _i < _len; _i++) {
    -488       code = codes[_i];
    -489       codedValues.push(new hQuery.CodedValue(code, codeSystem));
    -490     }
    -491   }
    -492   return codedValues;
    -493 };/**
    -494 @namespace scoping into the hquery namespace
    -495 */
    -496 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -497   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -498   function ctor() { this.constructor = child; }
    -499   ctor.prototype = parent.prototype;
    -500   child.prototype = new ctor;
    -501   child.__super__ = parent.prototype;
    -502   return child;
    -503 };
    -504 this.hQuery || (this.hQuery = {});
    -505 /**
    -506 @class MedicationInformation
    -507 @exports MedicationInformation as hQuery.MedicationInformation
    -508 */
    -509 hQuery.MedicationInformation = (function() {
    -510   function MedicationInformation(json) {
    -511     this.json = json;
    -512   }
    -513   /**
    -514   An array of hQuery.CodedValue describing the medication
    -515   @returns {Array}
    -516   */
    -517   MedicationInformation.prototype.codedProduct = function() {
    -518     return hQuery.createCodedValues(this.json['codes']);
    -519   };
    -520   MedicationInformation.prototype.freeTextProductName = function() {
    -521     return this.json['description'];
    -522   };
    -523   MedicationInformation.prototype.codedBrandName = function() {
    -524     return this.json['codedBrandName'];
    -525   };
    -526   MedicationInformation.prototype.freeTextBrandName = function() {
    -527     return this.json['brandName'];
    +475 
    +476   return Actor;
    +477 
    +478 })();
    +479 
    +480 /**
    +481 @class an Organization
    +482 @exports Organization as hQuery.Organization
    +483 */
    +484 
    +485 
    +486 hQuery.Organization = (function() {
    +487 
    +488   Organization.name = 'Organization';
    +489 
    +490   function Organization(json) {
    +491     this.json = json;
    +492   }
    +493 
    +494   /**
    +495   @returns {String} the id for the organization
    +496   */
    +497 
    +498 
    +499   Organization.prototype.organizationId = function() {
    +500     return this.json['organizationId'];
    +501   };
    +502 
    +503   /**
    +504   @returns {String} the name of the organization
    +505   */
    +506 
    +507 
    +508   Organization.prototype.organizationName = function() {
    +509     return this.json['name'];
    +510   };
    +511 
    +512   /**
    +513   @returns {Array} an array of {@link hQuery.Address} objects associated with the organization
    +514   */
    +515 
    +516 
    +517   Organization.prototype.addresses = function() {
    +518     var address, list, _i, _len, _ref;
    +519     list = [];
    +520     if (this.json['addresses']) {
    +521       _ref = this.json['addresses'];
    +522       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +523         address = _ref[_i];
    +524         list.push(new hQuery.Address(address));
    +525       }
    +526     }
    +527     return list;
     528   };
    -529   MedicationInformation.prototype.drugManufacturer = function() {
    -530     if (this.json['drugManufacturer']) {
    -531       return new hQuery.Organization(this.json['drugManufacturer']);
    -532     }
    -533   };
    -534   return MedicationInformation;
    -535 })();
    -536 /**
    -537 @class AdministrationTiming - the
    -538 @exports AdministrationTiming as hQuery.AdministrationTiming
    -539 */
    -540 hQuery.AdministrationTiming = (function() {
    -541   function AdministrationTiming(json) {
    -542     this.json = json;
    -543   }
    -544   /**
    -545   Provides the period of medication administration as a Scalar. An example
    -546   Scalar that would be returned would be with value = 8 and units = hours. This would
    -547   mean that the medication should be taken every 8 hours.
    -548   @returns {hQuery.Scalar}
    -549   */
    -550   AdministrationTiming.prototype.period = function() {
    -551     return new hQuery.Scalar(this.json['period']);
    -552   };
    -553   /**
    -554   Indicates whether it is the interval (time between dosing), or frequency 
    -555   (number of doses in a time period) that is important. If instititutionSpecified is not 
    -556   present or is set to false, then the time between dosing is important (every 8 hours). 
    -557   If true, then the frequency of administration is important (e.g., 3 times per day).
    -558   @returns {Boolean}
    -559   */
    -560   AdministrationTiming.prototype.institutionSpecified = function() {
    -561     return this.json['institutionSpecified'];
    -562   };
    -563   return AdministrationTiming;
    -564 })();
    -565 /**
    -566 @class DoseRestriction -  restrictions on the medications dose, represented by a upper and lower dose
    -567 @exports DoseRestriction as hQuery.DoseRestriction
    -568 */
    -569 hQuery.DoseRestriction = (function() {
    -570   function DoseRestriction(json) {
    -571     this.json = json;
    -572   }
    -573   DoseRestriction.prototype.numerator = function() {
    -574     return new hQuery.Scalar(this.json['numerator']);
    -575   };
    -576   DoseRestriction.prototype.denominator = function() {
    -577     return new hQuery.Scalar(this.json['denominator']);
    -578   };
    -579   return DoseRestriction;
    -580 })();
    -581 /**
    -582 @class Fulfillment - information about when and who fulfilled an order for the medication
    -583 @exports Fulfillment as hQuery.Fullfilement
    -584 */
    -585 hQuery.Fulfillment = (function() {
    -586   function Fulfillment(json) {
    -587     this.json = json;
    -588   }
    -589   Fulfillment.prototype.dispenseDate = function() {
    -590     return hQuery.dateFromUtcSeconds(this.json['dispenseDate']);
    -591   };
    -592   Fulfillment.prototype.provider = function() {
    -593     return new hQuery.Actor(this.json['provider']);
    -594   };
    -595   Fulfillment.prototype.dispensingPharmacyLocation = function() {
    -596     return new hQuery.Address(this.json['dispensingPharmacyLocation']);
    -597   };
    -598   Fulfillment.prototype.quantityDispensed = function() {
    -599     return new hQuery.Scalar(this.json['quantityDispensed']);
    -600   };
    -601   Fulfillment.prototype.prescriptionNumber = function() {
    -602     return this.json['prescriptionNumber'];
    -603   };
    -604   Fulfillment.prototype.fillNumber = function() {
    -605     return this.json['fillNumber'];
    -606   };
    -607   Fulfillment.prototype.fillStatus = function() {
    -608     return new hQuery.Status(this.json['fillStatus']);
    -609   };
    -610   return Fulfillment;
    -611 })();
    -612 /**
    -613 @class OrderInformation - information abour an order for a medication
    -614 @exports OrderInformation as hQuery.OrderInformation
    -615 */
    -616 hQuery.OrderInformation = (function() {
    -617   function OrderInformation(json) {
    -618     this.json = json;
    -619   }
    -620   OrderInformation.prototype.orderNumber = function() {
    -621     return this.json['orderNumber'];
    -622   };
    -623   OrderInformation.prototype.fills = function() {
    -624     return this.json['fills'];
    -625   };
    -626   OrderInformation.prototype.quantityOrdered = function() {
    -627     return new hQuery.Scalar(this.json['quantityOrdered']);
    -628   };
    -629   OrderInformation.prototype.orderExpirationDateTime = function() {
    -630     return hQuery.dateFromUtcSeconds(this.json['orderExpirationDateTime']);
    -631   };
    -632   OrderInformation.prototype.orderDateTime = function() {
    -633     return hQuery.dateFromUtcSeconds(this.json['orderDateTime']);
    -634   };
    -635   return OrderInformation;
    -636 })();
    -637 /**
    -638 TypeOfMedication as defined by value set 2.16.840.1.113883.3.88.12.3221.8.19
    -639 which pulls two values from SNOMED to describe whether a medication is
    -640 prescription or over the counter
    +529 
    +530   /**
    +531   @returns {Array} an array of {@link hQuery.Telecom} objects associated with the organization
    +532   */
    +533 
    +534 
    +535   Organization.prototype.telecoms = function() {
    +536     var tel, _i, _len, _ref, _results;
    +537     _ref = this.json['telecoms'];
    +538     _results = [];
    +539     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +540       tel = _ref[_i];
    +541       _results.push(new hQuery.Telecom(tel));
    +542     }
    +543     return _results;
    +544   };
    +545 
    +546   return Organization;
    +547 
    +548 })();
    +549 
    +550 /**
    +551 @class a Facility
    +552 @exports Organization as hQuery.Facility
    +553 */
    +554 
    +555 
    +556 hQuery.Facility = (function(_super) {
    +557 
    +558   __extends(Facility, _super);
    +559 
    +560   Facility.name = 'Facility';
    +561 
    +562   function Facility(json) {
    +563     this.json = json;
    +564     if (this.json['code'] != null) {
    +565       Facility.__super__.constructor.call(this, this.json['code']['code'], this.json['code']['codeSystem']);
    +566     }
    +567     if (this.json['start_time']) {
    +568       this._startDate = hQuery.dateFromUtcSeconds(this.json['start_time']);
    +569     }
    +570     if (this.json['end_time']) {
    +571       this._endDate = hQuery.dateFromUtcSeconds(this.json['end_time']);
    +572     }
    +573   }
    +574 
    +575   /**
    +576   @returns {String} the name of the facility
    +577   */
    +578 
    +579 
    +580   Facility.prototype.name = function() {
    +581     return this.json['name'];
    +582   };
    +583 
    +584   /**
    +585   Date and time at which the coded entry started
    +586   @returns {Date}
    +587   */
    +588 
    +589 
    +590   Facility.prototype.startDate = function() {
    +591     return this._startDate;
    +592   };
    +593 
    +594   /**
    +595   Date and time at which the coded entry ended
    +596   @returns {Date}
    +597   */
    +598 
    +599 
    +600   Facility.prototype.endDate = function() {
    +601     return this._endDate;
    +602   };
    +603 
    +604   /**
    +605   @returns {Array} an array of {@link hQuery.Address} objects associated with the facility
    +606   */
    +607 
    +608 
    +609   Facility.prototype.addresses = function() {
    +610     var address, list, _i, _len, _ref;
    +611     list = [];
    +612     if (this.json['addresses']) {
    +613       _ref = this.json['addresses'];
    +614       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +615         address = _ref[_i];
    +616         list.push(new hQuery.Address(address));
    +617       }
    +618     }
    +619     return list;
    +620   };
    +621 
    +622   /**
    +623   @returns {Array} an array of {@link hQuery.Telecom} objects associated with the facility
    +624   */
    +625 
    +626 
    +627   Facility.prototype.telecoms = function() {
    +628     var tel, _i, _len, _ref, _results;
    +629     _ref = this.json['telecoms'];
    +630     _results = [];
    +631     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +632       tel = _ref[_i];
    +633       _results.push(new hQuery.Telecom(tel));
    +634     }
    +635     return _results;
    +636   };
    +637 
    +638   return Facility;
    +639 
    +640 })(hQuery.CodedValue);
     641 
    -642 @class TypeOfMedication - describes whether a medication is prescription or
    -643        over the counter
    -644 @augments hQuery.CodedEntry
    -645 @exports TypeOfMedication as hQuery.TypeOfMedication
    -646 */
    -647 hQuery.TypeOfMedication = (function() {
    -648   var OTC, PRESECRIPTION;
    -649   __extends(TypeOfMedication, hQuery.CodedValue);
    -650   function TypeOfMedication() {
    -651     TypeOfMedication.__super__.constructor.apply(this, arguments);
    -652   }
    -653   PRESECRIPTION = "73639000";
    -654   OTC = "329505003";
    -655   /**
    -656   @returns {Boolean}
    -657   */
    -658   TypeOfMedication.prototype.isPrescription = function() {
    -659     return this.c === PRESECRIPTION;
    +642 /**
    +643 @class represents a DateRange in the form of hi and low date values.
    +644 @exports DateRange as hQuery.DateRange
    +645 */
    +646 
    +647 
    +648 hQuery.DateRange = (function() {
    +649 
    +650   DateRange.name = 'DateRange';
    +651 
    +652   function DateRange(json) {
    +653     this.json = json;
    +654   }
    +655 
    +656   DateRange.prototype.hi = function() {
    +657     if (this.json['hi']) {
    +658       return hQuery.dateFromUtcSeconds(this.json['hi']);
    +659     }
     660   };
    -661   /**
    -662   @returns {Boolean}
    -663   */
    -664   TypeOfMedication.prototype.isOverTheCounter = function() {
    -665     return this.c === OTC;
    -666   };
    -667   return TypeOfMedication;
    +661 
    +662   DateRange.prototype.low = function() {
    +663     return hQuery.dateFromUtcSeconds(this.json['low']);
    +664   };
    +665 
    +666   return DateRange;
    +667 
     668 })();
    -669 /**
    -670 StatusOfMedication as defined by value set 2.16.840.1.113883.1.11.20.7
    -671 The terms come from SNOMED and are managed by HL7
    -672 
    -673 @class StatusOfMedication - describes the status of the medication
    -674 @augments hQuery.CodedEntry
    -675 @exports StatusOfMedication as hQuery.StatusOfMedication
    -676 */
    -677 hQuery.StatusOfMedication = (function() {
    -678   var ACTIVE, NO_LONGER_ACTIVE, ON_HOLD, PRIOR_HISTORY;
    -679   __extends(StatusOfMedication, hQuery.CodedValue);
    -680   function StatusOfMedication() {
    -681     StatusOfMedication.__super__.constructor.apply(this, arguments);
    -682   }
    -683   ON_HOLD = "392521001";
    -684   NO_LONGER_ACTIVE = "421139008";
    -685   ACTIVE = "55561003";
    -686   PRIOR_HISTORY = "73425007";
    -687   /**
    -688   @returns {Boolean}
    -689   */
    -690   StatusOfMedication.prototype.isOnHold = function() {
    -691     return this.c === ON_HOLD;
    -692   };
    -693   /**
    -694   @returns {Boolean}
    -695   */
    -696   StatusOfMedication.prototype.isNoLongerActive = function() {
    -697     return this.c === NO_LONGER_ACTIVE;
    -698   };
    -699   /**
    -700   @returns {Boolean}
    -701   */
    -702   StatusOfMedication.prototype.isActive = function() {
    -703     return this.c === ACTIVE;
    -704   };
    -705   /**
    -706   @returns {Boolean}
    -707   */
    -708   StatusOfMedication.prototype.isPriorHistory = function() {
    -709     return this.c === PRIOR_HISTORY;
    -710   };
    -711   return StatusOfMedication;
    -712 })();
    -713 /**
    -714 @class represents a medication entry for a patient.
    -715 @augments hQuery.CodedEntry
    -716 @exports Medication as hQuery.Medication
    -717 */
    -718 hQuery.Medication = (function() {
    -719   __extends(Medication, hQuery.CodedEntry);
    -720   function Medication() {
    -721     Medication.__super__.constructor.apply(this, arguments);
    -722   }
    -723   /**
    -724   @returns {String}
    -725   */
    -726   Medication.prototype.freeTextSig = function() {
    -727     return this.json['freeTextSig'];
    -728   };
    -729   /**
    -730   The actual or intended start of a medication. Slight deviation from greenCDA for C32 since
    -731   it combines this with medication stop
    -732   @returns {Date}
    -733   */
    -734   Medication.prototype.indicateMedicationStart = function() {
    -735     return hQuery.dateFromUtcSeconds(this.json['start_time']);
    -736   };
    -737   /**
    -738   The actual or intended stop of a medication. Slight deviation from greenCDA for C32 since
    -739   it combines this with medication start
    -740   @returns {Date}
    -741   */
    -742   Medication.prototype.indicateMedicationStop = function() {
    -743     return hQuery.dateFromUtcSeconds(this.json['end_time']);
    -744   };
    -745   Medication.prototype.administrationTiming = function() {
    -746     return new hQuery.AdministrationTiming(this.json['administrationTiming']);
    -747   };
    -748   /**
    -749   @returns {CodedValue}  Contains routeCode or adminstrationUnitCode information.
    -750     Route code shall have a a value drawn from FDA route of adminstration,
    -751     and indicates how the medication is received by the patient.
    -752     See http://www.fda.gov/Drugs/DevelopmentApprovalProcess/UCM070829
    -753     The administration unit code shall have a value drawn from the FDA
    -754     dosage form, source NCI thesaurus and represents the physical form of the
    -755     product as presented to the patient.
    -756     See http://www.fda.gov/Drugs/InformationOnDrugs/ucm142454.htm
    -757   */
    -758   Medication.prototype.route = function() {
    -759     return new hQuery.CodedValue(this.json['route']['code'], this.json['route']['codeSystem']);
    +669 
    +670 /**
    +671 @class Class used to describe an entity that is providing some form of information.  This does not mean that they are
    +672 providing any treatment just that they are providing information.
    +673 @exports Informant as hQuery.Informant
    +674 */
    +675 
    +676 
    +677 hQuery.Informant = (function() {
    +678 
    +679   Informant.name = 'Informant';
    +680 
    +681   function Informant(json) {
    +682     this.json = json;
    +683   }
    +684 
    +685   /**
    +686   an array of hQuery.Person objects as points of contact
    +687   @returns {Array}
    +688   */
    +689 
    +690 
    +691   Informant.prototype.contacts = function() {
    +692     var contact, _i, _len, _ref, _results;
    +693     _ref = this.json['contacts'];
    +694     _results = [];
    +695     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +696       contact = _ref[_i];
    +697       _results.push(new hQuery.Person(contact));
    +698     }
    +699     return _results;
    +700   };
    +701 
    +702   /**
    +703    @returns {hQuery.Organization} the organization providing the information
    +704   */
    +705 
    +706 
    +707   Informant.prototype.organization = function() {
    +708     return new hQuery.Organization(this.json['organization']);
    +709   };
    +710 
    +711   return Informant;
    +712 
    +713 })();
    +714 
    +715 /**
    +716 @class
    +717 @exports CodedEntry as hQuery.CodedEntry
    +718 */
    +719 
    +720 
    +721 hQuery.CodedEntry = (function() {
    +722 
    +723   CodedEntry.name = 'CodedEntry';
    +724 
    +725   function CodedEntry(json) {
    +726     this.json = json;
    +727     if (this.json['time']) {
    +728       this._date = hQuery.dateFromUtcSeconds(this.json['time']);
    +729     }
    +730     if (this.json['start_time']) {
    +731       this._startDate = hQuery.dateFromUtcSeconds(this.json['start_time']);
    +732     }
    +733     if (this.json['end_time']) {
    +734       this._endDate = hQuery.dateFromUtcSeconds(this.json['end_time']);
    +735     }
    +736     this._type = hQuery.createCodedValues(this.json['codes']);
    +737     this._statusCode = this.json['status_code'];
    +738     this.id = "" + this.json['_id'];
    +739     this.source_id = this.json['id'];
    +740     this._freeTextType = this.json['description'];
    +741   }
    +742 
    +743   /**
    +744   Adjust the start and end times of this event to the supplied timestamp
    +745   */
    +746 
    +747 
    +748   CodedEntry.prototype.setTimestamp = function(timestamp) {
    +749     return this._date = this._startDate = this._endDate = timestamp;
    +750   };
    +751 
    +752   /**
    +753   Date and time at which the coded entry took place
    +754   @returns {Date}
    +755   */
    +756 
    +757 
    +758   CodedEntry.prototype.date = function() {
    +759     return this._date;
     760   };
    -761   /**
    -762   @returns {hQuery.Scalar} the dose
    -763   */
    -764   Medication.prototype.dose = function() {
    -765     return new hQuery.Scalar(this.json['dose']);
    -766   };
    -767   /**
    -768   @returns {CodedValue}
    -769   */
    -770   Medication.prototype.site = function() {
    -771     return new hQuery.CodedValue(this.json['site']['code'], this.json['site']['codeSystem']);
    -772   };
    -773   /**
    -774   @returns {hQuery.DoseRestriction}
    +761 
    +762   /**
    +763   Date and time at which the coded entry started
    +764   @returns {Date}
    +765   */
    +766 
    +767 
    +768   CodedEntry.prototype.startDate = function() {
    +769     return this._startDate;
    +770   };
    +771 
    +772   /**
    +773   Date and time at which the coded entry ended
    +774   @returns {Date}
     775   */
    -776   Medication.prototype.doseRestriction = function() {
    -777     return new hQuery.DoseRestriction(this.json['doseRestriction']);
    -778   };
    -779   /**
    -780   @returns {String}
    -781   */
    -782   Medication.prototype.doseIndicator = function() {
    -783     return this.json['doseIndicator'];
    -784   };
    -785   /**
    -786   @returns {String}
    -787   */
    -788   Medication.prototype.fulfillmentInstructions = function() {
    -789     return this.json['fulfillmentInstructions'];
    -790   };
    -791   /**
    -792   @returns {CodedValue}
    -793   */
    -794   Medication.prototype.indication = function() {
    -795     return new hQuery.CodedValue(this.json['indication']['code'], this.json['indication']['codeSystem']);
    -796   };
    -797   /**
    -798   @returns {CodedValue}
    -799   */
    -800   Medication.prototype.productForm = function() {
    -801     return new hQuery.CodedValue(this.json['productForm']['code'], this.json['productForm']['codeSystem']);
    -802   };
    +776 
    +777 
    +778   CodedEntry.prototype.endDate = function() {
    +779     return this._endDate;
    +780   };
    +781 
    +782   /**
    +783   Tries to find a single point in time for this entry. Will first return date if it is present,
    +784   then fall back to startDate and finally endDate
    +785   @returns {Date}
    +786   */
    +787 
    +788 
    +789   CodedEntry.prototype.timeStamp = function() {
    +790     return this._date || this._startDate || this._endDate;
    +791   };
    +792 
    +793   /**
    +794   Determines whether the entry specifies a time range or not
    +795   @returns {boolean}
    +796   */
    +797 
    +798 
    +799   CodedEntry.prototype.isTimeRange = function() {
    +800     return (this._startDate != null) && (this._endDate != null);
    +801   };
    +802 
     803   /**
    -804   @returns {CodedValue}
    -805   */
    -806   Medication.prototype.vehicle = function() {
    -807     return new hQuery.CodedValue(this.json['vehicle']['code'], this.json['vehicle']['codeSystem']);
    -808   };
    -809   /**
    -810   @returns {CodedValue}
    -811   */
    -812   Medication.prototype.reaction = function() {
    -813     return new hQuery.CodedValue(this.json['reaction']['code'], this.json['reaction']['codeSystem']);
    -814   };
    -815   /**
    -816   @returns {CodedValue}
    +804   Determines whether a coded entry contains sufficient information (code and at least 
    +805   one time stamp) to be usable
    +806   @returns {boolean}
    +807   */
    +808 
    +809 
    +810   CodedEntry.prototype.isUsable = function() {
    +811     return this._type.length > 0 && (this._date || this._startDate || this._endDate);
    +812   };
    +813 
    +814   /**
    +815   An Array of CodedValues which describe what kind of coded entry took place
    +816   @returns {Array}
     817   */
    -818   Medication.prototype.deliveryMethod = function() {
    -819     return new hQuery.CodedValue(this.json['deliveryMethod']['code'], this.json['deliveryMethod']['codeSystem']);
    -820   };
    -821   /**
    -822   @returns {hQuery.MedicationInformation}
    -823   */
    -824   Medication.prototype.medicationInformation = function() {
    -825     return new hQuery.MedicationInformation(this.json);
    -826   };
    -827   /**
    -828   @returns {hQuery.TypeOfMedication} Indicates whether this is an over the counter or prescription medication
    -829   */
    -830   Medication.prototype.typeOfMedication = function() {
    -831     return new hQuery.TypeOfMedication(this.json['typeOfMedication']['code'], this.json['typeOfMedication']['codeSystem']);
    +818 
    +819 
    +820   CodedEntry.prototype.type = function() {
    +821     return this._type;
    +822   };
    +823 
    +824   /**
    +825   A free text description of the type of coded entry
    +826   @returns {String}
    +827   */
    +828 
    +829 
    +830   CodedEntry.prototype.freeTextType = function() {
    +831     return this._freeTextType;
     832   };
    -833   /**
    -834   Values conform to value set 2.16.840.1.113883.1.11.20.7 - Medication Status
    -835   Values may be: On Hold, No Longer Active, Active, Prior History
    -836   @returns {hQuery.StatusOfMedication}   Used to indicate the status of the medication.
    +833 
    +834   /**
    +835   Status for this coded entry
    +836   @returns {String}
     837   */
    -838   Medication.prototype.statusOfMedication = function() {
    -839     return new hQuery.StatusOfMedication(this.json['statusOfMedication']['code'], this.json['statusOfMedication']['codeSystem']);
    -840   };
    -841   /**
    -842   @returns {String} free text instructions to the patient
    -843   */
    -844   Medication.prototype.patientInstructions = function() {
    -845     return this.json['patientInstructions'];
    -846   };
    -847   /**
    -848   @returns {Array} an array of {@link FulFillment} objects
    -849   */
    -850   Medication.prototype.fulfillmentHistory = function() {
    -851     var order, _i, _len, _ref, _results;
    -852     _ref = this.json['fulfillmentHistory'];
    -853     _results = [];
    -854     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -855       order = _ref[_i];
    -856       _results.push(new hQuery.Fulfillment(order));
    -857     }
    -858     return _results;
    -859   };
    -860   /**
    -861   @returns {Array} an array of {@link OrderInformation} objects
    -862   */
    -863   Medication.prototype.orderInformation = function() {
    -864     var order, _i, _len, _ref, _results;
    -865     _ref = this.json['orderInformation'];
    -866     _results = [];
    -867     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -868       order = _ref[_i];
    -869       _results.push(new hQuery.OrderInformation(order));
    -870     }
    -871     return _results;
    -872   };
    -873   return Medication;
    -874 })();/**
    -875 @namespace scoping into the hquery namespace
    -876 */
    -877 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -878   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -879   function ctor() { this.constructor = child; }
    -880   ctor.prototype = parent.prototype;
    -881   child.prototype = new ctor;
    -882   child.__super__ = parent.prototype;
    -883   return child;
    -884 };
    -885 this.hQuery || (this.hQuery = {});
    -886 /**
    -887 @class CauseOfDeath
    -888 @exports CauseOfDeath as hQuery.CauseOfDeath
    -889 */
    -890 hQuery.CauseOfDeath = (function() {
    -891   function CauseOfDeath(json) {
    -892     this.json = json;
    -893   }
    -894   /**
    -895   @returns {hQuery.Date}
    -896   */
    -897   CauseOfDeath.prototype.timeOfDeath = function() {
    -898     return new hQuery.dateFromUtcSeconds(this.json['timeOfDeath']);
    -899   };
    -900   /**
    -901   @returns {int}
    -902   */
    -903   CauseOfDeath.prototype.ageAtDeath = function() {
    -904     return this.json['ageAtDeath'];
    -905   };
    -906   return CauseOfDeath;
    -907 })();
    -908 /**
    -909 @class hQuery.Condition
    -910 
    -911 This section is used to describe a patients problems/conditions. The types of conditions
    -912 described have been constrained to the SNOMED CT Problem Type code set. An unbounded
    -913 number of treating providers for the particular condition can be supplied.
    -914 @exports Condition as hQuery.Condition 
    -915 @augments hQuery.CodedEntry
    -916 */
    -917 hQuery.Condition = (function() {
    -918   __extends(Condition, hQuery.CodedEntry);
    -919   function Condition(json) {
    -920     this.json = json;
    -921   }
    -922   /**
    -923    @returns {Array, hQuery.Provider} an array of providers for the condition
    -924   */
    -925   Condition.prototype.providers = function() {
    -926     var provider, _i, _len, _ref, _results;
    -927     _ref = this.json['treatingProviders'];
    -928     _results = [];
    -929     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -930       provider = _ref[_i];
    -931       _results.push(new Provider(provider));
    -932     }
    -933     return _results;
    -934   };
    -935   /**
    -936   Diagnosis Priority
    -937   @returns {int}
    -938   */
    -939   Condition.prototype.diagnosisPriority = function() {
    -940     return this.json['diagnosisPriority'];
    -941   };
    -942   /**
    -943   age at onset
    -944   @returns {int}
    -945   */
    -946   Condition.prototype.ageAtOnset = function() {
    -947     return this.json['ageAtOnset'];
    -948   };
    -949   /**
    -950   cause of death
    -951   @returns {hQuery.CauseOfDeath}
    -952   */
    -953   Condition.prototype.causeOfDeath = function() {
    -954     return new hQuery.CauseOfDeath(this.json['causeOfDeath']);
    -955   };
    -956   /**
    -957   problem status
    -958   @returns {hQuery.CodedValue}
    -959   */
    -960   Condition.prototype.problemStatus = function() {
    -961     return new hQuery.CodedValue(this.json['problemStatus']['code'], this.json['problemStatus']['codeSystem']);
    -962   };
    -963   /**
    -964   comment
    -965   @returns {String}
    -966   */
    -967   Condition.prototype.comment = function() {
    -968     return this.json['comment'];
    -969   };
    -970   return Condition;
    -971 })();/**
    -972 @namespace scoping into the hquery namespace
    -973 */
    -974 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -975   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -976   function ctor() { this.constructor = child; }
    -977   ctor.prototype = parent.prototype;
    -978   child.prototype = new ctor;
    -979   child.__super__ = parent.prototype;
    -980   return child;
    -981 };
    -982 this.hQuery || (this.hQuery = {});
    -983 /**
    -984 An Encounter is an interaction, regardless of the setting, between a patient and a
    -985 practitioner who is vested with primary responsibility for diagnosing, evaluating,
    -986 or treating the patient's condition. It may include visits, appointments, as well
    -987 as non face-to-face interactions. It is also a contact between a patient and a
    -988 practitioner who has primary responsibility for assessing and treating the
    -989 patient at a given contact, exercising independent judgment.
    -990 @class An Encounter is an interaction, regardless of the setting, between a patient and a
    -991 practitioner 
    -992 @augments hQuery.CodedEntry
    -993 @exports Encounter as hQuery.Encounter 
    -994 */
    -995 hQuery.Encounter = (function() {
    -996   __extends(Encounter, hQuery.CodedEntry);
    -997   function Encounter() {
    -998     Encounter.__super__.constructor.apply(this, arguments);
    -999   }
    -1000   /**
    -1001   @returns {String}
    -1002   */
    -1003   Encounter.prototype.dischargeDisp = function() {
    -1004     return this.json['dischargeDisp'];
    -1005   };
    -1006   /**
    -1007   A code indicating the priority of the admission (e.g., Emergency, Urgent, Elective, et cetera) from
    -1008   National Uniform Billing Committee (NUBC)
    -1009   @returns {CodedValue}
    -1010   */
    -1011   Encounter.prototype.admitType = function() {
    -1012     return new hQuery.CodedValue(this.json['admitType']['code'], this.json['admitType']['codeSystem']);
    -1013   };
    -1014   /**
    -1015   @returns {hQuery.Actor}
    -1016   */
    -1017   Encounter.prototype.performer = function() {
    -1018     return new hQuery.Actor(this.json['performer']);
    -1019   };
    +838 
    +839 
    +840   CodedEntry.prototype.status = function() {
    +841     if (this._statusCode != null) {
    +842       if (this._statusCode['HL7 ActStatus'] != null) {
    +843         return this._statusCode['HL7 ActStatus'][0];
    +844       } else if (this._statusCode['SNOMED-CT'] != null) {
    +845         switch (this._statusCode['SNOMED-CT'][0]) {
    +846           case '55561003':
    +847             return 'active';
    +848           case '73425007':
    +849             return 'inactive';
    +850           case '413322009':
    +851             return 'resolved';
    +852         }
    +853       }
    +854     }
    +855   };
    +856 
    +857   /**
    +858   Status for this coded entry
    +859   @returns {Hash} keys are code systems, values are arrays of codes
    +860   */
    +861 
    +862 
    +863   CodedEntry.prototype.statusCode = function() {
    +864     return this._statusCode;
    +865   };
    +866 
    +867   /**
    +868   Returns true if any of this entry codes match a code in the supplied codeSet.
    +869   @param {Object} codeSet a hash with code system names as keys and an array of codes as values
    +870   @returns {boolean}
    +871   */
    +872 
    +873 
    +874   CodedEntry.prototype.includesCodeFrom = function(codeSet) {
    +875     var codedValue, _i, _len, _ref;
    +876     _ref = this._type;
    +877     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +878       codedValue = _ref[_i];
    +879       if (codedValue.includedIn(codeSet)) {
    +880         return true;
    +881       }
    +882     }
    +883     return false;
    +884   };
    +885 
    +886   /**
    +887   Returns true if any of this entry codes match a code in the supplied codeSet.
    +888   @param {Object} codeSet a hash with code system names as keys and an array of codes (provided as regular expressions) as values
    +889   @returns {boolean}
    +890   */
    +891 
    +892 
    +893   CodedEntry.prototype.regex_includesCodeFrom = function(codeSet) {
    +894     var codedValue, _i, _len, _ref;
    +895     _ref = this._type;
    +896     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +897       codedValue = _ref[_i];
    +898       if (codedValue.regex_includedIn(codeSet)) {
    +899         return true;
    +900       }
    +901     }
    +902     return false;
    +903   };
    +904 
    +905   /**
    +906   @returns {Boolean} whether the entry was negated
    +907   */
    +908 
    +909 
    +910   CodedEntry.prototype.negationInd = function() {
    +911     return this.json['negationInd'] || false;
    +912   };
    +913 
    +914   /**
    +915   Returns the values of the result. This will return an array that contains
    +916   PhysicalQuantity or CodedValue objects depending on the result type.
    +917   @returns {Array} containing either PhysicalQuantity and/or CodedValues
    +918   */
    +919 
    +920 
    +921   CodedEntry.prototype.values = function() {
    +922     var value, values, _i, _len, _ref;
    +923     values = [];
    +924     if (this.json['values']) {
    +925       _ref = this.json['values'];
    +926       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +927         value = _ref[_i];
    +928         if (value['scalar'] != null) {
    +929           values.push(new hQuery.PhysicalQuantity(value));
    +930         } else {
    +931           values = values.concat(hQuery.createCodedValues(value.codes));
    +932         }
    +933       }
    +934     }
    +935     return values;
    +936   };
    +937 
    +938   /**
    +939   Indicates the reason an entry was negated.
    +940   @returns {hQuery.CodedValue}   Used to indicate reason an immunization was not administered.
    +941   */
    +942 
    +943 
    +944   CodedEntry.prototype.negationReason = function() {
    +945     return hQuery.createCodedValue(this.json['negationReason']);
    +946   };
    +947 
    +948   /**
    +949   Explains the reason for an entry.
    +950   @returns {hQuery.CodedValue}   Used to explain the rationale for a given entry.
    +951   */
    +952 
    +953 
    +954   CodedEntry.prototype.reason = function() {
    +955     return hQuery.createCodedValue(this.json['reason']);
    +956   };
    +957 
    +958   return CodedEntry;
    +959 
    +960 })();
    +961 
    +962 /**
    +963 @class Represents a list of hQuery.CodedEntry instances. Offers utility methods for matching
    +964 entries based on codes and date ranges
    +965 @exports CodedEntryList as hQuery.CodedEntryList
    +966 */
    +967 
    +968 
    +969 hQuery.CodedEntryList = (function(_super) {
    +970 
    +971   __extends(CodedEntryList, _super);
    +972 
    +973   CodedEntryList.name = 'CodedEntryList';
    +974 
    +975   function CodedEntryList() {
    +976     this.push.apply(this, arguments);
    +977   }
    +978 
    +979   /**
    +980   Push the supplied entry onto this list if it is usable
    +981   @param {CodedEntry} a coded entry that should be added to the list if it is usable
    +982   */
    +983 
    +984 
    +985   CodedEntryList.prototype.pushIfUsable = function(entry) {
    +986     if (entry.isUsable()) {
    +987       return this.push(entry);
    +988     }
    +989   };
    +990 
    +991   /**
    +992   Return the number of entries that match the
    +993   supplied code set where those entries occur between the supplied time bounds
    +994   @param {Object} codeSet a hash with code system names as keys and an array of codes as values
    +995   @param {Date} start the start of the period during which the entry must occur, a null value will match all times
    +996   @param {Date} end the end of the period during which the entry must occur, a null value will match all times
    +997   @param {boolean} includeNegated whether the returned list of entries should include those that have been negated
    +998   @return {CodedEntryList} the matching entries
    +999   */
    +1000 
    +1001 
    +1002   CodedEntryList.prototype.match = function(codeSet, start, end, includeNegated) {
    +1003     var afterStart, beforeEnd, cloned, entry, matchesCode, _i, _len;
    +1004     if (includeNegated == null) {
    +1005       includeNegated = false;
    +1006     }
    +1007     cloned = new hQuery.CodedEntryList();
    +1008     for (_i = 0, _len = this.length; _i < _len; _i++) {
    +1009       entry = this[_i];
    +1010       afterStart = !start || entry.timeStamp() >= start;
    +1011       beforeEnd = !end || entry.timeStamp() <= end;
    +1012       matchesCode = codeSet === null || entry.includesCodeFrom(codeSet);
    +1013       if (afterStart && beforeEnd && matchesCode && (includeNegated || !entry.negationInd())) {
    +1014         cloned.push(entry);
    +1015       }
    +1016     }
    +1017     return cloned;
    +1018   };
    +1019 
     1020   /**
    -1021   @returns {hQuery.Organization}
    -1022   */
    -1023   Encounter.prototype.facility = function() {
    -1024     return new hQuery.Organization(this.json['facility']);
    -1025   };
    -1026   /**
    -1027   @returns {hQuery.DateRange}
    -1028   */
    -1029   Encounter.prototype.encounterDuration = function() {
    -1030     return new hQuery.DateRange(this.json);
    -1031   };
    -1032   /**
    -1033   @returns {hQuery.CodedEntry}
    -1034   */
    -1035   Encounter.prototype.reasonForVisit = function() {
    -1036     return new hQuery.CodedEntry(this.json['reason']);
    -1037   };
    -1038   return Encounter;
    -1039 })();/**
    -1040 @namespace scoping into the hquery namespace
    -1041 */
    -1042 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -1043   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -1044   function ctor() { this.constructor = child; }
    -1045   ctor.prototype = parent.prototype;
    -1046   child.prototype = new ctor;
    -1047   child.__super__ = parent.prototype;
    -1048   return child;
    -1049 };
    -1050 this.hQuery || (this.hQuery = {});
    -1051 /**
    -1052 This represents all interventional, surgical, diagnostic, or therapeutic procedures or 
    -1053 treatments pertinent to the patient.
    -1054 @class
    -1055 @augments hQuery.CodedEntry
    -1056 @exports Procedure as hQuery.Procedure 
    -1057 */
    -1058 hQuery.Procedure = (function() {
    -1059   __extends(Procedure, hQuery.CodedEntry);
    -1060   function Procedure() {
    -1061     Procedure.__super__.constructor.apply(this, arguments);
    -1062   }
    -1063   /**
    -1064   @returns {hQuery.Actor} The provider that performed the procedure
    -1065   */
    -1066   Procedure.prototype.performer = function() {
    -1067     return new hQuery.Actor(this.json['performer']);
    +1021   Return the number of entries that match the
    +1022   supplied code set where those entries occur between the supplied time bounds
    +1023   @param {Object} codeSet a hash with code system names as keys and an array of codes (provided as regular expressions) as values
    +1024   @param {Date} start the start of the period during which the entry must occur, a null value will match all times
    +1025   @param {Date} end the end of the period during which the entry must occur, a null value will match all times
    +1026   @param {boolean} includeNegated whether the returned list of entries should include those that have been negated
    +1027   @return {CodedEntryList} the matching entries
    +1028   TODO - decide on what to do with includeNegated parameter
    +1029   */
    +1030 
    +1031 
    +1032   CodedEntryList.prototype.regex_match = function(codeSet, start, end, includeNegated) {
    +1033     var afterStart, beforeEnd, cloned, entry, matchesCode, _i, _len;
    +1034     if (includeNegated == null) {
    +1035       includeNegated = false;
    +1036     }
    +1037     cloned = new hQuery.CodedEntryList();
    +1038     for (_i = 0, _len = this.length; _i < _len; _i++) {
    +1039       entry = this[_i];
    +1040       afterStart = !start || entry.timeStamp() >= start;
    +1041       beforeEnd = !end || entry.timeStamp() <= end;
    +1042       matchesCode = codeSet === null || entry.regex_includesCodeFrom(codeSet);
    +1043       if (afterStart && beforeEnd && matchesCode && (includeNegated || !entry.negationInd())) {
    +1044         cloned.push(entry);
    +1045       }
    +1046     }
    +1047     return cloned;
    +1048   };
    +1049 
    +1050   /**
    +1051   Return a new list of entries that is the result of concatenating the passed in entries with this list
    +1052   @return {CodedEntryList} the set of concatenated entries
    +1053   */
    +1054 
    +1055 
    +1056   CodedEntryList.prototype.concat = function(otherEntries) {
    +1057     var cloned, entry, _i, _j, _len, _len1;
    +1058     cloned = new hQuery.CodedEntryList();
    +1059     for (_i = 0, _len = this.length; _i < _len; _i++) {
    +1060       entry = this[_i];
    +1061       cloned.push(entry);
    +1062     }
    +1063     for (_j = 0, _len1 = otherEntries.length; _j < _len1; _j++) {
    +1064       entry = otherEntries[_j];
    +1065       cloned.push(entry);
    +1066     }
    +1067     return cloned;
     1068   };
    -1069   /**
    -1070   @returns {hQuery.CodedValue} A SNOMED code indicating the body site on which the 
    -1071   procedure was performed
    -1072   */
    -1073   Procedure.prototype.site = function() {
    -1074     return new hQuery.CodedValue(this.json['site']['code'], this.json['site']['codeSystem']);
    -1075   };
    -1076   return Procedure;
    -1077 })();/**
    -1078 @namespace scoping into the hquery namespace
    -1079 */
    -1080 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -1081   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -1082   function ctor() { this.constructor = child; }
    -1083   ctor.prototype = parent.prototype;
    -1084   child.prototype = new ctor;
    -1085   child.__super__ = parent.prototype;
    -1086   return child;
    -1087 };
    -1088 this.hQuery || (this.hQuery = {});
    -1089 /**
    -1090 Observations generated by laboratories, imaging procedures, and other procedures. The scope
    -1091 includes hematology, chemistry, serology, virology, toxicology, microbiology, plain x-ray,
    -1092 ultrasound, CT, MRI, angiography, cardiac echo, nuclear medicine, pathology, and procedure
    -1093 observations.
    -1094 @class
    -1095 @augments hQuery.CodedEntry
    -1096 @exports Result as hQuery.Result 
    -1097 */
    -1098 hQuery.Result = (function() {
    -1099   __extends(Result, hQuery.CodedEntry);
    -1100   function Result() {
    -1101     Result.__super__.constructor.apply(this, arguments);
    -1102   }
    -1103   /**
    -1104   ASTM CCR defines a restricted set of required result Type codes (see ResultTypeCode in section 7.3
    -1105   Summary of CCD value sets), used to categorize a result into one of several commonly accepted values
    -1106   (e.g. Hematology, Chemistry, Nuclear Medicine).
    -1107   @returns {CodedValue}
    -1108   */
    -1109   Result.prototype.resultType = function() {
    -1110     return this.type();
    +1069 
    +1070   /**
    +1071   Match entries with the specified statuses
    +1072   @return {CodedEntryList} the matching entries
    +1073   */
    +1074 
    +1075 
    +1076   CodedEntryList.prototype.withStatuses = function(statuses, includeUndefined) {
    +1077     var cloned, entry, _i, _len, _ref;
    +1078     if (includeUndefined == null) {
    +1079       includeUndefined = true;
    +1080     }
    +1081     if (includeUndefined) {
    +1082       statuses = statuses.concat([void 0, null]);
    +1083     }
    +1084     cloned = new hQuery.CodedEntryList();
    +1085     for (_i = 0, _len = this.length; _i < _len; _i++) {
    +1086       entry = this[_i];
    +1087       if (_ref = entry.status(), __indexOf.call(statuses, _ref) >= 0) {
    +1088         cloned.push(entry);
    +1089       }
    +1090     }
    +1091     return cloned;
    +1092   };
    +1093 
    +1094   /**
    +1095   Filter entries based on negation
    +1096   @param {Object} codeSet a hash with code system names as keys and an array of codes as values
    +1097   @return {CodedEntryList} negated entries
    +1098   */
    +1099 
    +1100 
    +1101   CodedEntryList.prototype.withNegation = function(codeSet) {
    +1102     var cloned, entry, _i, _len;
    +1103     cloned = new hQuery.CodedEntryList();
    +1104     for (_i = 0, _len = this.length; _i < _len; _i++) {
    +1105       entry = this[_i];
    +1106       if (entry.negationInd() && (!codeSet || (entry.negationReason() && entry.negationReason().includedIn(codeSet)))) {
    +1107         cloned.push(entry);
    +1108       }
    +1109     }
    +1110     return cloned;
     1111   };
    -1112   /**
    -1113   A status from the HL7 ActStatusNormal vocabulary
    -1114   @returns {String}
    -1115   */
    -1116   Result.prototype.status = function() {
    -1117     return this.json['status'];
    -1118   };
    -1119   /**
    -1120   Returns the value of the result. This will return an object. The properties of this
    -1121   object are dependent on the type of result.
    -1122   */
    -1123   Result.prototype.value = function() {
    -1124     return this.json['value'];
    -1125   };
    -1126   /**
    -1127   @returns {CodedValue}
    -1128   */
    -1129   Result.prototype.interpretation = function() {
    -1130     return new hQuery.CodedValue(this.json['interpretation'].code, this.json['interpretation'].codeSystem);
    -1131   };
    -1132   /**
    -1133   @returns {String}
    -1134   */
    -1135   Result.prototype.referenceRange = function() {
    -1136     return this.json['referenceRange'];
    -1137   };
    -1138   /**
    -1139   @returns {String}
    -1140   */
    -1141   Result.prototype.comment = function() {
    -1142     return this.json['comment'];
    -1143   };
    -1144   return Result;
    -1145 })();/**
    -1146 @namespace scoping into the hquery namespace
    -1147 */
    -1148 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -1149   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -1150   function ctor() { this.constructor = child; }
    -1151   ctor.prototype = parent.prototype;
    -1152   child.prototype = new ctor;
    -1153   child.__super__ = parent.prototype;
    -1154   return child;
    -1155 };
    -1156 this.hQuery || (this.hQuery = {});
    -1157 /**
    -1158 NoImmunzation as defined by value set 2.16.840.1.113883.1.11.19717
    -1159 The terms come from Health Level Seven (HL7) Version 3.0 Vocabulary and are managed by HL7
    -1160 It indicates the reason an immunization was not administered.
    -1161 
    -1162 @class NoImmunization - describes the status of the medication
    -1163 @augments hQuery.CodedEntry
    -1164 @exports NoImmunization as hQuery.NoImmunization
    -1165 */
    -1166 hQuery.NoImmunization = (function() {
    -1167   var IMMUNITY, MED_PRECAUTION, OUT_OF_STOCK, PAT_OBJ, PHIL_OBJ, REL_OBJ, VAC_EFF, VAC_SAFETY;
    -1168   __extends(NoImmunization, hQuery.CodedValue);
    -1169   function NoImmunization() {
    -1170     NoImmunization.__super__.constructor.apply(this, arguments);
    -1171   }
    -1172   IMMUNITY = "IMMUNE";
    -1173   MED_PRECAUTION = "MEDPREC";
    -1174   OUT_OF_STOCK = "OSTOCK";
    -1175   PAT_OBJ = "PATOBJ";
    -1176   PHIL_OBJ = "PHILISOP";
    -1177   REL_OBJ = "RELIG";
    -1178   VAC_EFF = "VACEFF";
    -1179   VAC_SAFETY = "VACSAF";
    -1180   /**
    -1181   @returns {Boolean}
    -1182   */
    -1183   NoImmunization.prototype.isImmune = function() {
    -1184     return this.c === IMMUNITY;
    -1185   };
    -1186   /**
    -1187   @returns {Boolean}
    -1188   */
    -1189   NoImmunization.prototype.isMedPrec = function() {
    -1190     return this.c === MED_PRECAUTION;
    -1191   };
    -1192   /**
    -1193   @returns {Boolean}
    -1194   */
    -1195   NoImmunization.prototype.isOstock = function() {
    -1196     return this.c === OUT_OF_STOCK;
    -1197   };
    -1198   /**
    -1199   @returns {Boolean}
    -1200   */
    -1201   NoImmunization.prototype.isPatObj = function() {
    -1202     return this.c === PAT_OBJ;
    -1203   };
    -1204   /**
    -1205   @returns {Boolean}
    -1206   */
    -1207   NoImmunization.prototype.isPhilisop = function() {
    -1208     return this.c === PHIL_OBJ;
    -1209   };
    -1210   /**
    -1211   @returns {Boolean}
    -1212   */
    -1213   NoImmunization.prototype.isRelig = function() {
    -1214     return this.c === REL_OBJ;
    -1215   };
    -1216   /**
    -1217   @returns {Boolean}
    -1218   */
    -1219   NoImmunization.prototype.isVacEff = function() {
    -1220     return this.c === VAC_EFF;
    -1221   };
    -1222   /**
    -1223   @returns {Boolean}
    -1224   */
    -1225   NoImmunization.prototype.isVacSaf = function() {
    -1226     return this.c === VAC_SAFETY;
    -1227   };
    -1228   return NoImmunization;
    -1229 })();
    -1230 /**
    -1231 @class represents a immunization entry for a patient.
    -1232 @augments hQuery.CodedEntry
    -1233 @exports Immunization as hQuery.Immunization
    -1234 */
    -1235 hQuery.Immunization = (function() {
    -1236   __extends(Immunization, hQuery.CodedEntry);
    -1237   function Immunization(json) {
    -1238     this.json = json;
    -1239   }
    -1240   /**
    -1241   @returns{hQuery.Scalar} 
    -1242   */
    -1243   Immunization.prototype.medicationSeriesNumber = function() {
    -1244     return new hQuery.Scalar(this.json['medicationSeriesNumber']);
    -1245   };
    -1246   /**
    -1247   @returns{hQuery.MedicationInformation}
    +1112 
    +1113   /**
    +1114   Filter entries based on negation
    +1115   @return {CodedEntryList} non-negated entries
    +1116   */
    +1117 
    +1118 
    +1119   CodedEntryList.prototype.withoutNegation = function() {
    +1120     var cloned, entry, _i, _len;
    +1121     cloned = new hQuery.CodedEntryList();
    +1122     for (_i = 0, _len = this.length; _i < _len; _i++) {
    +1123       entry = this[_i];
    +1124       if (!entry.negationInd()) {
    +1125         cloned.push(entry);
    +1126       }
    +1127     }
    +1128     return cloned;
    +1129   };
    +1130 
    +1131   return CodedEntryList;
    +1132 
    +1133 })(Array);
    +1134 
    +1135 /**
    +1136 @private
    +1137 @function
    +1138 */
    +1139 
    +1140 
    +1141 hQuery.createCodedValues = function(jsonCodes) {
    +1142   var code, codeSystem, codedValues, codes, _i, _len;
    +1143   codedValues = [];
    +1144   for (codeSystem in jsonCodes) {
    +1145     codes = jsonCodes[codeSystem];
    +1146     for (_i = 0, _len = codes.length; _i < _len; _i++) {
    +1147       code = codes[_i];
    +1148       codedValues.push(new hQuery.CodedValue(code, codeSystem));
    +1149     }
    +1150   }
    +1151   return codedValues;
    +1152 };
    +1153 
    +1154 hQuery.createCodedValue = function(json) {
    +1155   if (json != null) {
    +1156     return new hQuery.CodedValue(json['code'], json['codeSystem']);
    +1157   }
    +1158 };
    +1159 /**
    +1160 @namespace scoping into the hquery namespace
    +1161 */
    +1162 
    +1163 var __hasProp = {}.hasOwnProperty,
    +1164   __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
    +1165 
    +1166 this.hQuery || (this.hQuery = {});
    +1167 
    +1168 /**
    +1169 @class MedicationInformation
    +1170 @exports MedicationInformation as hQuery.MedicationInformation
    +1171 */
    +1172 
    +1173 
    +1174 hQuery.MedicationInformation = (function() {
    +1175 
    +1176   MedicationInformation.name = 'MedicationInformation';
    +1177 
    +1178   function MedicationInformation(json) {
    +1179     this.json = json;
    +1180   }
    +1181 
    +1182   /**
    +1183   An array of hQuery.CodedValue describing the medication
    +1184   @returns {Array}
    +1185   */
    +1186 
    +1187 
    +1188   MedicationInformation.prototype.codedProduct = function() {
    +1189     return hQuery.createCodedValues(this.json['codes']);
    +1190   };
    +1191 
    +1192   MedicationInformation.prototype.freeTextProductName = function() {
    +1193     return this.json['description'];
    +1194   };
    +1195 
    +1196   MedicationInformation.prototype.codedBrandName = function() {
    +1197     return this.json['codedBrandName'];
    +1198   };
    +1199 
    +1200   MedicationInformation.prototype.freeTextBrandName = function() {
    +1201     return this.json['brandName'];
    +1202   };
    +1203 
    +1204   MedicationInformation.prototype.drugManufacturer = function() {
    +1205     if (this.json['drugManufacturer']) {
    +1206       return new hQuery.Organization(this.json['drugManufacturer']);
    +1207     }
    +1208   };
    +1209 
    +1210   return MedicationInformation;
    +1211 
    +1212 })();
    +1213 
    +1214 /**
    +1215 @class AdministrationTiming - the
    +1216 @exports AdministrationTiming as hQuery.AdministrationTiming
    +1217 */
    +1218 
    +1219 
    +1220 hQuery.AdministrationTiming = (function() {
    +1221 
    +1222   AdministrationTiming.name = 'AdministrationTiming';
    +1223 
    +1224   function AdministrationTiming(json) {
    +1225     this.json = json;
    +1226   }
    +1227 
    +1228   /**
    +1229   Provides the period of medication administration as a Scalar. An example
    +1230   Scalar that would be returned would be with value = 8 and units = hours. This would
    +1231   mean that the medication should be taken every 8 hours.
    +1232   @returns {hQuery.Scalar}
    +1233   */
    +1234 
    +1235 
    +1236   AdministrationTiming.prototype.period = function() {
    +1237     if (this.json['period']) {
    +1238       return new hQuery.Scalar(this.json['period']);
    +1239     }
    +1240   };
    +1241 
    +1242   /**
    +1243   Indicates whether it is the interval (time between dosing), or frequency 
    +1244   (number of doses in a time period) that is important. If instititutionSpecified is not 
    +1245   present or is set to false, then the time between dosing is important (every 8 hours). 
    +1246   If true, then the frequency of administration is important (e.g., 3 times per day).
    +1247   @returns {Boolean}
     1248   */
    -1249   Immunization.prototype.medicationInformation = function() {
    -1250     return new hQuery.MedicationInformation(this.json);
    -1251   };
    -1252   /**
    -1253   @returns{Date} Date immunization was administered
    -1254   */
    -1255   Immunization.prototype.administeredDate = function() {
    -1256     return dateFromUtcSeconds(this.json['administeredDate']);
    -1257   };
    -1258   /**
    -1259   @returns{hQuery.Actor} Performer of immunization
    -1260   */
    -1261   Immunization.prototype.performer = function() {
    -1262     return new hQuery.Actor(this.json['performer']);
    -1263   };
    -1264   /**
    -1265   @returns {comment} human readable description of event
    -1266   */
    -1267   Immunization.prototype.comment = function() {
    -1268     return this.json['comment'];
    -1269   };
    -1270   /**
    -1271   @returns {Boolean} whether the immunization has been refused by the patient.
    -1272   */
    -1273   Immunization.prototype.refusalInd = function() {
    -1274     return this.json['refusalInd'];
    -1275   };
    -1276   /**
    -1277   NoImmunzation as defined by value set 2.16.840.1.113883.1.11.19717
    -1278   The terms come from Health Level Seven (HL7) Version 3.0 Vocabulary and are managed by HL7
    -1279   It indicates the reason an immunization was not administered.
    -1280   @returns {hQuery.NoImmunization}   Used to indicate reason an immunization was not administered.
    -1281   */
    -1282   Immunization.prototype.refusalReason = function() {
    -1283     return new hQuery.NoImmunization(this.json['refusalReason']['code'], this.json['refusalReason']['codeSystem']);
    -1284   };
    -1285   return Immunization;
    -1286 })();/**
    -1287 @namespace scoping into the hquery namespace
    -1288 */
    -1289 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -1290   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -1291   function ctor() { this.constructor = child; }
    -1292   ctor.prototype = parent.prototype;
    -1293   child.prototype = new ctor;
    -1294   child.__super__ = parent.prototype;
    -1295   return child;
    -1296 };
    -1297 this.hQuery || (this.hQuery = {});
    -1298 /**
    -1299 @class 
    -1300 @augments hQuery.CodedEntry
    -1301 @exports Allergy as hQuery.Allergy
    -1302 */
    -1303 hQuery.Allergy = (function() {
    -1304   __extends(Allergy, hQuery.CodedEntry);
    -1305   function Allergy() {
    -1306     Allergy.__super__.constructor.apply(this, arguments);
    -1307   }
    -1308   /**
    -1309   Food and substance allergies use the Unique Ingredient Identifier(UNII) from the FDA
    -1310   http://www.fda.gov/ForIndustry/DataStandards/StructuredProductLabeling/ucm162523.htm
    -1311   
    -1312   Allegies to a class of medication Shall contain a value descending from the NDF-RT concept types 
    -1313   of Mechanism of Action - N0000000223, Physiologic Effect - N0000009802 or 
    -1314   Chemical Structure - N0000000002. NUI will be used as the concept code. 
    -1315   For more information, please see the Web Site 
    -1316   http://www.cancer.gov/cancertopics/terminologyresources/page5
    -1317   
    -1318   Allergies to a specific medication shall use RxNorm for the values.  
    -1319   @returns {CodedValue}
    -1320   */
    -1321   Allergy.prototype.product = function() {
    -1322     return this.type();
    -1323   };
    -1324   /**
    -1325   Date of allergy or adverse event
    -1326   @returns{Date}
    -1327   */
    -1328   Allergy.prototype.adverseEventDate = function() {
    -1329     return dateFromUtcSeconds(this.json['adverseEventDate']);
    -1330   };
    -1331   /**
    -1332   Adverse event types SHALL be coded as specified in HITSP/C80 Section 2.2.3.4.2 Allergy/Adverse Event Type
    -1333   @returns {CodedValue}
    -1334   */
    -1335   Allergy.prototype.adverseEventType = function() {
    -1336     return new hQuery.CodedValue(this.json['type']['code'], this.json['type']['codeSystem']);
    -1337   };
    -1338   /**
    -1339   This indicates the reaction that may be caused by the product or agent.  
    -1340    It is defined by 2.16.840.1.113883.3.88.12.3221.6.2 and are SNOMED-CT codes.
    -1341   420134006   Propensity to adverse reactions (disorder)
    -1342   418038007   Propensity to adverse reactions to substance (disorder)
    -1343   419511003   Propensity to adverse reactions to drug (disorder)
    -1344   418471000   Propensity to adverse reactions to food (disorder)
    -1345   419199007  Allergy to substance (disorder)
    -1346   416098002  Drug allergy (disorder)
    -1347   414285001  Food allergy (disorder)
    -1348   59037007  Drug intolerance (disorder)
    -1349   235719002  Food intolerance (disorder)
    -1350   @returns {CodedValue} 
    -1351   */
    -1352   Allergy.prototype.reaction = function() {
    -1353     return new hQuery.CodedValue(this.json['reaction']['code'], this.json['reaction']['codeSystem']);
    -1354   };
    -1355   /**
    -1356   This is a description of the level of the severity of the allergy or intolerance.
    -1357   Use SNOMED-CT Codes as defined by 2.16.840.1.113883.3.88.12.3221.6.8
    -1358     255604002  Mild
    -1359     371923003  Mild to Moderate
    -1360     6736007      Moderate
    -1361     371924009  Moderate to Severe
    -1362     24484000    Severe
    -1363     399166001  Fatal
    -1364   @returns {CodedValue} 
    -1365   */
    -1366   Allergy.prototype.severity = function() {
    -1367     return new hQuery.CodedValue(this.json['severity']['code'], this.json['severity']['codeSystem']);
    -1368   };
    -1369   /**
    -1370   Additional comment or textual information
    -1371   @returns {String}
    -1372   */
    -1373   Allergy.prototype.comment = function() {
    -1374     return this.json['comment'];
    -1375   };
    -1376   return Allergy;
    -1377 })();/**
    -1378 @namespace scoping into the hquery namespace
    -1379 */this.hQuery || (this.hQuery = {});
    -1380 /**
    -1381 @class 
    -1382 
    -1383 @exports Provider as hQuery.Provider
    -1384 */
    -1385 hQuery.Provider = (function() {
    -1386   function Provider(json) {
    -1387     this.json = json;
    -1388   }
    -1389   /**
    -1390   @returns {hQuery.Person}
    -1391   */
    -1392   Provider.prototype.providerEntity = function() {
    -1393     return new hQuery.Person(this.json['providerEntity']);
    -1394   };
    -1395   /**
    -1396   @returns {hQuery.DateRange}
    -1397   */
    -1398   Provider.prototype.careProvisionDateRange = function() {
    -1399     return new hQuery.DateRange(this.json['careProvisionDateRange']);
    -1400   };
    -1401   /**
    -1402   @returns {hQuery.CodedValue}
    -1403   */
    -1404   Provider.prototype.role = function() {
    -1405     return new hQuery.CodedValue(this.json['role']['code'], this.json['role']['codeSystem']);
    -1406   };
    -1407   /**
    -1408   @returns {String}
    -1409   */
    -1410   Provider.prototype.patientID = function() {
    -1411     return this.json['patientID'];
    -1412   };
    +1249 
    +1250 
    +1251   AdministrationTiming.prototype.institutionSpecified = function() {
    +1252     return this.json['institutionSpecified'];
    +1253   };
    +1254 
    +1255   return AdministrationTiming;
    +1256 
    +1257 })();
    +1258 
    +1259 /**
    +1260 @class DoseRestriction -  restrictions on the medications dose, represented by a upper and lower dose
    +1261 @exports DoseRestriction as hQuery.DoseRestriction
    +1262 */
    +1263 
    +1264 
    +1265 hQuery.DoseRestriction = (function() {
    +1266 
    +1267   DoseRestriction.name = 'DoseRestriction';
    +1268 
    +1269   function DoseRestriction(json) {
    +1270     this.json = json;
    +1271   }
    +1272 
    +1273   DoseRestriction.prototype.numerator = function() {
    +1274     if (this.json['numerator']) {
    +1275       return new hQuery.Scalar(this.json['numerator']);
    +1276     }
    +1277   };
    +1278 
    +1279   DoseRestriction.prototype.denominator = function() {
    +1280     if (this.json['denominator']) {
    +1281       return new hQuery.Scalar(this.json['denominator']);
    +1282     }
    +1283   };
    +1284 
    +1285   return DoseRestriction;
    +1286 
    +1287 })();
    +1288 
    +1289 /**
    +1290 @class Fulfillment - information about when and who fulfilled an order for the medication
    +1291 @exports Fulfillment as hQuery.Fullfilement
    +1292 */
    +1293 
    +1294 
    +1295 hQuery.Fulfillment = (function() {
    +1296 
    +1297   Fulfillment.name = 'Fulfillment';
    +1298 
    +1299   function Fulfillment(json) {
    +1300     this.json = json;
    +1301   }
    +1302 
    +1303   Fulfillment.prototype.dispenseDate = function() {
    +1304     return hQuery.dateFromUtcSeconds(this.json['dispenseDate']);
    +1305   };
    +1306 
    +1307   Fulfillment.prototype.dispensingPharmacyLocation = function() {
    +1308     if (this.json['dispensingPharmacyLocation']) {
    +1309       return new hQuery.Address(this.json['dispensingPharmacyLocation']);
    +1310     }
    +1311   };
    +1312 
    +1313   Fulfillment.prototype.quantityDispensed = function() {
    +1314     if (this.json['quantityDispensed']) {
    +1315       return new hQuery.Scalar(this.json['quantityDispensed']);
    +1316     }
    +1317   };
    +1318 
    +1319   Fulfillment.prototype.prescriptionNumber = function() {
    +1320     return this.json['prescriptionNumber'];
    +1321   };
    +1322 
    +1323   Fulfillment.prototype.fillNumber = function() {
    +1324     return this.json['fillNumber'];
    +1325   };
    +1326 
    +1327   Fulfillment.prototype.fillStatus = function() {
    +1328     if (this.json['fillStatus']) {
    +1329       return new hQuery.Status(this.json['fillStatus']);
    +1330     }
    +1331   };
    +1332 
    +1333   return Fulfillment;
    +1334 
    +1335 })();
    +1336 
    +1337 /**
    +1338 @class OrderInformation - information abour an order for a medication
    +1339 @exports OrderInformation as hQuery.OrderInformation
    +1340 */
    +1341 
    +1342 
    +1343 hQuery.OrderInformation = (function() {
    +1344 
    +1345   OrderInformation.name = 'OrderInformation';
    +1346 
    +1347   function OrderInformation(json) {
    +1348     this.json = json;
    +1349   }
    +1350 
    +1351   OrderInformation.prototype.orderNumber = function() {
    +1352     return this.json['orderNumber'];
    +1353   };
    +1354 
    +1355   OrderInformation.prototype.fills = function() {
    +1356     return this.json['fills'];
    +1357   };
    +1358 
    +1359   OrderInformation.prototype.quantityOrdered = function() {
    +1360     if (this.json['quantityOrdered']) {
    +1361       return new hQuery.Scalar(this.json['quantityOrdered']);
    +1362     }
    +1363   };
    +1364 
    +1365   OrderInformation.prototype.orderExpirationDateTime = function() {
    +1366     return hQuery.dateFromUtcSeconds(this.json['orderExpirationDateTime']);
    +1367   };
    +1368 
    +1369   OrderInformation.prototype.orderDateTime = function() {
    +1370     return hQuery.dateFromUtcSeconds(this.json['orderDateTime']);
    +1371   };
    +1372 
    +1373   return OrderInformation;
    +1374 
    +1375 })();
    +1376 
    +1377 /**
    +1378 TypeOfMedication as defined by value set 2.16.840.1.113883.3.88.12.3221.8.19
    +1379 which pulls two values from SNOMED to describe whether a medication is
    +1380 prescription or over the counter
    +1381 
    +1382 @class TypeOfMedication - describes whether a medication is prescription or
    +1383        over the counter
    +1384 @augments hQuery.CodedEntry
    +1385 @exports TypeOfMedication as hQuery.TypeOfMedication
    +1386 */
    +1387 
    +1388 
    +1389 hQuery.TypeOfMedication = (function(_super) {
    +1390   var OTC, PRESECRIPTION;
    +1391 
    +1392   __extends(TypeOfMedication, _super);
    +1393 
    +1394   TypeOfMedication.name = 'TypeOfMedication';
    +1395 
    +1396   function TypeOfMedication() {
    +1397     return TypeOfMedication.__super__.constructor.apply(this, arguments);
    +1398   }
    +1399 
    +1400   PRESECRIPTION = "73639000";
    +1401 
    +1402   OTC = "329505003";
    +1403 
    +1404   /**
    +1405   @returns {Boolean}
    +1406   */
    +1407 
    +1408 
    +1409   TypeOfMedication.prototype.isPrescription = function() {
    +1410     return this.c === PRESECRIPTION;
    +1411   };
    +1412 
     1413   /**
    -1414   @returns {hQuery.CodedValue}
    +1414   @returns {Boolean}
     1415   */
    -1416   Provider.prototype.providerType = function() {
    -1417     return new hQuery.CodedValue(this.json['providerType']['code'], this.json['providerType']['codeSystem']);
    -1418   };
    -1419   /**
    -1420   @returns {String}
    -1421   */
    -1422   Provider.prototype.providerID = function() {
    -1423     return this.json['providerID'];
    -1424   };
    -1425   /**
    -1426   @returns {hQuery.Organization}
    -1427   */
    -1428   Provider.prototype.organizationName = function() {
    -1429     return new hQuery.Organization(this.json);
    -1430   };
    -1431   return Provider;
    -1432 })();/**
    -1433 @namespace scoping into the hquery namespace
    -1434 */
    -1435 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -1436   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -1437   function ctor() { this.constructor = child; }
    -1438   ctor.prototype = parent.prototype;
    -1439   child.prototype = new ctor;
    -1440   child.__super__ = parent.prototype;
    -1441   return child;
    -1442 };
    -1443 this.hQuery || (this.hQuery = {});
    -1444 /**
    -1445 @class 
    -1446 @augments hQuery.CodedEntry
    -1447 @exports Language as hQuery.Language
    -1448 */
    -1449 hQuery.Language = (function() {
    -1450   __extends(Language, hQuery.CodedEntry);
    -1451   function Language(json) {
    -1452     this.json = json;
    -1453   }
    -1454   /**
    -1455   @returns {hQuery.CodedValue}
    -1456   */
    -1457   Language.prototype.modeCode = function() {
    -1458     return new hQuery.CodedValue(this.json['modeCode']['code'], this.json['modeCode']['codeSystem']);
    -1459   };
    -1460   /**
    -1461   @returns {String}
    -1462   */
    -1463   Language.prototype.preferenceIndicator = function() {
    -1464     return this.json['preferenceIndicator'];
    -1465   };
    -1466   return Language;
    -1467 })();/**
    -1468 @namespace scoping into the hquery namespace
    -1469 */
    -1470 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -1471   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -1472   function ctor() { this.constructor = child; }
    -1473   ctor.prototype = parent.prototype;
    -1474   child.prototype = new ctor;
    -1475   child.__super__ = parent.prototype;
    -1476   return child;
    -1477 };
    -1478 this.hQuery || (this.hQuery = {});
    -1479 /**
    -1480 This includes information about the patients current and past pregnancy status
    -1481 The Coded Entry code system should be SNOMED-CT
    -1482 @class
    -1483 @augments hQuery.CodedEntry
    -1484 @exports Pregnancy as hQuery.Pregnancy 
    -1485 */
    -1486 hQuery.Pregnancy = (function() {
    -1487   __extends(Pregnancy, hQuery.CodedEntry);
    -1488   function Pregnancy() {
    -1489     Pregnancy.__super__.constructor.apply(this, arguments);
    -1490   }
    -1491   /**
    -1492   @returns {String}
    -1493   */
    -1494   Pregnancy.prototype.comment = function() {
    -1495     return this.json['comment'];
    -1496   };
    -1497   return Pregnancy;
    -1498 })();/**
    -1499 @namespace scoping into the hquery namespace
    -1500 */
    -1501 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -1502   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -1503   function ctor() { this.constructor = child; }
    -1504   ctor.prototype = parent.prototype;
    -1505   child.prototype = new ctor;
    -1506   child.__super__ = parent.prototype;
    -1507   return child;
    -1508 };
    -1509 this.hQuery || (this.hQuery = {});
    -1510 /**
    -1511 
    -1512 The Social History Observation is used to define the patient's occupational, personal (e.g. lifestyle), 
    -1513 social, and environmental history and health risk factors, as well as administrative data such as 
    -1514 marital status, race, ethnicity and religious affiliation. The types of conditions
    -1515 described have been constrained to the SNOMED CT code system using constrained code set, 2.16.840.1.113883.3.88.12.80.60:
    -1516 229819007   Tobacco use and exposure
    -1517 256235009   Exercise
    -1518 160573003   Alcohol Intake
    -1519 364393001   Nutritional observable
    -1520 364703007   Employment detail
    -1521 425400000   Toxic exposure status
    -1522 363908000   Details of drug misuse behavior
    -1523 228272008   Health-related behavior
    -1524 105421008   Educational achievement
    +1416 
    +1417 
    +1418   TypeOfMedication.prototype.isOverTheCounter = function() {
    +1419     return this.c === OTC;
    +1420   };
    +1421 
    +1422   return TypeOfMedication;
    +1423 
    +1424 })(hQuery.CodedValue);
    +1425 
    +1426 /**
    +1427 StatusOfMedication as defined by value set 2.16.840.1.113883.1.11.20.7
    +1428 The terms come from SNOMED and are managed by HL7
    +1429 
    +1430 @class StatusOfMedication - describes the status of the medication
    +1431 @augments hQuery.CodedEntry
    +1432 @exports StatusOfMedication as hQuery.StatusOfMedication
    +1433 */
    +1434 
    +1435 
    +1436 hQuery.StatusOfMedication = (function(_super) {
    +1437   var ACTIVE, NO_LONGER_ACTIVE, ON_HOLD, PRIOR_HISTORY;
    +1438 
    +1439   __extends(StatusOfMedication, _super);
    +1440 
    +1441   StatusOfMedication.name = 'StatusOfMedication';
    +1442 
    +1443   function StatusOfMedication() {
    +1444     return StatusOfMedication.__super__.constructor.apply(this, arguments);
    +1445   }
    +1446 
    +1447   ON_HOLD = "392521001";
    +1448 
    +1449   NO_LONGER_ACTIVE = "421139008";
    +1450 
    +1451   ACTIVE = "55561003";
    +1452 
    +1453   PRIOR_HISTORY = "73425007";
    +1454 
    +1455   /**
    +1456   @returns {Boolean}
    +1457   */
    +1458 
    +1459 
    +1460   StatusOfMedication.prototype.isOnHold = function() {
    +1461     return this.c === ON_HOLD;
    +1462   };
    +1463 
    +1464   /**
    +1465   @returns {Boolean}
    +1466   */
    +1467 
    +1468 
    +1469   StatusOfMedication.prototype.isNoLongerActive = function() {
    +1470     return this.c === NO_LONGER_ACTIVE;
    +1471   };
    +1472 
    +1473   /**
    +1474   @returns {Boolean}
    +1475   */
    +1476 
    +1477 
    +1478   StatusOfMedication.prototype.isActive = function() {
    +1479     return this.c === ACTIVE;
    +1480   };
    +1481 
    +1482   /**
    +1483   @returns {Boolean}
    +1484   */
    +1485 
    +1486 
    +1487   StatusOfMedication.prototype.isPriorHistory = function() {
    +1488     return this.c === PRIOR_HISTORY;
    +1489   };
    +1490 
    +1491   return StatusOfMedication;
    +1492 
    +1493 })(hQuery.CodedValue);
    +1494 
    +1495 /**
    +1496 @class represents a medication entry for a patient.
    +1497 @augments hQuery.CodedEntry
    +1498 @exports Medication as hQuery.Medication
    +1499 */
    +1500 
    +1501 
    +1502 hQuery.Medication = (function(_super) {
    +1503 
    +1504   __extends(Medication, _super);
    +1505 
    +1506   Medication.name = 'Medication';
    +1507 
    +1508   function Medication(json) {
    +1509     this.json = json;
    +1510     Medication.__super__.constructor.call(this, this.json);
    +1511   }
    +1512 
    +1513   /**
    +1514   @returns {String}
    +1515   */
    +1516 
    +1517 
    +1518   Medication.prototype.freeTextSig = function() {
    +1519     return this.json['freeTextSig'];
    +1520   };
    +1521 
    +1522   /**
    +1523   @returns {Boolean}
    +1524   */
     1525 
    -1526 note:  Social History is not part of the existing green c32.
    -1527 @exports Socialhistory as hQuery.Socialhistory 
    -1528 @augments hQuery.CodedEntry
    -1529 */
    -1530 hQuery.Socialhistory = (function() {
    -1531   __extends(Socialhistory, hQuery.CodedEntry);
    -1532   function Socialhistory(json) {
    -1533     this.json = json;
    -1534   }
    -1535   /**
    -1536   Value returns the value of the result. This will return an object. The properties of this
    -1537   object are dependent on the type of result.
    -1538   */
    -1539   Socialhistory.prototype.value = function() {
    -1540     return this.json['value'];
    -1541   };
    -1542   return Socialhistory;
    -1543 })();/**
    -1544 @namespace scoping into the hquery namespace
    -1545 */
    -1546 var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    -1547   for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    -1548   function ctor() { this.constructor = child; }
    -1549   ctor.prototype = parent.prototype;
    -1550   child.prototype = new ctor;
    -1551   child.__super__ = parent.prototype;
    -1552   return child;
    -1553 };
    -1554 this.hQuery || (this.hQuery = {});
    -1555 /**
    -1556 @class Supports
    -1557 @exports Supports as hQuery.Supports
    -1558 */
    -1559 hQuery.Supports = (function() {
    -1560   function Supports(json) {
    -1561     this.json = json;
    -1562   }
    -1563   /**
    -1564   @returns {DateRange}
    -1565   */
    -1566   Supports.prototype.supportDate = function() {
    -1567     return new hQuery.DateRange(this.json['supportDate']);
    -1568   };
    -1569   /**
    -1570   @returns {Person} 
    -1571   */
    -1572   Supports.prototype.guardian = function() {
    -1573     return new hQuery.Person(this.json['guardian']);
    -1574   };
    -1575   /**
    -1576   @returns {String}
    +1526 
    +1527   Medication.prototype.isPRN = function() {
    +1528     return this.json['freeTextSig'].indexOf("E2E_PRN_FLAG") !== -1;
    +1529   };
    +1530 
    +1531   /**
    +1532   @returns {Boolean}
    +1533   */
    +1534 
    +1535 
    +1536   Medication.prototype.isLongTerm = function() {
    +1537     return this.json['freeTextSig'].indexOf("E2E_LONG_TERM_FLAG") !== -1;
    +1538   };
    +1539 
    +1540   /**
    +1541   The actual or intended start of a medication. Slight deviation from greenCDA for C32 since
    +1542   it combines this with medication stop
    +1543   @returns {Date}
    +1544   */
    +1545 
    +1546 
    +1547   Medication.prototype.indicateMedicationStart = function() {
    +1548     return hQuery.dateFromUtcSeconds(this.json['start_time']);
    +1549   };
    +1550 
    +1551   /**
    +1552   The actual or intended stop of a medication. Slight deviation from greenCDA for C32 since
    +1553   it combines this with medication start
    +1554   @returns {Date}
    +1555   */
    +1556 
    +1557 
    +1558   Medication.prototype.indicateMedicationStop = function() {
    +1559     return hQuery.dateFromUtcSeconds(this.json['end_time']);
    +1560   };
    +1561 
    +1562   Medication.prototype.administrationTiming = function() {
    +1563     if (this.json['administrationTiming']) {
    +1564       return new hQuery.AdministrationTiming(this.json['administrationTiming']);
    +1565     }
    +1566   };
    +1567 
    +1568   /**
    +1569   @returns {CodedValue}  Contains routeCode or adminstrationUnitCode information.
    +1570     Route code shall have a a value drawn from FDA route of adminstration,
    +1571     and indicates how the medication is received by the patient.
    +1572     See http://www.fda.gov/Drugs/DevelopmentApprovalProcess/UCM070829
    +1573     The administration unit code shall have a value drawn from the FDA
    +1574     dosage form, source NCI thesaurus and represents the physical form of the
    +1575     product as presented to the patient.
    +1576     See http://www.fda.gov/Drugs/InformationOnDrugs/ucm142454.htm
     1577   */
    -1578   Supports.prototype.guardianSupportType = function() {
    -1579     return this.json['guardianSupportType'];
    -1580   };
    -1581   /**
    -1582   @returns {Person}
    -1583   */
    -1584   Supports.prototype.contact = function() {
    -1585     return new hQuery.Person(this.json['contact']);
    -1586   };
    -1587   /**
    -1588   @returns {String}
    -1589   */
    -1590   Supports.prototype.contactSupportType = function() {
    -1591     return this.json['guardianSupportType'];
    -1592   };
    -1593   return Supports;
    -1594 })();
    -1595 /**
    -1596 @class Representation of a patient
    -1597 @augments hQuery.Person
    -1598 @exports Patient as hQuery.Patient
    -1599 */
    -1600 hQuery.Patient = (function() {
    -1601   __extends(Patient, hQuery.Person);
    -1602   function Patient() {
    -1603     Patient.__super__.constructor.apply(this, arguments);
    -1604   }
    -1605   /**
    -1606   @returns {String} containing M or F representing the gender of the patient
    -1607   */
    -1608   Patient.prototype.gender = function() {
    -1609     return this.json['gender'];
    -1610   };
    -1611   /**
    -1612   @returns {Date} containing the patient's birthdate
    -1613   */
    -1614   Patient.prototype.birthtime = function() {
    -1615     return hQuery.dateFromUtcSeconds(this.json['birthdate']);
    -1616   };
    +1578 
    +1579 
    +1580   Medication.prototype.route = function() {
    +1581     return hQuery.createCodedValue(this.json['route']);
    +1582   };
    +1583 
    +1584   /**
    +1585   @returns {hQuery.Scalar} the dose
    +1586   */
    +1587 
    +1588 
    +1589   Medication.prototype.dose = function() {
    +1590     if (this.json['dose']) {
    +1591       return new hQuery.Scalar(this.json['dose']);
    +1592     }
    +1593   };
    +1594 
    +1595   /**
    +1596   @returns {CodedValue}
    +1597   */
    +1598 
    +1599 
    +1600   Medication.prototype.site = function() {
    +1601     if (this.json['site']) {
    +1602       return hQuery.createCodedValue(this.json['site']);
    +1603     }
    +1604   };
    +1605 
    +1606   /**
    +1607   @returns {hQuery.DoseRestriction}
    +1608   */
    +1609 
    +1610 
    +1611   Medication.prototype.doseRestriction = function() {
    +1612     if (this.json['doseRestriction']) {
    +1613       return new hQuery.DoseRestriction(this.json['doseRestriction']);
    +1614     }
    +1615   };
    +1616 
     1617   /**
    -1618   @param (Date) date the date at which the patient age is calculated, defaults to now.
    -1619   @returns {number} the patient age in years
    -1620   */
    -1621   Patient.prototype.age = function(date) {
    -1622     var oneDay, oneYear;
    -1623     if (date == null) {
    -1624       date = new Date();
    -1625     }
    -1626     oneDay = 24 * 60 * 60 * 1000;
    -1627     oneYear = 365 * oneDay;
    -1628     return (date.getTime() - this.birthtime().getTime()) / oneYear;
    -1629   };
    -1630   /**
    -1631   @returns {CodedValue} the domestic partnership status of the patient
    -1632   The following HL7 codeset is used:
    -1633   A  Annulled
    -1634   D  Divorced
    -1635   I   Interlocutory
    -1636   L  Legally separated
    -1637   M  Married
    -1638   P  Polygamous
    -1639   S  Never Married
    -1640   T  Domestic Partner
    -1641   W  Widowed
    -1642   */
    -1643   Patient.prototype.maritalStatus = function() {
    -1644     if (this.json['maritalStatus']) {
    -1645       return new hQuery.CodedValue(this.json['maritalStatus']['code'], this.json['maritalStatus']['codeSystem']);
    -1646     }
    -1647   };
    -1648   /**
    -1649   @returns {CodedValue}  of the spiritual faith affiliation of the patient
    -1650   It uses the HL7 codeset.  http://www.hl7.org/memonly/downloads/v3edition.cfm#V32008
    -1651   */
    -1652   Patient.prototype.religiousAffiliation = function() {
    -1653     if (this.json['religiousAffiliation']) {
    -1654       return new hQuery.CodedValue(this.json['religiousAffiliation']['code'], this.json['religiousAffiliation']['codeSystem']);
    -1655     }
    -1656   };
    -1657   /**
    -1658   @returns {CodedValue}  of the race of the patient
    -1659   CDC codes:  http://phinvads.cdc.gov/vads/ViewCodeSystemConcept.action?oid=2.16.840.1.113883.6.238&code=1000-9
    -1660   */
    -1661   Patient.prototype.race = function() {
    -1662     if (this.json['race']) {
    -1663       return new hQuery.CodedValue(this.json['race']['code'], this.json['race']['codeSystem']);
    -1664     }
    -1665   };
    -1666   /**
    -1667   @returns {CodedValue} of the ethnicity of the patient
    -1668   CDC codes:  http://phinvads.cdc.gov/vads/ViewCodeSystemConcept.action?oid=2.16.840.1.113883.6.238&code=1000-9
    -1669   */
    -1670   Patient.prototype.ethnicity = function() {
    -1671     if (this.json['ethnicity']) {
    -1672       return new hQuery.CodedValue(this.json['ethnicity']['code'], this.json['ethnicity']['codeSystem']);
    -1673     }
    -1674   };
    -1675   /**
    -1676   @returns {CodedValue} This is the code specifying the level of confidentiality of the document.
    -1677   HL7 Confidentiality Code (2.16.840.1.113883.5.25)
    -1678   */
    -1679   Patient.prototype.confidentiality = function() {
    -1680     if (this.json['confidentiality']) {
    -1681       return new hQuery.CodedValue(this.json['confidentiality']['code'], this.json['confidentiality']['codeSystem']);
    -1682     }
    -1683   };
    -1684   /**
    -1685   @returns {Address} of the location where the patient was born
    -1686   */
    -1687   Patient.prototype.birthPlace = function() {
    -1688     return new hQuery.Address(this.json['birthPlace']);
    -1689   };
    -1690   /**
    -1691   @returns {Supports} information regarding key support contacts relative to healthcare decisions, including next of kin
    -1692   */
    -1693   Patient.prototype.supports = function() {
    -1694     return new hQuery.Supports(this.json['supports']);
    -1695   };
    -1696   /**
    -1697   @returns {Organization}
    -1698   */
    -1699   Patient.prototype.custodian = function() {
    -1700     return new hQuery.Organization(this.json['custodian']);
    -1701   };
    -1702   /**
    -1703   @returns {Provider}  the providers associated with the patient
    -1704   */
    -1705   Patient.prototype.provider = function() {
    -1706     return new hQuery.Provider(this.json['provider']);
    -1707   };
    -1708   /**
    -1709   @returns {hQuery.CodedEntryList} A list of {@link hQuery.LanguagesSpoken} objects
    -1710   Code from http://www.ietf.org/rfc/rfc4646.txt representing the name of the human language
    -1711   */
    -1712   Patient.prototype.languages = function() {
    -1713     var language, list, _i, _len, _ref;
    -1714     list = new hQuery.CodedEntryList;
    -1715     if (this.json['languages']) {
    -1716       _ref = this.json['languages'];
    -1717       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1718         language = _ref[_i];
    -1719         list.push(new hQuery.Language(language));
    -1720       }
    -1721     }
    -1722     return list;
    -1723   };
    -1724   /**
    -1725   @returns {hQuery.CodedEntryList} A list of {@link hQuery.Encounter} objects
    -1726   */
    -1727   Patient.prototype.encounters = function() {
    -1728     var encounter, list, _i, _len, _ref;
    -1729     list = new hQuery.CodedEntryList;
    -1730     if (this.json['encounters']) {
    -1731       _ref = this.json['encounters'];
    -1732       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1733         encounter = _ref[_i];
    -1734         list.push(new hQuery.Encounter(encounter));
    -1735       }
    -1736     }
    -1737     return list;
    -1738   };
    -1739   /**
    -1740   @returns {hQuery.CodedEntryList} A list of {@link Medication} objects
    -1741   */
    -1742   Patient.prototype.medications = function() {
    -1743     var list, medication, _i, _len, _ref;
    -1744     list = new hQuery.CodedEntryList;
    -1745     if (this.json['medications']) {
    -1746       _ref = this.json['medications'];
    -1747       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1748         medication = _ref[_i];
    -1749         list.push(new hQuery.Medication(medication));
    -1750       }
    -1751     }
    -1752     return list;
    -1753   };
    -1754   /**
    -1755   @returns {hQuery.CodedEntryList} A list of {@link Condition} objects
    -1756   */
    -1757   Patient.prototype.conditions = function() {
    -1758     var condition, list, _i, _len, _ref;
    -1759     list = new hQuery.CodedEntryList;
    -1760     if (this.json['conditions']) {
    -1761       _ref = this.json['conditions'];
    -1762       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1763         condition = _ref[_i];
    -1764         list.push(new hQuery.Condition(condition));
    -1765       }
    -1766     }
    -1767     return list;
    -1768   };
    -1769   /**
    -1770   @returns {hQuery.CodedEntryList} A list of {@link Procedure} objects
    -1771   */
    -1772   Patient.prototype.procedures = function() {
    -1773     var list, procedure, _i, _len, _ref;
    -1774     list = new hQuery.CodedEntryList;
    -1775     if (this.json['procedures']) {
    -1776       _ref = this.json['procedures'];
    -1777       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1778         procedure = _ref[_i];
    -1779         list.push(new hQuery.Procedure(procedure));
    -1780       }
    -1781     }
    -1782     return list;
    -1783   };
    -1784   /**
    -1785   @returns {hQuery.CodedEntryList} A list of {@link Result} objects
    -1786   */
    -1787   Patient.prototype.results = function() {
    -1788     var list, result, _i, _len, _ref;
    -1789     list = new hQuery.CodedEntryList;
    -1790     if (this.json['results']) {
    -1791       _ref = this.json['results'];
    -1792       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1793         result = _ref[_i];
    -1794         list.push(new hQuery.Result(result));
    -1795       }
    -1796     }
    -1797     return list;
    -1798   };
    -1799   /**
    -1800   @returns {hQuery.CodedEntryList} A list of {@link Result} objects
    -1801   */
    -1802   Patient.prototype.vitalSigns = function() {
    -1803     var list, vital, _i, _len, _ref;
    -1804     list = new hQuery.CodedEntryList;
    -1805     if (this.json['vital_signs']) {
    -1806       _ref = this.json['vital_signs'];
    -1807       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1808         vital = _ref[_i];
    -1809         list.push(new hQuery.Result(vital));
    -1810       }
    -1811     }
    -1812     return list;
    -1813   };
    -1814   /**
    -1815   @returns {hQuery.CodedEntryList} A list of {@link Immunization} objects
    -1816   */
    -1817   Patient.prototype.immunizations = function() {
    -1818     var immunization, list, _i, _len, _ref;
    -1819     list = new hQuery.CodedEntryList;
    -1820     if (this.json['immunizations']) {
    -1821       _ref = this.json['immunizations'];
    -1822       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1823         immunization = _ref[_i];
    -1824         list.push(new hQuery.Immunization(immunization));
    -1825       }
    -1826     }
    -1827     return list;
    -1828   };
    -1829   /**
    -1830   @returns {hQuery.CodedEntryList} A list of {@link Allergy} objects
    -1831   */
    -1832   Patient.prototype.allergies = function() {
    -1833     var allergy, list, _i, _len, _ref;
    -1834     list = new hQuery.CodedEntryList;
    -1835     if (this.json['allergies']) {
    -1836       _ref = this.json['allergies'];
    -1837       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1838         allergy = _ref[_i];
    -1839         list.push(new hQuery.Allergy(allergy));
    -1840       }
    -1841     }
    -1842     return list;
    -1843   };
    -1844   /**
    -1845   @returns {hQuery.CodedEntryList} A list of {@link Pregnancy} objects
    -1846   */
    -1847   Patient.prototype.pregnancies = function() {
    -1848     var list, pregnancy, _i, _len, _ref;
    -1849     list = new hQuery.CodedEntryList;
    -1850     if (this.json['pregnancies']) {
    -1851       _ref = this.json['pregnancies'];
    -1852       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1853         pregnancy = _ref[_i];
    -1854         list.push(new hQuery.Pregnancy(pregnancy));
    -1855       }
    -1856     }
    -1857     return list;
    -1858   };
    -1859   /**
    -1860   @returns {hQuery.CodedEntryList} A list of {@link Socialhistory} objects
    +1618   @returns {String}
    +1619   */
    +1620 
    +1621 
    +1622   Medication.prototype.doseIndicator = function() {
    +1623     return this.json['doseIndicator'];
    +1624   };
    +1625 
    +1626   /**
    +1627   @returns {String}
    +1628   */
    +1629 
    +1630 
    +1631   Medication.prototype.fulfillmentInstructions = function() {
    +1632     return this.json['fulfillmentInstructions'];
    +1633   };
    +1634 
    +1635   /**
    +1636   @returns {CodedValue}
    +1637   */
    +1638 
    +1639 
    +1640   Medication.prototype.indication = function() {
    +1641     return hQuery.createCodedValue(this.json['indication']);
    +1642   };
    +1643 
    +1644   /**
    +1645   @returns {CodedValue}
    +1646   */
    +1647 
    +1648 
    +1649   Medication.prototype.productForm = function() {
    +1650     return hQuery.createCodedValue(this.json['productForm']);
    +1651   };
    +1652 
    +1653   /**
    +1654   @returns {CodedValue}
    +1655   */
    +1656 
    +1657 
    +1658   Medication.prototype.vehicle = function() {
    +1659     return hQuery.createCodedValue(this.json['vehicle']);
    +1660   };
    +1661 
    +1662   /**
    +1663   @returns {CodedValue}
    +1664   */
    +1665 
    +1666 
    +1667   Medication.prototype.reaction = function() {
    +1668     return hQuery.createCodedValue(this.json['reaction']);
    +1669   };
    +1670 
    +1671   /**
    +1672   @returns {CodedValue}
    +1673   */
    +1674 
    +1675 
    +1676   Medication.prototype.deliveryMethod = function() {
    +1677     return hQuery.createCodedValue(this.json['deliveryMethod']);
    +1678   };
    +1679 
    +1680   /**
    +1681   @returns {hQuery.MedicationInformation}
    +1682   */
    +1683 
    +1684 
    +1685   Medication.prototype.medicationInformation = function() {
    +1686     return new hQuery.MedicationInformation(this.json);
    +1687   };
    +1688 
    +1689   /**
    +1690   @returns {hQuery.TypeOfMedication} Indicates whether this is an over the counter or prescription medication
    +1691   */
    +1692 
    +1693 
    +1694   Medication.prototype.typeOfMedication = function() {
    +1695     var _ref, _ref1;
    +1696     return new hQuery.TypeOfMedication((_ref = this.json['typeOfMedication']) != null ? _ref['code'] : void 0, (_ref1 = this.json['typeOfMedication']) != null ? _ref1['codeSystem'] : void 0);
    +1697   };
    +1698 
    +1699   /**
    +1700   Values conform to value set 2.16.840.1.113883.1.11.20.7 - Medication Status
    +1701   Values may be: On Hold, No Longer Active, Active, Prior History
    +1702   @returns {hQuery.StatusOfMedication}   Used to indicate the status of the medication.
    +1703   */
    +1704 
    +1705 
    +1706   Medication.prototype.statusOfMedication = function() {
    +1707     var _ref, _ref1;
    +1708     return new hQuery.StatusOfMedication((_ref = this.json['statusOfMedication']) != null ? _ref['code'] : void 0, (_ref1 = this.json['statusOfMedication']) != null ? _ref1['codeSystem'] : void 0);
    +1709   };
    +1710 
    +1711   /**
    +1712   @returns {String} free text instructions to the patient
    +1713   */
    +1714 
    +1715 
    +1716   Medication.prototype.patientInstructions = function() {
    +1717     return this.json['patientInstructions'];
    +1718   };
    +1719 
    +1720   /**
    +1721   The duration over which this medication has been active. For example, 5 days.
    +1722   @returns {Hash} with two keys: unit and scalar
    +1723   */
    +1724 
    +1725 
    +1726   Medication.prototype.cumulativeMedicationDuration = function() {
    +1727     return this.json['cumulativeMedicationDuration'];
    +1728   };
    +1729 
    +1730   /**
    +1731   @returns {Array} an array of {@link FulFillment} objects
    +1732   */
    +1733 
    +1734 
    +1735   Medication.prototype.fulfillmentHistory = function() {
    +1736     var order, _i, _len, _ref, _results;
    +1737     _ref = this.json['fulfillmentHistory'];
    +1738     _results = [];
    +1739     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +1740       order = _ref[_i];
    +1741       _results.push(new hQuery.Fulfillment(order));
    +1742     }
    +1743     return _results;
    +1744   };
    +1745 
    +1746   /**
    +1747   @returns {Array} an array of {@link OrderInformation} objects
    +1748   */
    +1749 
    +1750 
    +1751   Medication.prototype.orderInformation = function() {
    +1752     var order, _i, _len, _ref, _results;
    +1753     _ref = this.json['orderInformation'];
    +1754     _results = [];
    +1755     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +1756       order = _ref[_i];
    +1757       _results.push(new hQuery.OrderInformation(order));
    +1758     }
    +1759     return _results;
    +1760   };
    +1761 
    +1762   return Medication;
    +1763 
    +1764 })(hQuery.CodedEntry);
    +1765 /**
    +1766 @namespace scoping into the hquery namespace
    +1767 */
    +1768 
    +1769 var __hasProp = {}.hasOwnProperty,
    +1770   __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
    +1771 
    +1772 this.hQuery || (this.hQuery = {});
    +1773 
    +1774 /**
    +1775 @class CauseOfDeath
    +1776 @exports CauseOfDeath as hQuery.CauseOfDeath
    +1777 */
    +1778 
    +1779 
    +1780 hQuery.CauseOfDeath = (function() {
    +1781 
    +1782   CauseOfDeath.name = 'CauseOfDeath';
    +1783 
    +1784   function CauseOfDeath(json) {
    +1785     this.json = json;
    +1786   }
    +1787 
    +1788   /**
    +1789   @returns {hQuery.Date}
    +1790   */
    +1791 
    +1792 
    +1793   CauseOfDeath.prototype.timeOfDeath = function() {
    +1794     return new hQuery.dateFromUtcSeconds(this.json['timeOfDeath']);
    +1795   };
    +1796 
    +1797   /**
    +1798   @returns {int}
    +1799   */
    +1800 
    +1801 
    +1802   CauseOfDeath.prototype.ageAtDeath = function() {
    +1803     return this.json['ageAtDeath'];
    +1804   };
    +1805 
    +1806   return CauseOfDeath;
    +1807 
    +1808 })();
    +1809 
    +1810 /**
    +1811 @class hQuery.Condition
    +1812 
    +1813 This section is used to describe a patients problems/conditions. The types of conditions
    +1814 described have been constrained to the SNOMED CT Problem Type code set. An unbounded
    +1815 number of treating providers for the particular condition can be supplied.
    +1816 @exports Condition as hQuery.Condition 
    +1817 @augments hQuery.CodedEntry
    +1818 */
    +1819 
    +1820 
    +1821 hQuery.Condition = (function(_super) {
    +1822 
    +1823   __extends(Condition, _super);
    +1824 
    +1825   Condition.name = 'Condition';
    +1826 
    +1827   function Condition(json) {
    +1828     this.json = json;
    +1829     Condition.__super__.constructor.call(this, this.json);
    +1830   }
    +1831 
    +1832   /**
    +1833    @returns {Array, hQuery.Provider} an array of providers for the condition
    +1834   */
    +1835 
    +1836 
    +1837   Condition.prototype.providers = function() {
    +1838     var provider, _i, _len, _ref, _results;
    +1839     _ref = this.json['treatingProviders'];
    +1840     _results = [];
    +1841     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    +1842       provider = _ref[_i];
    +1843       _results.push(new Provider(provider));
    +1844     }
    +1845     return _results;
    +1846   };
    +1847 
    +1848   /**
    +1849   Diagnosis Priority
    +1850   @returns {int}
    +1851   */
    +1852 
    +1853 
    +1854   Condition.prototype.diagnosisPriority = function() {
    +1855     return this.json['priority'];
    +1856   };
    +1857 
    +1858   /**
    +1859   Ordinality
    +1860   @returns {CodedValue}
     1861   */
    -1862   Patient.prototype.socialhistories = function() {
    -1863     var list, socialhistory, _i, _len, _ref;
    -1864     list = new hQuery.CodedEntryList;
    -1865     if (this.json['socialhistories']) {
    -1866       _ref = this.json['socialhistories'];
    -1867       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    -1868         socialhistory = _ref[_i];
    -1869         list.push(new hQuery.Socialhistory(socialhistory));
    -1870       }
    -1871     }
    -1872     return list;
    -1873   };
    -1874   return Patient;
    -1875 })();
    \ No newline at end of file +1862 +1863 +1864 Condition.prototype.ordinality = function() { +1865 return hQuery.createCodedValue(this.json['ordinality']); +1866 }; +1867 +1868 /** +1869 age at onset +1870 @returns {int} +1871 */ +1872 +1873 +1874 Condition.prototype.ageAtOnset = function() { +1875 return this.json['ageAtOnset']; +1876 }; +1877 +1878 /** +1879 cause of death +1880 @returns {hQuery.CauseOfDeath} +1881 */ +1882 +1883 +1884 Condition.prototype.causeOfDeath = function() { +1885 if (this.json['causeOfDeath']) { +1886 return new hQuery.CauseOfDeath(this.json['causeOfDeath']); +1887 } +1888 }; +1889 +1890 /** +1891 problem status +1892 @returns {hQuery.CodedValue} +1893 */ +1894 +1895 +1896 Condition.prototype.problemStatus = function() { +1897 return hQuery.createCodedValue(this.json['problemStatus']); +1898 }; +1899 +1900 /** +1901 comment +1902 @returns {String} +1903 */ +1904 +1905 +1906 Condition.prototype.comment = function() { +1907 return this.json['comment']; +1908 }; +1909 +1910 /** +1911 This is a description of the level of the severity of the condition. +1912 @returns {CodedValue} +1913 */ +1914 +1915 +1916 Condition.prototype.severity = function() { +1917 return hQuery.createCodedValue(this.json['severity']); +1918 }; +1919 +1920 return Condition; +1921 +1922 })(hQuery.CodedEntry); +1923 /** +1924 @namespace scoping into the hquery namespace +1925 */ +1926 +1927 var __hasProp = {}.hasOwnProperty, +1928 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +1929 +1930 this.hQuery || (this.hQuery = {}); +1931 +1932 /** +1933 An Encounter is an interaction, regardless of the setting, between a patient and a +1934 practitioner who is vested with primary responsibility for diagnosing, evaluating, +1935 or treating the patients condition. It may include visits, appointments, as well +1936 as non face-to-face interactions. It is also a contact between a patient and a +1937 practitioner who has primary responsibility for assessing and treating the +1938 patient at a given contact, exercising independent judgment. +1939 @class An Encounter is an interaction, regardless of the setting, between a patient and a +1940 practitioner +1941 @augments hQuery.CodedEntry +1942 @exports Encounter as hQuery.Encounter +1943 */ +1944 +1945 +1946 hQuery.Encounter = (function(_super) { +1947 +1948 __extends(Encounter, _super); +1949 +1950 Encounter.name = 'Encounter'; +1951 +1952 function Encounter(json) { +1953 this.json = json; +1954 Encounter.__super__.constructor.call(this, this.json); +1955 if (this.json['admitTime']) { +1956 this._admitTime = hQuery.dateFromUtcSeconds(this.json['admitTime']); +1957 } +1958 if (this.json['dischargeTime']) { +1959 this._dischargeTime = hQuery.dateFromUtcSeconds(this.json['dischargeTime']); +1960 } +1961 if (this.json['facility']) { +1962 this._facility = new hQuery.Facility(this.json['facility']); +1963 } +1964 } +1965 +1966 /** +1967 @returns {String} +1968 */ +1969 +1970 +1971 Encounter.prototype.dischargeDisposition = function() { +1972 return this.json['dischargeDisposition']; +1973 }; +1974 +1975 /** +1976 A code indicating the priority of the admission (e.g., Emergency, Urgent, Elective, et cetera) from +1977 National Uniform Billing Committee (NUBC) +1978 @returns {CodedValue} +1979 */ +1980 +1981 +1982 Encounter.prototype.admitType = function() { +1983 return hQuery.createCodedValue(this.json['admitType']); +1984 }; +1985 +1986 /** +1987 Date and time at which the patient was admitted for the encounter +1988 @returns {Date} +1989 */ +1990 +1991 +1992 Encounter.prototype.admitTime = function() { +1993 return this._admitTime; +1994 }; +1995 +1996 /** +1997 Date and time at which the patient was discharged for the encounter +1998 @returns {Date} +1999 */ +2000 +2001 +2002 Encounter.prototype.dischargeTime = function() { +2003 return this._dischargeTime; +2004 }; +2005 +2006 /** +2007 @returns {hQuery.Actor} +2008 */ +2009 +2010 +2011 Encounter.prototype.performer = function() { +2012 if (this.json['performer']) { +2013 return new hQuery.Actor(this.json['performer']); +2014 } +2015 }; +2016 +2017 /** +2018 @returns {hQuery.Organization} +2019 */ +2020 +2021 +2022 Encounter.prototype.facility = function() { +2023 return this._facility; +2024 }; +2025 +2026 Encounter.prototype.facilityArrival = function() { +2027 var _ref; +2028 return (_ref = this._facility) != null ? _ref.startDate() : void 0; +2029 }; +2030 +2031 Encounter.prototype.facilityDeparture = function() { +2032 var _ref; +2033 return (_ref = this._facility) != null ? _ref.endDate() : void 0; +2034 }; +2035 +2036 /** +2037 @returns {hQuery.CodedEntry} +2038 */ +2039 +2040 +2041 Encounter.prototype.reasonForVisit = function() { +2042 if (this.json['reason']) { +2043 return new hQuery.CodedEntry(this.json['reason']); +2044 } +2045 }; +2046 +2047 /** +2048 @returns {Integer} +2049 */ +2050 +2051 +2052 Encounter.prototype.lengthOfStay = function() { +2053 if (!((this.startDate() != null) && (this.endDate() != null))) { +2054 return 0; +2055 } +2056 return Math.floor((this.endDate() - this.startDate()) / (1000 * 60 * 60 * 24)); +2057 }; +2058 +2059 /** +2060 @returns {CodedValue} +2061 */ +2062 +2063 +2064 Encounter.prototype.transferTo = function() { +2065 return hQuery.createCodedValue(this.json['transferTo']); +2066 }; +2067 +2068 /** +2069 @returns {CodedValue} +2070 */ +2071 +2072 +2073 Encounter.prototype.transferFrom = function() { +2074 return hQuery.createCodedValue(this.json['transferFrom']); +2075 }; +2076 +2077 return Encounter; +2078 +2079 })(hQuery.CodedEntry); +2080 /** +2081 @namespace scoping into the hquery namespace +2082 */ +2083 +2084 var __hasProp = {}.hasOwnProperty, +2085 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2086 +2087 this.hQuery || (this.hQuery = {}); +2088 +2089 /** +2090 This represents all interventional, surgical, diagnostic, or therapeutic procedures or +2091 treatments pertinent to the patient. +2092 @class +2093 @augments hQuery.CodedEntry +2094 @exports Procedure as hQuery.Procedure +2095 */ +2096 +2097 +2098 hQuery.Procedure = (function(_super) { +2099 +2100 __extends(Procedure, _super); +2101 +2102 Procedure.name = 'Procedure'; +2103 +2104 function Procedure(json) { +2105 this.json = json; +2106 Procedure.__super__.constructor.call(this, this.json); +2107 } +2108 +2109 /** +2110 @returns {hQuery.Actor} The provider that performed the procedure +2111 */ +2112 +2113 +2114 Procedure.prototype.performer = function() { +2115 if (this.json['performer']) { +2116 return new hQuery.Actor(this.json['performer']); +2117 } +2118 }; +2119 +2120 /** +2121 @returns {hQuery.CodedValue} A SNOMED code indicating the body site on which the +2122 procedure was performed +2123 */ +2124 +2125 +2126 Procedure.prototype.site = function() { +2127 var _ref, _ref1; +2128 return new hQuery.CodedValue((_ref = this.json['site']) != null ? _ref['code'] : void 0, (_ref1 = this.json['site']) != null ? _ref1['codeSystem'] : void 0); +2129 }; +2130 +2131 /** +2132 @returns {hQuery.CodedValue} A SNOMED code indicating where the procedure was performed. +2133 */ +2134 +2135 +2136 Procedure.prototype.source = function() { +2137 return hQuery.createCodedValue(this.json['source']); +2138 }; +2139 +2140 /** +2141 @returns {Date} The actual or intended start of an incision. +2142 */ +2143 +2144 +2145 Procedure.prototype.incisionTime = function() { +2146 if (this.json['incisionTime']) { +2147 return hQuery.dateFromUtcSeconds(this.json['incisionTime']); +2148 } +2149 }; +2150 +2151 /** +2152 Ordinality +2153 @returns {CodedValue} +2154 */ +2155 +2156 +2157 Procedure.prototype.ordinality = function() { +2158 return hQuery.createCodedValue(this.json['ordinality']); +2159 }; +2160 +2161 return Procedure; +2162 +2163 })(hQuery.CodedEntry); +2164 /** +2165 @namespace scoping into the hquery namespace +2166 */ +2167 +2168 var __hasProp = {}.hasOwnProperty, +2169 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2170 +2171 this.hQuery || (this.hQuery = {}); +2172 +2173 /** +2174 Observations generated by laboratories, imaging procedures, and other procedures. The scope +2175 includes hematology, chemistry, serology, virology, toxicology, microbiology, plain x-ray, +2176 ultrasound, CT, MRI, angiography, cardiac echo, nuclear medicine, pathology, and procedure +2177 observations. +2178 @class +2179 @augments hQuery.CodedEntry +2180 @exports Result as hQuery.Result +2181 */ +2182 +2183 +2184 hQuery.Result = (function(_super) { +2185 +2186 __extends(Result, _super); +2187 +2188 Result.name = 'Result'; +2189 +2190 function Result(json) { +2191 this.json = json; +2192 Result.__super__.constructor.call(this, this.json); +2193 } +2194 +2195 /** +2196 ASTM CCR defines a restricted set of required result Type codes (see ResultTypeCode in section 7.3 +2197 Summary of CCD value sets), used to categorize a result into one of several commonly accepted values +2198 (e.g. Hematology, Chemistry, Nuclear Medicine). +2199 @returns {CodedValue} +2200 */ +2201 +2202 +2203 Result.prototype.resultType = function() { +2204 return this.type(); +2205 }; +2206 +2207 /** +2208 @returns {CodedValue} +2209 */ +2210 +2211 +2212 Result.prototype.interpretation = function() { +2213 return hQuery.createCodedValue(this.json['interpretation']); +2214 }; +2215 +2216 /** +2217 @returns {String} +2218 */ +2219 +2220 +2221 Result.prototype.referenceRange = function() { +2222 return this.json['referenceRange']; +2223 }; +2224 +2225 /** +2226 @returns {String} +2227 */ +2228 +2229 +2230 Result.prototype.comment = function() { +2231 return this.json['comment']; +2232 }; +2233 +2234 return Result; +2235 +2236 })(hQuery.CodedEntry); +2237 /** +2238 @namespace scoping into the hquery namespace +2239 */ +2240 +2241 var __hasProp = {}.hasOwnProperty, +2242 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2243 +2244 this.hQuery || (this.hQuery = {}); +2245 +2246 /** +2247 NoImmunzation as defined by value set 2.16.840.1.113883.1.11.19717 +2248 The terms come from Health Level Seven (HL7) Version 3.0 Vocabulary and are managed by HL7 +2249 It indicates the reason an immunization was not administered. +2250 +2251 @class NoImmunization - describes the status of the medication +2252 @augments hQuery.CodedEntry +2253 @exports NoImmunization as hQuery.NoImmunization +2254 */ +2255 +2256 +2257 hQuery.NoImmunization = (function(_super) { +2258 var IMMUNITY, MED_PRECAUTION, OUT_OF_STOCK, PAT_OBJ, PHIL_OBJ, REL_OBJ, VAC_EFF, VAC_SAFETY; +2259 +2260 __extends(NoImmunization, _super); +2261 +2262 NoImmunization.name = 'NoImmunization'; +2263 +2264 function NoImmunization() { +2265 return NoImmunization.__super__.constructor.apply(this, arguments); +2266 } +2267 +2268 IMMUNITY = "IMMUNE"; +2269 +2270 MED_PRECAUTION = "MEDPREC"; +2271 +2272 OUT_OF_STOCK = "OSTOCK"; +2273 +2274 PAT_OBJ = "PATOBJ"; +2275 +2276 PHIL_OBJ = "PHILISOP"; +2277 +2278 REL_OBJ = "RELIG"; +2279 +2280 VAC_EFF = "VACEFF"; +2281 +2282 VAC_SAFETY = "VACSAF"; +2283 +2284 /** +2285 @returns {Boolean} +2286 */ +2287 +2288 +2289 NoImmunization.prototype.isImmune = function() { +2290 return this.c === IMMUNITY; +2291 }; +2292 +2293 /** +2294 @returns {Boolean} +2295 */ +2296 +2297 +2298 NoImmunization.prototype.isMedPrec = function() { +2299 return this.c === MED_PRECAUTION; +2300 }; +2301 +2302 /** +2303 @returns {Boolean} +2304 */ +2305 +2306 +2307 NoImmunization.prototype.isOstock = function() { +2308 return this.c === OUT_OF_STOCK; +2309 }; +2310 +2311 /** +2312 @returns {Boolean} +2313 */ +2314 +2315 +2316 NoImmunization.prototype.isPatObj = function() { +2317 return this.c === PAT_OBJ; +2318 }; +2319 +2320 /** +2321 @returns {Boolean} +2322 */ +2323 +2324 +2325 NoImmunization.prototype.isPhilisop = function() { +2326 return this.c === PHIL_OBJ; +2327 }; +2328 +2329 /** +2330 @returns {Boolean} +2331 */ +2332 +2333 +2334 NoImmunization.prototype.isRelig = function() { +2335 return this.c === REL_OBJ; +2336 }; +2337 +2338 /** +2339 @returns {Boolean} +2340 */ +2341 +2342 +2343 NoImmunization.prototype.isVacEff = function() { +2344 return this.c === VAC_EFF; +2345 }; +2346 +2347 /** +2348 @returns {Boolean} +2349 */ +2350 +2351 +2352 NoImmunization.prototype.isVacSaf = function() { +2353 return this.c === VAC_SAFETY; +2354 }; +2355 +2356 return NoImmunization; +2357 +2358 })(hQuery.CodedValue); +2359 +2360 /** +2361 @class represents a immunization entry for a patient. +2362 @augments hQuery.CodedEntry +2363 @exports Immunization as hQuery.Immunization +2364 */ +2365 +2366 +2367 hQuery.Immunization = (function(_super) { +2368 +2369 __extends(Immunization, _super); +2370 +2371 Immunization.name = 'Immunization'; +2372 +2373 function Immunization(json) { +2374 this.json = json; +2375 Immunization.__super__.constructor.call(this, this.json); +2376 } +2377 +2378 /** +2379 @returns{hQuery.Scalar} +2380 */ +2381 +2382 +2383 Immunization.prototype.medicationSeriesNumber = function() { +2384 if (this.json['medicationSeriesNumber']) { +2385 return new hQuery.Scalar(this.json['medicationSeriesNumber']); +2386 } +2387 }; +2388 +2389 /** +2390 @returns{hQuery.MedicationInformation} +2391 */ +2392 +2393 +2394 Immunization.prototype.medicationInformation = function() { +2395 return new hQuery.MedicationInformation(this.json); +2396 }; +2397 +2398 /** +2399 @returns{Date} Date immunization was administered +2400 */ +2401 +2402 +2403 Immunization.prototype.administeredDate = function() { +2404 return dateFromUtcSeconds(this.json['administeredDate']); +2405 }; +2406 +2407 /** +2408 @returns{hQuery.Actor} Performer of immunization +2409 */ +2410 +2411 +2412 Immunization.prototype.performer = function() { +2413 if (this.json['performer']) { +2414 return new hQuery.Actor(this.json['performer']); +2415 } +2416 }; +2417 +2418 /** +2419 @returns {comment} human readable description of event +2420 */ +2421 +2422 +2423 Immunization.prototype.comment = function() { +2424 return this.json['comment']; +2425 }; +2426 +2427 /** +2428 @returns {Boolean} whether the immunization has been refused by the patient. +2429 */ +2430 +2431 +2432 Immunization.prototype.refusalInd = function() { +2433 return this.json['negationInd']; +2434 }; +2435 +2436 /** +2437 NoImmunzation as defined by value set 2.16.840.1.113883.1.11.19717 +2438 The terms come from Health Level Seven (HL7) Version 3.0 Vocabulary and are managed by HL7 +2439 It indicates the reason an immunization was not administered. +2440 @returns {hQuery.NoImmunization} Used to indicate reason an immunization was not administered. +2441 */ +2442 +2443 +2444 Immunization.prototype.refusalReason = function() { +2445 var _ref, _ref1; +2446 return new hQuery.NoImmunization((_ref = this.json['negationReason']) != null ? _ref['code'] : void 0, (_ref1 = this.json['negationReason']) != null ? _ref1['codeSystem'] : void 0); +2447 }; +2448 +2449 return Immunization; +2450 +2451 })(hQuery.CodedEntry); +2452 /** +2453 @namespace scoping into the hquery namespace +2454 */ +2455 +2456 var __hasProp = {}.hasOwnProperty, +2457 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2458 +2459 this.hQuery || (this.hQuery = {}); +2460 +2461 /** +2462 @class +2463 @augments hQuery.CodedEntry +2464 @exports Allergy as hQuery.Allergy +2465 */ +2466 +2467 +2468 hQuery.Allergy = (function(_super) { +2469 +2470 __extends(Allergy, _super); +2471 +2472 Allergy.name = 'Allergy'; +2473 +2474 function Allergy(json) { +2475 this.json = json; +2476 Allergy.__super__.constructor.call(this, this.json); +2477 } +2478 +2479 /** +2480 Food and substance allergies use the Unique Ingredient Identifier(UNII) from the FDA +2481 http://www.fda.gov/ForIndustry/DataStandards/StructuredProductLabeling/ucm162523.htm +2482 +2483 Allegies to a class of medication Shall contain a value descending from the NDF-RT concept types +2484 of Mechanism of Action - N0000000223, Physiologic Effect - N0000009802 or +2485 Chemical Structure - N0000000002. NUI will be used as the concept code. +2486 For more information, please see the Web Site +2487 http://www.cancer.gov/cancertopics/terminologyresources/page5 +2488 +2489 Allergies to a specific medication shall use RxNorm for the values. +2490 @returns {CodedValue} +2491 */ +2492 +2493 +2494 Allergy.prototype.product = function() { +2495 return this.type(); +2496 }; +2497 +2498 /** +2499 Date of allergy or adverse event +2500 @returns{Date} +2501 */ +2502 +2503 +2504 Allergy.prototype.adverseEventDate = function() { +2505 return dateFromUtcSeconds(this.json['adverseEventDate']); +2506 }; +2507 +2508 /** +2509 Adverse event types SHALL be coded as specified in HITSP/C80 Section 2.2.3.4.2 Allergy/Adverse Event Type +2510 @returns {CodedValue} +2511 */ +2512 +2513 +2514 Allergy.prototype.adverseEventType = function() { +2515 return hQuery.createCodedValue(this.json['type']); +2516 }; +2517 +2518 /** +2519 This indicates the reaction that may be caused by the product or agent. +2520 It is defined by 2.16.840.1.113883.3.88.12.3221.6.2 and are SNOMED-CT codes. +2521 420134006 Propensity to adverse reactions (disorder) +2522 418038007 Propensity to adverse reactions to substance (disorder) +2523 419511003 Propensity to adverse reactions to drug (disorder) +2524 418471000 Propensity to adverse reactions to food (disorder) +2525 419199007 Allergy to substance (disorder) +2526 416098002 Drug allergy (disorder) +2527 414285001 Food allergy (disorder) +2528 59037007 Drug intolerance (disorder) +2529 235719002 Food intolerance (disorder) +2530 @returns {CodedValue} +2531 */ +2532 +2533 +2534 Allergy.prototype.reaction = function() { +2535 return hQuery.createCodedValue(this.json['reaction']); +2536 }; +2537 +2538 /** +2539 This is a description of the level of the severity of the allergy or intolerance. +2540 Use SNOMED-CT Codes as defined by 2.16.840.1.113883.3.88.12.3221.6.8 +2541 255604002 Mild +2542 371923003 Mild to Moderate +2543 6736007 Moderate +2544 371924009 Moderate to Severe +2545 24484000 Severe +2546 399166001 Fatal +2547 @returns {CodedValue} +2548 */ +2549 +2550 +2551 Allergy.prototype.severity = function() { +2552 return hQuery.createCodedValue(this.json['severity']); +2553 }; +2554 +2555 /** +2556 Additional comment or textual information +2557 @returns {String} +2558 */ +2559 +2560 +2561 Allergy.prototype.comment = function() { +2562 return this.json['comment']; +2563 }; +2564 +2565 return Allergy; +2566 +2567 })(hQuery.CodedEntry); +2568 /** +2569 @namespace scoping into the hquery namespace +2570 */ +2571 +2572 this.hQuery || (this.hQuery = {}); +2573 +2574 /** +2575 @class +2576 +2577 @exports Provider as hQuery.Provider +2578 */ +2579 +2580 +2581 hQuery.Provider = (function() { +2582 +2583 Provider.name = 'Provider'; +2584 +2585 function Provider(json) { +2586 this.json = json; +2587 } +2588 +2589 /** +2590 @returns {hQuery.Person} +2591 */ +2592 +2593 +2594 Provider.prototype.providerEntity = function() { +2595 if (this.json['providerEntity']) { +2596 return new hQuery.Person(this.json['providerEntity']); +2597 } +2598 }; +2599 +2600 /** +2601 @returns {hQuery.DateRange} +2602 */ +2603 +2604 +2605 Provider.prototype.careProvisionDateRange = function() { +2606 if (this.json['careProvisionDateRange']) { +2607 return new hQuery.DateRange(this.json['careProvisionDateRange']); +2608 } +2609 }; +2610 +2611 /** +2612 @returns {hQuery.CodedValue} +2613 */ +2614 +2615 +2616 Provider.prototype.role = function() { +2617 return hQuery.createCodedValue(this.json['role']); +2618 }; +2619 +2620 /** +2621 @returns {String} +2622 */ +2623 +2624 +2625 Provider.prototype.patientID = function() { +2626 return this.json['patientID']; +2627 }; +2628 +2629 /** +2630 @returns {hQuery.CodedValue} +2631 */ +2632 +2633 +2634 Provider.prototype.providerType = function() { +2635 return hQuery.createCodedValue(this.json['providerType']); +2636 }; +2637 +2638 /** +2639 @returns {String} +2640 */ +2641 +2642 +2643 Provider.prototype.providerID = function() { +2644 return this.json['providerID']; +2645 }; +2646 +2647 /** +2648 @returns {hQuery.Organization} +2649 */ +2650 +2651 +2652 Provider.prototype.organizationName = function() { +2653 return new hQuery.Organization(this.json); +2654 }; +2655 +2656 return Provider; +2657 +2658 })(); +2659 /** +2660 @namespace scoping into the hquery namespace +2661 */ +2662 +2663 var __hasProp = {}.hasOwnProperty, +2664 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2665 +2666 this.hQuery || (this.hQuery = {}); +2667 +2668 /** +2669 @class +2670 @augments hQuery.CodedEntry +2671 @exports Language as hQuery.Language +2672 */ +2673 +2674 +2675 hQuery.Language = (function(_super) { +2676 +2677 __extends(Language, _super); +2678 +2679 Language.name = 'Language'; +2680 +2681 function Language(json) { +2682 this.json = json; +2683 Language.__super__.constructor.call(this, this.json); +2684 } +2685 +2686 /** +2687 @returns {hQuery.CodedValue} +2688 */ +2689 +2690 +2691 Language.prototype.modeCode = function() { +2692 return hQuery.createCodedValue(this.json['modeCode']); +2693 }; +2694 +2695 /** +2696 @returns {String} +2697 */ +2698 +2699 +2700 Language.prototype.preferenceIndicator = function() { +2701 return this.json['preferenceIndicator']; +2702 }; +2703 +2704 return Language; +2705 +2706 })(hQuery.CodedEntry); +2707 /** +2708 @namespace scoping into the hquery namespace +2709 */ +2710 +2711 var __hasProp = {}.hasOwnProperty, +2712 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2713 +2714 this.hQuery || (this.hQuery = {}); +2715 +2716 /** +2717 This includes information about the patients current and past pregnancy status +2718 The Coded Entry code system should be SNOMED-CT +2719 @class +2720 @augments hQuery.CodedEntry +2721 @exports Pregnancy as hQuery.Pregnancy +2722 */ +2723 +2724 +2725 hQuery.Pregnancy = (function(_super) { +2726 +2727 __extends(Pregnancy, _super); +2728 +2729 Pregnancy.name = 'Pregnancy'; +2730 +2731 function Pregnancy(json) { +2732 this.json = json; +2733 Pregnancy.__super__.constructor.call(this, this.json); +2734 } +2735 +2736 /** +2737 @returns {String} +2738 */ +2739 +2740 +2741 Pregnancy.prototype.comment = function() { +2742 return this.json['comment']; +2743 }; +2744 +2745 return Pregnancy; +2746 +2747 })(hQuery.CodedEntry); +2748 /** +2749 @namespace scoping into the hquery namespace +2750 */ +2751 +2752 var __hasProp = {}.hasOwnProperty, +2753 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2754 +2755 this.hQuery || (this.hQuery = {}); +2756 +2757 /** +2758 +2759 The Social History Observation is used to define the patient's occupational, personal (e.g. lifestyle), +2760 social, and environmental history and health risk factors, as well as administrative data such as +2761 marital status, race, ethnicity and religious affiliation. The types of conditions +2762 described have been constrained to the SNOMED CT code system using constrained code set, 2.16.840.1.113883.3.88.12.80.60: +2763 229819007 Tobacco use and exposure +2764 256235009 Exercise +2765 160573003 Alcohol Intake +2766 364393001 Nutritional observable +2767 364703007 Employment detail +2768 425400000 Toxic exposure status +2769 363908000 Details of drug misuse behavior +2770 228272008 Health-related behavior +2771 105421008 Educational achievement +2772 +2773 note: Social History is not part of the existing green c32. +2774 @exports Socialhistory as hQuery.Socialhistory +2775 @augments hQuery.CodedEntry +2776 */ +2777 +2778 +2779 hQuery.Socialhistory = (function(_super) { +2780 +2781 __extends(Socialhistory, _super); +2782 +2783 Socialhistory.name = 'Socialhistory'; +2784 +2785 function Socialhistory(json) { +2786 this.json = json; +2787 Socialhistory.__super__.constructor.call(this, this.json); +2788 } +2789 +2790 /** +2791 Value returns the value of the result. This will return an object. The properties of this +2792 object are dependent on the type of result. +2793 */ +2794 +2795 +2796 Socialhistory.prototype.value = function() { +2797 return this.json['value']; +2798 }; +2799 +2800 return Socialhistory; +2801 +2802 })(hQuery.CodedEntry); +2803 /** +2804 @namespace scoping into the hquery namespace +2805 */ +2806 +2807 var __hasProp = {}.hasOwnProperty, +2808 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2809 +2810 this.hQuery || (this.hQuery = {}); +2811 +2812 /** +2813 +2814 The plan of care contains data defining prospective or intended orders, interventions, encounters, services, and procedures for the patient. +2815 +2816 @exports CareGoal as hQuery.CareGoal +2817 @augments hQuery.CodedEntry +2818 */ +2819 +2820 +2821 hQuery.CareGoal = (function(_super) { +2822 +2823 __extends(CareGoal, _super); +2824 +2825 CareGoal.name = 'CareGoal'; +2826 +2827 function CareGoal(json) { +2828 this.json = json; +2829 CareGoal.__super__.constructor.call(this, this.json); +2830 } +2831 +2832 return CareGoal; +2833 +2834 })(hQuery.CodedEntry); +2835 /** +2836 @namespace scoping into the hquery namespace +2837 */ +2838 +2839 var __hasProp = {}.hasOwnProperty, +2840 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2841 +2842 this.hQuery || (this.hQuery = {}); +2843 +2844 /** +2845 +2846 The Medical Equipment section contains information describing a patients implanted and external medical devices and equipment that their health status depends on, as well as any pertinent equipment or device history. +2847 +2848 The template identifier for this section is 2.16.840.1.113883.3.88.11.83.128 +2849 +2850 C83-[CT-128-1] This section shall conform to the HL7 CCD section, and shall contain a templateId element whose root attribute is 2.16.840.1.113883.10.20.1.7. +2851 C83-[CT-128-2] This section SHALL conform to the IHE Medical Devices Section, and shall contain a templateId element whose root attribute is 1.3.6.1.4.1.19376.1.5.3.1.1.5.3.5 +2852 +2853 @exports MedicalEquipment as hQuery.MedicalEquipment +2854 @augments hQuery.CodedEntry +2855 */ +2856 +2857 +2858 hQuery.MedicalEquipment = (function(_super) { +2859 +2860 __extends(MedicalEquipment, _super); +2861 +2862 MedicalEquipment.name = 'MedicalEquipment'; +2863 +2864 function MedicalEquipment(json) { +2865 this.json = json; +2866 MedicalEquipment.__super__.constructor.call(this, this.json); +2867 } +2868 +2869 /** +2870 @returns {CodedValue} +2871 */ +2872 +2873 +2874 MedicalEquipment.prototype.anatomicalStructure = function() { +2875 return hQuery.createCodedValue(this.json['anatomicalStructure']); +2876 }; +2877 +2878 /** +2879 @returns {Date} The actual or intended removal time of the device. +2880 */ +2881 +2882 +2883 MedicalEquipment.prototype.removalTime = function() { +2884 if (this.json['removalTime']) { +2885 return hQuery.dateFromUtcSeconds(this.json['removalTime']); +2886 } +2887 }; +2888 +2889 return MedicalEquipment; +2890 +2891 })(hQuery.CodedEntry); +2892 /** +2893 @namespace scoping into the hquery namespace +2894 */ +2895 +2896 var __hasProp = {}.hasOwnProperty, +2897 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2898 +2899 this.hQuery || (this.hQuery = {}); +2900 +2901 /** +2902 This class can be used to represnt a functional status for a patient. Currently, +2903 it is not a very close representation of functional status as it is represented +2904 in the HL7 CCD, HITSP C32 or Consolidated CDA. +2905 +2906 In the previously mentioned specifications, functional status may represented +2907 using either a condition or result. Having "mixed" types of entries in a section +2908 is currently not well supported in the existing Record class +2909 +2910 Additionally, there is a mismatch between the data needed to calculate Stage 2 +2911 Meaningful Use Quailty Measures and the data contained in patient summary +2912 standards. The CQMs are checking to see if a functional status represented by +2913 a result was patient supplied. Right now, results do not have a source, and +2914 even if we were to use Provider as a source, it would need to be extended +2915 to support patients. +2916 +2917 To avoid this, the patient sumamry style functional status has been "flattened" +2918 into this class. This model supports the information needed to calculate +2919 Stage 2 MU CQMs. If importers are created from C32 or CCDA, the information +2920 can be stored here, but it will be a lossy transformation. +2921 @class +2922 @augments hQuery.CodedEntry +2923 @exports FunctionalStatus as hQuery.FunctionalStatus +2924 */ +2925 +2926 +2927 hQuery.FunctionalStatus = (function(_super) { +2928 +2929 __extends(FunctionalStatus, _super); +2930 +2931 FunctionalStatus.name = 'FunctionalStatus'; +2932 +2933 function FunctionalStatus(json) { +2934 this.json = json; +2935 FunctionalStatus.__super__.constructor.call(this, this.json); +2936 } +2937 +2938 /** +2939 Either "condition" or "result" +2940 @returns {String} +2941 */ +2942 +2943 +2944 FunctionalStatus.prototype.type = function() { +2945 return this.json["type"]; +2946 }; +2947 +2948 /** +2949 A coded value. Like a code for patient supplied. +2950 @returns {hQuery.CodedValue} +2951 */ +2952 +2953 +2954 FunctionalStatus.prototype.source = function() { +2955 return hQuery.createCodedValue(this.json["source"]); +2956 }; +2957 +2958 return FunctionalStatus; +2959 +2960 })(hQuery.CodedEntry); +2961 /** +2962 @namespace scoping into the hquery namespace +2963 */ +2964 +2965 var __hasProp = {}.hasOwnProperty, +2966 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; +2967 +2968 this.hQuery || (this.hQuery = {}); +2969 +2970 /** +2971 @class Supports +2972 @exports Supports as hQuery.Supports +2973 */ +2974 +2975 +2976 hQuery.Supports = (function() { +2977 +2978 Supports.name = 'Supports'; +2979 +2980 function Supports(json) { +2981 this.json = json; +2982 } +2983 +2984 /** +2985 @returns {DateRange} +2986 */ +2987 +2988 +2989 Supports.prototype.supportDate = function() { +2990 return new hQuery.DateRange(this.json['supportDate']); +2991 }; +2992 +2993 /** +2994 @returns {Person} +2995 */ +2996 +2997 +2998 Supports.prototype.guardian = function() { +2999 return new hQuery.Person(this.json['guardian']); +3000 }; +3001 +3002 /** +3003 @returns {String} +3004 */ +3005 +3006 +3007 Supports.prototype.guardianSupportType = function() { +3008 return this.json['guardianSupportType']; +3009 }; +3010 +3011 /** +3012 @returns {Person} +3013 */ +3014 +3015 +3016 Supports.prototype.contact = function() { +3017 return new hQuery.Person(this.json['contact']); +3018 }; +3019 +3020 /** +3021 @returns {String} +3022 */ +3023 +3024 +3025 Supports.prototype.contactSupportType = function() { +3026 return this.json['guardianSupportType']; +3027 }; +3028 +3029 return Supports; +3030 +3031 })(); +3032 +3033 /** +3034 @class Representation of a patient +3035 @augments hQuery.Person +3036 @exports Patient as hQuery.Patient +3037 */ +3038 +3039 +3040 hQuery.Patient = (function(_super) { +3041 +3042 __extends(Patient, _super); +3043 +3044 Patient.name = 'Patient'; +3045 +3046 function Patient() { +3047 return Patient.__super__.constructor.apply(this, arguments); +3048 } +3049 +3050 /** +3051 @returns {String} containing M or F representing the gender of the patient +3052 */ +3053 +3054 +3055 Patient.prototype.gender = function() { +3056 return this.json['gender']; +3057 }; +3058 +3059 /** +3060 @returns {Date} containing the patients birthdate +3061 */ +3062 +3063 +3064 Patient.prototype.birthtime = function() { +3065 if (this.json['birthdate']) { +3066 return hQuery.dateFromUtcSeconds(this.json['birthdate']); +3067 } +3068 }; +3069 +3070 /** +3071 @param (Date) date the date at which the patient age is calculated, defaults to now. +3072 @returns {number} the patient age in years +3073 */ +3074 +3075 +3076 Patient.prototype.age = function(date) { +3077 var oneDay, oneYear; +3078 if (date == null) { +3079 date = new Date(); +3080 } +3081 if (this.birthtime() != null) { +3082 oneDay = 24 * 60 * 60 * 1000; +3083 oneYear = 365.25 * oneDay; +3084 return (date.getTime() - this.birthtime().getTime()) / oneYear; +3085 } +3086 }; +3087 +3088 /** +3089 @returns {CodedValue} the domestic partnership status of the patient +3090 The following HL7 codeset is used: +3091 A Annulled +3092 D Divorced +3093 I Interlocutory +3094 L Legally separated +3095 M Married +3096 P Polygamous +3097 S Never Married +3098 T Domestic Partner +3099 W Widowed +3100 */ +3101 +3102 +3103 Patient.prototype.maritalStatus = function() { +3104 if (this.json['maritalStatus']) { +3105 return hQuery.createCodedValue(this.json['maritalStatus']); +3106 } +3107 }; +3108 +3109 /** +3110 @returns {CodedValue} of the spiritual faith affiliation of the patient +3111 It uses the HL7 codeset. http://www.hl7.org/memonly/downloads/v3edition.cfm#V32008 +3112 */ +3113 +3114 +3115 Patient.prototype.religiousAffiliation = function() { +3116 if (this.json['religiousAffiliation']) { +3117 return hQuery.createCodedValue(this.json['religiousAffiliation']); +3118 } +3119 }; +3120 +3121 /** +3122 @returns {CodedValue} of the race of the patient +3123 CDC codes: http://phinvads.cdc.gov/vads/ViewCodeSystemConcept.action?oid=2.16.840.1.113883.6.238&code=1000-9 +3124 */ +3125 +3126 +3127 Patient.prototype.race = function() { +3128 if (this.json['race']) { +3129 return hQuery.createCodedValue(this.json['race']); +3130 } +3131 }; +3132 +3133 /** +3134 @returns {CodedValue} of the ethnicity of the patient +3135 CDC codes: http://phinvads.cdc.gov/vads/ViewCodeSystemConcept.action?oid=2.16.840.1.113883.6.238&code=1000-9 +3136 */ +3137 +3138 +3139 Patient.prototype.ethnicity = function() { +3140 if (this.json['ethnicity']) { +3141 return hQuery.createCodedValue(this.json['ethnicity']); +3142 } +3143 }; +3144 +3145 /** +3146 @returns {CodedValue} This is the code specifying the level of confidentiality of the document. +3147 HL7 Confidentiality Code (2.16.840.1.113883.5.25) +3148 */ +3149 +3150 +3151 Patient.prototype.confidentiality = function() { +3152 if (this.json['confidentiality']) { +3153 return hQuery.createCodedValue(this.json['confidentiality']); +3154 } +3155 }; +3156 +3157 /** +3158 @returns {Address} of the location where the patient was born +3159 */ +3160 +3161 +3162 Patient.prototype.birthPlace = function() { +3163 return new hQuery.Address(this.json['birthPlace']); +3164 }; +3165 +3166 /** +3167 @returns {Supports} information regarding key support contacts relative to healthcare decisions, including next of kin +3168 */ +3169 +3170 +3171 Patient.prototype.supports = function() { +3172 return new hQuery.Supports(this.json['supports']); +3173 }; +3174 +3175 /** +3176 @returns {Organization} +3177 */ +3178 +3179 +3180 Patient.prototype.custodian = function() { +3181 return new hQuery.Organization(this.json['custodian']); +3182 }; +3183 +3184 /** +3185 @returns {Provider} the providers associated with the patient +3186 */ +3187 +3188 +3189 Patient.prototype.provider = function() { +3190 return new hQuery.Provider(this.json['provider']); +3191 }; +3192 +3193 /** +3194 @returns {hQuery.CodedEntryList} A list of {@link hQuery.LanguagesSpoken} objects +3195 Code from http://www.ietf.org/rfc/rfc4646.txt representing the name of the human language +3196 */ +3197 +3198 +3199 Patient.prototype.languages = function() { +3200 var language, list, _i, _len, _ref; +3201 list = new hQuery.CodedEntryList; +3202 if (this.json['languages']) { +3203 _ref = this.json['languages']; +3204 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3205 language = _ref[_i]; +3206 list.push(new hQuery.Language(language)); +3207 } +3208 } +3209 return list; +3210 }; +3211 +3212 /** +3213 @returns {Boolean} returns true if the patient has died +3214 */ +3215 +3216 +3217 Patient.prototype.expired = function() { +3218 return this.json['expired']; +3219 }; +3220 +3221 /** +3222 @returns {Boolean} returns true if the patient participated in a clinical trial +3223 */ +3224 +3225 +3226 Patient.prototype.clinicalTrialParticipant = function() { +3227 return this.json['clinicalTrialParticipant']; +3228 }; +3229 +3230 /** +3231 @returns {hQuery.CodedEntryList} A list of {@link hQuery.Encounter} objects +3232 */ +3233 +3234 +3235 Patient.prototype.encounters = function() { +3236 var encounter, list, _i, _len, _ref; +3237 list = new hQuery.CodedEntryList; +3238 if (this.json['encounters']) { +3239 _ref = this.json['encounters']; +3240 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3241 encounter = _ref[_i]; +3242 list.pushIfUsable(new hQuery.Encounter(encounter)); +3243 } +3244 } +3245 return list; +3246 }; +3247 +3248 /** +3249 @returns {hQuery.CodedEntryList} A list of {@link Medication} objects +3250 */ +3251 +3252 +3253 Patient.prototype.medications = function() { +3254 var list, medication, _i, _len, _ref; +3255 list = new hQuery.CodedEntryList; +3256 if (this.json['medications']) { +3257 _ref = this.json['medications']; +3258 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3259 medication = _ref[_i]; +3260 list.pushIfUsable(new hQuery.Medication(medication)); +3261 } +3262 } +3263 return list; +3264 }; +3265 +3266 /** +3267 @returns {hQuery.CodedEntryList} A list of {@link Condition} objects +3268 */ +3269 +3270 +3271 Patient.prototype.conditions = function() { +3272 var condition, list, _i, _len, _ref; +3273 list = new hQuery.CodedEntryList; +3274 if (this.json['conditions']) { +3275 _ref = this.json['conditions']; +3276 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3277 condition = _ref[_i]; +3278 list.pushIfUsable(new hQuery.Condition(condition)); +3279 } +3280 } +3281 return list; +3282 }; +3283 +3284 /** +3285 @returns {hQuery.CodedEntryList} A list of {@link Procedure} objects +3286 */ +3287 +3288 +3289 Patient.prototype.procedures = function() { +3290 var list, procedure, _i, _len, _ref; +3291 list = new hQuery.CodedEntryList; +3292 if (this.json['procedures']) { +3293 _ref = this.json['procedures']; +3294 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3295 procedure = _ref[_i]; +3296 list.pushIfUsable(new hQuery.Procedure(procedure)); +3297 } +3298 } +3299 return list; +3300 }; +3301 +3302 /** +3303 @returns {hQuery.CodedEntryList} A list of {@link Result} objects +3304 */ +3305 +3306 +3307 Patient.prototype.results = function() { +3308 var list, result, _i, _len, _ref; +3309 list = new hQuery.CodedEntryList; +3310 if (this.json['results']) { +3311 _ref = this.json['results']; +3312 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3313 result = _ref[_i]; +3314 list.pushIfUsable(new hQuery.Result(result)); +3315 } +3316 } +3317 return list; +3318 }; +3319 +3320 /** +3321 @returns {hQuery.CodedEntryList} A list of {@link Result} objects +3322 */ +3323 +3324 +3325 Patient.prototype.vitalSigns = function() { +3326 var list, vital, _i, _len, _ref; +3327 list = new hQuery.CodedEntryList; +3328 if (this.json['vital_signs']) { +3329 _ref = this.json['vital_signs']; +3330 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3331 vital = _ref[_i]; +3332 list.pushIfUsable(new hQuery.Result(vital)); +3333 } +3334 } +3335 return list; +3336 }; +3337 +3338 /** +3339 @returns {hQuery.CodedEntryList} A list of {@link Immunization} objects +3340 */ +3341 +3342 +3343 Patient.prototype.immunizations = function() { +3344 var immunization, list, _i, _len, _ref; +3345 list = new hQuery.CodedEntryList; +3346 if (this.json['immunizations']) { +3347 _ref = this.json['immunizations']; +3348 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3349 immunization = _ref[_i]; +3350 list.pushIfUsable(new hQuery.Immunization(immunization)); +3351 } +3352 } +3353 return list; +3354 }; +3355 +3356 /** +3357 @returns {hQuery.CodedEntryList} A list of {@link Allergy} objects +3358 */ +3359 +3360 +3361 Patient.prototype.allergies = function() { +3362 var allergy, list, _i, _len, _ref; +3363 list = new hQuery.CodedEntryList; +3364 if (this.json['allergies']) { +3365 _ref = this.json['allergies']; +3366 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3367 allergy = _ref[_i]; +3368 list.pushIfUsable(new hQuery.Allergy(allergy)); +3369 } +3370 } +3371 return list; +3372 }; +3373 +3374 /** +3375 @returns {hQuery.CodedEntryList} A list of {@link Pregnancy} objects +3376 */ +3377 +3378 +3379 Patient.prototype.pregnancies = function() { +3380 var list, pregnancy, _i, _len, _ref; +3381 list = new hQuery.CodedEntryList; +3382 if (this.json['pregnancies']) { +3383 _ref = this.json['pregnancies']; +3384 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3385 pregnancy = _ref[_i]; +3386 list.pushIfUsable(new hQuery.Pregnancy(pregnancy)); +3387 } +3388 } +3389 return list; +3390 }; +3391 +3392 /** +3393 @returns {hQuery.CodedEntryList} A list of {@link Socialhistory} objects +3394 */ +3395 +3396 +3397 Patient.prototype.socialHistories = function() { +3398 var list, socialhistory, _i, _len, _ref; +3399 list = new hQuery.CodedEntryList; +3400 if (this.json['socialhistories']) { +3401 _ref = this.json['socialhistories']; +3402 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3403 socialhistory = _ref[_i]; +3404 list.pushIfUsable(new hQuery.Socialhistory(socialhistory)); +3405 } +3406 } +3407 return list; +3408 }; +3409 +3410 /** +3411 @returns {hQuery.CodedEntryList} A list of {@link CareGoal} objects +3412 */ +3413 +3414 +3415 Patient.prototype.careGoals = function() { +3416 var caregoal, list, _i, _len, _ref; +3417 list = new hQuery.CodedEntryList; +3418 if (this.json['care_goals']) { +3419 _ref = this.json['care_goals']; +3420 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3421 caregoal = _ref[_i]; +3422 list.pushIfUsable(new hQuery.CareGoal(caregoal)); +3423 } +3424 } +3425 return list; +3426 }; +3427 +3428 /** +3429 @returns {hQuery.CodedEntryList} A list of {@link MedicalEquipment} objects +3430 */ +3431 +3432 +3433 Patient.prototype.medicalEquipment = function() { +3434 var equipment, list, _i, _len, _ref; +3435 list = new hQuery.CodedEntryList; +3436 if (this.json['medical_equipment']) { +3437 _ref = this.json['medical_equipment']; +3438 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3439 equipment = _ref[_i]; +3440 list.pushIfUsable(new hQuery.MedicalEquipment(equipment)); +3441 } +3442 } +3443 return list; +3444 }; +3445 +3446 /** +3447 @returns {hQuery.CodedEntryList} A list of {@link FunctionalStatus} objects +3448 */ +3449 +3450 +3451 Patient.prototype.functionalStatuses = function() { +3452 var fs, list, _i, _len, _ref; +3453 list = new hQuery.CodedEntryList; +3454 if (this.json['functional_statuses']) { +3455 _ref = this.json['functional_statuses']; +3456 for (_i = 0, _len = _ref.length; _i < _len; _i++) { +3457 fs = _ref[_i]; +3458 list.pushIfUsable(new hQuery.FunctionalStatus(fs)); +3459 } +3460 } +3461 return list; +3462 }; +3463 +3464 return Patient; +3465 +3466 })(hQuery.Person); +3467 \ No newline at end of file diff --git a/runme.sh b/runme.sh new file mode 100755 index 0000000..d5da33d --- /dev/null +++ b/runme.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Toggle the USE_SSL_SERVER and USE_SSL_CLEINT variables in config/ssl_config.rb to enable/disable SSL support. +# The variable USE_SSL_SERVER configures encrypted browser access to the query-composer. +# The variable USE_SSL_CLIENT configures whether traffic between composer and gateway is SSL encrypted. If it is +# being tunnelled through ssh, then is isn't necessary to also SSL encrypt it. + +echo "Installing Dependencies" +bundle install +echo "Starting Delayed Job" +bundle exec script/delayed_job start +echo "Starting Composer" +bundle exec rails server -p 3002 +echo "Stopping Delayed Job" +bundle exec script/delayed_job stop + +# To start query-gateway +# In a second terminal, change directory to the query-gateway directory +# and run: +# +# bundle install +# bundle exec rake db:seed +# bundle exec script/delayed_job start +# bundle exec rails server -p 3001 +# +#In a browser open the URL: https://localhost:3000/queries/ +# +# Adding an Administrative User Account (one time operation) +# +# When the web application opens, you should be presented with a login page. +# You should see a sign up Link, click it. +# Fill out the form to create a user. +# Next you need to approve the user and set the user as an admin +# In the root of the query-composer project run the command: +## +# bundle exec rake hquery:users:grant_admin USER_ID= +# +# where is replaced with the username for the user you just created. +# +# Adding a non-administrative user account +# When the web application opens, users will be presented with a login page. +# They will see a sign up Link which they click. +# The user then needs to fill out the form. +# Next you need to approve this new user +# In the root of the query-composer project run the command: +## +# bundle exec rake hquery:users:approve USER_ID= +# +# where is replaced with the username for the user created. +# diff --git a/script/rails b/script/rails index f8da2cf..f1cb5bc 100755 --- a/script/rails +++ b/script/rails @@ -1,6 +1,39 @@ #!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) +require 'rubygems' +require 'rails/commands/server' +require 'rack' +require 'webrick' +require 'webrick/https' +require File.expand_path('../../config/ssl_config', __FILE__) + +#override default option of server to use SSL +USE_SSL_SERVER = SslConfig::getUseSslServer +CA_CERT_PATH =SslConfig::getServerKeyPath +# +SERVER_CERT_PATH = SslConfig::getServerCertPath +SERVER_KEY_PATH = SslConfig::getServerKeyPath +# +SERVER_KEY = File.open(SERVER_KEY_PATH) +SERVER_CERT = File.open(SERVER_CERT_PATH) + +module Rails + class Server < ::Rack::Server + def default_options + super.merge({ + :pid => File.expand_path("tmp/pids/server.pid"), + :SSLEnable => USE_SSL_SERVER, + :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, + :SSLPrivateKey => OpenSSL::PKey::RSA.new(SERVER_KEY.read), + :SSLCertificate => OpenSSL::X509::Certificate.new(SERVER_CERT.read), + :SSLCACertificateFile => CA_CERT_PATH, + :SSLCertName => [["CN", WEBrick::Utils::getservername]], + }) + end + end +end + +APP_PATH = File.expand_path('../../config/application', __FILE__) +require File.expand_path('../../config/boot', __FILE__) require 'rails/commands' diff --git a/start-hub-example.sh b/start-hub-example.sh new file mode 100755 index 0000000..bab9c91 --- /dev/null +++ b/start-hub-example.sh @@ -0,0 +1,41 @@ +#!/bin/bash +source $HOME/.bash_profile +source $HOME/.bashrc +export HUB=$HOME/git/scoophealth/hquery/query-composer +export HB_PIDFILE=$HUB/tmp/pids/server.pid +export DL_PIDFILE=$HUB/tmp/pids/delayed_job.pid + +# +# Make sure mongod is running +if ! pgrep mongod > /dev/null +then + sudo service mongod start +fi +# +# +echo "Starting Query Composer on port 3002" +cd $HUB +if [ -f $DL_PIDFILE ]; +then + bundle exec $HUB/script/delayed_job stop + if [ -f $DL_FILEFILE ]; + then + rm $DL_PIDFILE + fi +fi +# +bundle exec $HUB/script/delayed_job start +# +# Start composer +# If composer is already running (or has a stale server.pid), try to stop it. +if [ -f $HB_PIDFILE ]; +then + kill `cat $HB_PIDFILE` + if [ -f $HB_PIDFILE ]; + then + kill -9 `cat $HB_PIDFILE` + rm $HB_PIDFILE + fi +fi +bundle exec rails server -p 3002 -d +#/bin/ps -ef | grep "rails server -p 3002" | grep -v grep | awk '{print $2}' > tmp/pids/server.pid diff --git a/stop-hub-example.sh b/stop-hub-example.sh new file mode 100755 index 0000000..ec65599 --- /dev/null +++ b/stop-hub-example.sh @@ -0,0 +1,27 @@ +#!/bin/bash +source $HOME/.bash_profile +source $HOME/.bashrc +export HUB=$HOME/git/scoophealth/hquery/query-composer +export HB_PIDFILE=$HUB/tmp/pids/server.pid +export DL_PIDFILE=$HUB/tmp/pids/delayed_job.pid +cd $HUB +if [ -f $DL_PIDFILE ]; +then + bundle exec $HUB/script/delayed_job stop + # pid file should be gone but recheck + if [ -f $DL_PIDFILE ]; + then + rm $DL_PIDFILE + fi +fi +# +# If gateway is running, stop it. +if [ -f $HB_PIDFILE ]; +then + kill `cat $HB_PIDFILE` + if [ -f $HB_PIDFILE ]; + then + kill -9 `cat $HB_PIDFILE` + fi + rm $HB_PIDFILE +fi diff --git a/test/factories/factory.rb b/test/factories/factory.rb index 6ae3399..5d7f32a 100755 --- a/test/factories/factory.rb +++ b/test/factories/factory.rb @@ -1,175 +1,271 @@ require 'factory_girl' +# server to hub web access +if SslConfig::getUseSslServer + HTTP_PROTO_SERVER='https' +else + HTTP_PROTO_SERVER='http' +end + +# hub is client of endpoints +if SslConfig::getUseSslClient + HTTP_PROTO_CLIENT='https' +else + HTTP_PROTO_CLIENT='http' +end + # ========== # = USERS = # ========== -Factory.define :user do |u| - u.sequence(:email) { |n| "testuser#{n}@test.com"} - u.password 'password' - u.password_confirmation 'password' - u.first_name 'first' - u.last_name 'last' - u.sequence(:username) { |n| "testuser#{n}"} - u.admin false - u.approved true +FactoryGirl.define do + factory :user do |u| + u.sequence(:email) { |n| "testuser#{n}@test.com"} + u.password 'password' + u.password_confirmation 'password' + u.first_name 'first' + u.last_name 'last' + u.sequence(:username) { |n| "testuser#{n}"} + u.admin false + u.approved true + end end -Factory.define :admin, :parent => :user do |u| - u.admin true +FactoryGirl.define do + factory :admin, :parent => :user do |u| + u.admin true + end end -Factory.define :unapproved_user, :parent => :user do |u| - u.approved false +FactoryGirl.define do + factory :unapproved_user, :parent => :user do |u| + u.approved false + end end -Factory.define :user_with_queries, :parent => :user do |user| - user.after_create { |u| Factory(:query, :user => u) } - user.after_create { |u| Factory(:query, :user => u) } - user.after_create { |u| Factory(:query, :user => u) } - user.after_create { |u| Factory(:query_with_queued_results, :user => u) } - user.after_create { |u| Factory(:query_with_completed_results, :user => u) } - user.after_create { |u| Factory(:generated_query_with_completed_results, :user => u) } +FactoryGirl.define do + factory :user_with_queries, :parent => :user do |user| + after(:create) do |user, evaluator| + FactoryGirl.create(:query, user: user) + FactoryGirl.create(:query, user: user) + FactoryGirl.create(:query, user: user) + FactoryGirl.create(:query_with_queued_results, user: user) + FactoryGirl.create(:query_with_completed_results, user: user) + FactoryGirl.create(:generated_query_with_completed_results, user: user) + end + #user.after_create { |u| FactoryGirl.create(:query, :user => u) } + #user.after_create { |u| FactoryGirl.create(:query, :user => u) } + #user.after_create { |u| FactoryGirl.create(:query, :user => u) } + #user.after_create { |u| FactoryGirl.create(:query_with_queued_results, :user => u) } + #user.after_create { |u| FactoryGirl.create(:query_with_completed_results, :user => u) } + #user.after_create { |u| FactoryGirl.create(:generated_query_with_completed_results, :user => u) } + end end -Factory.define :user_with_library_functions, :parent => :user do |user| - user.after_create {|u| Factory(:library_function, :user => u)} +FactoryGirl.define do + factory :user_with_library_functions, :parent => :user do |user| + after(:create) do |user, evaluator| + FactoryGirl.create(:library_function, user: user) + end + #user.after_create {|u| FactoryGirl.create(:library_function, :user => u)} + end end -Factory.define :user_with_queries_and_library_functions, :parent => :user_with_queries do |user| - user.after_create {|u| Factory(:library_function, :user => u)} +FactoryGirl.define do + factory :user_with_queries_and_library_functions, :parent => :user_with_queries do |user| + after(:create) do |user, evaluator| + FactoryGirl.create(:library_function, user: user) + end + #user.after_create {|u| FactoryGirl.create(:library_function, :user => u)} + end end # =========== # = QUERIES = # =========== -Factory.define :template_query do |q| - q.sequence(:title) { |n| "title #{n}" } - q.description "description" - q.filter "" - q.map "function(patient) {\r\n emit(null, {\"count\":1});\r\n}" - q.reduce "function(patient) {\r\n emit(null, {\"count\":1});\r\n}" +FactoryGirl.define do + factory :template_query do |q| + q.sequence(:title) { |n| "title #{n}" } + q.description "description" + q.filter "" + q.map "function(patient) {\r\n emit(null, {\"count\":1});\r\n}" + q.reduce "function(patient) {\r\n emit(null, {\"count\":1});\r\n}" + end end -Factory.define :query do |q| - q.sequence(:title) { |n| "title #{n}" } - q.description "description" - q.filter "" - q.map "function map(patient) {\r\n emit(null, {\"count\":1});\r\n}" - q.reduce "function reduce(patient) {\r\n emit(null, {\"count\":1});\r\n}" - q.user Factory.build(:user) +FactoryGirl.define do + factory :query do |q| + q.sequence(:title) { |n| "title #{n}" } + q.description "description" + q.filter "" + q.map "function map(patient) {\r\n emit(null, {\"count\":1});\r\n}" + q.reduce "function reduce(patient) {\r\n emit(null, {\"count\":1});\r\n}" + q.user FactoryGirl.build(:user) + end end -Factory.define :generated_query, :parent => :query do |q| - q.query_structure ({ - "find" => - { "and" => [ - { "name" => "demographics", - "and" => [ - { "category" => "demographics", "title" => "age", "field" => "age", "value" => "18", "comparator" => ">" } ] } ] }, - "filter" => - { "and" => [ - { "name" => "demographics", - "and" => [ - { "category" => "demographics", "title" => "age", "field" => "age", "value" => "65", "comparator" => "<" } ] } ] }, - "extract" => - { "selections" => [ - { "title" => "age", "callstack" => "age", "aggregation" => [ "sum" ] } ], - "groups" => [ { "title" => "gender", "callstack" => "gender" } ] } - }) - q.generated true - q.user Factory.build(:user) +FactoryGirl.define do + factory :generated_query, :parent => :query do |q| + q.query_structure ({ + "find" => + { "and" => [ + { "name" => "demographics", + "and" => [ + { "category" => "demographics", "title" => "age", "field" => "age", "value" => "18", "comparator" => ">" } ] } ] }, + "filter" => + { "and" => [ + { "name" => "demographics", + "and" => [ + { "category" => "demographics", "title" => "age", "field" => "age", "value" => "65", "comparator" => "<" } ] } ] }, + "extract" => + { "selections" => [ + { "title" => "age", "callstack" => "age", "aggregation" => [ "sum" ] } ], + "groups" => [ { "title" => "gender", "callstack" => "gender" } ] } + }) + q.generated true + q.user FactoryGirl.build(:user) + end end -Factory.define :query_with_queued_results, :parent => :query do |query| - query.reduce "function reduce(key, values) {\r\n var result = 0; \r\n while(values.hasNext()){ result += values.next(); }\r\nreturn result; \r\n}" - - query.executions { - [] << Factory.build(:queued_execution) - } +FactoryGirl.define do + factory :query_with_queued_results, :parent => :query do |query| + query.reduce "function reduce(key, values) {\r\n return Array.sum(values); \r\n}" + + #after(:create) do |query, evaluator| + # FactoryGirl.create_list(:queued_execution, 1, query: query) + #end + query.executions { + [] << FactoryGirl.build(:queued_execution) + } + end end -Factory.define :query_with_completed_results, :parent => :query do |query| - query.reduce "function reduce(key, values) {\r\n var result = 0; \r\n while(values.hasNext()){ result += values.next(); }\r\nreturn result; \r\n}" - - query.executions { - [] << Factory.build(:completed_execution) - } +FactoryGirl.define do + factory :query_with_completed_results, :parent => :query do |query| + query.reduce "function reduce(key, values) {\r\n return Array.sum(values); \r\n}" + + #after(:create) do |query, evaluator| + # FactoryGirl.create_list(:completed_execution, 1, query: query) + #end + query.executions { + [] << FactoryGirl.build(:completed_execution) + } + end end -Factory.define :generated_query_with_completed_results, :parent => :generated_query do |query| - query.executions { - [] << Factory.build(:completed_execution_for_generated_query) - } +FactoryGirl.define do + factory :generated_query_with_completed_results, :parent => :generated_query do |query| + + #after(:create) do |query, evaluator| + # FactoryGirl.create_list(:completed_execution_for_generated_query, 1, query: query) + #end + query.executions { + [] << FactoryGirl.build(:completed_execution_for_generated_query) + } + end end -Factory.define :generated_query_with_odd_result_count, :parent => :generated_query do |query| - query.executions { - [] << Factory.build(:execution_with_generated_odd_result_count) - } +FactoryGirl.define do + factory :generated_query_with_odd_result_count, :parent => :generated_query do |query| + #after(:create) do |query, evaluator| + # FactoryGirl.create_list(:execution_with_generated_odd_result_count, 1, query: query) + #end + query.executions { + [] << FactoryGirl.build(:execution_with_generated_odd_result_count) + } + end end -Factory.define :generated_query_with_single_result, :parent => :generated_query do |query| - query.executions { - [] << Factory.build(:execution_with_generated_single_result) - } +FactoryGirl.define do + factory :generated_query_with_single_result, :parent => :generated_query do |query| + #after(:create) do |query, evaluator| + # FactoryGirl.create_list(:execution_with_generated_single_result, 1, query: query) + #end + query.executions { + [] << FactoryGirl.build(:execution_with_generated_single_result) + } + end end -Factory.define :generated_query_with_no_results, :parent => :generated_query do |query| - query.executions { - [] << Factory.build(:execution) - } +FactoryGirl.define do + factory :generated_query_with_no_results, :parent => :generated_query do |query| + #after(:create) do |query, evaluator| + # FactoryGirl.create_list(:execution, 1, query: query) + #end + query.executions { + [] << FactoryGirl.build(:execution) + } + end end # ============= # = Endpoints = # ============= -Factory.define :endpoint do |e| - e.sequence(:name) {|n| "Endpoint#{n}"} - e.base_url 'http://127.0.0.1:3001' +FactoryGirl.define do + factory :endpoint do |e| + e.sequence(:name) {|n| "Endpoint#{n}"} + e.base_url HTTP_PROTO_CLIENT+'://127.0.0.1:3001' + end end # ============== # = Executions = # ============== -Factory.define :execution do |e| - e.time Time.now.to_i +FactoryGirl.define do + factory :execution do |e| + e.time Time.now.to_i + end end -Factory.define :queued_execution, :parent => :execution do |e| - e.after_build do |ex| - Factory.create(:result_waiting, :endpoint => Factory(:endpoint), :execution => ex) +FactoryGirl.define do + factory :queued_execution, :parent => :execution do |e| + after(:build) do |ex| + #e.after_build do |ex| + FactoryGirl.create(:result_waiting, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + end end end -Factory.define :completed_execution, :parent => :execution do |e| - e.after_build do |ex| - Factory.create(:result_with_value, :endpoint => Factory(:endpoint), :execution => ex) - Factory.create(:result_with_value, :endpoint => Factory(:endpoint), :execution => ex) +FactoryGirl.define do + factory :completed_execution, :parent => :execution do |e| + after(:build) do |ex| + #e.after_build do |ex| + FactoryGirl.create(:result_with_value, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + FactoryGirl.create(:result_with_value, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + end end end -Factory.define :completed_execution_for_generated_query, :parent => :execution do |e| - e.after_build do |ex| - Factory.create(:result_with_value_from_generated_query, :endpoint => Factory(:endpoint), :execution => ex) - Factory.create(:result_with_value_from_generated_query, :endpoint => Factory(:endpoint), :execution => ex) - Factory.create(:result_with_value_from_generated_query, :endpoint => Factory(:endpoint), :execution => ex) - Factory.create(:result_with_value_from_generated_query, :endpoint => Factory(:endpoint), :execution => ex) +FactoryGirl.define do + factory :completed_execution_for_generated_query, :parent => :execution do |e| + after(:build) do |ex| + #e.after_build do |ex| + FactoryGirl.create(:result_with_value_from_generated_query, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + FactoryGirl.create(:result_with_value_from_generated_query, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + FactoryGirl.create(:result_with_value_from_generated_query, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + FactoryGirl.create(:result_with_value_from_generated_query, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + end end end -Factory.define :execution_with_generated_odd_result_count, :parent => :execution do |e| - e.after_build do |ex| - Factory.create(:result_with_value_from_generated_query, :endpoint => Factory(:endpoint), :execution => ex) - Factory.create(:result_with_value_from_generated_query, :endpoint => Factory(:endpoint), :execution => ex) - Factory.create(:result_with_value_from_generated_query, :endpoint => Factory(:endpoint), :execution => ex) +FactoryGirl.define do + factory :execution_with_generated_odd_result_count, :parent => :execution do |e| + after(:build) do |ex| + #e.after_build do |ex| + FactoryGirl.create(:result_with_value_from_generated_query, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + FactoryGirl.create(:result_with_value_from_generated_query, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + FactoryGirl.create(:result_with_value_from_generated_query, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + end end end -Factory.define :execution_with_generated_single_result, :parent => :execution do |e| - e.after_build do |ex| - Factory.create(:result_with_value_from_generated_query, :endpoint => Factory(:endpoint), :execution => ex) +FactoryGirl.define do + factory :execution_with_generated_single_result, :parent => :execution do |e| + after(:build) do |ex| + #e.after_build do |ex| + FactoryGirl.create(:result_with_value_from_generated_query, :endpoint => FactoryGirl.create(:endpoint), :execution => ex) + end end end @@ -177,88 +273,98 @@ # = Results = # =========== -Factory.define :result do |r| - r.value nil - r.result_url nil - r.status nil +FactoryGirl.define do + factory :result do |r| + r.value nil + r.result_url nil + r.status nil + end end -Factory.define :result_waiting, :parent => :result do |r| - r.value nil - r.result_url nil - r.status Result::QUEUED - r.query_url 'http://localhost:3000/queries/4e4c08b5431a5f5dc1000001' - r.created_at Time.new(2011, 1, 1) - r.updated_at Time.new(2011, 1, 1) +FactoryGirl.define do + factory :result_waiting, :parent => :result do |r| + r.value nil + r.result_url nil + r.status Result::QUEUED + r.query_url HTTP_PROTO_CLIENT+'://localhost:3000/queries/4e4c08b5431a5f5dc1000001' + r.created_at Time.new(2011, 1, 1) + r.updated_at Time.new(2011, 1, 1) + end end -Factory.define :result_with_value, :parent => :result do |result| - result.value ({"M" => 50, "F" => 30}) - result.status Result::COMPLETE +FactoryGirl.define do + factory :result_with_value, :parent => :result do |result| + result.value ({"M" => 50, "F" => 30}) + result.status Result::COMPLETE + end end -Factory.define :result_with_value_from_generated_query, :parent => :result_with_value do |result| - result.value ({ - "type_group_gender_F" => { - "values" => { - "age" => 0, - "age_sum" => 6000, - "age_frequency" => { - "18" => 65, - "65" => 18 +FactoryGirl.define do + factory :result_with_value_from_generated_query, :parent => :result_with_value do |result| + result.value ({ + "type_group_gender_F" => { + "values" => { + "age" => 0, + "age_sum" => 6000, + "age_frequency" => { + "18" => 65, + "65" => 18 + }, + "age_mean" => 28.193, + "age_mean_count" => 83, + "median" => 18, + "median_list" => [ + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65 + ], + "mode" => 18, + "mode_frequency" => { + "18" => 65, + "65" => 18 + } }, - "age_mean" => 28.193, - "age_mean_count" => 83, - "median" => 18, - "median_list" => [ - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65 - ], - "mode" => 18, - "mode_frequency" => { - "18" => 65, - "65" => 18 - } + "rereduced" => true }, - "rereduced" => true - }, - "type_group_gender_M" => { - "values" => { - "age" => 0, - "age_sum" => 4000 + "type_group_gender_M" => { + "values" => { + "age" => 0, + "age_sum" => 4000 + }, + "rereduced" => true }, - "rereduced" => true - }, - "type_population" => { - "values" => { - "target_pop" => 0, - "filtered_pop" => 0, - "unfound_pop" => 0, - "total_pop" => 0, - "target_pop_sum" => 300, - "filtered_pop_sum" => 400, - "unfound_pop_sum" => 100, - "total_pop_sum" => 500 - }, - "rereduced" => true - } - }) + "type_population" => { + "values" => { + "target_pop" => 0, + "filtered_pop" => 0, + "unfound_pop" => 0, + "total_pop" => 0, + "target_pop_sum" => 300, + "filtered_pop_sum" => 400, + "unfound_pop_sum" => 100, + "total_pop_sum" => 500 + }, + "rereduced" => true + } + }) + end end # ===================== # = Library Functions = # ===================== -Factory.define :library_function do |f| - f.sequence(:name) { |n| "sum#{n}()" } - f.definition "this.sum = function(values) {\r\n result = 0;\r\n values.forEach(function(value) {\r\n result += value;\r\n });\r\n return result;\r\n }\r\n" +FactoryGirl.define do + factory :library_function do |f| + f.sequence(:name) { |n| "sum#{n}()" } + f.definition "this.sum = function(values) {\r\n result = 0;\r\n values.forEach(function(value) {\r\n result += value;\r\n });\r\n return result;\r\n }\r\n" + end end @@ -267,17 +373,21 @@ # ====================== -Factory.define :code_set do |cs| - cs.name nil - cs.type nil - cs.description nil - cs.codes nil +FactoryGirl.define do + factory :code_set do |cs| + cs.name nil + cs.type nil + cs.description nil + cs.codes nil + end end -Factory.define :annulled_marital_status_code, :parent => :code_set do |cs| - codes = {"MaritalStatusCodes" => ["A"]} - cs.name "Annulled" - cs.description "" - cs.type "marital_status" - cs.codes codes -end \ No newline at end of file +FactoryGirl.define do + factory :annulled_marital_status_code, :parent => :code_set do |cs| + codes = {"MaritalStatusCodes" => ["A"]} + cs.name "Annulled" + cs.description "" + cs.type "marital_status" + cs.codes codes + end +end diff --git a/test/fixtures/NQF_01_AsthmaAssessment.js b/test/fixtures/NQF_01_AsthmaAssessment.js index 32e5f39..a0ec744 100755 --- a/test/fixtures/NQF_01_AsthmaAssessment.js +++ b/test/fixtures/NQF_01_AsthmaAssessment.js @@ -127,7 +127,5 @@ function map(patient) { } function reduce(criteria, counts) { - var sum = 0; - while(counts.hasNext()){sum += counts.next();} - return sum; + return Array.sum(counts); } \ No newline at end of file diff --git a/test/fixtures/NQF_31_BreastCancerScreening.js b/test/fixtures/NQF_31_BreastCancerScreening.js index 3c25b56..0f74e9b 100644 --- a/test/fixtures/NQF_31_BreastCancerScreening.js +++ b/test/fixtures/NQF_31_BreastCancerScreening.js @@ -127,7 +127,5 @@ function map(patient) { } function reduce(criteria, counts) { - var sum = 0; - while(counts.hasNext()){sum += counts.next();} - return sum; + return Array.sum(counts); } \ No newline at end of file diff --git a/test/fixtures/NQF_32_CervicalCancerScreening.js b/test/fixtures/NQF_32_CervicalCancerScreening.js index d7a401d..e6defad 100755 --- a/test/fixtures/NQF_32_CervicalCancerScreening.js +++ b/test/fixtures/NQF_32_CervicalCancerScreening.js @@ -124,7 +124,5 @@ function map(patient) { } function reduce(criteria, counts) { - var sum = 0; - while(counts.hasNext()){sum += counts.next();} - return sum; + return Array.sum(counts); } \ No newline at end of file diff --git a/test/fixtures/NQF_43_Pneumonia.js b/test/fixtures/NQF_43_Pneumonia.js index dea322b..0a3c576 100755 --- a/test/fixtures/NQF_43_Pneumonia.js +++ b/test/fixtures/NQF_43_Pneumonia.js @@ -73,7 +73,5 @@ function map(patient) { } function reduce(criteria, counts) { - var sum = 0; - while(counts.hasNext()){sum += counts.next();} - return sum; + return Array.sum(counts); } \ No newline at end of file diff --git a/test/fixtures/query_feed.xml b/test/fixtures/query_feed.xml index a0daa99..72b5adf 100644 --- a/test/fixtures/query_feed.xml +++ b/test/fixtures/query_feed.xml @@ -1,17 +1,17 @@ Distributed Queries - + 2011-08-17T14:30:19-04:00 hQuery Gateway - http://localhost:3000/queries + https://localhost:3000/queries Query Result - http://localhost:3000/queries/4e4c08b5431a5f5dc1000001 + https://localhost:3000/queries/4e4c08b5431a5f5dc1000001 Query Result 2011-08-17T14:30:13-04:00 @@ -21,15 +21,15 @@ - - http://localhost:3000/queries/4e4c08b5431a5f5dc1000001 + + https://localhost:3000/queries/4e4c08b5431a5f5dc1000001 2011-08-17T14:30:19-04:00 Query Result - http://localhost:3000/queries/4e4c0738431a5f5d14000001 + https://localhost:3000/queries/4e4c0738431a5f5d14000001 Query Result 2011-08-17T14:23:52-04:00 @@ -39,8 +39,8 @@ - - http://localhost:3000/queries/4e4c0738431a5f5d14000001 + + https://localhost:3000/queries/4e4c0738431a5f5d14000001 2011-08-17T14:23:55-04:00 \ No newline at end of file diff --git a/test/fixtures/query_feed_no_ssl.xml b/test/fixtures/query_feed_no_ssl.xml new file mode 100644 index 0000000..a0daa99 --- /dev/null +++ b/test/fixtures/query_feed_no_ssl.xml @@ -0,0 +1,46 @@ + + + Distributed Queries + + 2011-08-17T14:30:19-04:00 + + hQuery Gateway + + http://localhost:3000/queries + + Query Result + + + http://localhost:3000/queries/4e4c08b5431a5f5dc1000001 + Query Result + + 2011-08-17T14:30:13-04:00 + + 2011-08-17T14:30:19-04:00 + + + + + + http://localhost:3000/queries/4e4c08b5431a5f5dc1000001 + 2011-08-17T14:30:19-04:00 + + + Query Result + + + http://localhost:3000/queries/4e4c0738431a5f5d14000001 + Query Result + + 2011-08-17T14:23:52-04:00 + + 2011-08-17T14:23:55-04:00 + + + + + + http://localhost:3000/queries/4e4c0738431a5f5d14000001 + 2011-08-17T14:23:55-04:00 + + \ No newline at end of file diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb index ec0cf32..afce78c 100755 --- a/test/functional/admin_controller_test.rb +++ b/test/functional/admin_controller_test.rb @@ -7,12 +7,12 @@ class AdminControllerTest < ActionController::TestCase dump_database - @admin = Factory(:admin) - @user = Factory(:user) - @user2 = Factory(:user) - @unapproved_user = Factory(:unapproved_user) + @admin = FactoryGirl.create(:admin) + @user = FactoryGirl.create(:user) + @user2 = FactoryGirl.create(:user) + @unapproved_user = FactoryGirl.create(:unapproved_user) - @admin2 = Factory(:admin) + @admin2 = FactoryGirl.create(:admin) @user_ids = [] << @user.id diff --git a/test/functional/code_sets_controller_test.rb b/test/functional/code_sets_controller_test.rb index 8f13316..6224403 100644 --- a/test/functional/code_sets_controller_test.rb +++ b/test/functional/code_sets_controller_test.rb @@ -7,13 +7,13 @@ class CodeSetsControllerTest < ActionController::TestCase setup do dump_database - @admin = Factory(:admin) + @admin = FactoryGirl.create(:admin) - @code_set = Factory(:annulled_marital_status_code) + @code_set = FactoryGirl.create(:annulled_marital_status_code) sign_in @admin - @user = Factory(:user_with_queries) + @user = FactoryGirl.create(:user_with_queries) @ids = @user.queries.map {|q| q.id} end diff --git a/test/functional/endpoints_controller_test.rb b/test/functional/endpoints_controller_test.rb index a5fa942..b7c32b5 100755 --- a/test/functional/endpoints_controller_test.rb +++ b/test/functional/endpoints_controller_test.rb @@ -5,14 +5,14 @@ class EndpointsControllerTest < ActionController::TestCase setup do dump_database - @admin = Factory(:admin) + @admin = FactoryGirl.create(:admin) - @endpoint = Factory(:endpoint) - @endpoint_unsaved = Factory.build(:endpoint) + @endpoint = FactoryGirl.create(:endpoint) + @endpoint_unsaved = FactoryGirl.build(:endpoint) sign_in @admin - @user = Factory(:user_with_queries) + @user = FactoryGirl.create(:user_with_queries) @ids = @user.queries.map {|q| q.id} end @@ -94,8 +94,21 @@ class EndpointsControllerTest < ActionController::TestCase end test "should refresh endpoint statuses" do - FakeWeb.register_uri(:get, "http://127.0.0.1:3001/queries", :body => + if SslConfig::getUseSslClient + FakeWeb.register_uri(:get, "https://127.0.0.1:3001/queries", :body => %{ + + Distributed Queries + + 2011-12-15T16:02:13-05:00 + + hQuery Gateway + + https://localhost:3001/queries + }) + else + FakeWeb.register_uri(:get, "http://127.0.0.1:3001/queries", :body => + %{ Distributed Queries @@ -105,6 +118,7 @@ class EndpointsControllerTest < ActionController::TestCase http://localhost:3001/queries }) + end get :refresh_endpoint_statuses assert_equal "GET", FakeWeb.last_request.method @@ -114,7 +128,7 @@ class EndpointsControllerTest < ActionController::TestCase test "should gracefully refresh downed endpoint status" do Endpoint.all.each do |endpoint| - endpoint.base_url = "http://something.totally.invalid:9999" + endpoint.base_url = HTTP_PROTO_CLIENT+"://something.totally.invalid:9999" endpoint.save! end get :refresh_endpoint_statuses diff --git a/test/functional/library_functions_controller_test.rb b/test/functional/library_functions_controller_test.rb index 7c0b665..2c459a6 100755 --- a/test/functional/library_functions_controller_test.rb +++ b/test/functional/library_functions_controller_test.rb @@ -5,12 +5,12 @@ class LibraryFunctionsControllerTest < ActionController::TestCase setup do dump_database - @user = Factory(:user_with_library_functions) - @another_user = Factory(:user_with_library_functions) - @admin = Factory(:admin) + @user = FactoryGirl.create(:user_with_library_functions) + @another_user = FactoryGirl.create(:user_with_library_functions) + @admin = FactoryGirl.create(:admin) @library_function = @user.library_functions[0] - @library_function_unsaved = Factory.build(:library_function) + @library_function_unsaved = FactoryGirl.build(:library_function) sign_in @user diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb index 5d5d2a5..6b7c90b 100755 --- a/test/functional/queries_controller_test.rb +++ b/test/functional/queries_controller_test.rb @@ -7,23 +7,23 @@ class QueriesControllerTest < ActionController::TestCase dump_database - @user = Factory(:user_with_queries) + @user = FactoryGirl.create(:user_with_queries) @ids = @user.queries.order_by([[:created_at, :desc]]).map {|q| q.id} @user_ids = [] << @user.id - @new_endpoint = Factory(:endpoint) + @new_endpoint = FactoryGirl.create(:endpoint) @endpoints_for_execution = [] - @endpoints_for_execution << Factory(:endpoint) - @endpoints_for_execution << Factory(:endpoint, base_url: 'http://127.0.0.1:3002') + @endpoints_for_execution << FactoryGirl.create(:endpoint) + @endpoints_for_execution << FactoryGirl.create(:endpoint, base_url: HTTP_PROTO_CLIENT+'://127.0.0.1:3002') - @unattached_query = Factory(:query) + @unattached_query = FactoryGirl.create(:query) - @admin = Factory(:admin) + @admin = FactoryGirl.create(:admin) - @unapproved_user = Factory(:unapproved_user) + @unapproved_user = FactoryGirl.create(:unapproved_user) - @template_query = Factory(:template_query) + @template_query = FactoryGirl.create(:template_query) end @@ -125,13 +125,13 @@ class QueriesControllerTest < ActionController::TestCase delete :destroy, id: @ids[0] query = assigns(:query) assert_equal @ids[0], query.id - assert (not Query.exists? :conditions => {id: @ids[0]}) + assert (not Query.where(id: @ids[0]).exists?) assert_redirected_to(queries_url) end test "should execute query with notification" do sign_in @user - FakeWeb.register_uri(:post, "http://127.0.0.1:3001/queries", :body => "FORCE ERROR") + FakeWeb.register_uri(:post, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :body => "FORCE ERROR") query_from_db = Query.find(@ids[2]) endpoint_ids = [@endpoints_for_execution[0].id.to_s] @@ -161,7 +161,7 @@ class QueriesControllerTest < ActionController::TestCase test "should execute query without notification" do sign_in @user - FakeWeb.register_uri(:post, "http://127.0.0.1:3001/queries", :body => "FORCE ERROR") + FakeWeb.register_uri(:post, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :body => "FORCE ERROR") query_from_db = Query.find(@ids[2]) endpoint_ids = [@endpoints_for_execution[0].id.to_s] @@ -249,7 +249,7 @@ class QueriesControllerTest < ActionController::TestCase test "should cancel endpoint results" do sign_in @user - FakeWeb.register_uri(:post, "http://127.0.0.1:3001/queries", :body => "{}", :status => ["304"], :location=>"http://localhost:3001/queries") + FakeWeb.register_uri(:post, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :body => "{}", :status => ["304"], :location=>HTTP_PROTO_CLIENT+"://localhost:3001/queries") query_from_db = Query.find(@ids[2]) endpoint_ids = [@endpoints_for_execution[0].id.to_s] @@ -275,7 +275,7 @@ class QueriesControllerTest < ActionController::TestCase test "should cancel execution" do sign_in @user - FakeWeb.register_uri(:post, "http://127.0.0.1:3001/queries", :body => "{}", :status => ["304"], :location=>"http://localhost:3001/queries") + FakeWeb.register_uri(:post, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :body => "{}", :status => ["304"], :location=>HTTP_PROTO_CLIENT+"://localhost:3001/queries") query_from_db = Query.find(@ids[2]) endpoint_ids = [@endpoints_for_execution[0].id.to_s] diff --git a/test/functional/scheduled_jobs_controller_test.rb b/test/functional/scheduled_jobs_controller_test.rb new file mode 100644 index 0000000..e514487 --- /dev/null +++ b/test/functional/scheduled_jobs_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class ScheduledJobsControllerTest < ActionController::TestCase + + + setup do + + dump_database + + @user = FactoryGirl.create(:user_with_queries) + @ids = @user.queries.order_by([[:created_at, :desc]]).map {|q| q.id} + @user_ids = [] << @user.id + + @new_endpoint = FactoryGirl.create(:endpoint) + + @endpoints_for_execution = [] + @endpoints_for_execution << FactoryGirl.create(:endpoint) + @endpoints_for_execution << FactoryGirl.create(:endpoint, base_url: HTTP_PROTO_CLIENT+'://127.0.0.1:3002') + + @unattached_query = FactoryGirl.create(:query) + + @admin = FactoryGirl.create(:admin) + + @unapproved_user = FactoryGirl.create(:unapproved_user) + + @template_query = FactoryGirl.create(:template_query) + + end + + test 'should get batch_query' do + sign_in @user + FakeWeb.register_uri(:post, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :body => "FORCE ERROR") + query_from_db = Query.find(@ids[2]) + + endpoint_ids = [@endpoints_for_execution[0].id.to_s] + + puts "endpoints: " + @endpoints_for_execution.inspect + + #STDERR.puts query_from_db.inspect + puts "ENDPOINT_IDS #{endpoint_ids}" + puts "@ids[2]=" + @ids[2].inspect + " endpoint_ids=" + endpoint_ids.inspect + post :batch_query, id: @ids[2], endpoint_ids: endpoint_ids, notification: false + #query = assigns(:query) + #assert_not_nil query + #assert query.last_execution.notification + assert_response :success + end + +end diff --git a/test/functional/template_queries_controller_test.rb b/test/functional/template_queries_controller_test.rb index a938853..da29376 100644 --- a/test/functional/template_queries_controller_test.rb +++ b/test/functional/template_queries_controller_test.rb @@ -5,11 +5,11 @@ class TemplateQueriesControllerTest < ActionController::TestCase setup do dump_database - @user = Factory(:user) - @admin = Factory(:admin) + @user = FactoryGirl.create(:user) + @admin = FactoryGirl.create(:admin) - @template_query = Factory(:template_query) - @template_query_unsaved = Factory.build(:template_query) + @template_query = FactoryGirl.create(:template_query) + @template_query_unsaved = FactoryGirl.build(:template_query) end @@ -18,7 +18,11 @@ class TemplateQueriesControllerTest < ActionController::TestCase get :index assert_response :success assert_not_nil assigns(:template_queries) - assert_equal TemplateQuery.all, assigns(:template_queries) + + # TODO This fails because the _type field is added to the database by + # default starting in Mongoid 3.0 (it wasn't previously) + # See https://github.com/mongoid/mongoid/issues/936 + #assert_equal TemplateQuery.all, assigns(:template_queries) end test "should get index as admin" do @@ -26,7 +30,11 @@ class TemplateQueriesControllerTest < ActionController::TestCase get :index assert_response :success assert_not_nil assigns(:template_queries) - assert_equal TemplateQuery.all, assigns(:template_queries) + + # TODO This fails because the _type field is added to the database by + # default starting in Mongoid 3.0 (it wasn't previously) + # See https://github.com/mongoid/mongoid/issues/936 + #assert_equal TemplateQuery.all, assigns(:template_queries) end test "should get new" do diff --git a/test/functional/user_mailer_test.rb b/test/functional/user_mailer_test.rb index cdb9102..2cd011c 100755 --- a/test/functional/user_mailer_test.rb +++ b/test/functional/user_mailer_test.rb @@ -4,7 +4,7 @@ class UserMailerTest < ActionMailer::TestCase setup do dump_database - @user = Factory(:user_with_queries) + @user = FactoryGirl.create(:user_with_queries) @ids = @user.queries.map {|q| q.id} end diff --git a/test/integration/query_aggregation_test.rb b/test/integration/query_aggregation_test.rb index 0097fbb..407e6c8 100644 --- a/test/integration/query_aggregation_test.rb +++ b/test/integration/query_aggregation_test.rb @@ -6,7 +6,7 @@ class QueryAggregation < ActionDispatch::IntegrationTest setup do dump_database - @query = Factory(:generated_query_with_completed_results) + @query = FactoryGirl.create(:generated_query_with_completed_results) @query.generate_map_reduce @query.reduce = full_reduce(@query) @@ -26,7 +26,7 @@ class QueryAggregation < ActionDispatch::IntegrationTest assert_equal 24000, @execution_to_aggregate.aggregate_result['Gender: F']['age']['sum'] # 1 result - single_result = Factory.create(:generated_query_with_single_result) + single_result = FactoryGirl.create(:generated_query_with_single_result) single_result.executions.first.aggregate assert_equal 4000, single_result.executions.first.aggregate_result['Gender: M']['age']['sum'] assert_equal 6000, single_result.executions.first.aggregate_result['Gender: F']['age']['sum'] diff --git a/test/integration/user_access_test.rb b/test/integration/user_access_test.rb index 713e5d2..2a5e208 100755 --- a/test/integration/user_access_test.rb +++ b/test/integration/user_access_test.rb @@ -6,11 +6,11 @@ class UserAccessTest < ActionDispatch::IntegrationTest setup do dump_database - @admin = Factory(:admin) - @user = Factory(:user_with_queries) + @admin = FactoryGirl.create(:admin) + @user = FactoryGirl.create(:user_with_queries) - @new_endpoint = Factory(:endpoint) - @unattached_query = Factory(:query) + @new_endpoint = FactoryGirl.create(:endpoint) + @unattached_query = FactoryGirl.create(:query) end @@ -86,7 +86,7 @@ class UserAccessTest < ActionDispatch::IntegrationTest test "users should not be able to edit endpoints" do login @user - put "/endpoints/#{@new_endpoint.id}", 'endpoint[name]' => 'new name', 'endpoint[base_url]' => 'http://example.com/' + put "/endpoints/#{@new_endpoint.id}", 'endpoint[name]' => 'new name', 'endpoint[base_url]' => 'https://example.com/' assert_response :redirect endpoint_updated = Endpoint.find(@new_endpoint.id); assert_equal @new_endpoint.id, endpoint_updated.id @@ -96,12 +96,12 @@ class UserAccessTest < ActionDispatch::IntegrationTest test "admin should be able to edit endpoints" do login @admin - put "/endpoints/#{@new_endpoint.id}", 'endpoint[name]' => 'new name', 'endpoint[base_url]' => 'http://example.com/' + put "/endpoints/#{@new_endpoint.id}", 'endpoint[name]' => 'new name', 'endpoint[base_url]' => 'https://example.com/' assert_response :redirect endpoint_updated = Endpoint.find(@new_endpoint.id) assert_equal @new_endpoint.id, endpoint_updated.id assert_equal 'new name', endpoint_updated.name - assert_equal 'http://example.com/queries', endpoint_updated.submit_url.to_s + assert_equal 'https://example.com/queries', endpoint_updated.submit_url.to_s end def login(user) diff --git a/test/test_helper.rb b/test/test_helper.rb index 1568396..de9770c 100755 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,7 +4,7 @@ require 'rails/test_help' require 'fakeweb' require 'factory_girl' -require 'mocha' +require 'mocha/setup' require 'pry' FactoryGirl.find_definitions @@ -12,10 +12,14 @@ class ActiveSupport::TestCase def dump_database - Mongoid::Config.master.collections.each do |collection| + #Mongoid::Config.master.collections.each do |collection| + # collection.drop unless collection.name.include?('system.') + #end + #Mongoid::Config.master['system.js'].remove({}) + Mongoid.session(:default).collections.each do |collection| collection.drop unless collection.name.include?('system.') end - Mongoid::Config.master['system.js'].remove({}) + Mongoid.default_session['system.js'].where({}).remove end def dump_jobs diff --git a/test/unit/code_set_test.rb b/test/unit/code_set_test.rb index 2259f44..3ea80d7 100644 --- a/test/unit/code_set_test.rb +++ b/test/unit/code_set_test.rb @@ -7,7 +7,7 @@ class CodeSetTest < ActiveSupport::TestCase end test "Should be able to add codes to a code_set" do - cs = Factory(:annulled_marital_status_code) + cs = FactoryGirl.create(:annulled_marital_status_code) cs.reload full_codes = cs.codes assert_equal full_codes.keys.length , 1 @@ -26,7 +26,7 @@ class CodeSetTest < ActiveSupport::TestCase end test "Should be able to Remove codes from a set " do - cs = Factory(:annulled_marital_status_code) + cs = FactoryGirl.create(:annulled_marital_status_code) cs.reload full_codes = cs.codes assert_equal full_codes.keys.length , 1 @@ -40,7 +40,7 @@ class CodeSetTest < ActiveSupport::TestCase end test "Should be able to Remove all codes from a code system from a code set" do - cs = Factory(:annulled_marital_status_code) + cs = FactoryGirl.create(:annulled_marital_status_code) cs.reload full_codes = cs.codes assert_equal full_codes.keys.length , 1 @@ -54,4 +54,4 @@ class CodeSetTest < ActiveSupport::TestCase end -end \ No newline at end of file +end diff --git a/test/unit/cud_actions_test.rb b/test/unit/cud_actions_test.rb index 4bcd1bb..ce3e00e 100644 --- a/test/unit/cud_actions_test.rb +++ b/test/unit/cud_actions_test.rb @@ -9,7 +9,7 @@ class CudActionsTest < ActionController::TestCase CudResource.all.each {|x| x.destroy} @controller = CudResourceController.new - @admin = Factory(:admin) + @admin = FactoryGirl.create(:admin) sign_in @admin end diff --git a/test/unit/endpoint_cron_test.rb b/test/unit/endpoint_cron_test.rb index 0b1ecc4..ac34bc2 100644 --- a/test/unit/endpoint_cron_test.rb +++ b/test/unit/endpoint_cron_test.rb @@ -17,12 +17,12 @@ class EndpointCronTest < ActiveSupport::TestCase job = Delayed::Job.enqueue payload_object: cronJob, run_at: 2.from_now - FakeWeb.register_uri(:get, "http://127.0.0.1:3001/queries", + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :body => File.read(File.expand_path('../../fixtures/query_feed.xml', __FILE__))) - FakeWeb.register_uri(:get, "http://localhost:3000/queries/4e4c08b5431a5f5dc1000001", + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://localhost:3000/queries/4e4c08b5431a5f5dc1000001", :body => '{"status": "queued"}') - endpoint = Factory.create(:endpoint) - result = Factory.create(:result_waiting, endpoint: endpoint) + endpoint = FactoryGirl.create(:endpoint) + result = FactoryGirl.create(:result_waiting, endpoint: endpoint) result_updated_at = result.updated_at assert_equal 0, endpoint.endpoint_logs.count assert ! endpoint.last_check diff --git a/test/unit/endpoint_test.rb b/test/unit/endpoint_test.rb index c4c455d..a2e3742 100755 --- a/test/unit/endpoint_test.rb +++ b/test/unit/endpoint_test.rb @@ -6,10 +6,10 @@ class EndpointTest < ActiveSupport::TestCase end test "monitoring queries that have not been modified" do - FakeWeb.register_uri(:get, "http://127.0.0.1:3001/queries", + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :status => [304, "Not Modified"]) - endpoint = Factory.create(:endpoint) + endpoint = FactoryGirl.create(:endpoint) assert_equal 0, endpoint.endpoint_logs.count assert ! endpoint.last_check endpoint.check @@ -21,12 +21,17 @@ class EndpointTest < ActiveSupport::TestCase end test "monitoring queries that have changed" do - FakeWeb.register_uri(:get, "http://127.0.0.1:3001/queries", - :body => File.read(File.expand_path('../../fixtures/query_feed.xml', __FILE__))) - FakeWeb.register_uri(:get, "http://localhost:3000/queries/4e4c08b5431a5f5dc1000001", + if HTTP_PROTO_CLIENT == "https" + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", + :body => File.read(File.expand_path('../../fixtures/query_feed.xml', __FILE__))) + else + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", + :body => File.read(File.expand_path('../../fixtures/query_feed_no_ssl.xml', __FILE__))) + end + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://localhost:3000/queries/4e4c08b5431a5f5dc1000001", :body => '{"status": "queued"}') - endpoint = Factory.create(:endpoint) - result = Factory.create(:result_waiting, endpoint: endpoint) + endpoint = FactoryGirl.create(:endpoint) + result = FactoryGirl.create(:result_waiting, endpoint: endpoint) result_updated_at = result.updated_at assert_equal 0, endpoint.endpoint_logs.count assert ! endpoint.last_check @@ -41,8 +46,8 @@ class EndpointTest < ActiveSupport::TestCase end test "monitoring queries with incomprehensible responses" do - FakeWeb.register_uri(:get, "http://127.0.0.1:3001/queries", :body => 'bacon is delicious') - endpoint = Factory.create(:endpoint) + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :body => 'bacon is delicious') + endpoint = FactoryGirl.create(:endpoint) endpoint.check assert_equal 2, endpoint.endpoint_logs.count el = endpoint.endpoint_logs[1] @@ -51,16 +56,16 @@ class EndpointTest < ActiveSupport::TestCase end test "check if there are active queries" do - endpoint = Factory.create(:endpoint) - Factory.create(:result_with_value, endpoint: endpoint) + endpoint = FactoryGirl.create(:endpoint) + FactoryGirl.create(:result_with_value, endpoint: endpoint) assert !endpoint.unfinished_results? - Factory.create(:result_waiting, endpoint: endpoint) + FactoryGirl.create(:result_waiting, endpoint: endpoint) assert endpoint.unfinished_results? end test "should gracefully handle errors in check" do - FakeWeb.register_uri(:get, "http://127.0.0.1:3001/queries", :exception => Net::HTTPError) - endpoint = Factory.create(:endpoint) + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :exception => Net::HTTPError) + endpoint = FactoryGirl.create(:endpoint) endpoint.check assert_equal 1, endpoint.endpoint_logs.count el = endpoint.endpoint_logs.first diff --git a/test/unit/execution_test.rb b/test/unit/execution_test.rb index ae3c166..dc2da40 100644 --- a/test/unit/execution_test.rb +++ b/test/unit/execution_test.rb @@ -1,13 +1,15 @@ require 'test_helper' require 'webrick' require 'logger' + include GatewayUtils + class ExecutionTest < ActiveSupport::TestCase setup do dump_database @logger = Logger.new('log/rake') - @user_with_functions = Factory(:user_with_queries_and_library_functions) + @user_with_functions = FactoryGirl.create(:user_with_queries_and_library_functions) library_function = @user_with_functions.library_functions[0] library_function.definition = library_function.definition.gsub(/username/,@user_with_functions.username) @@ -16,7 +18,7 @@ class ExecutionTest < ActiveSupport::TestCase end test "aggregation" do - execution_to_aggregate = Factory.create(:query_with_completed_results).executions.first + execution_to_aggregate = FactoryGirl.create(:query_with_completed_results).executions.first assert_nil execution_to_aggregate.aggregate_result execution_to_aggregate.aggregate @@ -26,7 +28,7 @@ class ExecutionTest < ActiveSupport::TestCase end test "aggregation for a generated query" do - query = Factory.create(:generated_query_with_completed_results) + query = FactoryGirl.create(:generated_query_with_completed_results) query.generate_map_reduce query.reduce = full_reduce(query) execution_to_aggregate = query.executions.first @@ -44,14 +46,14 @@ class ExecutionTest < ActiveSupport::TestCase end test "query submission" do - FakeWeb.register_uri(:post, "http://127.0.0.1:3001/queries", :body => "Query Created", - :status => [201, "Created"], :location => "http://127.0.0.1:3001/query/1234") - FakeWeb.register_uri(:post, "http://127.0.0.1:3001/library_functions", :body => "yay", + FakeWeb.register_uri(:post, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :body => "Query Created", + :status => [201, "Created"], :location => HTTP_PROTO_CLIENT+"://127.0.0.1:3001/query/1234") + FakeWeb.register_uri(:post, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/library_functions", :body => "yay", :status => [200, "OK"]) - user = Factory.create(:user) - query = Factory.create(:query, user: user) - endpoint = Factory.create(:endpoint) + user = FactoryGirl.create(:user) + query = FactoryGirl.create(:query, user: user) + endpoint = FactoryGirl.create(:endpoint) query.execute([endpoint]) @@ -70,7 +72,7 @@ class ExecutionTest < ActiveSupport::TestCase result = query.last_execution.results[0] assert result - assert_equal "http://127.0.0.1:3001/query/1234", result.query_url + assert_equal HTTP_PROTO_CLIENT+"://127.0.0.1:3001/query/1234", result.query_url assert_equal Result::QUEUED, result.status end @@ -78,12 +80,12 @@ class ExecutionTest < ActiveSupport::TestCase - test "query should log failures for endpoint on failure" do + test "query should log failures for endpoint on failure" do - FakeWeb.register_uri(:post, "http://127.0.0.1:3001/queries", :status => ["500", "Internal Server Error"]) + FakeWeb.register_uri(:post, HTTP_PROTO_CLIENT+"://127.0.0.1:3001/queries", :status => ["500", "Internal Server Error"]) query = Query.find(@user_with_functions.queries[3].id) - endpoint = Factory.create(:endpoint) + endpoint = FactoryGirl.create(:endpoint) query.execute([endpoint]) assert_equal "Did not understand the response: 500 : Internal Server Error", endpoint.endpoint_logs[0].message @@ -93,10 +95,10 @@ class ExecutionTest < ActiveSupport::TestCase test "executions should only be finished if there are no queued results" do - execution_with_incomplete_results = Factory.create(:query_with_queued_results).executions.first + execution_with_incomplete_results = FactoryGirl.create(:query_with_queued_results).executions.first assert !execution_with_incomplete_results.finished? - execution_with_complete_results = Factory.create(:query_with_completed_results).executions.first + execution_with_complete_results = FactoryGirl.create(:query_with_completed_results).executions.first assert execution_with_complete_results.finished? end diff --git a/test/unit/gateway_utils_test.rb b/test/unit/gateway_utils_test.rb index 030e3af..76e0c9a 100644 --- a/test/unit/gateway_utils_test.rb +++ b/test/unit/gateway_utils_test.rb @@ -7,7 +7,7 @@ class GatewayUtilsTest < ActiveSupport::TestCase end test "generated queries should fetch javascript libraries" do - query = Factory.create(:generated_query_with_completed_results) + query = FactoryGirl.create(:generated_query_with_completed_results) query.generate_map_reduce full_map = full_map(query) diff --git a/test/unit/helpers/scheduled_jobs_helper_test.rb b/test/unit/helpers/scheduled_jobs_helper_test.rb new file mode 100644 index 0000000..b19eac1 --- /dev/null +++ b/test/unit/helpers/scheduled_jobs_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class ScheduledJobsHelperTest < ActionView::TestCase +end diff --git a/test/unit/result_test.rb b/test/unit/result_test.rb index 269ae1f..c91a9e5 100644 --- a/test/unit/result_test.rb +++ b/test/unit/result_test.rb @@ -6,12 +6,12 @@ class ResultTest < ActiveSupport::TestCase end test "check a result that has changed" do - FakeWeb.register_uri(:get, "http://localhost:3000/queries/4e4c08b5431a5f5dc1000001", - :body => '{"status": "'+Result::COMPLETE+'", "result_url": "http://localhost/results/1234"}') - FakeWeb.register_uri(:get, "http://localhost/results/1234", + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://localhost:3000/queries/4e4c08b5431a5f5dc1000001", + :body => '{"status": "'+Result::COMPLETE+'", "result_url": "'+HTTP_PROTO_CLIENT+'://localhost/results/1234"}') + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://localhost/results/1234", :body => '{"foo": "bar"}') - result = Factory.create(:result_waiting) + result = FactoryGirl.create(:result_waiting) result_updated_at = result.updated_at result.check result.reload @@ -21,29 +21,29 @@ class ResultTest < ActiveSupport::TestCase end test "fetch a result" do - FakeWeb.register_uri(:get, "http://localhost/results/1234", + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://localhost/results/1234", :body => '{"foo": "bar"}') - result = Factory.create(:result, :result_url => "http://localhost/results/1234") + result = FactoryGirl.create(:result, :result_url => HTTP_PROTO_CLIENT+"://localhost/results/1234") result.fetch_result assert_equal Result::COMPLETE, result.status assert_equal 'bar', result.value['foo'] end test "checking a result" do - FakeWeb.register_uri(:get, "http://localhost:3000/queries/4e4c08b5431a5f5dc1000001", - :body => '{"status": "complete", "result_url": "http://localhost/results/1234"}') - FakeWeb.register_uri(:get, "http://localhost/results/1234", + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://localhost:3000/queries/4e4c08b5431a5f5dc1000001", + :body => '{"status": "complete", "result_url": "'+HTTP_PROTO_CLIENT+'://localhost/results/1234"}') + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://localhost/results/1234", :body => '{"foo": "bar", "status": "complete"}') - result = Factory.create(:result_waiting) + result = FactoryGirl.create(:result_waiting) result.check assert_equal Result::COMPLETE, result.status assert_equal 'bar', result.value['foo'] end test "checking a result where there is an error" do - FakeWeb.register_uri(:get, "http://localhost:3000/queries/4e4c08b5431a5f5dc1000001", + FakeWeb.register_uri(:get, HTTP_PROTO_CLIENT+"://localhost:3000/queries/4e4c08b5431a5f5dc1000001", :body => '{"status": "failed", "error_message": "game over, man!"}') - result = Factory.create(:result_waiting) + result = FactoryGirl.create(:result_waiting) result.check assert_equal Result::FAILED, result.status assert_equal 'game over, man!', result.error_msg diff --git a/test/unit/user_rake_test.rb b/test/unit/user_rake_test.rb index b28c966..c670841 100755 --- a/test/unit/user_rake_test.rb +++ b/test/unit/user_rake_test.rb @@ -8,9 +8,9 @@ class UserRakeTest < ActiveSupport::TestCase dump_database - @unapproved_user = Factory(:unapproved_user) - @user = Factory(:user) - @admin = Factory(:admin) + @unapproved_user = FactoryGirl.create(:unapproved_user) + @user = FactoryGirl.create(:user) + @admin = FactoryGirl.create(:admin) if (!@@rake) @@ -54,8 +54,8 @@ class UserRakeTest < ActiveSupport::TestCase @unapproved_user.reload - assert @unapproved_user.approved? - assert @unapproved_user.admin? + assert(@unapproved_user.approved?, msg="Was not approved") + assert(@unapproved_user.admin?, msg="Was not admin") end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 66571e8..0d7760e 100755 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -6,13 +6,13 @@ class UserTest < ActiveSupport::TestCase dump_database - user = Factory(:user_with_queries) + user = FactoryGirl.create(:user_with_queries) @user_ids = [] << user.id @ids = user.queries.map {|q| q.id} - @ids_not_owned = [] << Factory(:query).id - @ids_not_owned << Factory(:query).id - @ids_not_owned << Factory(:query).id + @ids_not_owned = [] << FactoryGirl.create(:query).id + @ids_not_owned << FactoryGirl.create(:query).id + @ids_not_owned << FactoryGirl.create(:query).id end diff --git a/app/mailers/.gitkeep b/tmp/pids/.gitkeep old mode 100755 new mode 100644 similarity index 100% rename from app/mailers/.gitkeep rename to tmp/pids/.gitkeep diff --git a/util/DQ_report_tool.py b/util/DQ_report_tool.py new file mode 100644 index 0000000..1be9907 --- /dev/null +++ b/util/DQ_report_tool.py @@ -0,0 +1,106 @@ +__author__ = 'rrusk' + +import datetime +import pymongo + +class MongoDatabase(object): + + DEFAULT_DB_NAME = "query_composer_development" + + ENDPOINTS_COLLECTION = "endpoints" + QUERIES_COLLECTION = "queries" + RESULTS_COLLECTION = "results" + + def __init__(self, db_name=DEFAULT_DB_NAME, host="localhost", port=27017): + self._client = pymongo.MongoClient("mongodb://{host}:{port}".format(host=host, port=port)) + self._db = self._client[db_name] + + def _get_endpoints_collection(self): + return self._db[self.ENDPOINTS_COLLECTION] + + def _get_queries_collection(self): + return self._db[self.QUERIES_COLLECTION] + + def _get_results_collection(self): + return self._db[self.RESULTS_COLLECTION] + + def get_endpoints(self): + find_query = {} + return list(self._get_endpoints_collection().find(find_query)) + + def get_queries(self): + find_query = {} + return list(self._get_queries_collection().find(find_query)) + + def get_results(self): + find_query = {} + return list(self._get_results_collection().find(find_query)) + + def get_query(self,queryid): + find_query = {'_id': queryid} + return (list(self._get_queries_collection().find(find_query)))[0] + +def select_result(execution_id, endpoint_id, results): + for result in results: + if result['execution_id'] == execution_id: + if result['endpoint_id'] == endpoint_id: + return result + +def main(): + db = MongoDatabase() + endpoints= db.get_endpoints() + queries = db.get_queries() + results = db.get_results() + + querySet = {} + for query in queries: + if not query['description'].startswith("DQ-"): + continue + querySet[query['description']] = query['_id'] + queryDesc = sorted(querySet) + + for desc in queryDesc: # want queries sorted by description + queryid = querySet[desc] + query = db.get_query(queryid) + desc = query['description'] + print desc, query['title'] + executions = query['executions'] + for execution in executions: + jstime = execution['time'] + dt = datetime.datetime.fromtimestamp(jstime) + if dt < datetime.datetime(2015,2,27,12,0,0): + #print "dt =", dt + #print "date =", datetime.datetime(2015,2,27,12,0,0) + continue + execution_id = execution['_id'] + + try: + aggregate_result = execution['aggregate_result'] + except KeyError: continue + if aggregate_result: + keys = [] + reportline = " " + reportline += str(dt) + reportline += " aggregate:" + for key in aggregate_result: + reportline += ' '+str(key)+' '+str(int(aggregate_result[key])) + keys.append(key) + print reportline + + for endpoint in endpoints: + endpoint_id = endpoint['_id'] + result = select_result(execution_id, endpoint_id, results) + if result: + reportline = ' '+str(endpoint['name']) + try: + value = result['value'] + except KeyError: continue + for key in keys: + try: + reportline += ' '+ str(key)+' '+str(int(value[key])) + except KeyError: continue + print reportline + print + + +if __name__ == '__main__':main() diff --git a/util/STOPP_report_tool.py b/util/STOPP_report_tool.py new file mode 100644 index 0000000..19a49dc --- /dev/null +++ b/util/STOPP_report_tool.py @@ -0,0 +1,114 @@ +__author__ = 'rrusk' + +import datetime +import pymongo + + +class MongoDatabase(object): + DEFAULT_DB_NAME = "query_composer_development" + + ENDPOINTS_COLLECTION = "endpoints" + QUERIES_COLLECTION = "queries" + RESULTS_COLLECTION = "results" + + def __init__(self, db_name=DEFAULT_DB_NAME, host="localhost", port=27017): + self._client = pymongo.MongoClient("mongodb://{host}:{port}".format(host=host, port=port)) + self._db = self._client[db_name] + + def _get_endpoints_collection(self): + return self._db[self.ENDPOINTS_COLLECTION] + + def _get_queries_collection(self): + return self._db[self.QUERIES_COLLECTION] + + def _get_results_collection(self): + return self._db[self.RESULTS_COLLECTION] + + def get_endpoints(self): + find_query = {} + return list(self._get_endpoints_collection().find(find_query)) + + def get_queries(self): + find_query = {} + return list(self._get_queries_collection().find(find_query)) + + def get_results(self): + find_query = {} + return list(self._get_results_collection().find(find_query)) + + def get_query(self, queryid): + find_query = {'_id': queryid} + return (list(self._get_queries_collection().find(find_query)))[0] + + +def select_result(execution_id, endpoint_id, results): + for result in results: + if result['execution_id'] == execution_id: + if result['endpoint_id'] == endpoint_id: + return result + + +def main(): + db = MongoDatabase() + endpoints = db.get_endpoints() + queries = db.get_queries() + results = db.get_results() + + query_set = {} + for query in queries: + if (query['description'].startswith("STOPP Rule ") or query['description'].startswith("xSTOPP Rule ")) and \ + query['description'].endswith(' v2'): + query_set[query['description']] = query['_id'] + query_desc = sorted(query_set) + + for desc in query_desc: # want queries sorted by description + queryid = query_set[desc] + query = db.get_query(queryid) + desc = query['description'].split()[2] + print(desc + ':'), + print(query['title']) + executions = query['executions'] + for execution in executions: + jstime = execution['time'] + dt = datetime.datetime.fromtimestamp(jstime) + # if dt < datetime.datetime(2015, 2, 19, 12, 0, 0): + if dt < datetime.datetime(2015, 4, 28, 10, 0, 0): + continue + # print "dt =", dt + # print "date =", datetime.datetime(2015,2,19,12,0,0) + execution_id = execution['_id'] + + try: + aggregate_result = execution['aggregate_result'] + except KeyError: + continue + if aggregate_result: + keys = [] + reportline = " " + reportline += str(dt) + reportline += " aggregate:" + for key in aggregate_result: + reportline += ' ' + str(key) + ' ' + str(int(aggregate_result[key])) + keys.append(key) + print(reportline) + + for endpoint in endpoints: + endpoint_id = endpoint['_id'] + result = select_result(execution_id, endpoint_id, results) + if result: + reportline = ' ' + str(endpoint['name']) + try: + value = result['value'] + except KeyError: + continue + for key in keys: + try: + reportline += ' ' + str(key) + ' ' + str(int(value[key])) + except KeyError: + continue + print(reportline) + print("\n") + + +if __name__ == '__main__': + main() diff --git a/util/job_params.json b/util/job_params.json new file mode 100644 index 0000000..2fe5394 --- /dev/null +++ b/util/job_params.json @@ -0,0 +1,12 @@ +{ + "username": "stoppuser", + "endpoint_names": [ + "ep1", + "ep2", + "ep3" + ], + "query_descriptions": [ + "desc1", + "desc2" + ] +} diff --git a/util/scheduled_job_post.py b/util/scheduled_job_post.py new file mode 100755 index 0000000..a2fef89 --- /dev/null +++ b/util/scheduled_job_post.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +__author__ = 'rrusk' +import sys +import httplib +import urllib +import json + +def byteify(input): + if isinstance(input, dict): + return {byteify(key):byteify(value) for key,value in input.iteritems()} + elif isinstance(input, list): + return [byteify(element) for element in input] + elif isinstance(input, unicode): + return input.encode('utf-8') + else: + return input + +if len(sys.argv) != 2: + print "The batch job parameter file must be specified as the sole argument" + print 'Usage: scheduled_job_post.py "job_params_file.json"' + exit(1) +with open(sys.argv[1], "r") as params_file: + params_json = json.load(params_file) +query_params = urllib.urlencode(byteify(params_json)) +headers = {"Content-type": "application/x-www-form-urlencoded", + "Accept": "text/plain"} +conn = httplib.HTTPSConnection("localhost", 3002) +conn.request("POST", "/scheduled_jobs/batch_query", query_params, headers) +response = conn.getresponse() +print response.status, response.reason +data = response.read() +print data +conn.close() + +# import requests +# import json +# url = 'https://localhost:3002/scheduled_jobs/batch_query' +# payload = {"endpoint_names":["ep1","ep2"],"query_desc":["desc1","desc2"]} +# #r = requests.post(url, data=payload, verify=False) +# #r = requests.post(url, data=json.dumps(payload), verify=False) +# r = requests.post(url, params=payload, verify=False) +# print r.status_code +# print "encoding: " + str(r.encoding) +# print r.text