luma 0.0.6 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +49 -14
- data/lib/luma/appointment.rb +23 -0
- data/lib/luma/appointment_type.rb +2 -2
- data/lib/luma/authentication.rb +14 -31
- data/lib/luma/connection.rb +5 -3
- data/lib/luma/luma_exception.rb +2 -2
- data/lib/luma/models/appointment.rb +17 -0
- data/lib/luma/models/contact.rb +18 -0
- data/lib/luma/models/date_of_birth.rb +12 -0
- data/lib/luma/models/patient.rb +19 -0
- data/lib/luma/patient.rb +14 -0
- data/lib/luma/provider.rb +1 -1
- data/lib/luma/version.rb +1 -1
- data/lib/luma.rb +6 -55
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ba2fd974740d61c1665cefa352759fb62aa9a104740362a419bf105891faa14
|
4
|
+
data.tar.gz: c1557993c05a3b72da33217b5f2ec919ee2effdce2f33c0c7125a60571766c17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e03019b01901ac0718cebd31ebcce588707ac84459f29031b9a6b006a9e8a1847a88908754b9620e19720d634e7b54f5b703d103d4e27884ee22447b4ac8973a
|
7
|
+
data.tar.gz: 9d2b8aaba0b48ef57c17a6b51d0257af898753c664ed9502111125dfc6bcb35e0206d5e8b0756a5254fb45bb38550c72a140b29bfe3bf144acc01ebc490c866b
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,33 @@ 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.1] - 2021-11-16
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- Added API access for updating an appointment (PUT)
|
12
|
+
|
13
|
+
## [0.1.0] - 2021-11-10
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- Removed global configuration of API credentials
|
18
|
+
- Added required email and password parameters to Authentication as API user is client-specific.
|
19
|
+
|
20
|
+
## [0.0.8] - 2021-11-02
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
- Add API access for creating an appointment (POST)
|
25
|
+
- Add Appointment model for use in creating appointment payload
|
26
|
+
|
27
|
+
## [0.0.7] - 2021-10-25
|
28
|
+
|
29
|
+
### Added
|
30
|
+
|
31
|
+
- Add API access for creating a patient (POST)
|
32
|
+
- Add Patient, Date of Birth and Contact models used in create patient payload
|
33
|
+
|
7
34
|
## [0.0.6] - 2021-10-15
|
8
35
|
|
9
36
|
### Changed
|
@@ -42,6 +69,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
42
69
|
|
43
70
|
- Initial Create
|
44
71
|
|
72
|
+
[0.1.1]: https://github.com/WeInfuse/luma/compare/v0.1.0...v0.1.1
|
73
|
+
[0.1.0]: https://github.com/WeInfuse/luma/compare/v0.0.8...v0.1.0
|
74
|
+
[0.0.8]: https://github.com/WeInfuse/luma/compare/v0.0.7...v0.0.8
|
75
|
+
[0.0.7]: https://github.com/WeInfuse/luma/compare/v0.0.6...v0.0.7
|
45
76
|
[0.0.6]: https://github.com/WeInfuse/luma/compare/v0.0.5...v0.0.6
|
46
77
|
[0.0.5]: https://github.com/WeInfuse/luma/compare/v0.0.4...v0.0.5
|
47
78
|
[0.0.4]: https://github.com/WeInfuse/luma/compare/v0.0.3...v0.0.4
|
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,58 @@ 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)
|
46
|
+
```
|
47
|
+
|
48
|
+
### Create Patient
|
49
|
+
```ruby
|
50
|
+
dob = Luma::Models::DateOfBirth.new(year: 1993, month: 1, day: 2)
|
51
|
+
contact = Luma::Models::Contact.new(type: Luma::Models::Contact::CONTACT_TYPES[:email],
|
52
|
+
value: "ruby@test.com",
|
53
|
+
active: true
|
54
|
+
)
|
55
|
+
body = Luma::Models::Patient.new(first_name: 'Ruby',
|
56
|
+
last_name: 'Jones',
|
57
|
+
dob: dob,
|
58
|
+
address: '123 Main',
|
59
|
+
city: 'Austin',
|
60
|
+
state: 'TX',
|
61
|
+
zip_code: 78701,
|
62
|
+
contact: [contact],
|
63
|
+
do_not_contact: false
|
64
|
+
)
|
65
|
+
|
66
|
+
Luma::Patient.new(email: email, password: password).create_patient(body: body)
|
67
|
+
```
|
68
|
+
|
69
|
+
### Create Appointment
|
70
|
+
```ruby
|
71
|
+
body = Luma::Models::Appointment.new(
|
72
|
+
appt_date: '2019-06-18T15:45:00.000Z',
|
73
|
+
appt_duration: '60',
|
74
|
+
appt_status: 'Unconfirmed',
|
75
|
+
patient_id: '12345',
|
76
|
+
provider_id: '23456',
|
77
|
+
facility_id: '34567',
|
78
|
+
appt_type_id: '45678',
|
79
|
+
)
|
80
|
+
|
81
|
+
Luma::Appointment.new(email: email, password: password).create_appointment(body: body)
|
82
|
+
```
|
83
|
+
|
84
|
+
### Update Appointment
|
85
|
+
```ruby
|
86
|
+
body = {
|
87
|
+
appt_duration: '60'
|
88
|
+
}
|
89
|
+
|
90
|
+
Luma::Appointment.new(email: email, password: password).update_appointment('appointment_id', body: body)
|
56
91
|
```
|
57
92
|
|
58
93
|
## 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
|
@@ -10,14 +10,14 @@ module Luma
|
|
10
10
|
url = "api/appointmentTypes?name=#{name}&description=#{description}"
|
11
11
|
full_url = "https://api.lumahealth.io/" + url
|
12
12
|
|
13
|
-
|
13
|
+
HTTParty.get(full_url.to_str, headers: @headers, debug_output: $stdout)
|
14
14
|
end
|
15
15
|
|
16
16
|
def create_appointment_type(endpoint: APPOINTMENT_TYPE_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post, debug_output: $stdout)
|
17
17
|
@body = body
|
18
18
|
self.add_headers_and_body if auth
|
19
19
|
|
20
|
-
|
20
|
+
self.class.send(verb.to_s, endpoint, body: @body, headers: @headers, debug_output: $stdout)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/luma/authentication.rb
CHANGED
@@ -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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
}
|
17
|
+
request = {
|
18
|
+
body: { email: email, password: password },
|
19
|
+
endpoint: AUTH_ENDPOINT
|
20
|
+
}
|
20
21
|
|
21
|
-
|
22
|
+
response = self.request(**request, auth: false)
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
data/lib/luma/connection.rb
CHANGED
@@ -10,9 +10,11 @@ module Luma
|
|
10
10
|
|
11
11
|
format :json
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
@
|
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
|
36
|
+
@auth = Authentication.new(email: @email, password: @password)
|
35
37
|
|
36
38
|
return @auth.authenticate.access_header
|
37
39
|
end
|
data/lib/luma/luma_exception.rb
CHANGED
@@ -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
|
-
|
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
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Luma
|
2
|
+
module Models
|
3
|
+
class Contact < Hashie::Trash
|
4
|
+
include Hashie::Extensions::IgnoreUndeclared
|
5
|
+
include Hashie::Extensions::IndifferentAccess
|
6
|
+
|
7
|
+
CONTACT_TYPES = {
|
8
|
+
email: "email",
|
9
|
+
text: "sms",
|
10
|
+
phone: "voice"
|
11
|
+
}
|
12
|
+
|
13
|
+
property :type, required: false
|
14
|
+
property :value, required: false
|
15
|
+
property :active, required: false, default: false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Luma
|
2
|
+
module Models
|
3
|
+
class DateOfBirth < Hashie::Trash
|
4
|
+
include Hashie::Extensions::IgnoreUndeclared
|
5
|
+
include Hashie::Extensions::IndifferentAccess
|
6
|
+
|
7
|
+
property :year, required: false
|
8
|
+
property :month, required: false
|
9
|
+
property :day, required: false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Luma
|
2
|
+
module Models
|
3
|
+
class Patient < Hashie::Trash
|
4
|
+
include Hashie::Extensions::IgnoreUndeclared
|
5
|
+
include Hashie::Extensions::IndifferentAccess
|
6
|
+
|
7
|
+
property :firstname, from: :first_name, required: false
|
8
|
+
property :lastname, from: :last_name, required: false
|
9
|
+
property :dateOfBirth, from: :dob, required: false, default: {}
|
10
|
+
property :address, required: false
|
11
|
+
property :city, required: false
|
12
|
+
property :state, required: false
|
13
|
+
property :postcode, from: :zip_code, required: false
|
14
|
+
property :contact, required: false
|
15
|
+
property :doNotContact, from: :do_not_contact, required: false, default: true
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/luma/patient.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Luma
|
2
|
+
class Patient < Connection
|
3
|
+
PATIENT_ENDPOINT = '/api/patients'.freeze
|
4
|
+
|
5
|
+
base_uri 'https://api.lumahealth.io/'.freeze
|
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
|
10
|
+
|
11
|
+
self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/luma/provider.rb
CHANGED
@@ -9,7 +9,7 @@ module Luma
|
|
9
9
|
|
10
10
|
self.add_headers_and_body if auth
|
11
11
|
|
12
|
-
|
12
|
+
self.class.send(verb.to_s, endpoint, body: @body, headers: @headers, debug_output: $stdout)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/luma/version.rb
CHANGED
data/lib/luma.rb
CHANGED
@@ -7,61 +7,12 @@ require 'luma/authentication'
|
|
7
7
|
require 'luma/provider'
|
8
8
|
require 'luma/appointment_type'
|
9
9
|
require 'luma/facilities'
|
10
|
+
require 'luma/patient'
|
11
|
+
require 'luma/models/contact'
|
12
|
+
require 'luma/models/date_of_birth'
|
13
|
+
require 'luma/models/patient'
|
14
|
+
require 'luma/appointment'
|
15
|
+
require 'luma/models/appointment'
|
10
16
|
|
11
17
|
module Luma
|
12
|
-
class Configuration
|
13
|
-
attr_accessor :email, :password
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
@email = nil
|
17
|
-
@password = nil
|
18
|
-
end
|
19
|
-
|
20
|
-
def api_endpoint=(endpoint)
|
21
|
-
Connection.base_uri(endpoint.freeze)
|
22
|
-
end
|
23
|
-
|
24
|
-
def api_endpoint
|
25
|
-
return Connection.base_uri
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_h
|
29
|
-
return {
|
30
|
-
email: @email,
|
31
|
-
password: @password,
|
32
|
-
api_endpoint: api_endpoint
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
def from_h(h)
|
37
|
-
self.email = h[:email]
|
38
|
-
self.password = h[:password]
|
39
|
-
self.api_endpoint = h[:api_endpoint]
|
40
|
-
|
41
|
-
return self
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class << self
|
46
|
-
def configuration
|
47
|
-
@configuration ||= Configuration.new
|
48
|
-
end
|
49
|
-
|
50
|
-
def configure
|
51
|
-
yield(configuration)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Luma API client
|
56
|
-
class LumaClient
|
57
|
-
class << self
|
58
|
-
def connection
|
59
|
-
@connection ||= Connection.new
|
60
|
-
end
|
61
|
-
|
62
|
-
def release
|
63
|
-
@connection = nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
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.
|
4
|
+
version: 0.1.1
|
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-
|
11
|
+
date: 2021-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -155,11 +155,17 @@ 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
|
165
|
+
- lib/luma/models/contact.rb
|
166
|
+
- lib/luma/models/date_of_birth.rb
|
167
|
+
- lib/luma/models/patient.rb
|
168
|
+
- lib/luma/patient.rb
|
163
169
|
- lib/luma/provider.rb
|
164
170
|
- lib/luma/version.rb
|
165
171
|
- luma.gemspec
|
@@ -183,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
189
|
- !ruby/object:Gem::Version
|
184
190
|
version: '0'
|
185
191
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
192
|
+
rubygems_version: 3.0.3
|
187
193
|
signing_key:
|
188
194
|
specification_version: 4
|
189
195
|
summary: Ruby wrapper for the Luma Health API
|