Skip to content

Commit

Permalink
[CDRIS-3170] Literal search over all documents. RB:EH
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Bates authored and ehinterlang committed Dec 2, 2016
1 parent 79d26a5 commit e46fbc4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -104,4 +104,4 @@ DEPENDENCIES
yard (= 0.8.7)

BUNDLED WITH
1.12.5
1.13.1
17 changes: 17 additions & 0 deletions lib/cdris/gateway/patient_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion lib/cdris/gateway/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Cdris
module Gateway
VERSION = '3.4.0dev0.09'.freeze
VERSION = '3.5.0dev0.01'.freeze
end
end
14 changes: 14 additions & 0 deletions spec/cdris/gateway/patient_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit e46fbc4

Please sign in to comment.