Skip to content

Commit

Permalink
CDRIS-4230-display-ingestion-error-payload
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanRMeyer committed Mar 28, 2019
1 parent 6b67aca commit d9756ed
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 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 (4.5.0dev0.00)
cdris_api_client (4.5.0dev0.01)
activesupport (~> 3.0)
api-auth (= 1.4.1)
mime-types (< 2.99)
Expand Down Expand Up @@ -111,4 +111,4 @@ DEPENDENCIES
yard (= 0.8.7)

BUNDLED WITH
1.14.6
1.16.1
16 changes: 15 additions & 1 deletion lib/cdris/gateway/patient_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def delete(patient_document_id, options = {})
end



# Gets a list of ingestion errors
#
# @param [Hash] params specify which root to get `:root` (optional)
Expand All @@ -198,6 +197,21 @@ def ingestion_errors(params, options = {})
.to_hash
end

# Gets an ingestion error by id
#
# @param [Hash] params specify which id to get `:id`
# @param [Hash] options specify query values
# @return payload of an ingestion error
# @raise [Exceptions::BadRequestError] when CDRIS returns a 4xx status
def ingestion_error_by_id(params, options = {})
path = "#{api(options)}/patient_document/ingestion_error"
path << "/#{params[:id]}" if params[:id]
request(path, options)
.if_400_raise(Cdris::Gateway::Exceptions::BadRequestError)
.if_403_raise(Cdris::Gateway::Exceptions::InvalidTenantOperation)
.to_hash
end

# Gets a list of a hl7 document ids
#
# @param [Hash] params specify which documents to get, must specify `:root`
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 = '4.5.0dev0.00'.freeze
VERSION = '4.5.0dev0.01'.freeze
end
end
19 changes: 18 additions & 1 deletion spec/cdris/gateway/patient_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
'http://testhost:4242/api/v1/patient_document/ingestion_errors?user%5Bextension%5D=spameggs&user%5Broot%5D=foobar',
body: DataSamples.ingestion_errors.to_s)

it 'requests and returns the expected patient cluster' do
it 'requests and returns the list of ingestion errors' do
expect(described_class.ingestion_errors(
{}, {
user: { root: 'foobar', extension: 'spameggs' }
Expand All @@ -496,6 +496,23 @@

end

describe 'self.ingestion_error_by_id' do

FakeWeb.register_uri(
:get,
'http://testhost:4242/api/v1/patient_document/ingestion_error?user%5Bextension%5D=spameggs&user%5Broot%5D=foobar',
body: DataSamples.ingestion_error.to_s)

it 'requests and returns the ingestion error by id' do
expect(described_class.ingestion_error_by_id(
{}, {
user: { root: 'foobar', extension: 'spameggs' }
})).to eq(DataSamples.ingestion_error.to_hash)
end

end


describe 'self.base_uri' do

context 'when id, root and extension are not given' do
Expand Down
8 changes: 8 additions & 0 deletions spec/fixtures/sample_ingestion_error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"id" :"1",
"created_at" : "2018-12-13T21:39:14.497Z",
"patient_document_root" : "root.d",
"error_response_reason" : "{\"data_format\":[\"can't be blank\",\"is not included in the list\"],\"source_last_modified_at\":[\"can't be blank\"]}"
}
]
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ def self.ingestion_errors
self
end

def self.ingestion_error
read_fixture('sample_ingestion_error.json')
self
end

def self.info_deployments
read_fixture('sample_info_deployments.json')
self
Expand Down

0 comments on commit d9756ed

Please sign in to comment.