Skip to content

Commit

Permalink
[cdris-4228]display ingestion errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanying (Elsa) Huang committed Jan 14, 2019
1 parent 3ef49d6 commit eeb0e62
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
cdris_api_client (4.4.0dev0.03)
cdris_api_client (4.4.0dev0.04)
activesupport (~> 3.0)
api-auth (= 1.4.1)
mime-types (< 2.99)
Expand Down
17 changes: 17 additions & 0 deletions lib/cdris/gateway/patient_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,23 @@ def delete(patient_document_id, options = {})
.to_hash
end



# Gets a list of ingestion errors
#
# @param [Hash] params specify which root to get `:root` (optional)
# @param [Hash] options specify query values
# @return [Array] the ingestion erros
# @raise [Exceptions::BadRequestError] when CDRIS returns a 4xx status
def ingestion_errors(params, options = {})
path = "#{api(options)}/patient_document/ingestion_errors"
path << "/#{params[:root]}" if params[:root]
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.4.0dev0.03'.freeze
VERSION = '4.4.0dev0.04'.freeze
end
end
16 changes: 16 additions & 0 deletions spec/cdris/gateway/patient_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,22 @@

end

describe 'self.ingestion_errors' do

FakeWeb.register_uri(
:get,
'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
expect(described_class.ingestion_errors(
{}, {
user: { root: 'foobar', extension: 'spameggs' }
})).to eq(DataSamples.ingestion_errors.to_hash)
end

end

describe 'self.base_uri' do

context 'when id, root and extension are not given' do
Expand Down
14 changes: 14 additions & 0 deletions spec/fixtures/sample_ingestion_errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"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\"]}"
},
{
"id" :"1",
"created_at" : "2018-12-13T21:22: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 @@ -113,6 +113,11 @@ def self.cdris_create_patient_document_error
self
end

def self.ingestion_errors
read_fixture('sample_ingestion_errors.json')
self
end

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

0 comments on commit eeb0e62

Please sign in to comment.