daisybill_api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e8269993c99548a07b1677f02fe24b0adeaaecc
4
- data.tar.gz: db4a9a11d1b9809c664d96e85c4d06e65422fd79
3
+ metadata.gz: 0abccdc5a2212a74a5b2b18892ab3dd689add83a
4
+ data.tar.gz: d716e83dfd7c5bb3645dacb41b93976394214f6d
5
5
  SHA512:
6
- metadata.gz: ff52d15f1e5243952fe6dd7b479ca0e06a1b552891bae4da761a1187cfd6537e0baadf7d0260d14d7579f5fd601a720dc29c62f5d3a7b46fd1971dd107f7821f
7
- data.tar.gz: c3318559d318c167a6fe403d5e72681ead3541751a5152e85d491a260f899bebfaa32f0db4396ee010ff444657be8b3151421017121456becfcb4d6f9a094b4a
6
+ metadata.gz: b93853d2c9774511620a43832e96ebe653c7602f48ca75dbb69614aedbb831f0174fe0b8e7f05c1d9678e055d583e304182bbe0da74f1f5ef21641ee23458852
7
+ data.tar.gz: 4f5be29dfc21dd1c313936c9875f61556af5e42e4bbc6a4d9d532fadf401393225c0c93e6c0a248f4d1055fe33cf75c0258003148618284133c653e0744ee36f
@@ -5,14 +5,16 @@ module DaisybillApi
5
5
  # @private
6
6
  module Data
7
7
  class Client
8
- class InternalServerError < Exception; end
9
-
10
- class UnauthorizedError < Exception; end
8
+ class BasicError < Exception; end
9
+ class InternalServerError < BasicError; end
10
+ class UnauthorizedError < BasicError; end
11
+ class InvalidParams < BasicError; end
11
12
 
12
13
  def self.build(method, path, params = {})
13
14
  client = new method, path, params
14
15
  raise InternalServerError.new(client.response['error']) if client.error?
15
16
  raise UnauthorizedError.new(client.response['error']) if client.unauthorized?
17
+ raise InvalidParams.new(client.response['error']) if client.forbidden?
16
18
  client
17
19
  end
18
20
 
@@ -58,6 +60,10 @@ module DaisybillApi
58
60
  status == '404'
59
61
  end
60
62
 
63
+ def forbidden?
64
+ status == '403'
65
+ end
66
+
61
67
  def error?
62
68
  status == '500'
63
69
  end
@@ -3,6 +3,7 @@ require 'daisybill_api/ext/crud/create'
3
3
  require 'daisybill_api/ext/crud/show'
4
4
  require 'daisybill_api/ext/crud/update'
5
5
  require 'daisybill_api/ext/crud/destroy'
6
+ require 'daisybill_api/ext/crud/search'
6
7
 
7
8
  module DaisybillApi
8
9
  module Ext
@@ -64,6 +65,10 @@ module DaisybillApi
64
65
  end
65
66
  end
66
67
 
68
+ def search_path(prefix_id)
69
+ "#{index_path(prefix_id)}/search"
70
+ end
71
+
67
72
  def client(method, path, params = {})
68
73
  DaisybillApi::Data::Client.build method, path, params
69
74
  end
@@ -0,0 +1,41 @@
1
+ module DaisybillApi
2
+ module Ext
3
+ module CRUD
4
+ module Search
5
+ module ClassMethods
6
+ # Retrieves a list of records
7
+ #
8
+ # @patients = DaisybillApi::Models::Patient.search(billing_provider_id: 2)
9
+ # # => #<DaisybillApi::Ext::PageableCollection>
10
+ #
11
+ # @param [Hash] options
12
+ # @return [Object] a {DaisybillApi::Ext::PageableCollection PageableCollection} that includes Enumerable
13
+ def search(options = {})
14
+ id = options[@prefix_property]
15
+ c = client(:get, search_path(id), options)
16
+
17
+ if c.success?
18
+ DaisybillApi::Ext::PageableCollection.new(
19
+ c.response[plural_key.to_s].map { |attributes|
20
+ instance = new(attributes)
21
+ instance.send("#{prefix_property}=", id) if path_prefix?
22
+ instance
23
+ },
24
+ {
25
+ headers: c.headers,
26
+ params: options,
27
+ resource_class: self
28
+ }
29
+ )
30
+ else
31
+ DaisybillApi::Ext::PageableCollection.new([])
32
+ end
33
+ end
34
+ end
35
+
36
+ # @private
37
+ module InstanceMethods; end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -2,6 +2,7 @@ require 'daisybill_api/models/address'
2
2
  require 'daisybill_api/models/contact'
3
3
  require 'daisybill_api/models/base'
4
4
  require 'daisybill_api/models/claims_administrator'
5
+ require 'daisybill_api/models/payer'
5
6
  require 'daisybill_api/models/bill_submission'
6
7
  require 'daisybill_api/models/billing_provider'
7
8
  require 'daisybill_api/models/employer'
@@ -11,6 +12,7 @@ require 'daisybill_api/models/place_of_service'
11
12
  require 'daisybill_api/models/referring_provider'
12
13
  require 'daisybill_api/models/rendering_provider'
13
14
  require 'daisybill_api/models/attachment'
15
+ require 'daisybill_api/models/billing_provider_attachment'
14
16
  require 'daisybill_api/models/service_line_item'
15
17
  require 'daisybill_api/models/bill'
16
18
  require 'daisybill_api/models/bill_payment'
@@ -8,6 +8,11 @@ module DaisybillApi
8
8
  id: :integer,
9
9
  document_url: :string,
10
10
  inactive: :boolean,
11
+ review_status: :string,
12
+ review_errors: [:string],
13
+ document_file_name: :string,
14
+ document_content_type: :string,
15
+ document_file_size: :integer,
11
16
  readonly: true
12
17
  )
13
18
 
@@ -20,6 +20,7 @@ module DaisybillApi
20
20
  has_many :rendering_providers, class: 'RenderingProvider'
21
21
  has_many :referring_providers, class: 'ReferringProvider'
22
22
  has_many :places_of_service, class: 'PlaceOfService'
23
+ has_many :attachments, class: 'BillingProviderAttachment'
23
24
  end
24
25
  end
25
26
  end
@@ -0,0 +1,25 @@
1
+ module DaisybillApi
2
+ module Models
3
+ class BillingProviderAttachment < DaisybillApi::Models::Base
4
+ rest_actions :index
5
+ self.path = '/attachments'
6
+ path_prefix '/billing_providers', :billing_provider_id
7
+
8
+ attributes(
9
+ id: :integer,
10
+ document_url: :string,
11
+ inactive: :boolean,
12
+ review_status: :string,
13
+ review_errors: [:string],
14
+ document_file_name: :string,
15
+ document_content_type: :string,
16
+ document_file_size: :integer,
17
+ report_type: :string,
18
+ document: :attachment,
19
+ readonly: true
20
+ )
21
+
22
+ link :bill, class: 'Bill'
23
+ end
24
+ end
25
+ end
@@ -6,8 +6,11 @@ module DaisybillApi
6
6
  attributes(
7
7
  id: :integer,
8
8
  name: :string,
9
+ description: :string,
9
10
  readonly: true
10
11
  )
12
+
13
+ has_many :payers, class: 'Payer'
11
14
  end
12
15
  end
13
16
  end
@@ -2,7 +2,7 @@ module DaisybillApi
2
2
  module Models
3
3
  class Patient < DaisybillApi::Models::Base
4
4
  path_prefix '/billing_providers', :billing_provider_id
5
- rest_actions :index, :show, :create, :update, :destroy
5
+ rest_actions :index, :show, :create, :update, :destroy, :search
6
6
 
7
7
  attributes(
8
8
  id: :integer,
@@ -0,0 +1,16 @@
1
+ module DaisybillApi
2
+ module Models
3
+ class Payer < DaisybillApi::Models::Base
4
+ path_prefix '/claims_administrators', :claims_administrator_id
5
+ rest_actions :index
6
+
7
+ attributes(
8
+ id: :integer,
9
+ name: :string,
10
+ description: :string,
11
+ main: :boolean,
12
+ readonly: true
13
+ )
14
+ end
15
+ end
16
+ end
@@ -20,7 +20,8 @@ module DaisybillApi
20
20
  diagnosis_code_2: :string,
21
21
  diagnosis_code_3: :string,
22
22
  diagnosis_code_4: :string,
23
- custom_unit_charge_cents: :integer
23
+ custom_unit_charge_cents: :integer,
24
+ _destroy: :boolean
24
25
  )
25
26
  end
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module DaisybillApi
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -33,6 +33,13 @@ describe DaisybillApi::Data::Client, :vcr do
33
33
  it_behaves_like 'returned error with status', '401'
34
34
  end
35
35
 
36
+ context 'when invalid params' do
37
+ let(:params) { { created_on: 'invalid' } }
38
+ let(:path) { '/invalid/params' }
39
+
40
+ it_behaves_like 'returned error with status', '403'
41
+ end
42
+
36
43
  context 'when record was not found' do
37
44
  let(:path) { '/billing_providers/unknown-id' }
38
45
 
@@ -44,4 +51,52 @@ describe DaisybillApi::Data::Client, :vcr do
44
51
 
45
52
  it_behaves_like 'returned error with status', '500'
46
53
  end
54
+
55
+ context '.build' do
56
+ subject { -> { described_class.build :method, '/path' } }
57
+ let(:status) { 200 }
58
+ let(:message) { '' }
59
+
60
+ before do
61
+ client = doubled_client(status, { 'error' => message })
62
+ allow(DaisybillApi::Data::Client).to receive(:new).and_return(client)
63
+ end
64
+
65
+ it { is_expected.not_to raise_error }
66
+
67
+ context 'when bad request' do
68
+ let(:status) { 400 }
69
+ let(:message) { 'invalid record' }
70
+
71
+ it { is_expected.not_to raise_error }
72
+ end
73
+
74
+ context 'when unauthorized' do
75
+ let(:status) { 401 }
76
+ let(:message) { 'invalid or missed api token' }
77
+
78
+ it { is_expected.to raise_error(DaisybillApi::Data::Client::UnauthorizedError).with_message(message) }
79
+ end
80
+
81
+ context 'when forbidden' do
82
+ let(:status) { 403 }
83
+ let(:message) { 'invalid params or incorrect url endpoint' }
84
+
85
+ it { is_expected.to raise_error(DaisybillApi::Data::Client::InvalidParams).with_message(message) }
86
+ end
87
+
88
+ context 'when page not found' do
89
+ let(:status) { 404 }
90
+ let(:response) { { error: 'Record Not Found' } }
91
+
92
+ it { is_expected.to_not raise_error }
93
+ end
94
+
95
+ context 'when internal server error' do
96
+ let(:status) { 500 }
97
+ let(:message) { 'Internal Server Error' }
98
+
99
+ it { is_expected.to raise_error(DaisybillApi::Data::Client::InternalServerError).with_message(message) }
100
+ end
101
+ end
47
102
  end
@@ -2,7 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  describe DaisybillApi::Models::Attachment do
4
4
  it_behaves_like DaisybillApi::Ext::Attributes, :id, :document_url, :inactive, :report_type, :document,
5
- :bill_id, :created_at, :updated_at
5
+ :bill_id, :created_at, :updated_at, :review_status, :document_file_name,
6
+ :document_content_type, :document_file_size, review_errors: :collection
7
+
6
8
  it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :report_type, :document, :bill_id
7
9
  it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, :update, :destroy, '/attachments', bill_id: '/bills'
8
10
  it_behaves_like DaisybillApi::Ext::Links, bill: DaisybillApi::Models::Bill
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::BillingProviderAttachment do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :document_url, :inactive, :report_type, :document,
5
+ :billing_provider_id, :bill_id, :created_at, :updated_at, :review_status, :document_file_name,
6
+ :document_content_type, :document_file_size, review_errors: :collection
7
+
8
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, '/attachments', billing_provider_id: '/billing_providers'
9
+ it_behaves_like DaisybillApi::Ext::Links, bill: DaisybillApi::Models::Bill
10
+ end
@@ -9,5 +9,6 @@ describe DaisybillApi::Models::BillingProvider do
9
9
  it_behaves_like DaisybillApi::Ext::Associations, :rendering_providers
10
10
  it_behaves_like DaisybillApi::Ext::Associations, :referring_providers
11
11
  it_behaves_like DaisybillApi::Ext::Associations, :places_of_service
12
+ it_behaves_like DaisybillApi::Ext::Associations, :attachments
12
13
  it_behaves_like DaisybillApi::Ext::Links
13
14
  end
@@ -1,7 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DaisybillApi::Models::ClaimsAdministrator do
4
- it_behaves_like DaisybillApi::Ext::Attributes, :id, :name, :created_at, :updated_at
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :name, :created_at, :updated_at, :description
5
5
  it_behaves_like DaisybillApi::Ext::Attributes::SendAs
6
+ it_behaves_like DaisybillApi::Ext::Associations, :payers
6
7
  it_behaves_like DaisybillApi::Ext::CRUD, :all, '/claims_administrators'
7
8
  end
@@ -7,7 +7,7 @@ describe DaisybillApi::Models::Patient do
7
7
  it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :first_name, :last_name, :gender, :date_of_birth,
8
8
  :ssn, :address_attributes, :suffix, :middle_initial, :practice_internal_id, :telephone,
9
9
  :billing_provider_id
10
- it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, :update, :destroy, '/patients',
10
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, :update, :destroy, :search, '/patients',
11
11
  billing_provider_id: '/billing_providers'
12
12
  it_behaves_like DaisybillApi::Ext::Associations, :injuries
13
13
  it_behaves_like DaisybillApi::Ext::Links, billing_provider: DaisybillApi::Models::BillingProvider
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::Payer do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :name, :description, :main, :claims_administrator_id,
5
+ :created_at, :updated_at
6
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs
7
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, '/payers', claims_administrator_id: '/claims_administrators'
8
+ end
@@ -4,8 +4,8 @@ describe DaisybillApi::Models::ServiceLineItem do
4
4
  it_behaves_like DaisybillApi::Ext::Attributes, :id, :units, :supplemental_data, :procedure_code,
5
5
  :diagnosis_code_1, :diagnosis_code_2, :diagnosis_code_3, :diagnosis_code_4, :charge_cents,
6
6
  :expected_payment_cents, :allowed_cents, :balance_due_cents, :write_off_cents, :created_at,
7
- :updated_at, :custom_unit_charge_cents, modifier_codes: :collection
7
+ :updated_at, :custom_unit_charge_cents, :_destroy, modifier_codes: :collection
8
8
  it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :id, :procedure_code, :units, :supplemental_data,
9
9
  :diagnosis_code_1, :diagnosis_code_2, :diagnosis_code_3, :diagnosis_code_4, :custom_unit_charge_cents,
10
- :modifier_codes
10
+ :_destroy, :modifier_codes
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daisybill_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Liscio
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-10-26 00:00:00.000000000 Z
13
+ date: 2016-04-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
@@ -190,6 +190,7 @@ files:
190
190
  - lib/daisybill_api/ext/crud/create.rb
191
191
  - lib/daisybill_api/ext/crud/destroy.rb
192
192
  - lib/daisybill_api/ext/crud/index.rb
193
+ - lib/daisybill_api/ext/crud/search.rb
193
194
  - lib/daisybill_api/ext/crud/show.rb
194
195
  - lib/daisybill_api/ext/crud/update.rb
195
196
  - lib/daisybill_api/ext/links.rb
@@ -203,11 +204,13 @@ files:
203
204
  - lib/daisybill_api/models/bill_payment.rb
204
205
  - lib/daisybill_api/models/bill_submission.rb
205
206
  - lib/daisybill_api/models/billing_provider.rb
207
+ - lib/daisybill_api/models/billing_provider_attachment.rb
206
208
  - lib/daisybill_api/models/claims_administrator.rb
207
209
  - lib/daisybill_api/models/contact.rb
208
210
  - lib/daisybill_api/models/employer.rb
209
211
  - lib/daisybill_api/models/injury.rb
210
212
  - lib/daisybill_api/models/patient.rb
213
+ - lib/daisybill_api/models/payer.rb
211
214
  - lib/daisybill_api/models/place_of_service.rb
212
215
  - lib/daisybill_api/models/referring_provider.rb
213
216
  - lib/daisybill_api/models/rendering_provider.rb
@@ -226,12 +229,14 @@ files:
226
229
  - spec/daisybill_api/models/bill_payment_spec.rb
227
230
  - spec/daisybill_api/models/bill_spec.rb
228
231
  - spec/daisybill_api/models/bill_submission_spec.rb
232
+ - spec/daisybill_api/models/billing_provider_attachment_spec.rb
229
233
  - spec/daisybill_api/models/billing_provider_spec.rb
230
234
  - spec/daisybill_api/models/claims_administrator_spec.rb
231
235
  - spec/daisybill_api/models/contact_spec.rb
232
236
  - spec/daisybill_api/models/employer_spec.rb
233
237
  - spec/daisybill_api/models/injury_spec.rb
234
238
  - spec/daisybill_api/models/patient_spec.rb
239
+ - spec/daisybill_api/models/payer_spec.rb
235
240
  - spec/daisybill_api/models/place_of_service_spec.rb
236
241
  - spec/daisybill_api/models/referring_provider_spec.rb
237
242
  - spec/daisybill_api/models/rendering_provider_spec.rb
@@ -275,12 +280,14 @@ test_files:
275
280
  - spec/daisybill_api/models/bill_payment_spec.rb
276
281
  - spec/daisybill_api/models/bill_spec.rb
277
282
  - spec/daisybill_api/models/bill_submission_spec.rb
283
+ - spec/daisybill_api/models/billing_provider_attachment_spec.rb
278
284
  - spec/daisybill_api/models/billing_provider_spec.rb
279
285
  - spec/daisybill_api/models/claims_administrator_spec.rb
280
286
  - spec/daisybill_api/models/contact_spec.rb
281
287
  - spec/daisybill_api/models/employer_spec.rb
282
288
  - spec/daisybill_api/models/injury_spec.rb
283
289
  - spec/daisybill_api/models/patient_spec.rb
290
+ - spec/daisybill_api/models/payer_spec.rb
284
291
  - spec/daisybill_api/models/place_of_service_spec.rb
285
292
  - spec/daisybill_api/models/referring_provider_spec.rb
286
293
  - spec/daisybill_api/models/rendering_provider_spec.rb