updox 0.10.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -2
- data/README.md +5 -4
- data/lib/updox.rb +13 -1
- data/lib/updox/connection.rb +5 -3
- data/lib/updox/error_message.rb +60 -0
- data/lib/updox/models/appointment.rb +5 -3
- data/lib/updox/models/appointment_status.rb +2 -0
- data/lib/updox/models/calendar.rb +2 -0
- data/lib/updox/models/extensions/exists.rb +17 -0
- data/lib/updox/models/extensions/sync.rb +32 -0
- data/lib/updox/models/location.rb +3 -0
- data/lib/updox/models/model.rb +28 -44
- data/lib/updox/models/patient.rb +24 -1
- data/lib/updox/models/patient_message.rb +15 -0
- data/lib/updox/models/practice.rb +8 -2
- data/lib/updox/models/reminder.rb +1 -1
- data/lib/updox/models/user.rb +20 -2
- data/lib/updox/updox_exception.rb +8 -5
- data/lib/updox/version.rb +1 -1
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6049aac6b73ee5ff489628158400adeb752a25f5688b7edf199f3e29a3adcefe
|
4
|
+
data.tar.gz: c4dfa73f09d4ee510f2d8cf7b6b7a4ae63ab63ac9df61dbfdccec437b8ad6f89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58056e6ae6d7382fc1c47ee8099ced74f57edc6e1804057535853ad4d9ebc4af9acb5d51afbc984da5e454a8635f1631eb0f52673b240d3da53748b03e1e648c
|
7
|
+
data.tar.gz: '09d340be087a5a2b25dbce98459f9e4f5068f2564cd1c2b3b001130af04d292bb6a649644bdf13a87e298c353477ba0b52398a5ce7e18769769ffa2297a01deb'
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,37 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [0.
|
7
|
+
## [1.0.2] - [2020-12-29]
|
8
|
+
### Fixed
|
9
|
+
- Bug where we serialized an `updox_status`
|
10
|
+
|
11
|
+
## [1.0.1] - [2020-03-27]
|
12
|
+
### Added
|
13
|
+
- Patient#reminderMethodId to set reminder preferences
|
14
|
+
|
15
|
+
## [1.0.0] - [2020-02-25]
|
16
|
+
### Added
|
17
|
+
- Aliases canceled to cancelled
|
18
|
+
- Patient#exists?
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
- `failure_action = :raise` works better
|
22
|
+
- README fix for `failure_action` method
|
23
|
+
|
24
|
+
## [0.12.0] - [2020-02-21]
|
25
|
+
### Added
|
26
|
+
- Configuration to `raise` on non-success response
|
27
|
+
- Configuration to call a lambda on non-success response
|
28
|
+
|
29
|
+
### Fixed
|
30
|
+
- Bug with `as_json` method
|
31
|
+
- Bug when no date returns on statuses
|
32
|
+
|
33
|
+
## [0.11.0] - [2020-02-19]
|
34
|
+
### Added
|
35
|
+
- More fields to User model
|
36
|
+
|
37
|
+
## [0.10.0] - [2020-02-19]
|
8
38
|
### Fixed
|
9
39
|
- Bug with User#exists? always returning true
|
10
40
|
|
@@ -76,7 +106,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
76
106
|
### Added
|
77
107
|
- Initial Release with ability to ping Updox api
|
78
108
|
|
79
|
-
[0.
|
109
|
+
[1.0.2]: https://github.com/WeInfuse/updox/compare/v1.0.1...HEAD
|
110
|
+
[1.0.1]: https://github.com/WeInfuse/updox/compare/v1.0.0...v1.0.1
|
111
|
+
[1.0.0]: https://github.com/WeInfuse/updox/compare/v0.12.0...v1.0.0
|
112
|
+
[0.12.0]: https://github.com/WeInfuse/updox/compare/v0.11.0...v0.12.0
|
113
|
+
[0.11.0]: https://github.com/WeInfuse/updox/compare/v0.10.0...v0.11.0
|
114
|
+
[0.10.0]: https://github.com/WeInfuse/updox/compare/v0.9.0...v0.10.0
|
80
115
|
[0.9.0]: https://github.com/WeInfuse/updox/compare/v0.8.0...v0.9.0
|
81
116
|
[0.8.0]: https://github.com/WeInfuse/updox/compare/v0.7.0...v0.8.0
|
82
117
|
[0.7.0]: https://github.com/WeInfuse/updox/compare/v0.6.0...v0.7.0
|
data/README.md
CHANGED
@@ -146,9 +146,9 @@ response.practices # Has the practices as Updox::Models::Practice model
|
|
146
146
|
response.items # Same as practices, always exists on any model if alias is broken
|
147
147
|
response.item # If there is no array, we populate this object
|
148
148
|
|
149
|
-
|
150
|
-
|
151
|
-
|
149
|
+
response.successful? # Indicates Updox successful indication
|
150
|
+
response.response_code? # Indicates Updox response code
|
151
|
+
response.response_message? # Indicates Updox response message
|
152
152
|
|
153
153
|
response.response # Raw HTTParty response is here
|
154
154
|
```
|
@@ -159,8 +159,9 @@ response.response # Raw HTTParty response is here
|
|
159
159
|
Updox.configure do |c|
|
160
160
|
c.application_id = ENV['UPDOX_APP_ID']
|
161
161
|
c.application_password = ENV['UPDOX_APP_PASS']
|
162
|
-
c.api_endpoint =
|
162
|
+
c.api_endpoint = Updox::Connection::PROD_ENDPOINT # Defaults to Updox QA endpoint
|
163
163
|
c.parse_responses = false # Defaults to true
|
164
|
+
c.failure_action = :raise # Defaults to do nothing and allows lambdas
|
164
165
|
end
|
165
166
|
```
|
166
167
|
|
data/lib/updox.rb
CHANGED
@@ -4,6 +4,8 @@ require 'updox/version'
|
|
4
4
|
require 'updox/updox_exception'
|
5
5
|
require 'updox/connection'
|
6
6
|
require 'updox/models/model'
|
7
|
+
require 'updox/models/extensions/exists'
|
8
|
+
require 'updox/models/extensions/sync'
|
7
9
|
require 'updox/models/auth'
|
8
10
|
require 'updox/models/application'
|
9
11
|
require 'updox/models/appointment'
|
@@ -11,6 +13,7 @@ require 'updox/models/appointment_status'
|
|
11
13
|
require 'updox/models/calendar'
|
12
14
|
require 'updox/models/location'
|
13
15
|
require 'updox/models/patient'
|
16
|
+
require 'updox/models/patient_message'
|
14
17
|
require 'updox/models/practice'
|
15
18
|
require 'updox/models/reminder'
|
16
19
|
require 'updox/models/status'
|
@@ -19,6 +22,7 @@ require 'updox/models/user'
|
|
19
22
|
module Updox
|
20
23
|
class Configuration
|
21
24
|
attr_accessor :application_id, :application_password, :parse_responses
|
25
|
+
attr_reader :failure_action
|
22
26
|
|
23
27
|
alias_method :parse_responses?, :parse_responses
|
24
28
|
|
@@ -26,6 +30,12 @@ module Updox
|
|
26
30
|
@application_id = nil
|
27
31
|
@application_password = nil
|
28
32
|
@parse_responses = true
|
33
|
+
@failure_action = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def failure_action=(value)
|
37
|
+
raise "Failure action must be 'nil', ':raise' or callable object!" unless value.nil? || value.respond_to?(:call) || :raise == value
|
38
|
+
@failure_action = value
|
29
39
|
end
|
30
40
|
|
31
41
|
def api_endpoint=(endpoint)
|
@@ -41,7 +51,8 @@ module Updox
|
|
41
51
|
application_id: @application_id,
|
42
52
|
application_password: @application_password,
|
43
53
|
api_endpoint: api_endpoint,
|
44
|
-
parse_responses: @parse_responses
|
54
|
+
parse_responses: @parse_responses,
|
55
|
+
failure_action: @failure_action
|
45
56
|
}
|
46
57
|
end
|
47
58
|
|
@@ -50,6 +61,7 @@ module Updox
|
|
50
61
|
self.application_password = h[:application_password]
|
51
62
|
self.api_endpoint = h[:api_endpoint]
|
52
63
|
self.parse_responses = h[:parse_responses]
|
64
|
+
self.failure_action = h[:failure_action]
|
53
65
|
|
54
66
|
return self
|
55
67
|
end
|
data/lib/updox/connection.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module Updox
|
2
2
|
class Connection
|
3
|
-
|
4
|
-
|
3
|
+
URI_BUILDER = ->(host) { "https://#{host}/api/io/".freeze }
|
4
|
+
|
5
|
+
QA_ENDPOINT = URI_BUILDER.call('updoxqa.com')
|
6
|
+
PROD_ENDPOINT = URI_BUILDER.call('myupdox.com')
|
5
7
|
|
6
8
|
include HTTParty
|
7
9
|
|
8
|
-
base_uri
|
10
|
+
base_uri QA_ENDPOINT
|
9
11
|
|
10
12
|
headers 'Content-Type' => 'application/json'
|
11
13
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Updox
|
2
|
+
ERROR_CODES = {
|
3
|
+
"2000"=>"OK",
|
4
|
+
"4000"=>"Bad Request",
|
5
|
+
"4010"=>"Unauthorized",
|
6
|
+
"4011"=>"Unauthorized [Practice does not exist or is inactive]",
|
7
|
+
"4012"=>"Unauthorized [User does not exist or is inactive]",
|
8
|
+
"4060"=>"A validation error in the request. For example not including a required field, an invalid e-mail address, too long of a value, etc. A list of the errors is included in the message.",
|
9
|
+
"5000"=>"an unknown error has occurred",
|
10
|
+
"5100"=>"an unknown server error has occurred",
|
11
|
+
"5110"=>"an unknown server error has occurred",
|
12
|
+
"4130"=>"account already exists",
|
13
|
+
"4110"=>"no practice ID",
|
14
|
+
"4160"=>"direct domain is invalid",
|
15
|
+
"4621"=>"direct address error: domain does not match the direct domain for this vendor",
|
16
|
+
"4150"=>"direct domain is already taken",
|
17
|
+
"4163"=>"direct domain is unavailable",
|
18
|
+
"4610"=>"direct address error: direct address is taken",
|
19
|
+
"4161"=>"web address is invalid",
|
20
|
+
"4131"=>"account does not exist",
|
21
|
+
"4140"=>"web address is already taken",
|
22
|
+
"4230"=>"user already exists",
|
23
|
+
"4210"=>"no user ID",
|
24
|
+
"4241"=>"invalid user ID, user IDs starting with '@' are reserved for practice users",
|
25
|
+
"4251"=>"invalid NPI",
|
26
|
+
"4252"=>"invalid taxonomy code",
|
27
|
+
"4630"=>"direct address error: account does not have a direct domain configured",
|
28
|
+
"4232"=>"user password is required",
|
29
|
+
"4240"=>"user does not exist, use practice methods instead",
|
30
|
+
"4231"=>"user does not exist",
|
31
|
+
"4641"=>"direct address error: sending user does not have a direct address configured",
|
32
|
+
"4642"=>"direct address error: identity verification required to send to this address",
|
33
|
+
"4640"=>"direct address error: invalid direct address",
|
34
|
+
"4650"=>"direct error: send failed",
|
35
|
+
"4651"=>"direct error: send failed and/or invalid direct address",
|
36
|
+
"4430"=>"message type does not have any MDNs",
|
37
|
+
"4410"=>"message not found",
|
38
|
+
"4652"=>"direct error: either from or patientDemographics is required",
|
39
|
+
"4071"=>"Recipient not found",
|
40
|
+
"4070"=>"Invalid recipient",
|
41
|
+
"4831"=>"portal account does not exist",
|
42
|
+
"4830"=>"portal account already exists",
|
43
|
+
"4832"=>"patient has opted out of portal communications",
|
44
|
+
"4731"=>"patient account does not exist",
|
45
|
+
"4960"=>"image not found",
|
46
|
+
"4331"=>"contact does not exist",
|
47
|
+
"4931"=>"you sent zero bulk faxes with this bulkFaxId",
|
48
|
+
"4021"=>"Invalid date format",
|
49
|
+
"4930"=>"no fax found for this ID",
|
50
|
+
"4932"=>"fax number does not appear to be available",
|
51
|
+
"4933"=>"invalid fax number",
|
52
|
+
"4330"=>"contact already exists",
|
53
|
+
"6212"=>"at least one id must be specified for the request",
|
54
|
+
"4162"=>"ip is invalid",
|
55
|
+
"4165"=>"port is invalid",
|
56
|
+
"6210"=>"at least one value must be provided",
|
57
|
+
"6213"=>"record does not exist for ID",
|
58
|
+
"9010"=>"the date format must be in the format is yyyy-MM-dd"
|
59
|
+
}
|
60
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Updox
|
2
2
|
module Models
|
3
3
|
class Appointment < Model
|
4
|
+
extend Updox::Models::Extensions::Sync
|
5
|
+
|
4
6
|
SYNC_ENDPOINT = '/AppointmentsSync'.freeze
|
5
7
|
|
6
8
|
SYNC_LIST_TYPE = 'appointments'.freeze
|
@@ -14,8 +16,8 @@ module Updox
|
|
14
16
|
property :typeId, from: :type_id
|
15
17
|
property :summary
|
16
18
|
property :details
|
17
|
-
property :blocked, required: true,
|
18
|
-
property :cancelled, required: true,
|
19
|
+
property :blocked, required: true, default: false
|
20
|
+
property :cancelled, required: true, from: :canceled, default: false
|
19
21
|
property :locationId, from: :location_id
|
20
22
|
property :reminderTokens, from: :reminder_tokens
|
21
23
|
|
@@ -25,6 +27,7 @@ module Updox
|
|
25
27
|
alias_method :type_id, :typeId
|
26
28
|
alias_method :location_id, :locationId
|
27
29
|
alias_method :reminder_tokens, :reminderTokens
|
30
|
+
alias_method :canceled, :cancelled
|
28
31
|
|
29
32
|
def to_h
|
30
33
|
result = super.to_h
|
@@ -33,7 +36,6 @@ module Updox
|
|
33
36
|
|
34
37
|
result
|
35
38
|
end
|
36
|
-
alias_method :as_json, :to_h
|
37
39
|
|
38
40
|
def save(account_id: )
|
39
41
|
self.class.sync([self], account_id: account_id)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Updox
|
2
|
+
module Models
|
3
|
+
module Extensions
|
4
|
+
module Exists
|
5
|
+
def exists?(item_id, account_id: , cached_query: nil)
|
6
|
+
raise UpdoxException.new('Not implemented on this model.') unless self.respond_to?(:find)
|
7
|
+
opts = { account_id: account_id }
|
8
|
+
opts[:cached_query] = cached_query unless cached_query.nil?
|
9
|
+
|
10
|
+
response = self.find(item_id, **opts)
|
11
|
+
|
12
|
+
false == response.nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Updox
|
2
|
+
module Models
|
3
|
+
module Extensions
|
4
|
+
module Sync
|
5
|
+
RECOMMENDED_BATCH_SIZE = 200
|
6
|
+
|
7
|
+
def sync(items, account_id: , batch_size: RECOMMENDED_BATCH_SIZE, endpoint: self.const_get(:SYNC_ENDPOINT))
|
8
|
+
response = nil
|
9
|
+
list_type = self.const_get(:SYNC_LIST_TYPE)
|
10
|
+
|
11
|
+
if 0 >= batch_size
|
12
|
+
response = request(endpoint: endpoint, body: { list_type => items }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
|
13
|
+
else
|
14
|
+
items.each_slice(batch_size) do |batch|
|
15
|
+
r = request(endpoint: endpoint, body: { list_type => batch }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
|
16
|
+
|
17
|
+
return r unless r.successful?
|
18
|
+
|
19
|
+
if response
|
20
|
+
response.items += r.items
|
21
|
+
else
|
22
|
+
response = r
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
return response
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/updox/models/model.rb
CHANGED
@@ -1,69 +1,43 @@
|
|
1
1
|
module Updox
|
2
2
|
module Models
|
3
3
|
DATETIME_FORMAT = '%Y-%m-%d %H:%M'.freeze
|
4
|
-
|
5
|
-
|
6
|
-
RECOMMENDED_BATCH_SIZE = 200
|
4
|
+
DATETIME_TZ_FORMAT = '%m/%d/%Y %H:%M:%s %z'.freeze
|
7
5
|
|
8
6
|
class Model < Hashie::Trash
|
9
7
|
include Hashie::Extensions::IgnoreUndeclared
|
10
8
|
include Hashie::Extensions::IndifferentAccess
|
11
9
|
|
10
|
+
attr_writer :updox_status
|
11
|
+
|
12
12
|
LIST_TYPE = 'undefined'
|
13
13
|
LIST_NAME = 'models'
|
14
14
|
ITEM_TYPE = 'model'
|
15
15
|
|
16
16
|
property :item, required: false
|
17
17
|
property :items, required: false
|
18
|
-
property :updox_status, default: {}
|
19
18
|
|
20
19
|
def successful?
|
21
|
-
|
20
|
+
@updox_status['successful']
|
22
21
|
end
|
23
22
|
|
24
23
|
def response_code
|
25
|
-
|
24
|
+
@updox_status['responseCode']
|
26
25
|
end
|
27
26
|
|
28
27
|
def response_message
|
29
|
-
|
28
|
+
@updox_status['responseMessage']
|
30
29
|
end
|
31
30
|
|
32
|
-
def
|
33
|
-
|
31
|
+
def updox_status
|
32
|
+
@updox_status ||= {}
|
34
33
|
end
|
35
34
|
|
36
|
-
def
|
37
|
-
|
38
|
-
opts = { account_id: account_id }
|
39
|
-
opts[:cached_query] = cached_query unless cached_query.nil?
|
40
|
-
|
41
|
-
response = self.find(item_id, **opts)
|
42
|
-
|
43
|
-
false == response.nil? && (false == self.const_defined?(:FIND_ENDPOINT) || response.successful?)
|
35
|
+
def error_message
|
36
|
+
"#{response_code}: #{response_message}"
|
44
37
|
end
|
45
38
|
|
46
|
-
def
|
47
|
-
|
48
|
-
list_type = self.const_get(:SYNC_LIST_TYPE)
|
49
|
-
|
50
|
-
if 0 >= batch_size
|
51
|
-
response = request(endpoint: endpoint, body: { list_type => items }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
|
52
|
-
else
|
53
|
-
items.each_slice(batch_size) do |batch|
|
54
|
-
r = request(endpoint: endpoint, body: { list_type => batch }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
|
55
|
-
|
56
|
-
return r unless r.successful?
|
57
|
-
|
58
|
-
if response
|
59
|
-
response.items += r.items
|
60
|
-
else
|
61
|
-
response = r
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
return response
|
39
|
+
def as_json(options = nil)
|
40
|
+
self.to_h
|
67
41
|
end
|
68
42
|
|
69
43
|
def self.request(**kwargs)
|
@@ -88,22 +62,32 @@ module Updox
|
|
88
62
|
model.item = klazz.new(data.dig(klazz.const_get(:ITEM_TYPE)))
|
89
63
|
model.define_singleton_method(klazz.const_get(:ITEM_TYPE)) { self.item }
|
90
64
|
else
|
91
|
-
|
92
|
-
|
65
|
+
status_key = data&.keys&.find {|k| k.to_s.downcase.end_with?('statuses') }
|
66
|
+
status_class = 'Updox::Models::' + status_key[0..-3].capitalize if status_key
|
93
67
|
|
94
|
-
if
|
68
|
+
if status_key.nil? || false == Module.const_defined?(status_class)
|
95
69
|
model.items = [data]
|
96
70
|
else
|
97
|
-
statuses = data.delete(
|
71
|
+
statuses = data.delete(status_key)
|
98
72
|
|
99
|
-
model.items = statuses.map {|status| Object.const_get(
|
73
|
+
model.items = statuses.map {|status| Object.const_get(status_class).new(status) }
|
100
74
|
model.define_singleton_method(:statuses) { self.items }
|
101
75
|
end
|
102
76
|
|
103
77
|
model.item = data
|
104
78
|
end
|
105
79
|
|
106
|
-
|
80
|
+
if (data.is_a?(Hash))
|
81
|
+
model.updox_status = data&.select {|k,v| ['successful', 'responseMessage', 'responseCode'].include?(k)} || {}
|
82
|
+
|
83
|
+
if false == model.successful? && false == Updox.configuration.failure_action.nil?
|
84
|
+
if Updox.configuration.failure_action.respond_to?(:call)
|
85
|
+
Updox.configuration.failure_action.call(model)
|
86
|
+
elsif :raise == Updox.configuration.failure_action
|
87
|
+
raise UpdoxException.from_response(response, msg: 'request')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
107
91
|
else
|
108
92
|
raise UpdoxException.from_response(response)
|
109
93
|
end
|
data/lib/updox/models/patient.rb
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
module Updox
|
2
2
|
module Models
|
3
3
|
class Patient < Model
|
4
|
+
extend Updox::Models::Extensions::Sync
|
5
|
+
|
4
6
|
SYNC_ENDPOINT = '/PatientsSync'.freeze
|
5
7
|
SYNC_LIST_TYPE = 'patients'.freeze
|
6
8
|
|
9
|
+
REMINDER_PREFERENCES = {
|
10
|
+
practice: 0,
|
11
|
+
email: 1,
|
12
|
+
home_phone: 2,
|
13
|
+
mobile_phone: 3,
|
14
|
+
mobile_text: 4,
|
15
|
+
off: 5
|
16
|
+
}
|
17
|
+
|
7
18
|
property :id
|
8
19
|
property :internalId, required: true, from: :internal_id
|
9
20
|
property :firstName, from: :first_name
|
@@ -15,6 +26,7 @@ module Updox
|
|
15
26
|
property :workPhone, from: :work_phone
|
16
27
|
property :mobileNumber, from: :mobile_number
|
17
28
|
property :mobileNumber, from: :mobile_phone
|
29
|
+
property :reminderMethodId, from: :reminder_method_id
|
18
30
|
property :active, default: true
|
19
31
|
|
20
32
|
alias_method :email, :emailAddress
|
@@ -27,13 +39,24 @@ module Updox
|
|
27
39
|
alias_method :work_phone, :workPhone
|
28
40
|
alias_method :mobile_number, :mobileNumber
|
29
41
|
alias_method :mobile_phone, :mobileNumber
|
42
|
+
alias_method :reminder_preference, :reminderMethodId
|
43
|
+
|
44
|
+
def reminder_preference=(value)
|
45
|
+
if Updox::Models::Patient::REMINDER_PREFERENCES.include?(value)
|
46
|
+
self[:reminderMethodId] = Updox::Models::Patient::REMINDER_PREFERENCES[value]
|
47
|
+
else
|
48
|
+
self[:reminderMethodId] = value
|
49
|
+
end
|
50
|
+
|
51
|
+
self
|
52
|
+
end
|
30
53
|
|
31
54
|
def save(account_id: )
|
32
55
|
self.class.sync([self], account_id: account_id)
|
33
56
|
end
|
34
57
|
|
35
58
|
def self.exists?(patient_id, account_id: )
|
36
|
-
|
59
|
+
Updox::Models::PatientMessage.exists?(patient_id, account_id: account_id)
|
37
60
|
end
|
38
61
|
end
|
39
62
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Updox
|
2
|
+
module Models
|
3
|
+
class PatientMessage < Model
|
4
|
+
LIST_ENDPOINT = '/PatientMessageCountSince'.freeze
|
5
|
+
|
6
|
+
def self.query(patient_id, account_id: )
|
7
|
+
request(endpoint: LIST_ENDPOINT, body: { patientId: patient_id }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.exists?(patient_id, account_id: )
|
11
|
+
request(endpoint: LIST_ENDPOINT, body: { patientId: patient_id }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT).successful?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -40,11 +40,17 @@ module Updox
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.exists?(account_id)
|
43
|
-
self.find(account_id).
|
43
|
+
false == self.find(account_id).nil?
|
44
44
|
end
|
45
45
|
|
46
46
|
def self.find(account_id)
|
47
|
-
request(endpoint: FIND_ENDPOINT, body: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_APP)
|
47
|
+
response = request(endpoint: FIND_ENDPOINT, body: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_APP)
|
48
|
+
|
49
|
+
if response.successful?
|
50
|
+
response
|
51
|
+
else
|
52
|
+
nil
|
53
|
+
end
|
48
54
|
end
|
49
55
|
|
50
56
|
def self.query
|
@@ -3,7 +3,7 @@ module Updox
|
|
3
3
|
class Reminder < Model
|
4
4
|
property :reminderId
|
5
5
|
property :reminderStatus
|
6
|
-
property :reminderStatusDate, transform_with: ->(v) { DateTime.strptime(v,
|
6
|
+
property :reminderStatusDate, transform_with: ->(v) { DateTime.strptime(v, DATETIME_TZ_FORMAT) unless v.nil? || v.empty? }
|
7
7
|
property :reminderType
|
8
8
|
|
9
9
|
alias_method :reminder_id, :reminderId
|
data/lib/updox/models/user.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Updox
|
2
2
|
module Models
|
3
3
|
class User < Model
|
4
|
+
extend Updox::Models::Extensions::Exists
|
5
|
+
|
4
6
|
SAVE_ENDPOINT = '/UserSave'.freeze
|
5
7
|
QUERY_ENDPOINT = '/UserList'.freeze
|
6
8
|
FIND_ENDPOINT = '/UserGet'.freeze
|
@@ -21,21 +23,37 @@ module Updox
|
|
21
23
|
property :city
|
22
24
|
property :state
|
23
25
|
property :postal
|
26
|
+
property :timeZone, from: :time_zone
|
27
|
+
property :metadata
|
28
|
+
property :vetted
|
29
|
+
property :active, default: true
|
30
|
+
property :searchOptOut, from: :search_opt_out, default: true
|
31
|
+
property :npi
|
32
|
+
property :providerTaxonomyCode, from: :provider_taxonomy_code
|
33
|
+
property :directAddress, from: :direct_address
|
24
34
|
property :provider, default: false
|
25
35
|
property :admin, default: false
|
26
|
-
property :searchOptOut, from: :search_opt_out, default: true
|
27
36
|
|
28
37
|
alias_method :user_id, :userId
|
29
38
|
alias_method :first_name, :firstName
|
30
39
|
alias_method :last_name, :lastName
|
31
40
|
alias_method :login_password, :loginPassword
|
41
|
+
alias_method :time_zone, :timeZone
|
42
|
+
alias_method :provider_taxonomy_code, :providerTaxonomyCode
|
43
|
+
alias_method :direct_address, :directAddress
|
32
44
|
|
33
45
|
def create(account_id: )
|
34
46
|
self.class.request(endpoint: SAVE_ENDPOINT, body: self.to_h, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
|
35
47
|
end
|
36
48
|
|
37
49
|
def self.find(user_id, account_id: )
|
38
|
-
request(endpoint: FIND_ENDPOINT, account_id: account_id, body: { userId: user_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
|
50
|
+
response = request(endpoint: FIND_ENDPOINT, account_id: account_id, body: { userId: user_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
|
51
|
+
|
52
|
+
if response.successful?
|
53
|
+
response
|
54
|
+
else
|
55
|
+
nil
|
56
|
+
end
|
39
57
|
end
|
40
58
|
|
41
59
|
def self.query
|
@@ -1,27 +1,30 @@
|
|
1
1
|
module Updox
|
2
2
|
class UpdoxException < Exception
|
3
3
|
def self.from_response(response, msg: nil)
|
4
|
+
data = {}
|
4
5
|
exception_msg = "Failed #{msg}:"
|
5
|
-
|
6
|
+
data['HTTP_CODE'] = response.code
|
6
7
|
|
7
8
|
begin
|
8
9
|
error_response = JSON.parse(response.body)
|
9
10
|
|
10
11
|
if error_response.is_a?(Hash)
|
11
12
|
if error_response.include?('responseMessage')
|
12
|
-
|
13
|
+
data['MSG'] = error_response['responseMessage']
|
13
14
|
end
|
14
15
|
|
15
16
|
if error_response.include?('responseCode')
|
16
|
-
|
17
|
+
data['UPDOX_CODE'] = error_response['responseCode']
|
17
18
|
end
|
18
19
|
else
|
19
|
-
|
20
|
+
data['MSG'] = error_response
|
20
21
|
end
|
21
22
|
rescue JSON::ParserError
|
22
|
-
|
23
|
+
data['MSG'] = response.body
|
23
24
|
end
|
24
25
|
|
26
|
+
data.each {|k,v| exception_msg << " #{k} '#{v}'" }
|
27
|
+
|
25
28
|
return UpdoxException.new(exception_msg)
|
26
29
|
end
|
27
30
|
end
|
data/lib/updox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: updox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Crockett
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -128,7 +128,7 @@ dependencies:
|
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0.9'
|
131
|
-
description:
|
131
|
+
description:
|
132
132
|
email:
|
133
133
|
- mike.crockett@weinfuse.com
|
134
134
|
executables: []
|
@@ -142,14 +142,18 @@ files:
|
|
142
142
|
- Rakefile
|
143
143
|
- lib/updox.rb
|
144
144
|
- lib/updox/connection.rb
|
145
|
+
- lib/updox/error_message.rb
|
145
146
|
- lib/updox/models/application.rb
|
146
147
|
- lib/updox/models/appointment.rb
|
147
148
|
- lib/updox/models/appointment_status.rb
|
148
149
|
- lib/updox/models/auth.rb
|
149
150
|
- lib/updox/models/calendar.rb
|
151
|
+
- lib/updox/models/extensions/exists.rb
|
152
|
+
- lib/updox/models/extensions/sync.rb
|
150
153
|
- lib/updox/models/location.rb
|
151
154
|
- lib/updox/models/model.rb
|
152
155
|
- lib/updox/models/patient.rb
|
156
|
+
- lib/updox/models/patient_message.rb
|
153
157
|
- lib/updox/models/practice.rb
|
154
158
|
- lib/updox/models/reminder.rb
|
155
159
|
- lib/updox/models/status.rb
|
@@ -162,7 +166,7 @@ licenses:
|
|
162
166
|
- MIT
|
163
167
|
metadata:
|
164
168
|
allowed_push_host: https://rubygems.org
|
165
|
-
post_install_message:
|
169
|
+
post_install_message:
|
166
170
|
rdoc_options: []
|
167
171
|
require_paths:
|
168
172
|
- lib
|
@@ -177,9 +181,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
181
|
- !ruby/object:Gem::Version
|
178
182
|
version: '0'
|
179
183
|
requirements: []
|
180
|
-
rubyforge_project:
|
184
|
+
rubyforge_project:
|
181
185
|
rubygems_version: 2.7.6
|
182
|
-
signing_key:
|
186
|
+
signing_key:
|
183
187
|
specification_version: 4
|
184
188
|
summary: Ruby wrapper for the Updox API
|
185
189
|
test_files: []
|