luma 0.0.5 → 0.1.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: 4fa51b1a67a6654b087dd07a6fac2cbfa92d5bdabd78adb9ac1dc7b7a61d4f20
4
- data.tar.gz: 152164770be9e7a8753b0456f2a94b15f2fcfc1f75795b9266b09cb81fbecc20
3
+ metadata.gz: 0b1c0cd76f2a756cf7bc743c37bff453c3ec10296f0b454b76666a8e4f55a858
4
+ data.tar.gz: 6fff9b6757c64c9449f64f54afaafa1bac2f183a6b7452dce7e35eaaf1d1c3b6
5
5
  SHA512:
6
- metadata.gz: 0fd82fa1ded48b2aea24bdedaa370ec498d28fe3be85748974b606273d3be0991ee570d2083c83bd19e5217e8b8181ab063df3abbf31f74ec0595a05c478934a
7
- data.tar.gz: c9769fb14069ad01e56b53f9ac512735ee51f2cab42f003b3bd9eb9a3d59a452e52ae9a21e5db0548de48700463a4f2e3007e9e4f47689fa41f282a568baf9c5
6
+ metadata.gz: e06a22f14e2f101dafd0669d60f1ec04a8e924ab0cdf8576faf9aa21f661433d05ac971cb590fdd8bb019519bd84d4c0a6e7fa29515b8d850c93f2abd45dd035
7
+ data.tar.gz: 0f9b502a82e0ee14568d8cc7b15b7e09c8b80003b148506a1e04a2c299169686411ee603b735f3584e58d3435fc70fe353554c2bd51d3a6d02df589faebb71b4
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.0] - 2021-11-10
8
+
9
+ ### Changed
10
+
11
+ - Removed global configuration of API credentials
12
+ - Added required email and password parameters to Authentication as API user is client-specific.
13
+
14
+ ## [0.0.8] - 2021-11-02
15
+
16
+ ### Added
17
+
18
+ - Add API access for creating an appointment (POST)
19
+ - Add Appointment model for use in creating appointment payload
20
+
21
+ ## [0.0.7] - 2021-10-25
22
+
23
+ ### Added
24
+
25
+ - Add API access for creating a patient (POST)
26
+ - Add Patient, Date of Birth and Contact models used in create patient payload
27
+
28
+ ## [0.0.6] - 2021-10-15
29
+
30
+ ### Changed
31
+
32
+ - Adjust provider to accept body parameter
33
+
7
34
  ## [0.0.5] - 2021-10-14
8
35
 
9
36
  ### Changed
@@ -36,6 +63,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
36
63
 
37
64
  - Initial Create
38
65
 
66
+ [0.1.0]: https://github.com/WeInfuse/luma/compare/v0.0.8...v0.1.0
67
+ [0.0.8]: https://github.com/WeInfuse/luma/compare/v0.0.7...v0.0.8
68
+ [0.0.7]: https://github.com/WeInfuse/luma/compare/v0.0.6...v0.0.7
69
+ [0.0.6]: https://github.com/WeInfuse/luma/compare/v0.0.5...v0.0.6
39
70
  [0.0.5]: https://github.com/WeInfuse/luma/compare/v0.0.4...v0.0.5
40
71
  [0.0.4]: https://github.com/WeInfuse/luma/compare/v0.0.3...v0.0.4
41
72
  [0.0.3]: https://github.com/WeInfuse/luma/compare/v0.0.2...v0.0.3
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,12 +36,49 @@ 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
- Luma::Provider.new.create_provider(name: 'Billy Bob', npi: 1234567891)
44
+ body = { "name": "Billy Bob 2", "npi": 1234567891 }
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)
55
82
  ```
56
83
 
57
84
  ## Development
@@ -0,0 +1,14 @@
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
+ end
14
+ 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
- result = HTTParty.get(full_url.to_str, headers: @headers, debug_output: $stdout)
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
- result = self.class.send(verb.to_s, endpoint, body: @body, headers: @headers, debug_output: $stdout)
20
+ self.class.send(verb.to_s, endpoint, body: @body, headers: @headers, debug_output: $stdout)
21
21
  end
22
22
  end
23
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
@@ -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
@@ -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
@@ -4,15 +4,12 @@ module Luma
4
4
 
5
5
  base_uri 'https://api.lumahealth.io/'.freeze
6
6
 
7
- def create_provider(endpoint: PROVIDER_ENDPOINT, name: "", npi: nil, headers: {}, auth: true, verb: :post)
8
- @body = {
9
- name: name,
10
- npi: npi
11
- }
7
+ def create_provider(endpoint: PROVIDER_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post)
8
+ @body = body
12
9
 
13
10
  self.add_headers_and_body if auth
14
11
 
15
- result = self.class.send(verb.to_s, endpoint, body: @body, headers: @headers, debug_output: $stdout)
12
+ self.class.send(verb.to_s, endpoint, body: @body, headers: @headers, debug_output: $stdout)
16
13
  end
17
14
  end
18
15
  end
data/lib/luma/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Luma
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.1.0'.freeze
3
3
  end
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.0.5
4
+ version: 0.1.0
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-14 00:00:00.000000000 Z
11
+ date: 2021-11-10 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