redox 1.3.1 → 1.4.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: 740cc0762bcf54c65c0767f1e6254aa304a193b493babdd5993859866911a7c2
4
- data.tar.gz: df1e7871ffde6efcd565255ea17ad05a5940fa951879e30db4e152c9c78679ae
3
+ metadata.gz: e2c926b510dc2e56b85369003ee89caf82292929308a18775df049e4a57e1d95
4
+ data.tar.gz: 9799c173cb24daa74f3dfe02eefb3f8c2a456557dafa819fb7ca2760621a3b4e
5
5
  SHA512:
6
- metadata.gz: f49cff5f2b525ff29499104f008ca393d1676d8a0963fad72154f8a8bfd0cd807fafc9017606d7d3d45c4ed81e8598d06843096b731699f972ed3143e147ad37
7
- data.tar.gz: 3dd1d039480dc5573df999aa9f74f44e6a63acef237dc8257e4bdc22f073033d75b7be6b1d9617e26dcbac22e8f6d199f5d995e019bd73e3c866cde98c9acd62
6
+ metadata.gz: 1499bf55b2c53f0a0dafc2d68d3b420bc5a0a0760d4258103360d32526b32e4f418a59fddb50afb3feb80ac45a979045b943018d24a717129e7db072c7233faf
7
+ data.tar.gz: 2b2eeebee1f5a35c028cee6c77f582e0dff10734cec40ce620fdc02617c01daf42f73d62e4960ec7a7b77ed4290f733c3fb0ce46f408566f826fa86f1d71a970
@@ -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
+ ## [1.4.0] - 2020-10-13
8
+ ### Added
9
+ - AbstractModel that does not add top level key
10
+ - OrderingProvider that is the base for PCP
11
+ - Provider model
12
+ - Provider#query
13
+ - Created new method that can add helpers dynamically from response
14
+
7
15
  ## [1.3.1] - 2020-10-02
8
16
  ### Added
9
17
  - Transaction#as\_json
@@ -113,6 +121,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
113
121
  ### Added
114
122
  - Initial Release
115
123
 
124
+ [1.4.0]: https://github.com/WeInfuse/redox/compare/v1.3.1...v1.4.0
116
125
  [1.3.1]: https://github.com/WeInfuse/redox/compare/v1.3.0...v1.3.1
117
126
  [1.3.0]: https://github.com/WeInfuse/redox/compare/v1.2.0...v1.3.0
118
127
  [1.2.0]: https://github.com/WeInfuse/redox/compare/v1.1.1...v1.2.0
@@ -6,7 +6,9 @@ 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'
@@ -19,6 +21,7 @@ require 'redox/request/request'
19
21
  require 'redox/request/financial'
20
22
  require 'redox/request/patient_admin'
21
23
  require 'redox/request/patient_search'
24
+ require 'redox/request/provider'
22
25
 
23
26
  module Redox
24
27
  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
@@ -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
@@ -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
@@ -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,6 +45,18 @@ module Redox
48
45
  self
49
46
  end
50
47
 
48
+ def add_ordering_provider(**kwargs)
49
+ self[:OrderingProviders] ||= []
50
+ self[:OrderingProviders] << OrderingProvider.new(kwargs)
51
+ self
52
+ end
53
+
54
+ def add_performer(**kwargs)
55
+ self[:Performers] ||= []
56
+ self[:Performers] << OrderingProvider.new(kwargs)
57
+ self
58
+ end
59
+
51
60
  def to_h
52
61
  result = super.to_h
53
62
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Redox
2
- VERSION = '1.3.1'.freeze
2
+ VERSION = '1.4.0'.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.1
4
+ version: 1.4.0
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-10-02 00:00:00.000000000 Z
13
+ date: 2020-10-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -150,18 +150,21 @@ 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
154
155
  - lib/redox/models/patient/demographics.rb
155
156
  - lib/redox/models/patient/identifier.rb
156
157
  - lib/redox/models/patient/insurance.rb
157
158
  - lib/redox/models/patient/p_c_p.rb
158
159
  - lib/redox/models/potential_matches.rb
160
+ - lib/redox/models/provider.rb
159
161
  - lib/redox/models/transaction.rb
160
162
  - lib/redox/models/visit.rb
161
163
  - lib/redox/redox_exception.rb
162
164
  - lib/redox/request/financial.rb
163
165
  - lib/redox/request/patient_admin.rb
164
166
  - lib/redox/request/patient_search.rb
167
+ - lib/redox/request/provider.rb
165
168
  - lib/redox/request/request.rb
166
169
  - lib/redox/version.rb
167
170
  - redox.gemspec