updox 0.6.0 → 0.7.0

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
  SHA256:
3
- metadata.gz: 012ec2142bd40cd1717538f15d9c20d93020c63526bd6ef6db06ede30596dd75
4
- data.tar.gz: 676af6481645729aaf1c9ecdd187185c853203174ead58120375de8d4322a362
3
+ metadata.gz: 330210debd9f3caa13bc37acbdafadd76cee2a2cde2f1d89e8be424948d6fc42
4
+ data.tar.gz: f078682f62f95674ca95ea0f91d0303600b0715618a73454c1b47c3e9f922909
5
5
  SHA512:
6
- metadata.gz: ce55c116e9a6f25022a2515194c16fc894f6cc60218971cbe22cded9d85f17184080b1056e22f9c65d9e95bb1ef79b3c241ef8216f37dc8e52de8a21a1f3d51e
7
- data.tar.gz: 202765e4aba6a39adc1e99f7bbb67b7d5366d87b74c298bd3ed8f26d85bd3e251f75d38b33e02e6197f631e59109a896c977a08524818e21c7c81c7365e30a33
6
+ metadata.gz: a38e7a6a09796e65a6c3abde8f0fadd7188cb3cd6295782f413ef34959c7ae6177ff29df8e91aff555f2a8dcab6220e0855f25354bd8f5ba95e30e7a1b216bda
7
+ data.tar.gz: daa1c9efc99c7b196fc25dc4ee6591ff9bb8a17724e9bd05b0cb741f6fa95cb1db7da8e1defe580e609ee75f566d6c47aa9f7f2428cd6212007392e531adbb9e
data/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ 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.0] - [UNRELEASED]
8
+ ### Added
9
+ - AppointmentStatus
10
+ - Reminder
11
+ - Status
12
+ - Can batch sync requests
13
+ - Response with statuses is automatically converted into status objects
14
+
7
15
  ## [0.6.0] - 2020-02-13
8
16
  ### Added
9
17
  - Calendar#query
@@ -52,6 +60,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
52
60
  ### Added
53
61
  - Initial Release with ability to ping Updox api
54
62
 
63
+ [0.7.0]: https://github.com/WeInfuse/updox/compare/v0.6.0...HEAD
55
64
  [0.6.0]: https://github.com/WeInfuse/updox/compare/v0.5.0...v0.6.0
56
65
  [0.5.0]: https://github.com/WeInfuse/updox/compare/v0.4.0...v0.5.0
57
66
  [0.4.0]: https://github.com/WeInfuse/updox/compare/v0.3.0...v0.4.0
@@ -2,7 +2,8 @@ module Updox
2
2
  module Models
3
3
  class Appointment < Model
4
4
  SYNC_ENDPOINT = '/AppointmentsSync'.freeze
5
- LIST_ENDPOINT = '/AppointmentStatusesGetByIds'.freeze
5
+
6
+ SYNC_LIST_TYPE = 'appointments'.freeze
6
7
 
7
8
  property :id, required: true
8
9
  property :updoxId, from: :updox_id
@@ -38,21 +39,7 @@ module Updox
38
39
  end
39
40
 
40
41
  def self.exists?(appointment_id, account_id: , cached_query: nil)
41
- false == self.find(appointment_id, account_id: account_id, cached_query: cached_query).nil?
42
- end
43
-
44
- def self.find(appointment_id, account_id: , cached_query: nil)
45
- obj = cached_query || self.query([appointment_id], account_id: account_id)
46
-
47
- obj.item['appointmentStatuses'].find {|appointment| appointment_id.to_s == appointment[:externalAppointmentId].to_s }
48
- end
49
-
50
- def self.query(appointment_ids, account_id: , active_only: false)
51
- request(endpoint: LIST_ENDPOINT, body: { apopintmentIds: appointment_ids }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
52
- end
53
-
54
- def self.sync(appointments, account_id: )
55
- request(endpoint: SYNC_ENDPOINT, body: { appointments: appointments.map(&:to_h) }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
42
+ Updox::Models::AppointmentStatus.exists?(appointment_id, account_id: account_id, cached_query: cached_query)
56
43
  end
57
44
  end
58
45
  end
@@ -0,0 +1,33 @@
1
+ module Updox
2
+ module Models
3
+ class AppointmentStatus < Model
4
+ LIST_ENDPOINT = '/AppointmentStatusesGetByIds'.freeze
5
+
6
+ LIST_TYPE = 'appointmentStatuses'
7
+ LIST_NAME = 'statuses'
8
+
9
+ property :appointmentId
10
+ property :externalAppointmentId
11
+ property :appointmentStatus
12
+ property :reminders, transform_with: ->(list) { list.map {|item| Updox::Models::Reminder.new(item) } }
13
+
14
+ alias_method :appointment_id, :appointmentId
15
+ alias_method :external_appointment_id, :externalAppointmentId
16
+ alias_method :appointment_status, :appointmentStatus
17
+
18
+ def self.exists?(appointment_id, account_id: , cached_query: nil)
19
+ false == self.find(appointment_id, account_id: account_id, cached_query: cached_query).nil?
20
+ end
21
+
22
+ def self.find(appointment_id, account_id: , cached_query: nil)
23
+ obj = cached_query || self.query([appointment_id], account_id: account_id)
24
+
25
+ obj.statuses.find {|status| appointment_id.to_s == status.external_appointment_id.to_s }
26
+ end
27
+
28
+ def self.query(appointment_ids, account_id: , active_only: false)
29
+ request(endpoint: LIST_ENDPOINT, body: { appointmentIds: appointment_ids }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -4,8 +4,9 @@ module Updox
4
4
  SYNC_ENDPOINT = '/LocationsSync'.freeze
5
5
  LIST_ENDPOINT = '/PracticeLocationsRetrieve'.freeze
6
6
 
7
- LIST_TYPE = 'locations'
7
+ LIST_TYPE = 'locations'.freeze
8
8
  LIST_NAME = LIST_TYPE
9
+ SYNC_LIST_TYPE = LIST_TYPE
9
10
 
10
11
  property :id
11
12
  property :code
@@ -50,10 +51,6 @@ module Updox
50
51
  def self.query(account_id: , active_only: false)
51
52
  request(endpoint: LIST_ENDPOINT, body: { activeOnly: active_only }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
52
53
  end
53
-
54
- def self.sync(locations, account_id: )
55
- request(endpoint: SYNC_ENDPOINT, body: { locations: locations }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
56
- end
57
54
  end
58
55
  end
59
56
  end
@@ -1,8 +1,9 @@
1
1
  module Updox
2
2
  module Models
3
3
  DATETIME_FORMAT = '%Y-%m-%d %H:%M'.freeze
4
+ DATETIME_OTHER_FORMAT = '%m/%d/%Y %H:%M:%s %z'.freeze
4
5
 
5
- #BATCH_SIZE = 200
6
+ RECOMMENDED_BATCH_SIZE = 200
6
7
 
7
8
  class Model < Hashie::Trash
8
9
  include Hashie::Extensions::IgnoreUndeclared
@@ -32,6 +33,29 @@ module Updox
32
33
  "#{response_code}: #{response_message}"
33
34
  end
34
35
 
36
+ def self.sync(items, account_id: , batch_size: RECOMMENDED_BATCH_SIZE, endpoint: self.const_get(:SYNC_ENDPOINT))
37
+ response = nil
38
+ list_type = self.const_get(:SYNC_LIST_TYPE)
39
+
40
+ if 0 >= batch_size
41
+ response = request(endpoint: endpoint, body: { list_type => items }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
42
+ else
43
+ items.each_slice(batch_size) do |batch|
44
+ r = request(endpoint: endpoint, body: { list_type => batch }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
45
+
46
+ return r unless r.successful?
47
+
48
+ if response
49
+ response.items += r.items
50
+ else
51
+ response = r
52
+ end
53
+ end
54
+ end
55
+
56
+ return response
57
+ end
58
+
35
59
  def self.request(**kwargs)
36
60
  from_response(UpdoxClient.connection.request(kwargs))
37
61
  end
@@ -54,7 +78,18 @@ module Updox
54
78
  model.item = klazz.new(data.dig(klazz.const_get(:ITEM_TYPE)))
55
79
  model.define_singleton_method(klazz.const_get(:ITEM_TYPE)) { self.item }
56
80
  else
57
- model.items = [data]
81
+ k = data&.keys&.find {|k| k.to_s.downcase.end_with?('statuses') }
82
+ c = 'Updox::Models::' + k[0..-3].capitalize if k
83
+
84
+ if k.nil? || false == Module.const_defined?(c)
85
+ model.items = [data]
86
+ else
87
+ statuses = data.delete(k)
88
+
89
+ model.items = statuses.map {|status| Object.const_get(c).new(status) }
90
+ model.define_singleton_method(:statuses) { self.items }
91
+ end
92
+
58
93
  model.item = data
59
94
  end
60
95
 
@@ -2,6 +2,7 @@ module Updox
2
2
  module Models
3
3
  class Patient < Model
4
4
  SYNC_ENDPOINT = '/PatientsSync'.freeze
5
+ SYNC_LIST_TYPE = 'patients'.freeze
5
6
 
6
7
  property :id
7
8
  property :internalId, required: true, from: :internal_id
@@ -34,10 +35,6 @@ module Updox
34
35
  def self.exists?(patient_id, account_id: )
35
36
  request(endpoint: MESSAGE_COUNT_ENDPOINT, body: { patientId: patient_id }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT).successful?
36
37
  end
37
-
38
- def self.sync(patients, account_id: )
39
- request(endpoint: SYNC_ENDPOINT, body: { patients: patients }, auth: {accountId: account_id}, required_auths: Updox::Models::Auth::AUTH_ACCT)
40
- end
41
38
  end
42
39
  end
43
40
  end
@@ -0,0 +1,19 @@
1
+ module Updox
2
+ module Models
3
+ class Reminder < Model
4
+ property :reminderId
5
+ property :reminderStatus
6
+ property :reminderStatusDate, transform_with: ->(v) { DateTime.strptime(v, DATETIME_OTHER_FORMAT) }
7
+ property :reminderType
8
+
9
+ alias_method :reminder_id, :reminderId
10
+ alias_method :reminder_status, :reminderStatus
11
+ alias_method :reminder_status_date, :reminderStatusDate
12
+ alias_method :reminder_type, :reminderType
13
+ alias_method :id, :reminderId
14
+ alias_method :date, :reminderStatusDate
15
+ alias_method :status, :reminderStatus
16
+ alias_method :type, :reminderType
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ module Updox
2
+ module Models
3
+ class Status < Model
4
+ LIST_TYPE = 'statuses'
5
+ LIST_NAME = LIST_TYPE
6
+
7
+ property :id
8
+ property :success
9
+ property :message
10
+
11
+ alias_method :success?, :success
12
+ end
13
+ end
14
+ end
data/lib/updox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Updox
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
data/lib/updox.rb CHANGED
@@ -7,10 +7,13 @@ require 'updox/models/model'
7
7
  require 'updox/models/auth'
8
8
  require 'updox/models/application'
9
9
  require 'updox/models/appointment'
10
+ require 'updox/models/appointment_status'
10
11
  require 'updox/models/calendar'
11
12
  require 'updox/models/location'
12
13
  require 'updox/models/patient'
13
14
  require 'updox/models/practice'
15
+ require 'updox/models/reminder'
16
+ require 'updox/models/status'
14
17
  require 'updox/models/user'
15
18
 
16
19
  module Updox
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.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Crockett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-13 00:00:00.000000000 Z
11
+ date: 2020-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -144,12 +144,15 @@ files:
144
144
  - lib/updox/connection.rb
145
145
  - lib/updox/models/application.rb
146
146
  - lib/updox/models/appointment.rb
147
+ - lib/updox/models/appointment_status.rb
147
148
  - lib/updox/models/auth.rb
148
149
  - lib/updox/models/calendar.rb
149
150
  - lib/updox/models/location.rb
150
151
  - lib/updox/models/model.rb
151
152
  - lib/updox/models/patient.rb
152
153
  - lib/updox/models/practice.rb
154
+ - lib/updox/models/reminder.rb
155
+ - lib/updox/models/status.rb
153
156
  - lib/updox/models/user.rb
154
157
  - lib/updox/updox_exception.rb
155
158
  - lib/updox/version.rb