athena_health 0.2.0 → 0.3.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
  SHA1:
3
- metadata.gz: 3d6421f4e82d9baceb3cc863df051453c79bc1fc
4
- data.tar.gz: 1ddbeca3dc8409eb06aeb9c3a19554547cd741a2
3
+ metadata.gz: 77e416329d6f818297a22516bc3bc7d4160a4051
4
+ data.tar.gz: b98a97a52574be96e084999d20e9a5b4eb0744d0
5
5
  SHA512:
6
- metadata.gz: 7e0500b98eddced67eaa21e937b9d0a0bac1f7f69b327185e4b2f20d3d4fe91204d8135f89872cf8a7dcffa5abaa6c03a6904207fb69ab0f687e8f198adfe412
7
- data.tar.gz: 3df3b128080fc78e7734acd0221991e543eec67bf89b32195474341d6d58114eb16333458d3f4667bb102064ca7b43819060085509dc43bd39cbc091da35efb0
6
+ metadata.gz: cd79d3250cb825bae096b619c11bc9e08d87521c931fb061f5f2b85eafef6a7ed98511a0c074b008368c0bb84ac25c05d76e9f5cd661b620e5b99f73842889cf
7
+ data.tar.gz: a340bce4db7ba12169e09723db4b95e43e7fbf4b6215682b12728a8588789374d7ea8b2b45f324106eb1d70949c9cc1abbed770ce636e0c61935de359f253b0a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/athena_health.svg)](https://badge.fury.io/rb/athena_health)
2
- [![Build Status](https://travis-ci.org/MatUrbanski/athena_health.svg?branch=master)](https://travis-ci.org/MatUrbanski/athena_health)
3
- [![Dependency Status](https://gemnasium.com/MatUrbanski/athena_health.svg)](https://gemnasium.com/MatUrbanski/athena_health)
2
+ [![Build Status](https://travis-ci.org/zywy/athena_health.svg?branch=master)](https://travis-ci.org/zywy/athena_health)
3
+ [![Dependency Status](https://gemnasium.com/zywy/athena_health.svg)](https://gemnasium.com/zywy/athena_health)
4
4
 
5
5
  # AthenaHealth
6
6
 
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = 'Ruby wrapper for Athenahealth API.'
13
13
  spec.description = 'Ruby wrapper for Athenahealth API. See https://developer.athenahealth.com/io-docs for more details.'
14
- spec.homepage = 'https://github.com/MatUrbanski/athena_health'
14
+ spec.homepage = 'https://github.com/zywy/athena_health'
15
15
  spec.license = 'MIT'
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.bindir = 'exe'
data/lib/athena_health.rb CHANGED
@@ -4,6 +4,9 @@ require 'virtus'
4
4
  require 'athena_health/version'
5
5
  require 'athena_health/connection'
6
6
  require 'athena_health/error'
7
+ require 'athena_health/endpoints/practices'
8
+ require 'athena_health/endpoints/departments'
9
+ require 'athena_health/endpoints/patients'
7
10
  require 'athena_health/client'
8
11
  require 'athena_health/base_collection'
9
12
  require 'athena_health/base_model'
@@ -4,29 +4,8 @@ module AthenaHealth
4
4
  @api = AthenaHealth::Connection.new(version: version, key: key, secret: secret)
5
5
  end
6
6
 
7
- def all_practices(params: {})
8
- response = @api.call(endpoint: '1/practiceinfo', method: :get, params: params)
9
- PracticeCollection.new(response)
10
- end
11
-
12
- def find_practice(practice_id:, params: {})
13
- response = @api.call(endpoint: "#{practice_id}/practiceinfo", method: :get, params: params)
14
- PracticeCollection.new(response).practiceinfo.first
15
- end
16
-
17
- def all_departments(practice_id:, params: {})
18
- response = @api.call(endpoint: "#{practice_id}/departments", method: :get, params: params)
19
- DepartmentCollection.new(response)
20
- end
21
-
22
- def find_department(practice_id:, department_id:, params: {})
23
- response = @api.call(endpoint: "#{practice_id}/departments/#{department_id}", method: :get, params: params)
24
- Department.new(response.first)
25
- end
26
-
27
- def all_patients(practice_id:, department_id:, params: {})
28
- response = @api.call(endpoint: "#{practice_id}/patients", method: :get, params: params.merge!(departmentid: department_id))
29
- PatientCollection.new(response)
30
- end
7
+ include Endpoints::Practices
8
+ include Endpoints::Departments
9
+ include Endpoints::Patients
31
10
  end
32
11
  end
@@ -21,14 +21,15 @@ module AthenaHealth
21
21
  @token = JSON.parse(response)['access_token']
22
22
  end
23
23
 
24
- def call(endpoint:, method:, params: {}, second_call: false)
24
+ def call(endpoint:, method:, params: {}, body: {}, second_call: false)
25
25
  authenticate if @token.nil?
26
26
 
27
27
  response = Typhoeus::Request.new(
28
28
  "#{BASE_URL}/#{@version}/#{endpoint}",
29
29
  method: method,
30
30
  headers: { "Authorization" => "Bearer #{@token}"},
31
- params: params
31
+ params: params,
32
+ body: body,
32
33
  ).run
33
34
 
34
35
  if response.response_code == 401 && !second_call
@@ -36,7 +37,7 @@ module AthenaHealth
36
37
  call(endpoint: endpoint, method: method, second_call: true)
37
38
  end
38
39
 
39
- AthenaHealth::Error.new(code: response.response_code).render if response.response_code != 200
40
+ AthenaHealth::Error.new(code: response.response_code).render unless [200, 400].include? response.response_code
40
41
 
41
42
  JSON.parse(response.response_body)
42
43
  end
@@ -0,0 +1,15 @@
1
+ module AthenaHealth
2
+ module Endpoints
3
+ module Departments
4
+ def all_departments(practice_id:, params: {})
5
+ response = @api.call(endpoint: "#{practice_id}/departments", method: :get, params: params)
6
+ DepartmentCollection.new(response)
7
+ end
8
+
9
+ def find_department(practice_id:, department_id:, params: {})
10
+ response = @api.call(endpoint: "#{practice_id}/departments/#{department_id}", method: :get, params: params)
11
+ Department.new(response.first)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ module AthenaHealth
2
+ module Endpoints
3
+ module Patients
4
+ def all_patients(practice_id:, department_id:, params: {})
5
+ response = @api.call(endpoint: "#{practice_id}/patients", method: :get, params: params.merge!(departmentid: department_id))
6
+ PatientCollection.new(response)
7
+ end
8
+
9
+ def find_patient(practice_id:, patient_id:, params: {})
10
+ response = @api.call(endpoint: "#{practice_id}/patients/#{patient_id}", method: :get, params: params)
11
+ Patient.new(response.first)
12
+ end
13
+
14
+ def create_patient(practice_id:, department_id:, params: {})
15
+ @api.call(endpoint: "#{practice_id}/patients", method: :post, body: params.merge!(departmentid: department_id))
16
+ end
17
+
18
+ def update_patient(practice_id:, patient_id:, params: {})
19
+ @api.call(endpoint: "#{practice_id}/patients/#{patient_id}", method: :put, params: params)
20
+ end
21
+
22
+ def delete_patient(practice_id:, patient_id:)
23
+ @api.call(endpoint: "#{practice_id}/patients/#{patient_id}", method: :put, params: { status: 'deleted' })
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ module AthenaHealth
2
+ module Endpoints
3
+ module Practices
4
+ def all_practices(params: {})
5
+ response = @api.call(endpoint: '1/practiceinfo', method: :get, params: params)
6
+ PracticeCollection.new(response)
7
+ end
8
+
9
+ def find_practice(practice_id:, params: {})
10
+ response = @api.call(endpoint: "#{practice_id}/practiceinfo", method: :get, params: params)
11
+ PracticeCollection.new(response).practiceinfo.first
12
+ end
13
+ end
14
+ end
15
+ end
@@ -12,7 +12,6 @@ module AthenaHealth
12
12
 
13
13
  def errors
14
14
  {
15
- 400 => BadRequestError,
16
15
  401 => UnauthorizedError,
17
16
  402 => IncorrectPermissionsError,
18
17
  403 => ForbiddenError,
@@ -24,7 +23,6 @@ module AthenaHealth
24
23
  end
25
24
  end
26
25
 
27
- class BadRequestError < StandardError; end
28
26
  class UnauthorizedError < StandardError; end
29
27
  class IncorrectPermissionsError < StandardError; end
30
28
  class ForbiddenError < StandardError; end
@@ -1,3 +1,3 @@
1
1
  module AthenaHealth
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: athena_health
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Urbański
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-16 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -118,13 +118,16 @@ files:
118
118
  - lib/athena_health/connection.rb
119
119
  - lib/athena_health/department.rb
120
120
  - lib/athena_health/department_collection.rb
121
+ - lib/athena_health/endpoints/departments.rb
122
+ - lib/athena_health/endpoints/patients.rb
123
+ - lib/athena_health/endpoints/practices.rb
121
124
  - lib/athena_health/error.rb
122
125
  - lib/athena_health/patient.rb
123
126
  - lib/athena_health/patient_collection.rb
124
127
  - lib/athena_health/practice.rb
125
128
  - lib/athena_health/practice_collection.rb
126
129
  - lib/athena_health/version.rb
127
- homepage: https://github.com/MatUrbanski/athena_health
130
+ homepage: https://github.com/zywy/athena_health
128
131
  licenses:
129
132
  - MIT
130
133
  metadata: {}