luma 0.0.8 → 0.1.3

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: 154f08ce7d11575161ae8c86c50e69caa8194a205562e94d340591bfaa6dd906
4
- data.tar.gz: 2e29bfa638c795d4708e449ca8fbfc93a6ed23d9eed67c075687bd4b6eee158c
3
+ metadata.gz: f722a4bfdbfbdc81d2e9b85e52c8dd78aef2fdd64df668be3424bcbec766876d
4
+ data.tar.gz: 21be1a31248e6787d5b2b6a272a5d0ef424dcc01564a5a6e2942a880a4108014
5
5
  SHA512:
6
- metadata.gz: f8d86c0863c92155c7e4700ab0cc827a4b4b10e1a6985f158427db84144f971e1764696616d0f5416d2bed915b53e8f881a7751aae1e20cc46c835b685b852ca
7
- data.tar.gz: 8f12b4d72357213e5db9e6f5c110abccced32403344541d57bf1edf2288d188143e0060a7183cbe26a4cb3ffb2c3bf1babe3443cdf58eb981266030425a9f7b4
6
+ metadata.gz: 6cfc178b60a519cfe2fec7d61c0aa26e410e5a47dc2c743239cfeb275f97548366ea7e61961cad3d1495df2696e6c66421126f1a98200963c855291cf1653fe1
7
+ data.tar.gz: d39c57e2e8c78fe22f425fdbf560691907f308b4ae2e4e4553f5f4b362dbc4fc07e1f83ea4d42bc452adfb95e9b5af3470343073e83d6f6b618917ec7fc084c5
data/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@ All notable changes to this project will be documented in this file.
3
3
 
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
+ ## [0.1.3] - 2022-02-10
7
+
8
+ ### Changed
9
+
10
+ - Added API access for patient data (GET)
11
+
12
+ ## [0.1.2] - 2022-01-13
13
+
14
+ ### Changed
15
+
16
+ - Added API access for updating a patient (PUT)
17
+
18
+ ## [0.1.1] - 2021-11-16
19
+
20
+ ### Changed
21
+
22
+ - Added API access for updating an appointment (PUT)
23
+
24
+ ## [0.1.0] - 2021-11-10
25
+
26
+ ### Changed
27
+
28
+ - Removed global configuration of API credentials
29
+ - Added required email and password parameters to Authentication as API user is client-specific.
6
30
 
7
31
  ## [0.0.8] - 2021-11-02
8
32
 
@@ -56,6 +80,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
56
80
 
57
81
  - Initial Create
58
82
 
83
+ [0.1.3]: https://github.com/WeInfuse/luma/compare/v0.1.2...v0.1.3
84
+ [0.1.2]: https://github.com/WeInfuse/luma/compare/v0.1.1...v0.1.2
85
+ [0.1.1]: https://github.com/WeInfuse/luma/compare/v0.1.0...v0.1.1
86
+ [0.1.0]: https://github.com/WeInfuse/luma/compare/v0.0.8...v0.1.0
59
87
  [0.0.8]: https://github.com/WeInfuse/luma/compare/v0.0.7...v0.0.8
60
88
  [0.0.7]: https://github.com/WeInfuse/luma/compare/v0.0.6...v0.0.7
61
89
  [0.0.6]: https://github.com/WeInfuse/luma/compare/v0.0.5...v0.0.6
data/README.md CHANGED
@@ -18,21 +18,11 @@ Or install it yourself as:
18
18
  $ gem install luma
19
19
 
20
20
  ## Usage
21
-
22
- ### Configuration
23
-
24
- ```ruby
25
- Luma.configure do |c|
26
- c.email = ENV['LUMA_EMAIL']
27
- c.password = ENV['LUMA_PASSWORD']
28
- c.api_endpoint = 'http://hello.com' # Defaults to Luma endpoint
29
- end
30
- ```
31
-
21
+ Supply email and password with each request based upon the requesting client/group's API user.
32
22
  ### Create Appointment Type
33
23
  ```ruby
34
24
  body = { "name": "Infusion", "description": "Infusion" }
35
- Luma::AppointmentType.new.create_appointment_type(body: body)
25
+ Luma::AppointmentType.new(email: email, password: password).create_appointment_type(body: body)
36
26
  ```
37
27
 
38
28
  ### Create Facility
@@ -46,13 +36,13 @@ body = {
46
36
  postcode: 78705
47
37
  }
48
38
 
49
- Luma::Facilities.new.create_facility(body: body)
39
+ Luma::Facilities.new(email: email, password: password).create_facility(body: body)
50
40
  ```
51
41
 
52
42
  ### Create Provider
53
43
  ```ruby
54
44
  body = { "name": "Billy Bob 2", "npi": 1234567891 }
55
- Luma::Provider.new.create_provider(body: body)
45
+ Luma::Provider.new(email: email, password: password).create_provider(body: body)
56
46
  ```
57
47
 
58
48
  ### Create Patient
@@ -73,7 +63,22 @@ body = Luma::Models::Patient.new(first_name: 'Ruby',
73
63
  do_not_contact: false
74
64
  )
75
65
 
76
- Luma::Patient.new.create_patient(body: body)
66
+ Luma::Patient.new(email: email, password: password).create_patient(body: body)
67
+ ```
68
+
69
+ ### Update Patient
70
+ ```ruby
71
+ body = Luma::Models::Patient.new(address: '456 Old Main')
72
+ patient_identifier = '12345a45b67c89101d2e3456'
73
+
74
+ Luma::Patient.new(email: email, password: password).update_patient(identifier: patient_identifier, body: body)
75
+ ```
76
+
77
+ ### GET Patient
78
+ ```ruby
79
+ patient_identifier = '12345a45b67c89101d2e3456'
80
+
81
+ Luma::Patient.new(email: email, password: password).get_patient(identifier: patient_identifier)
77
82
  ```
78
83
 
79
84
  ### Create Appointment
@@ -88,7 +93,16 @@ body = Luma::Models::Appointment.new(
88
93
  appt_type_id: '45678',
89
94
  )
90
95
 
91
- Luma::Appointment.new.create_appointment(body: body)
96
+ Luma::Appointment.new(email: email, password: password).create_appointment(body: body)
97
+ ```
98
+
99
+ ### Update Appointment
100
+ ```ruby
101
+ body = {
102
+ appt_duration: '60'
103
+ }
104
+
105
+ Luma::Appointment.new(email: email, password: password).update_appointment('appointment_id', body: body)
92
106
  ```
93
107
 
94
108
  ## Development
@@ -10,5 +10,14 @@ module Luma
10
10
 
11
11
  self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
12
12
  end
13
+
14
+ def update_appointment(appt_identifier, endpoint: APPOINTMENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :put, debug_output: $stdout)
15
+ @body = body
16
+ self.add_headers_and_body if auth
17
+
18
+ endpoint = "#{endpoint}/#{appt_identifier}"
19
+
20
+ self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
21
+ end
13
22
  end
14
23
  end
@@ -1,32 +1,31 @@
1
1
  module Luma
2
2
  class Authentication < Connection
3
- attr_accessor :response, :validation_response
3
+ attr_accessor :email, :password, :response, :validation_response
4
4
 
5
5
  BASE_ENDPOINT = '/api'.freeze
6
6
  AUTH_ENDPOINT = "#{BASE_ENDPOINT}/users/login".freeze
7
7
  VALIDATE_ENDPOINT = "#{BASE_ENDPOINT}/tokens/validate".freeze
8
8
 
9
- def initialize
9
+ def initialize(email: nil, password: nil)
10
+ @email = email
11
+ @password = password
10
12
  @response = nil
11
13
  @validation_response = nil
12
14
  end
13
15
 
14
16
  def authenticate
15
- if (self.expires?)
16
- request = {
17
- body: { email: Luma.configuration.email, password: Luma.configuration.password },
18
- endpoint: AUTH_ENDPOINT
19
- }
17
+ request = {
18
+ body: { email: email, password: password },
19
+ endpoint: AUTH_ENDPOINT
20
+ }
20
21
 
21
- response = self.request(**request, auth: false)
22
+ response = self.request(**request, auth: false)
22
23
 
23
- if (false == response.ok?)
24
- @response = nil
25
- raise LumaException.from_response(response, msg: 'Authentication')
26
- else
27
- @response = response
28
- validate
29
- end
24
+ if (false == response.ok?)
25
+ @response = nil
26
+ raise LumaException.from_response(response, msg: 'Authentication')
27
+ else
28
+ @response = response
30
29
  end
31
30
 
32
31
  return self
@@ -52,26 +51,10 @@ module Luma
52
51
  return @response['token'] if @response
53
52
  end
54
53
 
55
- def expiry
56
- return @validation_response['exp'] if @validation_response
57
- end
58
-
59
- def expires?
60
- if (self.expiry)
61
- return self.expiry <= (Time.now.to_f * 1000).floor
62
- else
63
- return true
64
- end
65
- end
66
-
67
54
  def access_header
68
55
  return {
69
56
  'X-Access-Token' => self.access_token,
70
57
  }
71
58
  end
72
-
73
- def expire!
74
- @response = nil
75
- end
76
59
  end
77
60
  end
@@ -10,9 +10,11 @@ module Luma
10
10
 
11
11
  format :json
12
12
 
13
- def initialize(body: nil, headers: {})
14
- @body = body
13
+ def initialize(email: nil, password: nil, headers: {})
14
+ @email = email
15
+ @password = password
15
16
  @headers = headers
17
+ @body = nil
16
18
  end
17
19
 
18
20
  def request(endpoint: DEFAULT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post)
@@ -31,7 +33,7 @@ module Luma
31
33
  private
32
34
 
33
35
  def auth_header
34
- @auth ||= Authentication.new
36
+ @auth = Authentication.new(email: @email, password: @password)
35
37
 
36
38
  return @auth.authenticate.access_header
37
39
  end
@@ -9,8 +9,8 @@ module Luma
9
9
 
10
10
  if (error_response.is_a?(Hash) && error_response.include?("Meta") && error_response["Meta"].include?("Errors"))
11
11
  exception_msg << error_response["Meta"]["Errors"]
12
- else
13
- exception_msg << error_response
12
+ elsif (error_response.is_a?(Hash) && error_response.include?("message") && error_response.include?("detail"))
13
+ exception_msg << error_response["message"] + ": " + error_response["detail"]
14
14
  end
15
15
  rescue JSON::ParserError
16
16
  exception_msg << response.body
@@ -0,0 +1,30 @@
1
+ module Luma
2
+ module Models
3
+ class PatientResponse
4
+ attr_reader :data
5
+
6
+ def initialize(data: nil, response: nil)
7
+ @data = data
8
+ @data = response.parsed_response if @data.nil? && response && response.ok?
9
+ @data ||= {}
10
+ @response = response
11
+ end
12
+
13
+ def do_not_contact
14
+ @data['doNotContact']
15
+ end
16
+
17
+ def contact
18
+ @data['contact']
19
+ end
20
+
21
+ def ok?
22
+ @response&.ok?
23
+ end
24
+
25
+ def errors?
26
+ !@data['errors'].nil? && !@data['errors'].empty?
27
+ end
28
+ end
29
+ end
30
+ end
data/lib/luma/patient.rb CHANGED
@@ -1,14 +1,33 @@
1
1
  module Luma
2
2
  class Patient < Connection
3
- PATIENT_ENDPOINT = '/api/patients'.freeze
3
+ PATIENT_ENDPOINT = '/api/patients'.freeze
4
4
 
5
- base_uri 'https://api.lumahealth.io/'.freeze
5
+ base_uri 'https://api.lumahealth.io/'.freeze
6
6
 
7
- def create_patient(endpoint: PATIENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post, debug_output: $stdout)
8
- @body = body
9
- self.add_headers_and_body if auth
7
+ def create_patient(endpoint: PATIENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post, debug_output: $stdout)
8
+ @body = body
9
+ self.add_headers_and_body if auth
10
10
 
11
- self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
12
- end
11
+ self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
12
+ end
13
+
14
+ def update_patient(identifier:, endpoint: PATIENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :put, debug_output: $stdout)
15
+ @body = body
16
+ self.add_headers_and_body if auth
17
+
18
+ endpoint = "#{endpoint}/#{identifier}"
19
+
20
+ self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
21
+ end
22
+
23
+ def get_patient(identifier:, endpoint: PATIENT_ENDPOINT, headers: {}, auth: true, verb: :get, debug_output: $stdout)
24
+ self.add_headers_and_body if auth
25
+
26
+ endpoint = "#{endpoint}/#{identifier}"
27
+
28
+ response = self.class.send(verb.to_s, endpoint, headers: @headers)
29
+
30
+ Luma::Models::PatientResponse.new(response: response)
31
+ end
13
32
  end
14
33
  end
data/lib/luma/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Luma
2
- VERSION = '0.0.8'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
data/lib/luma.rb CHANGED
@@ -10,64 +10,10 @@ require 'luma/facilities'
10
10
  require 'luma/patient'
11
11
  require 'luma/models/contact'
12
12
  require 'luma/models/date_of_birth'
13
+ require 'luma/models/patient_response'
13
14
  require 'luma/models/patient'
14
15
  require 'luma/appointment'
15
16
  require 'luma/models/appointment'
16
17
 
17
18
  module Luma
18
- class Configuration
19
- attr_accessor :email, :password
20
-
21
- def initialize
22
- @email = nil
23
- @password = nil
24
- end
25
-
26
- def api_endpoint=(endpoint)
27
- Connection.base_uri(endpoint.freeze)
28
- end
29
-
30
- def api_endpoint
31
- return Connection.base_uri
32
- end
33
-
34
- def to_h
35
- return {
36
- email: @email,
37
- password: @password,
38
- api_endpoint: api_endpoint
39
- }
40
- end
41
-
42
- def from_h(h)
43
- self.email = h[:email]
44
- self.password = h[:password]
45
- self.api_endpoint = h[:api_endpoint]
46
-
47
- return self
48
- end
49
- end
50
-
51
- class << self
52
- def configuration
53
- @configuration ||= Configuration.new
54
- end
55
-
56
- def configure
57
- yield(configuration)
58
- end
59
- end
60
-
61
- # Luma API client
62
- class LumaClient
63
- class << self
64
- def connection
65
- @connection ||= Connection.new
66
- end
67
-
68
- def release
69
- @connection = nil
70
- end
71
- end
72
- end
73
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angela Rodriguez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2022-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -142,7 +142,7 @@ dependencies:
142
142
  - - ">="
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
- description:
145
+ description:
146
146
  email:
147
147
  - angela.rodriguez@weinfuse.com
148
148
  executables: []
@@ -165,6 +165,7 @@ files:
165
165
  - lib/luma/models/contact.rb
166
166
  - lib/luma/models/date_of_birth.rb
167
167
  - lib/luma/models/patient.rb
168
+ - lib/luma/models/patient_response.rb
168
169
  - lib/luma/patient.rb
169
170
  - lib/luma/provider.rb
170
171
  - lib/luma/version.rb
@@ -174,7 +175,7 @@ licenses:
174
175
  - MIT
175
176
  metadata:
176
177
  allowed_push_host: https://rubygems.org
177
- post_install_message:
178
+ post_install_message:
178
179
  rdoc_options: []
179
180
  require_paths:
180
181
  - lib
@@ -189,8 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
190
  - !ruby/object:Gem::Version
190
191
  version: '0'
191
192
  requirements: []
192
- rubygems_version: 3.0.3
193
- signing_key:
193
+ rubygems_version: 3.1.4
194
+ signing_key:
194
195
  specification_version: 4
195
196
  summary: Ruby wrapper for the Luma Health API
196
197
  test_files: []