daisybill_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +20 -0
  4. data/lib/daisybill_api.rb +53 -0
  5. data/lib/daisybill_api/configuration.rb +46 -0
  6. data/lib/daisybill_api/data.rb +7 -0
  7. data/lib/daisybill_api/data/client.rb +66 -0
  8. data/lib/daisybill_api/data/rest_client/payload.rb +30 -0
  9. data/lib/daisybill_api/data/url.rb +26 -0
  10. data/lib/daisybill_api/ext.rb +20 -0
  11. data/lib/daisybill_api/ext/associations.rb +39 -0
  12. data/lib/daisybill_api/ext/attributes.rb +103 -0
  13. data/lib/daisybill_api/ext/attributes/attribute.rb +60 -0
  14. data/lib/daisybill_api/ext/attributes/type_castings.rb +78 -0
  15. data/lib/daisybill_api/ext/crud.rb +147 -0
  16. data/lib/daisybill_api/ext/crud/create.rb +107 -0
  17. data/lib/daisybill_api/ext/crud/destroy.rb +28 -0
  18. data/lib/daisybill_api/ext/crud/index.rb +41 -0
  19. data/lib/daisybill_api/ext/crud/show.rb +22 -0
  20. data/lib/daisybill_api/ext/crud/update.rb +37 -0
  21. data/lib/daisybill_api/ext/links.rb +65 -0
  22. data/lib/daisybill_api/ext/links/link.rb +35 -0
  23. data/lib/daisybill_api/ext/pageable_collection.rb +124 -0
  24. data/lib/daisybill_api/models.rb +22 -0
  25. data/lib/daisybill_api/models/address.rb +16 -0
  26. data/lib/daisybill_api/models/attachment.rb +22 -0
  27. data/lib/daisybill_api/models/base.rb +29 -0
  28. data/lib/daisybill_api/models/bill.rb +42 -0
  29. data/lib/daisybill_api/models/bill_payment.rb +22 -0
  30. data/lib/daisybill_api/models/bill_submission.rb +18 -0
  31. data/lib/daisybill_api/models/billing_provider.rb +25 -0
  32. data/lib/daisybill_api/models/claims_administrator.rb +13 -0
  33. data/lib/daisybill_api/models/contact.rb +19 -0
  34. data/lib/daisybill_api/models/employer.rb +13 -0
  35. data/lib/daisybill_api/models/injury.rb +30 -0
  36. data/lib/daisybill_api/models/patient.rb +32 -0
  37. data/lib/daisybill_api/models/place_of_service.rb +29 -0
  38. data/lib/daisybill_api/models/referring_provider.rb +21 -0
  39. data/lib/daisybill_api/models/rendering_provider.rb +23 -0
  40. data/lib/daisybill_api/models/service_line_item.rb +27 -0
  41. data/lib/daisybill_api/version.rb +3 -0
  42. data/spec/daisybill_api/configuration_spec.rb +16 -0
  43. data/spec/daisybill_api/data/client_spec.rb +47 -0
  44. data/spec/daisybill_api/data/rest_client/payload_spec.rb +17 -0
  45. data/spec/daisybill_api/data/url_spec.rb +13 -0
  46. data/spec/daisybill_api/ext/attributes/attribute_spec.rb +120 -0
  47. data/spec/daisybill_api/ext/attributes/type_castings_spec.rb +50 -0
  48. data/spec/daisybill_api/ext/links/link_spec.rb +50 -0
  49. data/spec/daisybill_api/ext/pageable_collection_spec.rb +145 -0
  50. data/spec/daisybill_api/models/address_spec.rb +7 -0
  51. data/spec/daisybill_api/models/attachment_spec.rb +9 -0
  52. data/spec/daisybill_api/models/bill_payment_spec.rb +11 -0
  53. data/spec/daisybill_api/models/bill_spec.rb +22 -0
  54. data/spec/daisybill_api/models/bill_submission_spec.rb +9 -0
  55. data/spec/daisybill_api/models/billing_provider_spec.rb +13 -0
  56. data/spec/daisybill_api/models/claims_administrator_spec.rb +7 -0
  57. data/spec/daisybill_api/models/contact_spec.rb +6 -0
  58. data/spec/daisybill_api/models/employer_spec.rb +7 -0
  59. data/spec/daisybill_api/models/injury_spec.rb +13 -0
  60. data/spec/daisybill_api/models/patient_spec.rb +14 -0
  61. data/spec/daisybill_api/models/place_of_service_spec.rb +14 -0
  62. data/spec/daisybill_api/models/referring_provider_spec.rb +11 -0
  63. data/spec/daisybill_api/models/rendering_provider_spec.rb +12 -0
  64. data/spec/daisybill_api/models/service_line_item_spec.rb +11 -0
  65. data/spec/daisybill_api_spec.rb +35 -0
  66. metadata +289 -0
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Ext::Attributes::TypeCastings do
4
+ let(:converter) { described_class }
5
+
6
+ it { expect(converter.convert_to('2015-03-13', :date)).to eq Date.new(2015, 3, 13) }
7
+ it { expect(converter.convert_to(DateTime.new(2015, 3, 3, 12, 27, 13), :date)).to eq Date.new(2015, 3, 3) }
8
+ it { expect(converter.convert_to('not a date', :date)).to be_nil }
9
+ it { expect(converter.convert_to('', :date)).to be_nil }
10
+ it 'casting of date time' do
11
+ casted = converter.convert_to('2015-03-13T12:27:13.666-08:00', :datetime)
12
+ expect(casted).to eq DateTime.new(2015, 3, 13, 12, 27, 13.666, '-8')
13
+ end
14
+ it { expect(converter.convert_to(Date.new(2015, 3, 13), :datetime)).to eq DateTime.new(2015, 3, 13) }
15
+ it { expect(converter.convert_to('not a datetime', :datetime)).to be_nil }
16
+ it { expect(converter.convert_to('', :datetime)).to be_nil }
17
+ it { expect(converter.convert_to('123', :integer)).to eq 123 }
18
+ it { expect(converter.convert_to(123, :string)).to eq '123' }
19
+ it { expect(converter.convert_to(' ', :integer)).to be_nil }
20
+ it { expect(converter.convert_to(nil, :integer)).to be_nil }
21
+ it { expect(converter.convert_to(nil, [:integer])).to be_empty }
22
+ it { expect(converter.convert_to(%w(1 2 3), [:integer])).to eq [1, 2, 3] }
23
+ it { expect(converter.convert_to(nil, :string)).to be_nil }
24
+ it { expect(converter.convert_to(%w(hello world !!!), [:string])).to eq %w(hello world !!!) }
25
+ it { expect(converter.convert_to(nil, :date)).to be_nil }
26
+ it { expect(converter.convert_to(nil, :datetime)).to be_nil }
27
+ it { expect(converter.convert_to({}, DaisybillApi::Models::Address)).to be_a DaisybillApi::Models::Address }
28
+
29
+ context 'attachment', vcr: true do
30
+ it { expect(converter.convert_to(nil, :attachment)).to be_nil }
31
+ it { expect(converter.convert_to('http://path.to/attachment', :attachment)).to be_a StringIO }
32
+ it { expect(converter.convert_to(File.open(__FILE__), :attachment)).to be_a File }
33
+ end
34
+
35
+ context 'convert collection of hashes to collection of models' do
36
+ let(:clazz) { DaisybillApi::Models::Address }
37
+ subject { converter.convert_to([{}, {}, {}], [clazz]) }
38
+
39
+ it { is_expected.to be_a Array }
40
+ it { is_expected.to have(3).models }
41
+ it { is_expected.to all( be_a clazz ) }
42
+ end
43
+
44
+ it 'when converting model' do
45
+ clazz = DaisybillApi::Models::Address
46
+ expect(converter.convert_to(clazz.new, clazz)).to be_a clazz
47
+ end
48
+ it { expect(converter.convert_to('{}', DaisybillApi::Models::Address)).to be_nil }
49
+ it { expect{ converter.convert_to('some value', :unknown) }.to raise_error }
50
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Ext::Links::Link do
4
+ subject { described_class.new :rendering_provider, 'DaisybillApi::Models::RenderingProvider' }
5
+
6
+ let(:status) { 200 }
7
+ let(:response) { {} }
8
+
9
+ before do
10
+ subject.href = '/api/v1/some/url/:id'
11
+ client = doubled_client status, response
12
+ allow(DaisybillApi::Data::Client).to receive(:new).and_return(client)
13
+ end
14
+
15
+ its(:value) { is_expected.to be_a DaisybillApi::Models::RenderingProvider }
16
+ its(:foreign_id) { is_expected.to eq(':id') }
17
+
18
+ it 'when href is nil' do
19
+ subject.href = nil
20
+ expect(subject.value).to be_nil
21
+ end
22
+
23
+ it 'must send data to correct url' do
24
+ expect(DaisybillApi::Data::Client).to receive(:new).with(:get, '/some/url/:id', {})
25
+ subject.value
26
+ end
27
+
28
+ context 'when link was not found' do
29
+ let(:status) { 404 }
30
+ let(:response) { { 'error' => 'Record Not Found' } }
31
+
32
+ its(:value) { is_expected.to be nil }
33
+ end
34
+
35
+ context 'when was server error' do
36
+ let(:status) { 500 }
37
+ let(:message) { 'Internal Server Error' }
38
+ let(:response) { { 'error' => message } }
39
+
40
+ it { expect{ subject.value }.to raise_error(DaisybillApi::Data::Client::InternalServerError).with_message(message) }
41
+ end
42
+
43
+ context 'when was server error' do
44
+ let(:status) { 401 }
45
+ let(:message) { 'Not Authorized' }
46
+ let(:response) { { 'error' => message } }
47
+
48
+ it { expect{ subject.value }.to raise_error(DaisybillApi::Data::Client::UnauthorizedError).with_message(message) }
49
+ end
50
+ end
@@ -0,0 +1,145 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Ext::PageableCollection do
4
+ let(:resource_class) { DaisybillApi::Models::Bill }
5
+ let(:page) { described_class.new(entries, options) }
6
+ let(:entries) { 2.times.map { resource_class.new } }
7
+ let(:options) { { resource_class: resource_class, params: params, headers: headers } }
8
+ let(:headers) { {} }
9
+ let(:params) { {} }
10
+ let(:another_page) { described_class.new(entries, another_page_options) }
11
+ let(:another_page_headers) { {} }
12
+ let(:another_page_options) { { resource_class: resource_class, params: params, headers: another_page_headers } }
13
+
14
+ before do
15
+ allow(DaisybillApi::Models::Bill).to receive(:all) { another_page }
16
+ end
17
+
18
+ describe "enumerable" do
19
+ subject { page }
20
+
21
+ it { is_expected.to respond_to(:each) }
22
+ it { expect(described_class.included_modules).to include(Enumerable) }
23
+ end
24
+
25
+ describe "#first_page" do
26
+ subject { page.first_page }
27
+
28
+ let(:headers) { {
29
+ x_prev_page: "2",
30
+ x_next_page: "4",
31
+ x_page: "3"
32
+ } }
33
+
34
+ let(:another_page_headers) { {
35
+ x_prev_page: "",
36
+ x_next_page: "2",
37
+ x_page: "1"
38
+ } }
39
+
40
+ it { is_expected.to be_a(described_class) }
41
+ it { expect(subject.previous_page).to be_nil }
42
+ it { expect(subject.current_page_number).to eq(1) }
43
+ end
44
+
45
+ describe "#last_page" do
46
+ subject { page.last_page }
47
+
48
+ let(:headers) { {
49
+ total_page_count: "3",
50
+ x_next_page: "2",
51
+ x_page: "1"
52
+ } }
53
+
54
+ let(:another_page_headers) { {
55
+ x_prev_page: "2",
56
+ x_next_page: "",
57
+ x_page: "3"
58
+ } }
59
+
60
+ it { is_expected.to be_a(described_class) }
61
+ it { expect(subject.current_page_number).to eq(3) }
62
+ it { expect(subject.next_page).to be_nil }
63
+ end
64
+
65
+ describe "#next_page" do
66
+ subject { page.next_page }
67
+
68
+ context "when there is a next page" do
69
+ let(:headers) { {
70
+ total_page_count: "3",
71
+ x_next_page: "2",
72
+ x_page: "1"
73
+ } }
74
+
75
+ let(:another_page_headers) { {
76
+ x_prev_page: "2",
77
+ x_next_page: "",
78
+ x_page: "3"
79
+ } }
80
+
81
+ it { is_expected.to be_a(described_class) }
82
+ it { expect(subject.current_page_number).to eq(3) }
83
+ it { expect(subject.next_page).to be_nil }
84
+ end
85
+
86
+ context "when next page is nil" do
87
+ let(:headers) { {
88
+ total_page_count: "3",
89
+ x_next_page: "",
90
+ x_page: "3"
91
+ } }
92
+
93
+ it { is_expected.to be_nil }
94
+ end
95
+ end
96
+
97
+ describe "#previous_page" do
98
+ subject { page.previous_page }
99
+
100
+ context "when there is a previous page" do
101
+ let(:headers) { {
102
+ total_page_count: "3",
103
+ x_next_page: "3",
104
+ x_prev_page: "1",
105
+ x_page: "2"
106
+ } }
107
+
108
+ let(:another_page_headers) { {
109
+ total_page_count: "3",
110
+ x_prev_page: "",
111
+ x_next_page: "2",
112
+ x_page: "1"
113
+ } }
114
+
115
+ it { is_expected.to be_a(described_class) }
116
+ it { expect(subject.current_page_number).to eq(1) }
117
+ it { expect(subject.previous_page).to be_nil }
118
+ end
119
+
120
+ context "when previous page is nil" do
121
+ let(:headers) { {
122
+ x_next_page: "2",
123
+ x_prev_page: "",
124
+ x_page: "1"
125
+ } }
126
+
127
+ it { is_expected.to be_nil }
128
+ end
129
+ end
130
+ describe "#current_page_number" do
131
+ subject { page.current_page_number }
132
+
133
+ context "when x page is set in headers" do
134
+ let(:headers) { { x_page: "2" } }
135
+
136
+ it { expect(subject).to eq(2) }
137
+ end
138
+
139
+ context "when x page is not set in headers" do
140
+ let(:headers) { { x_page: "" } }
141
+
142
+ it { expect(subject).to be_nil }
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::Address do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :address_1, :address_2, :city, :state, :zip_code,
5
+ :created_at, :updated_at
6
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :address_1, :address_2, :city, :state, :zip_code
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::Attachment do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :document_url, :inactive, :report_type, :document,
5
+ :bill_id, :created_at, :updated_at
6
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :report_type, :document, :bill_id
7
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, :update, :destroy, '/attachments', bill_id: '/bills'
8
+ it_behaves_like DaisybillApi::Ext::Links, bill: DaisybillApi::Models::Bill
9
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::BillPayment do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :payment_amount_cents, :check_amount, :check_number,
5
+ :check_effective_date, :payment_source, :created_at, :updated_at, :bill_id, :bill_submission_id
6
+
7
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, '/bill_payments', bill_id: '/bills'
8
+
9
+ it_behaves_like DaisybillApi::Ext::Links, bill: DaisybillApi::Models::Bill,
10
+ bill_submission: DaisybillApi::Models::BillSubmission
11
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::Bill do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :date_of_service, :authorization_number, :status,
5
+ :admission_date, :practice_bill_id, :additional_information, :charge_cents, :expected_payment_cents,
6
+ :allowed_cents, :balance_due_cents, :write_off_cents, :created_at, :updated_at, :injury_id,
7
+ :place_of_service_id, :rendering_provider_id, :referring_provider_id, :supervising_provider_id,
8
+ :review_status, :diagnosis_type, review_errors: :collection, diagnosis_codes: :collection,
9
+ service_line_items: :collection
10
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :date_of_service, :place_of_service_id,
11
+ :rendering_provider_id, :referring_provider_id, :supervising_provider_id, :authorization_number,
12
+ :admission_date, :additional_information, :practice_bill_id, :diagnosis_type, :diagnosis_codes,
13
+ :service_line_items_attributes, :injury_id
14
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, :update, :destroy, '/bills', injury_id: '/injuries'
15
+ it_behaves_like DaisybillApi::Ext::Links, injury: DaisybillApi::Models::Injury,
16
+ place_of_service: DaisybillApi::Models::PlaceOfService,
17
+ rendering_provider: DaisybillApi::Models::RenderingProvider,
18
+ referring_provider: DaisybillApi::Models::ReferringProvider,
19
+ supervising_provider: DaisybillApi::Models::RenderingProvider
20
+ it_behaves_like DaisybillApi::Ext::Associations, :bill_submissions
21
+ it_behaves_like DaisybillApi::Ext::Associations, :attachments
22
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::BillSubmission do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :type, :mode, :bill_id,
5
+ :created_at, :updated_at, claims_administrator: :model
6
+
7
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, '/bill_submissions', bill_id: '/bills'
8
+ it_behaves_like DaisybillApi::Ext::Links, bill: DaisybillApi::Models::Bill
9
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::BillingProvider do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :name, :fein, :npi, :telephone, :fax_number,
5
+ :created_at, :updated_at, :dol_provider_number, physical_address: :model, pay_to_address: :model
6
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs
7
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, '/billing_providers'
8
+ it_behaves_like DaisybillApi::Ext::Associations, :patients
9
+ it_behaves_like DaisybillApi::Ext::Associations, :rendering_providers
10
+ it_behaves_like DaisybillApi::Ext::Associations, :referring_providers
11
+ it_behaves_like DaisybillApi::Ext::Associations, :places_of_service
12
+ it_behaves_like DaisybillApi::Ext::Links
13
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::ClaimsAdministrator do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :name, :created_at, :updated_at
5
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs
6
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, '/claims_administrators'
7
+ end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::Contact do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :first_name, :last_name, :company, :role, :telephone,
5
+ :email, :fax, :created_at, :updated_at, address: :model
6
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::Employer do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :name, :created_at, :updated_at,
5
+ address: :model
6
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :id, :name, :address_attributes
7
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::Injury do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :description, :claim_number, :adj_number,
5
+ :start_date, :end_date, :updated_at, :created_at, :patient_id, :claims_administrator_id, :review_status,
6
+ review_errors: :collection, claims_administrator: :model, employer: :model, diagnosis_codes: :collection,
7
+ contacts: :collection
8
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :description, :start_date, :end_date,
9
+ :claims_administrator_id, :claim_number, :employer_attributes, :adj_number, :patient_id
10
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, :update, :destroy, '/injuries', patient_id: '/patients'
11
+ it_behaves_like DaisybillApi::Ext::Associations, :bills
12
+ it_behaves_like DaisybillApi::Ext::Links, patient: DaisybillApi::Models::Patient
13
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::Patient do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :first_name, :last_name, :middle_initial, :suffix,
5
+ :gender, :practice_internal_id, :date_of_birth, :ssn, :telephone, :created_at, :updated_at,
6
+ :billing_provider_id, :review_status, review_errors: :collection, address: :model
7
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :first_name, :last_name, :gender, :date_of_birth,
8
+ :ssn, :address_attributes, :suffix, :middle_initial, :practice_internal_id, :telephone,
9
+ :billing_provider_id
10
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, :update, :destroy, '/patients',
11
+ billing_provider_id: '/billing_providers'
12
+ it_behaves_like DaisybillApi::Ext::Associations, :injuries
13
+ it_behaves_like DaisybillApi::Ext::Links, billing_provider: DaisybillApi::Models::BillingProvider
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::PlaceOfService do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :name, :nick_name, :county, :npi, :active,
5
+ :authorization_telephone_number, :authorization_fax_number, :place_of_service_type_code,
6
+ :billing_provider_id, :created_at, :updated_at, address: :model
7
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :name, :nick_name, :place_of_service_type_code,
8
+ :county, :address_attributes, :npi, :authorization_fax_number, :authorization_telephone_number,
9
+ :billing_provider_id, :active
10
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, :update, '/places_of_service',
11
+ billing_provider_id: '/billing_providers'
12
+ it_behaves_like DaisybillApi::Ext::Associations
13
+ it_behaves_like DaisybillApi::Ext::Links, billing_provider: DaisybillApi::Models::BillingProvider
14
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::ReferringProvider do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :first_name, :last_name, :middle_initial, :suffix,
5
+ :npi, :state_license_number, :active, :billing_provider_id, :created_at, :updated_at
6
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :first_name, :last_name, :npi, :state_license_number,
7
+ :middle_initial, :suffix, :active, :billing_provider_id
8
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, :update, '/referring_providers', billing_provider_id: '/billing_providers'
9
+ it_behaves_like DaisybillApi::Ext::Associations
10
+ it_behaves_like DaisybillApi::Ext::Links, billing_provider: DaisybillApi::Models::BillingProvider
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::RenderingProvider do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :first_name, :last_name, :middle_initial, :suffix,
5
+ :npi, :state_license_number, :taxonomy_code, :type_of_specialty, :active, :billing_provider_id,
6
+ :created_at, :updated_at
7
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :first_name, :last_name, :npi, :state_license_number,
8
+ :taxonomy_code, :type_of_specialty, :middle_initial, :suffix, :active, :billing_provider_id
9
+ it_behaves_like DaisybillApi::Ext::CRUD, :all, :find, :create, :update, '/rendering_providers', billing_provider_id: '/billing_providers'
10
+ it_behaves_like DaisybillApi::Ext::Associations
11
+ it_behaves_like DaisybillApi::Ext::Links, billing_provider: DaisybillApi::Models::BillingProvider
12
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi::Models::ServiceLineItem do
4
+ it_behaves_like DaisybillApi::Ext::Attributes, :id, :units, :supplemental_data, :procedure_code,
5
+ :diagnosis_code_1, :diagnosis_code_2, :diagnosis_code_3, :diagnosis_code_4, :charge_cents,
6
+ :expected_payment_cents, :allowed_cents, :balance_due_cents, :write_off_cents, :created_at,
7
+ :updated_at, :custom_unit_charge_cents, modifier_codes: :collection
8
+ it_behaves_like DaisybillApi::Ext::Attributes::SendAs, :id, :procedure_code, :units, :supplemental_data,
9
+ :diagnosis_code_1, :diagnosis_code_2, :diagnosis_code_3, :diagnosis_code_4, :custom_unit_charge_cents,
10
+ :modifier_codes
11
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaisybillApi do
4
+ describe '::configure' do
5
+ let(:token) { 'api token' }
6
+ let(:host) { nil }
7
+ let(:port) { nil }
8
+ let(:params) { {} }
9
+
10
+ before do
11
+ DaisybillApi.configure do |config|
12
+ config.api_token = token
13
+ config.host = host if host
14
+ config.port = port if port
15
+ end
16
+ end
17
+
18
+ subject { DaisybillApi::Data::Url.build('/billing_providers').to_s }
19
+
20
+ it { is_expected.to eq 'https://go.daisybill.com/api/v1/billing_providers?api_token=api+token' }
21
+
22
+ context 'when host and port changed' do
23
+ let(:host) { 'localhost' }
24
+ let(:port) { 3000 }
25
+
26
+ it { is_expected.to eq('http://localhost:3000/api/v1/billing_providers?api_token=api+token') }
27
+
28
+ context 'after reset' do
29
+ before { DaisybillApi.reset_configuration }
30
+
31
+ it { is_expected.to eq('https://go.daisybill.com/api/v1/billing_providers?api_token') }
32
+ end
33
+ end
34
+ end
35
+ end