redox 1.3.0 → 1.5.2

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: 0666bbb5152f4d34f3966dad512c2b1c6bb62cd661235516ad2a123eca63e653
4
- data.tar.gz: ec535077633c70fa241a3ee5a8af81812791e53e36f72dfcfcb87900b96a9fe5
3
+ metadata.gz: 4e502173db4efa95ee3c6e4f338ad78344c25c52aa35be766d4f6137724a4923
4
+ data.tar.gz: 339890660bea9426b4950c33697a7e38eada9b07ba0a4356ecda5076271d404c
5
5
  SHA512:
6
- metadata.gz: 844d30e49f7d57e5ca0dd7acc91d3bbc0aac672213e7016de5f5f52cac6e77e1123f1cb94613c5521d90c2f0a7445e0174af223c1e5b93c092386f6be5d2f9d6
7
- data.tar.gz: 1d09377d50c8729f7e3698bd2de877b3b4c081a8ec21a3b9997e0da6dbc9c5bab7f58fb6cb1da273e062443b41168bdb7178c872c8beeda77e24f8239cd7636f
6
+ metadata.gz: a434730a3fb38681fdd434ac7451c1c9ee5ed49f9f136292991f2499e97f6f16537c853bb1d1b2c13b25882e3ea0210d2cb301f64594fc97c9a229341a5fc213
7
+ data.tar.gz: 7d9ab435afe16ae9288f5a8dea5c18e137d592adc4122ecd3b65dbd6504ecbe22b5ecd0ba1c262abcd797ecc230f8c24ce39963fbabf315c8233eb7d9b0334f7
@@ -4,6 +4,42 @@ 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
+ ## [1.5.2] - 2021-01-08
8
+ ### Added
9
+ - Visit#Type
10
+ - Visit#Status
11
+ - Visit#Reason
12
+ - Visit#Equipment
13
+
14
+ ## [1.5.1] - 2020-12-22
15
+ ### Added
16
+ - Contacts model
17
+ - Patient#contacts
18
+
19
+ ### Changed
20
+ - typo of martialstatus is now maritalstatus for Demographics model
21
+
22
+ ## [1.5.0] - 2020-12-15
23
+ ### Added
24
+ - Scheduling model
25
+ - Scheduling#create
26
+ - Scheduling#cancel
27
+ - Scheduling#reschedule
28
+ - Scheduling#modification
29
+
30
+ ## [1.4.0] - 2020-10-13
31
+ ### Added
32
+ - AbstractModel that does not add top level key
33
+ - OrderingProvider that is the base for PCP
34
+ - Provider model
35
+ - Provider#query
36
+ - Created new method that can add helpers dynamically from response
37
+
38
+ ## [1.3.1] - 2020-10-02
39
+ ### Added
40
+ - Transaction#as\_json
41
+ - Visit#as\_json
42
+
7
43
  ## [1.3.0] - 2020-09-17
8
44
  ### Added
9
45
  - Transaction model
@@ -23,7 +59,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
23
59
  - Moving to Requst classes instead of mixing in logic to models (kept backwards compatibility)
24
60
  - Added potential matches to responses and implemented for patient search
25
61
 
26
- =======
27
62
  ### Added
28
63
  - PotentialMatches class
29
64
 
@@ -108,6 +143,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
108
143
  ### Added
109
144
  - Initial Release
110
145
 
146
+ [1.5.2]: https://github.com/WeInfuse/redox/compare/v1.5.1...v1.5.2
147
+ [1.5.1]: https://github.com/WeInfuse/redox/compare/v1.5.0...v1.5.1
148
+ [1.5.0]: https://github.com/WeInfuse/redox/compare/v1.4.0...v1.5.0
149
+ [1.4.0]: https://github.com/WeInfuse/redox/compare/v1.3.1...v1.4.0
150
+ [1.3.1]: https://github.com/WeInfuse/redox/compare/v1.3.0...v1.3.1
111
151
  [1.3.0]: https://github.com/WeInfuse/redox/compare/v1.2.0...v1.3.0
112
152
  [1.2.0]: https://github.com/WeInfuse/redox/compare/v1.1.1...v1.2.0
113
153
  [1.1.1]: https://github.com/WeInfuse/redox/compare/v1.1.0...v1.1.1
@@ -6,19 +6,25 @@ require 'redox/connection'
6
6
  require 'redox/authentication'
7
7
  require 'redox/models/model'
8
8
  require 'redox/models/meta'
9
+ require 'redox/models/ordering_provider'
9
10
  require 'redox/models/patient'
11
+ require 'redox/models/provider'
10
12
  require 'redox/models/visit'
11
13
  require 'redox/models/transaction'
12
14
  require 'redox/models/financial'
13
15
  require 'redox/models/patient/demographics'
16
+ require 'redox/models/patient/contacts'
14
17
  require 'redox/models/patient/identifier'
15
18
  require 'redox/models/patient/insurance'
16
19
  require 'redox/models/patient/p_c_p'
17
20
  require 'redox/models/potential_matches'
21
+ require 'redox/models/scheduling'
18
22
  require 'redox/request/request'
19
23
  require 'redox/request/financial'
20
24
  require 'redox/request/patient_admin'
21
25
  require 'redox/request/patient_search'
26
+ require 'redox/request/provider'
27
+ require 'redox/request/scheduling'
22
28
 
23
29
  module Redox
24
30
  class Configuration
@@ -1,9 +1,6 @@
1
1
  module Redox
2
2
  module Models
3
- class Financial < Hashie::Trash
4
- include Hashie::Extensions::IgnoreUndeclared
5
- include Hashie::Extensions::IndifferentAccess
6
-
3
+ class Financial < AbstractModel
7
4
  property :Visit, required: false, from: :visit, default: Redox::Models::Visit.new
8
5
  property :Patient, required: false, from: :patient, default: Redox::Models::Patient.new
9
6
  property :Transactions, required: false, from: :transactions, default: []
@@ -8,10 +8,12 @@ module Redox
8
8
  end
9
9
  end
10
10
 
11
- class Model < Hashie::Trash
11
+ class AbstractModel < Hashie::Trash
12
12
  include Hashie::Extensions::IgnoreUndeclared
13
13
  include Hashie::Extensions::IndifferentAccess
14
14
 
15
+ HIGH_LEVEL_KEYS = %w[Meta Patient Visit PotentialMatches]
16
+
15
17
  property :Meta, from: :meta, required: false
16
18
  property :Patient, from: :patient, required: false
17
19
  property :Visit, from: :visit, required: false
@@ -24,6 +26,70 @@ module Redox
24
26
  alias_method :visit, :Visit
25
27
  alias_method :meta, :Meta
26
28
 
29
+ def to_json(args = {})
30
+ return self.to_h.to_json
31
+ end
32
+
33
+ def insurances
34
+ (self.patient&.insurances || []) + (self.visit&.insurances || [])
35
+ end
36
+
37
+ def self.from_response(response)
38
+ model = Model.new
39
+ model.response = response
40
+
41
+ HIGH_LEVEL_KEYS.each do |k|
42
+ begin
43
+ model.send("#{k}=", Module.const_get("Redox::Models::#{k}").new(response[k])) if response[k]
44
+ rescue
45
+ end
46
+ end
47
+
48
+ return model
49
+ end
50
+
51
+ def self.from_response_inflected(response)
52
+ model = self.from_response(response)
53
+
54
+ if (model.response.ok?)
55
+ data = model.response.parsed_response
56
+
57
+ if data.respond_to?(:keys)
58
+ model_class = nil
59
+
60
+ if model.meta&.data_model
61
+ model_class = "Redox::Models::#{model.meta.data_model}"
62
+
63
+ begin
64
+ model_class = Object.const_get(model_class)
65
+ rescue NameError
66
+ model_class = nil
67
+ end
68
+ end
69
+
70
+ data.keys.each do |key|
71
+ next if HIGH_LEVEL_KEYS.include?(key.to_s)
72
+
73
+ helper_name = key.to_s.downcase.to_sym
74
+
75
+ if model_class.nil?
76
+ model.define_singleton_method(helper_name) { data[key] }
77
+ else
78
+ if data[key].is_a?(Array)
79
+ model.define_singleton_method(helper_name) { data[key].map {|obj| model_class.new(obj) } }
80
+ else
81
+ model.define_singleton_method(helper_name) { model_class.new(data[key]) }
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ return model
89
+ end
90
+ end
91
+
92
+ class Model < AbstractModel
27
93
  def initialize(data = {})
28
94
  if data.is_a?(Hash)
29
95
  if data.include?(key)
@@ -40,32 +106,7 @@ module Redox
40
106
  return { key => super.to_h }
41
107
  end
42
108
 
43
- def to_json(args = {})
44
- return self.to_h.to_json
45
- end
46
-
47
- def insurances
48
- (self.patient&.insurances || []) + (self.visit&.insurances || [])
49
- end
50
-
51
- class << self
52
- def from_response(response)
53
- model = Model.new
54
- model.response = response
55
-
56
- %w[Meta Patient Visit PotentialMatches].each do |k|
57
- begin
58
- model.send("#{k}=", Module.const_get("Redox::Models::#{k}").new(response[k])) if response[k]
59
- rescue
60
- end
61
- end
62
-
63
- return model
64
- end
65
- end
66
-
67
109
  private
68
-
69
110
  def key
70
111
  return self.class.to_s.split('::').last.to_s
71
112
  end
@@ -0,0 +1,15 @@
1
+ module Redox
2
+ module Models
3
+ class OrderingProvider < AbstractModel
4
+ property :ID, required: false, from: :id
5
+ property :IDType, required: false, from: :id_type
6
+ property :FirstName, required: false, from: :first_name
7
+ property :LastName, required: false, from: :last_name
8
+
9
+ alias_method :first_name, :FirstName
10
+ alias_method :last_name, :LastName
11
+ alias_method :id, :ID
12
+ alias_method :id_type, :IDType
13
+ end
14
+ end
15
+ end
@@ -4,10 +4,12 @@ module Redox
4
4
  property :Identifiers, from: :identifiers, required: false, default: []
5
5
  property :Insurances, from: :insurances, required: false, default: []
6
6
  property :Demographics, from: :demographics, required: false
7
+ property :Contacts, from: :contacts, required: false, default: []
7
8
  property :PCP, from: :primary_care_provider, required: false
8
9
 
9
10
  alias_method :identifiers, :Identifiers
10
11
  alias_method :insurances, :Insurances
12
+ alias_method :contacts, :Contacts
11
13
 
12
14
  def demographics
13
15
  self[:Demographics] = Demographics.new(self[:Demographics]) unless self[:Demographics].is_a?(Redox::Models::Demographics)
@@ -22,6 +24,10 @@ module Redox
22
24
  self[:PCP] ||= PCP.new
23
25
  end
24
26
 
27
+ def contacts
28
+ self[:Contacts] = self[:Contacts].map {|contact| contact.is_a?(Redox::Models::Contact) ? contact : Contact.new(contact)}
29
+ end
30
+
25
31
  def add_identifier(type: , value: )
26
32
  self[:Identifiers] << Identifier.new({'ID' => value, 'IDType' => type})
27
33
 
@@ -0,0 +1,20 @@
1
+ module Redox
2
+ module Models
3
+ class Contact < AbstractModel
4
+ property :FirstName, required: false, from: :first_name
5
+ property :MiddleName, required: false, from: :middle_name
6
+ property :LastName, required: false, from: :last_name
7
+ property :RelationToPatient, required: false
8
+ property :EmailAddresses, required: false, default: []
9
+ property :Address, required: false, default: {}
10
+ property :PhoneNumber, required: false, default: {}
11
+ property :Roles, required: false, default: []
12
+
13
+ alias_method :first_name, :FirstName
14
+ alias_method :middle_name, :MiddleName
15
+ alias_method :last_name, :LastName
16
+ alias_method :address, :Address
17
+ alias_method :phone_number, :PhoneNumber
18
+ end
19
+ end
20
+ end
@@ -1,6 +1,6 @@
1
1
  module Redox
2
2
  module Models
3
- class Demographics < Model
3
+ class Demographics < AbstractModel
4
4
  property :FirstName, required: false, from: :first_name
5
5
  property :MiddleName, required: false, from: :middle_name
6
6
  property :LastName, required: false, from: :last_name
@@ -9,7 +9,7 @@ module Redox
9
9
  property :Sex, required: false, from: :sex
10
10
  property :Race, required: false, from: :race
11
11
  property :IsHispanic, required: false
12
- property :MaritalStatus, required: false, from: :martial_status
12
+ property :MaritalStatus, required: false, from: :marital_status
13
13
  property :IsDeceased, required: false
14
14
  property :DeathDateTime, required: false
15
15
  property :Language, required: false, from: :language
@@ -25,7 +25,7 @@ module Redox
25
25
  alias_method :ssn, :SSN
26
26
  alias_method :sex, :Sex
27
27
  alias_method :race, :Race
28
- alias_method :martial_status, :MaritalStatus
28
+ alias_method :marital_status, :MaritalStatus
29
29
  alias_method :language, :Language
30
30
  alias_method :address, :Address
31
31
  alias_method :phone_number, :PhoneNumber
@@ -1,6 +1,6 @@
1
1
  module Redox
2
2
  module Models
3
- class Identifier < Model
3
+ class Identifier < AbstractModel
4
4
  property :ID, from: :id
5
5
  property :IDType, from: :id_type
6
6
 
@@ -1,13 +1,9 @@
1
1
  module Redox
2
2
  module Models
3
- class PCP < Model
3
+ class PCP < OrderingProvider
4
4
  property :NPI, from: :npi
5
- property :FirstName, required: false, from: :first_name
6
- property :LastName, required: false, from: :last_name
7
5
 
8
6
  alias_method :npi, :NPI
9
- alias_method :first_name, :FirstName
10
- alias_method :last_name, :LastName
11
7
  end
12
8
  end
13
9
  end
@@ -0,0 +1,21 @@
1
+ module Redox
2
+ module Models
3
+ class Provider < Model
4
+ property :Identifiers, from: :identifiers, required: false, default: []
5
+ property :Demographics, from: :demographics, required: false
6
+
7
+ alias_method :identifiers, :Identifiers
8
+
9
+ def demographics
10
+ self[:Demographics] = Demographics.new(self[:Demographics]) unless self[:Demographics].is_a?(Redox::Models::Demographics)
11
+ self[:Demographics] ||= Demographics.new
12
+ end
13
+
14
+ def add_identifier(type: , value: )
15
+ self[:Identifiers] << Identifier.new({'ID' => value, 'IDType' => type})
16
+
17
+ return self
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ module Redox
2
+ module Models
3
+ class Scheduling < AbstractModel
4
+ property :Visit, required: false, from: :visit, default: Redox::Models::Visit.new
5
+ property :Patient, required: false, from: :patient, default: Redox::Models::Patient.new
6
+ property :AppointmentInfo, required: false, from: :appointment_info, default: []
7
+
8
+ alias_method :patient, :Patient
9
+ alias_method :visit, :Visit
10
+ alias_method :appointment_info, :AppointmentInfo
11
+
12
+ def add_appointment_info(code: nil, codeset: nil, description: nil, value: nil)
13
+ self[:AppointmentInfo] << {
14
+ Code: code,
15
+ Codeset: codeset,
16
+ Description: description,
17
+ Value: value
18
+ }
19
+
20
+ self
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,9 +1,6 @@
1
1
  module Redox
2
2
  module Models
3
- class Transaction < Hashie::Trash
4
- include Hashie::Extensions::IgnoreUndeclared
5
- include Hashie::Extensions::IndifferentAccess
6
-
3
+ class Transaction < AbstractModel
7
4
  property :Chargeable, required: false, from: :chargeable, default: {}
8
5
  property :DateTimeOfService, required: false, from: :start
9
6
  property :Department, required: false, from: :department, default: {}
@@ -48,14 +45,30 @@ module Redox
48
45
  self
49
46
  end
50
47
 
51
- def to_json(args = nil)
52
- d = self.dup
48
+ def add_ordering_provider(**kwargs)
49
+ self[:OrderingProviders] ||= []
50
+ self[:OrderingProviders] << OrderingProvider.new(kwargs)
51
+ self
52
+ end
53
53
 
54
- [:EndDateTime, :DateTimeOfService].each do |k|
55
- d[k] = Redox::Models.format_datetime(d[k])
54
+ def add_performer(**kwargs)
55
+ self[:Performers] ||= []
56
+ self[:Performers] << OrderingProvider.new(kwargs)
57
+ self
58
+ end
59
+
60
+ def to_h
61
+ result = super.to_h
62
+
63
+ %w[EndDateTime DateTimeOfService].each do |k|
64
+ result[k] = Redox::Models.format_datetime(result[k])
56
65
  end
57
66
 
58
- d.to_h.to_json
67
+ result
68
+ end
69
+
70
+ def as_json(args)
71
+ self.to_h
59
72
  end
60
73
  end
61
74
  end
@@ -9,8 +9,13 @@ module Redox
9
9
  property :Insurances, from: :insurances, required: false, default: []
10
10
  property :Location, from: :location, required: false, default: DEFAULT_LOCATION
11
11
  property :VisitDateTime, from: :start, required: false
12
+ property :Duration, from: :duration, required: false
12
13
  property :VisitNumber, from: :visit_number, required: false
13
14
  property :AccountNumber, from: :account_number, required: false
15
+ property :Status, from: :status, required: false
16
+ property :Type, from: :type, required: false
17
+ property :Reason, from: :reason, required: false
18
+ property :Equipment, from: :equipment, required: false
14
19
 
15
20
  alias_method :insurances, :Insurances
16
21
  alias_method :start, :VisitDateTime
@@ -27,14 +32,32 @@ module Redox
27
32
  self
28
33
  end
29
34
 
35
+ def add_equipment(description: nil, code: nil)
36
+ self[:Equipment] ||= []
37
+ self[:Equipment] << { Description: description, Code: code }
38
+ self
39
+ end
40
+
30
41
  def insurances
31
42
  self[:Insurances] = self[:Insurances].map {|ins| ins.is_a?(Redox::Models::Insurance) ? ins : Insurance.new(ins) }
32
43
  end
33
44
 
34
- def to_json(args = nil)
35
- d = self.dup
36
- d[:VisitDateTime] = Redox::Models.format_datetime(d[:VisitDateTime])
37
- d.to_h.to_json
45
+ def to_h
46
+ result = super.to_h
47
+
48
+ %w[VisitDateTime].each do |k|
49
+ result[key][k] = Redox::Models.format_datetime(result[key][k])
50
+ end
51
+
52
+ result
53
+ end
54
+
55
+ def to_json(args = {})
56
+ self.to_h.to_json
57
+ end
58
+
59
+ def as_json(args = {})
60
+ self.to_h.dig('Visit')
38
61
  end
39
62
  end
40
63
  end
@@ -0,0 +1,12 @@
1
+ module Redox
2
+ module Request
3
+ class Provider
4
+ QUERY_META = Redox::Models::Meta.new(EventType: 'ProviderQuery', DataModel: 'Provider')
5
+
6
+ def self.query(provider, meta: Redox::Models::Meta.new)
7
+ meta = QUERY_META.merge(meta)
8
+ return Redox::Models::Model.from_response_inflected((RedoxClient.connection.request(body: Redox::Request.build_body(provider, meta))))
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ module Redox
2
+ module Request
3
+ class Scheduling
4
+ CREATE_META = Redox::Models::Meta.new(EventType: 'New', DataModel: 'Scheduling')
5
+ CANCEL_META = Redox::Models::Meta.new(EventType: 'Cancel', DataModel: 'Scheduling')
6
+ RESCHEDULE_META = Redox::Models::Meta.new(EventType: 'Reschedule', DataModel: 'Scheduling')
7
+ MODIFICATION_META = Redox::Models::Meta.new(EventType: 'Modification', DataModel: 'Scheduling')
8
+
9
+ def self.create(model, meta: Redox::Models::Meta.new)
10
+ meta = CREATE_META.merge(meta)
11
+ return Redox::Models::Model.from_response((RedoxClient.connection.request(body: Redox::Request.build_body(model, meta))))
12
+ end
13
+
14
+ def self.cancel(model, meta: Redox::Models::Meta.new)
15
+ meta = CANCEL_META.merge(meta)
16
+ return Redox::Models::Model.from_response((RedoxClient.connection.request(body: Redox::Request.build_body(model, meta))))
17
+ end
18
+
19
+ def self.reschedule(model, meta: Redox::Models::Meta.new)
20
+ meta = RESCHEDULE_META.merge(meta)
21
+ return Redox::Models::Model.from_response((RedoxClient.connection.request(body: Redox::Request.build_body(model, meta))))
22
+ end
23
+
24
+ def self.modification(model, meta: Redox::Models::Meta.new)
25
+ meta = MODIFICATION_META.merge(meta)
26
+ return Redox::Models::Model.from_response((RedoxClient.connection.request(body: Redox::Request.build_body(model, meta))))
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module Redox
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '1.5.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Clark
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2020-09-17 00:00:00.000000000 Z
13
+ date: 2021-01-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -150,19 +150,25 @@ files:
150
150
  - lib/redox/models/financial.rb
151
151
  - lib/redox/models/meta.rb
152
152
  - lib/redox/models/model.rb
153
+ - lib/redox/models/ordering_provider.rb
153
154
  - lib/redox/models/patient.rb
155
+ - lib/redox/models/patient/contacts.rb
154
156
  - lib/redox/models/patient/demographics.rb
155
157
  - lib/redox/models/patient/identifier.rb
156
158
  - lib/redox/models/patient/insurance.rb
157
159
  - lib/redox/models/patient/p_c_p.rb
158
160
  - lib/redox/models/potential_matches.rb
161
+ - lib/redox/models/provider.rb
162
+ - lib/redox/models/scheduling.rb
159
163
  - lib/redox/models/transaction.rb
160
164
  - lib/redox/models/visit.rb
161
165
  - lib/redox/redox_exception.rb
162
166
  - lib/redox/request/financial.rb
163
167
  - lib/redox/request/patient_admin.rb
164
168
  - lib/redox/request/patient_search.rb
169
+ - lib/redox/request/provider.rb
165
170
  - lib/redox/request/request.rb
171
+ - lib/redox/request/scheduling.rb
166
172
  - lib/redox/version.rb
167
173
  - redox.gemspec
168
174
  homepage: https://github.com/WeInfuse/redox