luma 0.0.7 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '00429d3b54d9cda59b281b0446ff7585008fcc498f2199f0fce23855c2582cc6'
4
- data.tar.gz: 1c15d031ecf8b95be3d2fa97082ef6e6f72ba0d090351ad5c8fae594764a6312
3
+ metadata.gz: '0871b808e3b0a1f5b1a1781146de35a15ddbccc56c9a7b85a665de32f6ac7512'
4
+ data.tar.gz: 6a9dafee86762e0ff5deb116710b2ae2a7bbb7b9748e54c7d0b760e4577a6afd
5
5
  SHA512:
6
- metadata.gz: b50ab8b8b32e94a2d10d5782b01935781613af96aeae2e6efd5c1211f6cfbe5528d92fb134aa0248c5131ca59a9ae485f855d28f7eb102469f66b39c1f98a1ed
7
- data.tar.gz: 3353c539d5e508a10af4f8807620935d07db0432f9382ef0355a135f9dc9ba1ffbd073179da644efcb69fcf15a0b5ff4914d59f86f009321708754b71143e6f0
6
+ metadata.gz: 0251c298510a2e4e5afa7e565b32228e66f80c5037636d32784fe72f26ea6a27f70ac8272d7bf56c250481ecb9f69658f1ee1eb2617cea1130b248fe064a4902
7
+ data.tar.gz: e25a6f8b08eb7c1241916b352e23126f978a6851bc3cfadc0165f28602125794f31ac24f13e7c14ec1dbb65ea67c5fda6c119faebdfc856b0e0480344bfe5381
data/CHANGELOG.md CHANGED
@@ -4,6 +4,32 @@ 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.1.2] - 2022-01-13
8
+
9
+ ### Changed
10
+
11
+ - Added API access for updating a patient (PUT)
12
+
13
+ ## [0.1.1] - 2021-11-16
14
+
15
+ ### Changed
16
+
17
+ - Added API access for updating an appointment (PUT)
18
+
19
+ ## [0.1.0] - 2021-11-10
20
+
21
+ ### Changed
22
+
23
+ - Removed global configuration of API credentials
24
+ - Added required email and password parameters to Authentication as API user is client-specific.
25
+
26
+ ## [0.0.8] - 2021-11-02
27
+
28
+ ### Added
29
+
30
+ - Add API access for creating an appointment (POST)
31
+ - Add Appointment model for use in creating appointment payload
32
+
7
33
  ## [0.0.7] - 2021-10-25
8
34
 
9
35
  ### Added
@@ -49,6 +75,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
49
75
 
50
76
  - Initial Create
51
77
 
78
+ [0.1.2]: https://github.com/WeInfuse/luma/compare/v0.1.1...v0.1.2
79
+ [0.1.1]: https://github.com/WeInfuse/luma/compare/v0.1.0...v0.1.1
80
+ [0.1.0]: https://github.com/WeInfuse/luma/compare/v0.0.8...v0.1.0
81
+ [0.0.8]: https://github.com/WeInfuse/luma/compare/v0.0.7...v0.0.8
52
82
  [0.0.7]: https://github.com/WeInfuse/luma/compare/v0.0.6...v0.0.7
53
83
  [0.0.6]: https://github.com/WeInfuse/luma/compare/v0.0.5...v0.0.6
54
84
  [0.0.5]: https://github.com/WeInfuse/luma/compare/v0.0.4...v0.0.5
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,39 @@ 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
+ ### Create Appointment
78
+ ```ruby
79
+ body = Luma::Models::Appointment.new(
80
+ appt_date: '2019-06-18T15:45:00.000Z',
81
+ appt_duration: '60',
82
+ appt_status: 'Unconfirmed',
83
+ patient_id: '12345',
84
+ provider_id: '23456',
85
+ facility_id: '34567',
86
+ appt_type_id: '45678',
87
+ )
88
+
89
+ Luma::Appointment.new(email: email, password: password).create_appointment(body: body)
90
+ ```
91
+
92
+ ### Update Appointment
93
+ ```ruby
94
+ body = {
95
+ appt_duration: '60'
96
+ }
97
+
98
+ Luma::Appointment.new(email: email, password: password).update_appointment('appointment_id', body: body)
77
99
  ```
78
100
 
79
101
  ## Development
@@ -0,0 +1,23 @@
1
+ module Luma
2
+ class Appointment < Connection
3
+ APPOINTMENT_ENDPOINT = '/api/appointments'.freeze
4
+
5
+ base_uri 'https://api.lumahealth.io/'.freeze
6
+
7
+ def create_appointment(endpoint: APPOINTMENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post, debug_output: $stdout)
8
+ @body = body
9
+ self.add_headers_and_body if auth
10
+
11
+ self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
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
22
+ end
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,17 @@
1
+ module Luma
2
+ module Models
3
+ class Appointment < Hashie::Trash
4
+ include Hashie::Extensions::IgnoreUndeclared
5
+ include Hashie::Extensions::IndifferentAccess
6
+
7
+ property :date, from: :appt_date, required: false
8
+ property :duration, from: :appt_duration, required: false
9
+ property :status, from: :appt_status, required: false
10
+ property :patient, from: :patient_id, required: false
11
+ property :provider, from: :provider_id, required: false
12
+ property :facility, from: :facility_id, required: false
13
+ property :type, from: :appt_type_id, required: false
14
+
15
+ end
16
+ end
17
+ end
data/lib/luma/patient.rb CHANGED
@@ -1,14 +1,23 @@
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
13
22
  end
14
23
  end
data/lib/luma/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Luma
2
- VERSION = '0.0.7'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
data/lib/luma.rb CHANGED
@@ -11,61 +11,8 @@ require 'luma/patient'
11
11
  require 'luma/models/contact'
12
12
  require 'luma/models/date_of_birth'
13
13
  require 'luma/models/patient'
14
+ require 'luma/appointment'
15
+ require 'luma/models/appointment'
14
16
 
15
17
  module Luma
16
- class Configuration
17
- attr_accessor :email, :password
18
-
19
- def initialize
20
- @email = nil
21
- @password = nil
22
- end
23
-
24
- def api_endpoint=(endpoint)
25
- Connection.base_uri(endpoint.freeze)
26
- end
27
-
28
- def api_endpoint
29
- return Connection.base_uri
30
- end
31
-
32
- def to_h
33
- return {
34
- email: @email,
35
- password: @password,
36
- api_endpoint: api_endpoint
37
- }
38
- end
39
-
40
- def from_h(h)
41
- self.email = h[:email]
42
- self.password = h[:password]
43
- self.api_endpoint = h[:api_endpoint]
44
-
45
- return self
46
- end
47
- end
48
-
49
- class << self
50
- def configuration
51
- @configuration ||= Configuration.new
52
- end
53
-
54
- def configure
55
- yield(configuration)
56
- end
57
- end
58
-
59
- # Luma API client
60
- class LumaClient
61
- class << self
62
- def connection
63
- @connection ||= Connection.new
64
- end
65
-
66
- def release
67
- @connection = nil
68
- end
69
- end
70
- end
71
18
  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.7
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angela Rodriguez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-25 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -155,11 +155,13 @@ files:
155
155
  - README.md
156
156
  - Rakefile
157
157
  - lib/luma.rb
158
+ - lib/luma/appointment.rb
158
159
  - lib/luma/appointment_type.rb
159
160
  - lib/luma/authentication.rb
160
161
  - lib/luma/connection.rb
161
162
  - lib/luma/facilities.rb
162
163
  - lib/luma/luma_exception.rb
164
+ - lib/luma/models/appointment.rb
163
165
  - lib/luma/models/contact.rb
164
166
  - lib/luma/models/date_of_birth.rb
165
167
  - lib/luma/models/patient.rb