daisybill_api 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -6
- data/lib/daisybill_api.rb +5 -5
- data/lib/daisybill_api/configuration.rb +3 -3
- data/lib/daisybill_api/data.rb +2 -2
- data/lib/daisybill_api/data/client.rb +18 -12
- data/lib/daisybill_api/data/url.rb +2 -2
- data/lib/daisybill_api/ext.rb +5 -5
- data/lib/daisybill_api/ext/associations.rb +1 -0
- data/lib/daisybill_api/ext/attributes.rb +2 -2
- data/lib/daisybill_api/ext/attributes/type_castings.rb +10 -4
- data/lib/daisybill_api/ext/crud.rb +12 -11
- data/lib/daisybill_api/ext/crud/create.rb +2 -2
- data/lib/daisybill_api/ext/crud/update.rb +1 -1
- data/lib/daisybill_api/ext/crud/write_off.rb +11 -0
- data/lib/daisybill_api/ext/links.rb +3 -3
- data/lib/daisybill_api/ext/links/link.rb +2 -2
- data/lib/daisybill_api/models.rb +31 -26
- data/lib/daisybill_api/models/attachment.rb +3 -2
- data/lib/daisybill_api/models/base.rb +1 -1
- data/lib/daisybill_api/models/bill.rb +23 -10
- data/lib/daisybill_api/models/bill_mailing_address.rb +16 -0
- data/lib/daisybill_api/models/bill_payment.rb +6 -5
- data/lib/daisybill_api/models/bill_submission.rb +2 -2
- data/lib/daisybill_api/models/billing_provider.rb +10 -10
- data/lib/daisybill_api/models/claim_adjustment_reason.rb +11 -0
- data/lib/daisybill_api/models/claims_administrator.rb +2 -1
- data/lib/daisybill_api/models/contact.rb +19 -11
- data/lib/daisybill_api/models/error_report.rb +30 -0
- data/lib/daisybill_api/models/injury.rb +1 -0
- data/lib/daisybill_api/models/paper_eor.rb +6 -3
- data/lib/daisybill_api/models/patient.rb +4 -3
- data/lib/daisybill_api/models/payer.rb +3 -1
- data/lib/daisybill_api/models/pharmacy_bill.rb +20 -8
- data/lib/daisybill_api/models/place_of_service.rb +4 -3
- data/lib/daisybill_api/models/prescribing_provider.rb +2 -2
- data/lib/daisybill_api/models/referring_provider.rb +2 -2
- data/lib/daisybill_api/models/remittance.rb +3 -3
- data/lib/daisybill_api/models/rendering_provider.rb +2 -2
- data/lib/daisybill_api/models/request_for_second_review.rb +3 -3
- data/lib/daisybill_api/models/service_line_item_payment.rb +14 -0
- data/lib/daisybill_api/models/task.rb +26 -0
- data/lib/daisybill_api/models/user.rb +16 -0
- data/lib/daisybill_api/version.rb +1 -1
- data/spec/daisybill_api/configuration_spec.rb +3 -3
- data/spec/daisybill_api/data/client_spec.rb +44 -38
- data/spec/daisybill_api/data/rest_client/payload_spec.rb +6 -6
- data/spec/daisybill_api/data/url_spec.rb +6 -6
- data/spec/daisybill_api/ext/attributes/attribute_spec.rb +32 -32
- data/spec/daisybill_api/ext/attributes/type_castings_spec.rb +22 -18
- data/spec/daisybill_api/ext/links/link_spec.rb +15 -15
- data/spec/daisybill_api/ext/pageable_collection_spec.rb +1 -1
- data/spec/daisybill_api/models/address_spec.rb +1 -1
- data/spec/daisybill_api/models/attachment_spec.rb +3 -3
- data/spec/daisybill_api/models/bill_mailing_address_spec.rb +6 -0
- data/spec/daisybill_api/models/bill_payment_spec.rb +5 -3
- data/spec/daisybill_api/models/bill_spec.rb +6 -4
- data/spec/daisybill_api/models/bill_submission_spec.rb +2 -2
- data/spec/daisybill_api/models/billing_provider_spec.rb +2 -2
- data/spec/daisybill_api/models/claim_number_verification_spec.rb +1 -1
- data/spec/daisybill_api/models/claims_administrator_spec.rb +3 -2
- data/spec/daisybill_api/models/contact_spec.rb +29 -3
- data/spec/daisybill_api/models/disputed_service_spec.rb +1 -1
- data/spec/daisybill_api/models/employer_spec.rb +1 -1
- data/spec/daisybill_api/models/error_report_spec.rb +10 -0
- data/spec/daisybill_api/models/injury_spec.rb +2 -1
- data/spec/daisybill_api/models/paper_eor_spec.rb +4 -3
- data/spec/daisybill_api/models/patient_spec.rb +4 -4
- data/spec/daisybill_api/models/payer_spec.rb +3 -2
- data/spec/daisybill_api/models/{pharamcy_bill_spec.rb → pharmacy_bill_spec.rb} +7 -6
- data/spec/daisybill_api/models/place_of_service_spec.rb +5 -5
- data/spec/daisybill_api/models/prescribing_provider_spec.rb +2 -2
- data/spec/daisybill_api/models/referring_provider_spec.rb +2 -2
- data/spec/daisybill_api/models/remittance_spec.rb +2 -2
- data/spec/daisybill_api/models/rendering_provider_spec.rb +2 -2
- data/spec/daisybill_api/models/request_for_second_review_spec.rb +2 -2
- data/spec/daisybill_api/models/service_line_item_payment_spec.rb +6 -0
- data/spec/daisybill_api/models/service_line_item_spec.rb +1 -1
- data/spec/daisybill_api/models/task_spec.rb +19 -0
- data/spec/daisybill_api/models/user_spec.rb +14 -0
- data/spec/daisybill_api_spec.rb +10 -10
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f4e06ac630954fbf2b73acf8cbcdb70701a4023
|
4
|
+
data.tar.gz: 5c2279c1252d5b4c10a12ed8cf9bc540824f12c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc8a3e51e32e99b04b0c711ad18f3322733d8b6ac6ebcf7161a02de71e6a93ccba160eefcec399477d064a8976e483c99eef5d30c0f809efccda5ea2e85e9d33
|
7
|
+
data.tar.gz: e72d81a145c9e7b296b32b1f59516f55fa8df339b132c6e442572d1ff0fec73eac8daa585999d358ffb68865d865f0e681c9c6afb40432ad43ee7efd4299cf27
|
data/Rakefile
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "bundler/setup"
|
3
3
|
rescue LoadError
|
4
|
-
puts
|
4
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
5
5
|
end
|
6
6
|
|
7
7
|
require "yard"
|
8
8
|
|
9
9
|
Bundler::GemHelper.install_tasks
|
10
10
|
|
11
|
-
require
|
11
|
+
require "rake/testtask"
|
12
12
|
|
13
13
|
Rake::TestTask.new(:test) do |t|
|
14
|
-
t.libs <<
|
15
|
-
t.libs <<
|
16
|
-
t.pattern =
|
14
|
+
t.libs << "lib"
|
15
|
+
t.libs << "test"
|
16
|
+
t.pattern = "test/**/*_test.rb"
|
17
17
|
t.verbose = false
|
18
18
|
end
|
19
19
|
|
data/lib/daisybill_api.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "daisybill_api/data"
|
2
|
+
require "daisybill_api/configuration"
|
3
|
+
require "daisybill_api/ext"
|
4
|
+
require "daisybill_api/models"
|
5
5
|
|
6
6
|
module DaisybillApi
|
7
7
|
# @private
|
8
|
-
ROOT = File.expand_path(
|
8
|
+
ROOT = File.expand_path("../..", __FILE__)
|
9
9
|
|
10
10
|
class << self
|
11
11
|
attr_writer :configuration
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "logger"
|
2
2
|
|
3
3
|
module DaisybillApi
|
4
4
|
class Configuration
|
@@ -7,7 +7,7 @@ module DaisybillApi
|
|
7
7
|
#
|
8
8
|
# DaisybillApi.configuration.api_token # => "987654321zyxwvu"
|
9
9
|
# DaisybillApi.configuration.api_token = "123456789abcdef" # => "123456789abcdef"
|
10
|
-
# DaisybillApi.configuration.api_token # => "123456789abcdef"
|
10
|
+
# DaisybillApi.configuration.api_token # => "123456789abcdef"
|
11
11
|
#
|
12
12
|
# @return [String]
|
13
13
|
attr_accessor :api_token
|
@@ -35,7 +35,7 @@ module DaisybillApi
|
|
35
35
|
|
36
36
|
def initialize
|
37
37
|
@port = 443
|
38
|
-
@host =
|
38
|
+
@host = "go.daisybill.com"
|
39
39
|
end
|
40
40
|
|
41
41
|
# @private
|
data/lib/daisybill_api/data.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "rest-client"
|
2
|
+
require "daisybill_api/data/rest_client/payload"
|
3
3
|
|
4
4
|
module DaisybillApi
|
5
5
|
# @private
|
@@ -9,12 +9,14 @@ module DaisybillApi
|
|
9
9
|
class InternalServerError < BasicError; end
|
10
10
|
class UnauthorizedError < BasicError; end
|
11
11
|
class InvalidParams < BasicError; end
|
12
|
+
class MethodNotAllowed < BasicError; end
|
12
13
|
|
13
14
|
def self.build(method, path, params = {})
|
14
15
|
client = new method, path, params
|
15
|
-
raise InternalServerError.new(client.response[
|
16
|
-
raise UnauthorizedError.new(client.response[
|
17
|
-
raise InvalidParams.new(client.response[
|
16
|
+
raise InternalServerError.new(client.response["error"]) if client.error?
|
17
|
+
raise UnauthorizedError.new(client.response["error"]) if client.unauthorized?
|
18
|
+
raise InvalidParams.new(client.response["error"]) if client.forbidden?
|
19
|
+
raise MethodNotAllowed.new(client.response["error"]) if client.method_not_allowed?
|
18
20
|
client
|
19
21
|
end
|
20
22
|
|
@@ -28,7 +30,7 @@ module DaisybillApi
|
|
28
30
|
method: method,
|
29
31
|
url: url,
|
30
32
|
payload: params,
|
31
|
-
headers: {
|
33
|
+
headers: { "Content-Type" => "application/json" }
|
32
34
|
}
|
33
35
|
RestClient::Request.execute(data) { |response, request, status|
|
34
36
|
@headers = response.headers
|
@@ -45,27 +47,31 @@ module DaisybillApi
|
|
45
47
|
end
|
46
48
|
|
47
49
|
def success?
|
48
|
-
status ==
|
50
|
+
status == "200" || status == "201"
|
49
51
|
end
|
50
52
|
|
51
53
|
def bad_request?
|
52
|
-
status ==
|
54
|
+
status == "400"
|
53
55
|
end
|
54
56
|
|
55
57
|
def unauthorized?
|
56
|
-
status ==
|
58
|
+
status == "401"
|
57
59
|
end
|
58
60
|
|
59
61
|
def not_found?
|
60
|
-
status ==
|
62
|
+
status == "404"
|
61
63
|
end
|
62
64
|
|
63
65
|
def forbidden?
|
64
|
-
status ==
|
66
|
+
status == "403"
|
67
|
+
end
|
68
|
+
|
69
|
+
def method_not_allowed?
|
70
|
+
status == "405"
|
65
71
|
end
|
66
72
|
|
67
73
|
def error?
|
68
|
-
status ==
|
74
|
+
status == "500"
|
69
75
|
end
|
70
76
|
end
|
71
77
|
end
|
data/lib/daisybill_api/ext.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "daisybill_api/ext/attributes"
|
2
|
+
require "daisybill_api/ext/links"
|
3
|
+
require "daisybill_api/ext/crud"
|
4
|
+
require "daisybill_api/ext/associations"
|
5
|
+
require "daisybill_api/ext/pageable_collection"
|
6
6
|
|
7
7
|
module DaisybillApi
|
8
8
|
module Ext
|
@@ -16,6 +16,7 @@ module DaisybillApi
|
|
16
16
|
define_method name do |params = {}|
|
17
17
|
params.merge!(:"#{self.class.singular_key}_id" => self.id)
|
18
18
|
params.merge!(path: "#{show_path}/#{name}") if options[:set_path]
|
19
|
+
params.merge!(path: clazz.constantize.index_path(id)) if options[:set_path] && options[:use_path_prefix]
|
19
20
|
params.merge!(collection_key: options[:collection_key]) if options[:collection_key]
|
20
21
|
clazz.constantize.all(params)
|
21
22
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "open-uri"
|
2
2
|
|
3
3
|
module DaisybillApi
|
4
4
|
module Ext
|
@@ -24,8 +24,10 @@ module DaisybillApi
|
|
24
24
|
to_attachment(value)
|
25
25
|
when :float
|
26
26
|
to_float(value)
|
27
|
+
when :hash
|
28
|
+
to_hash(value)
|
27
29
|
else
|
28
|
-
raise
|
30
|
+
raise "Unknown Type"
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
@@ -59,18 +61,22 @@ module DaisybillApi
|
|
59
61
|
|
60
62
|
def to_class(attributes, type)
|
61
63
|
return attributes if attributes.is_a? type
|
62
|
-
type.new
|
64
|
+
type.new(attributes) rescue nil
|
63
65
|
end
|
64
66
|
|
65
67
|
def to_array(values, type)
|
66
68
|
return [] if values.nil?
|
67
|
-
values.map { |value| convert_to
|
69
|
+
values.map { |value| convert_to(value, type) }
|
68
70
|
end
|
69
71
|
|
70
72
|
def to_attachment(value)
|
71
73
|
return open(value) if value.is_a? String
|
72
74
|
value if value.is_a?(StringIO) || value.kind_of?(IO)
|
73
75
|
end
|
76
|
+
|
77
|
+
def to_hash(value)
|
78
|
+
value.to_h rescue nil
|
79
|
+
end
|
74
80
|
end
|
75
81
|
end
|
76
82
|
end
|
@@ -1,9 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
require "daisybill_api/ext/crud/index"
|
2
|
+
require "daisybill_api/ext/crud/create"
|
3
|
+
require "daisybill_api/ext/crud/show"
|
4
|
+
require "daisybill_api/ext/crud/update"
|
5
|
+
require "daisybill_api/ext/crud/destroy"
|
6
|
+
require "daisybill_api/ext/crud/search"
|
7
|
+
require "daisybill_api/ext/crud/write_off"
|
7
8
|
|
8
9
|
module DaisybillApi
|
9
10
|
module Ext
|
@@ -12,7 +13,7 @@ module DaisybillApi
|
|
12
13
|
module ClassMethods
|
13
14
|
def rest_actions(*actions)
|
14
15
|
actions.each { |action|
|
15
|
-
name = action.
|
16
|
+
name = action.to_s.classify
|
16
17
|
extend "DaisybillApi::Ext::CRUD::#{name}::ClassMethods".constantize
|
17
18
|
include "DaisybillApi::Ext::CRUD::#{name}::InstanceMethods".constantize
|
18
19
|
}
|
@@ -75,7 +76,7 @@ module DaisybillApi
|
|
75
76
|
|
76
77
|
private
|
77
78
|
|
78
|
-
PREFIX_LENGTH =
|
79
|
+
PREFIX_LENGTH = "daisybill_api_models_".length
|
79
80
|
|
80
81
|
def demodulize(name)
|
81
82
|
name[PREFIX_LENGTH..name.length]
|
@@ -104,7 +105,7 @@ module DaisybillApi
|
|
104
105
|
|
105
106
|
def index_path
|
106
107
|
params = self.class.path_prefix? ? [self.send(self.class.prefix_property)] : []
|
107
|
-
self.class.index_path
|
108
|
+
self.class.index_path(*params)
|
108
109
|
end
|
109
110
|
|
110
111
|
def show_path
|
@@ -129,11 +130,11 @@ module DaisybillApi
|
|
129
130
|
def process_response(client)
|
130
131
|
if client.success?
|
131
132
|
response = client.response.clone
|
132
|
-
self.links = response.delete
|
133
|
+
self.links = response.delete "links"
|
133
134
|
self.attributes = response
|
134
135
|
true
|
135
136
|
elsif client.bad_request?
|
136
|
-
self.external_errors = client.response[
|
137
|
+
self.external_errors = client.response["errors"]
|
137
138
|
self.valid?
|
138
139
|
else
|
139
140
|
false
|
@@ -33,7 +33,7 @@ module DaisybillApi
|
|
33
33
|
#
|
34
34
|
# bill = DaisybillApi::Models::Bill.new(
|
35
35
|
# injury_id: 345,
|
36
|
-
# date_of_service:
|
36
|
+
# date_of_service: "2015-01-01",
|
37
37
|
# rendering_provider_id: rp.id,
|
38
38
|
# place_of_service_id: pos.id,
|
39
39
|
# diagnosis_codes: ["72700"],
|
@@ -91,7 +91,7 @@ module DaisybillApi
|
|
91
91
|
def save
|
92
92
|
return create if new_record?
|
93
93
|
return update if respond_to? :update
|
94
|
-
message =
|
94
|
+
message = "#save method is not supported for saved record"
|
95
95
|
DaisybillApi.logger.error message
|
96
96
|
raise NotImplementedError.new message
|
97
97
|
end
|
@@ -21,7 +21,7 @@ module DaisybillApi
|
|
21
21
|
def save
|
22
22
|
return update unless new_record?
|
23
23
|
return create if respond_to? :create
|
24
|
-
message =
|
24
|
+
message = "#save method is not supported for new record"
|
25
25
|
DaisybillApi.logger.error message
|
26
26
|
raise NotImplementedError.new message
|
27
27
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "daisybill_api/ext/links/link"
|
2
2
|
|
3
3
|
module DaisybillApi
|
4
4
|
module Ext
|
@@ -19,7 +19,7 @@ module DaisybillApi
|
|
19
19
|
|
20
20
|
module InstanceMethods
|
21
21
|
def initialize(attributes)
|
22
|
-
lnks = attributes.delete
|
22
|
+
lnks = attributes.delete "links"
|
23
23
|
super(attributes)
|
24
24
|
class_links.each { |link| links[link.name] = link.clone }
|
25
25
|
self.links = lnks
|
@@ -27,7 +27,7 @@ module DaisybillApi
|
|
27
27
|
|
28
28
|
def links=(values)
|
29
29
|
return if values.nil?
|
30
|
-
values.each { |link| write_link link[
|
30
|
+
values.each { |link| write_link link["rel"], link["href"] }
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
@@ -14,7 +14,7 @@ module DaisybillApi
|
|
14
14
|
def value
|
15
15
|
return unless href
|
16
16
|
default_path = DaisybillApi::Data::Url::DEFAULT_PATH
|
17
|
-
c = DaisybillApi::Data::Client.build(:get, href.gsub(default_path,
|
17
|
+
c = DaisybillApi::Data::Client.build(:get, href.gsub(default_path, ""))
|
18
18
|
klass.constantize.new(c.response) if c.success?
|
19
19
|
end
|
20
20
|
|
@@ -27,7 +27,7 @@ module DaisybillApi
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def foreign_id
|
30
|
-
href.split(
|
30
|
+
href.split("/").last
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/daisybill_api/models.rb
CHANGED
@@ -1,30 +1,35 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
1
|
+
require "daisybill_api/models/address"
|
2
|
+
require "daisybill_api/models/base"
|
3
|
+
require "daisybill_api/models/bill_mailing_address"
|
4
|
+
require "daisybill_api/models/contact"
|
5
|
+
require "daisybill_api/models/claims_administrator"
|
6
|
+
require "daisybill_api/models/payer"
|
7
|
+
require "daisybill_api/models/bill_submission"
|
8
|
+
require "daisybill_api/models/billing_provider"
|
9
|
+
require "daisybill_api/models/employer"
|
10
|
+
require "daisybill_api/models/injury"
|
11
|
+
require "daisybill_api/models/patient"
|
12
|
+
require "daisybill_api/models/place_of_service"
|
13
|
+
require "daisybill_api/models/prescribing_provider"
|
14
|
+
require "daisybill_api/models/referring_provider"
|
15
|
+
require "daisybill_api/models/rendering_provider"
|
16
|
+
require "daisybill_api/models/attachment"
|
17
|
+
require "daisybill_api/models/service_line_item"
|
18
|
+
require "daisybill_api/models/bill"
|
19
|
+
require "daisybill_api/models/pharmacy_bill"
|
20
|
+
require "daisybill_api/models/claim_adjustment_reason"
|
21
|
+
require "daisybill_api/models/service_line_item_payment"
|
22
|
+
require "daisybill_api/models/bill_payment"
|
23
|
+
require "daisybill_api/models/claim_number_verification"
|
24
|
+
require "daisybill_api/models/remittance"
|
25
|
+
require "daisybill_api/models/paper_eor"
|
26
|
+
require "daisybill_api/models/disputed_service"
|
27
|
+
require "daisybill_api/models/request_for_second_review"
|
28
|
+
require "daisybill_api/models/error_report"
|
29
|
+
require "daisybill_api/models/user"
|
30
|
+
require "daisybill_api/models/task"
|
25
31
|
|
26
32
|
module DaisybillApi
|
27
33
|
# @private
|
28
|
-
module Models
|
29
|
-
end
|
34
|
+
module Models; end
|
30
35
|
end
|