diff --git a/Gemfile.lock b/Gemfile.lock index 7120442..be1ed8a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - cdris_api_client (3.4.0dev0.09) + cdris_api_client (3.5.0dev0.01) activesupport (~> 3.0) api-auth (= 1.4.1) mime-types (< 2.99) @@ -104,4 +104,4 @@ DEPENDENCIES yard (= 0.8.7) BUNDLED WITH - 1.12.5 + 1.13.1 diff --git a/lib/cdris/gateway/patient_document.rb b/lib/cdris/gateway/patient_document.rb index e0f8599..36fc65b 100644 --- a/lib/cdris/gateway/patient_document.rb +++ b/lib/cdris/gateway/patient_document.rb @@ -196,6 +196,23 @@ def search(options = {}) .to_hash end + # Searches for documents + # + # @param [String] search_term specify what to search for + # @param [Hash] options specify query values + # @return [Hash] the patient's document metadata + # @raise [Cdris::Gateway::Exceptions::BadRequestError] when CDRIS returns a 400 status + # @raise [Cdris::Gateway::Exceptions::InvalidTenantOperation] when CDRIS returns a 403 status + # @raise [Cdris::Gateway::Exceptions::PatientDocumentNotFoundError] when CDRIS returns a 404 status + def literal_search(search_term, options = {}) + path = "#{api}/patient_document/search" + request(path, options.merge(literal: search_term)) + .if_400_raise(Cdris::Gateway::Exceptions::BadRequestError) + .if_403_raise(Cdris::Gateway::Exceptions::InvalidTenantOperation) + .if_404_raise(Cdris::Gateway::Exceptions::PatientDocumentNotFoundError) + .to_hash + end + # Gets a patient document cluster # # @param [Hash] params specify what patient to get, must specify either `:id` or `:root` and `extension` diff --git a/lib/cdris/gateway/version.rb b/lib/cdris/gateway/version.rb index 830c5fe..db1bf68 100644 --- a/lib/cdris/gateway/version.rb +++ b/lib/cdris/gateway/version.rb @@ -1,5 +1,5 @@ module Cdris module Gateway - VERSION = '3.4.0dev0.09'.freeze + VERSION = '3.5.0dev0.01'.freeze end end diff --git a/spec/cdris/gateway/patient_document_spec.rb b/spec/cdris/gateway/patient_document_spec.rb index ab9938a..9c5c2fe 100644 --- a/spec/cdris/gateway/patient_document_spec.rb +++ b/spec/cdris/gateway/patient_document_spec.rb @@ -684,6 +684,20 @@ end + describe 'self.literal_search' do + + FakeWeb.register_uri( + :get, + 'http://testhost:4242/api/v1/patient_document/search?literal=FizzBuzz&user%5Bextension%5D=spameggs&user%5Broot%5D=foobar', + body: DataSamples.patient_document_search.to_s) + + it 'requests and returns the expected patient document literal search' do + expect(described_class.literal_search('FizzBuzz', { user: { root: 'foobar', extension: 'spameggs' } } + )).to eq(DataSamples.patient_document_search.to_hash) + end + + end + describe 'self.cluster' do FakeWeb.register_uri(