dock_health_api 0.3.6
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 +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +59 -0
- data/LICENSE +201 -0
- data/README.md +701 -0
- data/Rakefile +10 -0
- data/bin/console +22 -0
- data/bin/setup +6 -0
- data/dock_health_api.gemspec +39 -0
- data/lib/dock_health_api/client.rb +27 -0
- data/lib/dock_health_api/config.rb +9 -0
- data/lib/dock_health_api/crud/create.rb +14 -0
- data/lib/dock_health_api/crud/delete.rb +12 -0
- data/lib/dock_health_api/crud/get.rb +11 -0
- data/lib/dock_health_api/crud/list.rb +19 -0
- data/lib/dock_health_api/crud/put.rb +15 -0
- data/lib/dock_health_api/crud/update.rb +21 -0
- data/lib/dock_health_api/object.rb +19 -0
- data/lib/dock_health_api/resource.rb +33 -0
- data/lib/dock_health_api/resources/customfield.rb +20 -0
- data/lib/dock_health_api/resources/developer.rb +5 -0
- data/lib/dock_health_api/resources/organization.rb +15 -0
- data/lib/dock_health_api/resources/patient.rb +9 -0
- data/lib/dock_health_api/resources/task.rb +22 -0
- data/lib/dock_health_api/resources/tasklist.rb +21 -0
- data/lib/dock_health_api/resources/user.rb +9 -0
- data/lib/dock_health_api/resources/webhook.rb +14 -0
- data/lib/dock_health_api/version.rb +3 -0
- data/lib/dock_health_api.rb +47 -0
- data/spec/client_spec.rb +35 -0
- data/spec/customfield_spec.rb +53 -0
- data/spec/developer_spec.rb +13 -0
- data/spec/dock_health_api_spec.rb +5 -0
- data/spec/organization.rb +58 -0
- data/spec/patient_spec.rb +59 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/task_group_spec.rb +70 -0
- data/spec/task_spec.rb +65 -0
- data/spec/tasklist_spec.rb +80 -0
- data/spec/tasklist_user_spec.rb +62 -0
- data/spec/user_spec.rb +60 -0
- data/spec/webhook_spec.rb +117 -0
- metadata +156 -0
data/bin/console
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "dock_health_api"
|
5
|
+
require "dotenv/load"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
DockHealthApi.api_key = ENV["DOCK_HEALTH_KEY"]
|
15
|
+
DockHealthApi.api_secret = ENV["DOCK_HEALTH_SECRET"]
|
16
|
+
DockHealthApi.resource_url = ENV["DOCK_HEALTH_URL"]
|
17
|
+
DockHealthApi.org_id = ENV["DOCK_ORG"]
|
18
|
+
DockHealthApi.user_id = ENV["DOCK_USER"]
|
19
|
+
DockHealthApi.api = ENV["DOCK_HEALTH_API"]
|
20
|
+
|
21
|
+
require "irb"
|
22
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'lib/dock_health_api/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "dock_health_api"
|
5
|
+
spec.version = DockHealthApi::VERSION
|
6
|
+
spec.authors = ["Robert Magomero", "Leo Lee"]
|
7
|
+
spec.email = ["", "rmagomero@mdlive.com"]
|
8
|
+
|
9
|
+
spec.summary = "Dock Health API"
|
10
|
+
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
11
|
+
#spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
spec.files = Dir['**/*'].keep_if { |file| File.file?(file) }
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
#spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
#spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
21
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
#spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
26
|
+
# `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
#end
|
28
|
+
#spec.bindir = "exe"
|
29
|
+
#spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
#spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_dependency "oauth2", "~>1.4"
|
33
|
+
|
34
|
+
spec.add_runtime_dependency "rspec", "~> 3.0"
|
35
|
+
spec.add_runtime_dependency "ostruct"
|
36
|
+
|
37
|
+
spec.add_development_dependency "pry"
|
38
|
+
spec.add_development_dependency "dotenv"
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "oauth2"
|
2
|
+
|
3
|
+
module DockHealthApi
|
4
|
+
class Client
|
5
|
+
attr_reader :config
|
6
|
+
|
7
|
+
def initialize(config = {})
|
8
|
+
@config = config
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.active_client
|
12
|
+
new(DockHealthApi.config)
|
13
|
+
end
|
14
|
+
|
15
|
+
def connection
|
16
|
+
@connection ||= OAuth2::Client.new(config.api_key, config.api_secret, token_url: config.token_url, raise_errors: false)
|
17
|
+
end
|
18
|
+
|
19
|
+
def token_connection
|
20
|
+
@token_connection ||= connection.client_credentials.get_token(scope:"dockhealth/system.developer.read dockhealth/user.all.write dockhealth/user.all.read dockhealth/system.developer.write dockhealth/patient.all.read dockhealth/patient.all.write")
|
21
|
+
end
|
22
|
+
|
23
|
+
def token
|
24
|
+
@token ||= token_connection.token
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module DockHealthApi
|
2
|
+
module Crud
|
3
|
+
module Delete
|
4
|
+
def delete(**params)
|
5
|
+
id = params.delete(:id)
|
6
|
+
response = execute_request(:delete, "#{resource_url}/#{id}", headers: headers, body_params: params)
|
7
|
+
return response.parsed
|
8
|
+
new(response.parsed)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module DockHealthApi
|
2
|
+
module Crud
|
3
|
+
module List
|
4
|
+
def list(**params)
|
5
|
+
response = execute_request(:get, "#{resource_url}", headers: headers)
|
6
|
+
if params.empty?
|
7
|
+
return response.parsed
|
8
|
+
else
|
9
|
+
search_result = response.parsed
|
10
|
+
params.each do |p|
|
11
|
+
search_result = search_result.select { |list| list[p[0].to_s] == p[1] }
|
12
|
+
end
|
13
|
+
return search_result
|
14
|
+
end
|
15
|
+
new(response.parsed)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DockHealthApi
|
2
|
+
module Crud
|
3
|
+
module Put
|
4
|
+
def put(**params)
|
5
|
+
id = params.delete(:id)
|
6
|
+
response = execute_request(:put,
|
7
|
+
"#{resource_url}/#{id}",
|
8
|
+
headers: headers,
|
9
|
+
body_params: params)
|
10
|
+
return response.parsed
|
11
|
+
new(response.parsed)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module DockHealthApi
|
2
|
+
module Crud
|
3
|
+
module Update
|
4
|
+
def update(**params)
|
5
|
+
if params.key?(:organizationId) && params.key?(:userId)
|
6
|
+
resource_url_fixed = "#{Organization.resource_url}/#{params[:organizationId]}/user"
|
7
|
+
params[:id] = params[:userId]
|
8
|
+
else
|
9
|
+
resource_url_fixed = resource_url
|
10
|
+
end
|
11
|
+
id = params.delete(:id)
|
12
|
+
response = execute_request(:patch,
|
13
|
+
"#{resource_url_fixed}/#{id}",
|
14
|
+
headers: headers,
|
15
|
+
body_params: params)
|
16
|
+
return response.parsed
|
17
|
+
new(response.parsed)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module DockHealthApi
|
4
|
+
class Object < OpenStruct
|
5
|
+
def initialize(attributes)
|
6
|
+
super to_ostruct(attributes)
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_ostruct(obj)
|
10
|
+
if obj.is_a?(Hash)
|
11
|
+
OpenStruct.new(obj.map { |key, val| [key, to_ostruct(val)] }.to_h)
|
12
|
+
elsif obj.is_a?(Array)
|
13
|
+
obj.map { |o| to_ostruct(o) }
|
14
|
+
else # Assumed to be a primitive value
|
15
|
+
obj
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module DockHealthApi
|
2
|
+
class Resource < Object
|
3
|
+
def self.class_name
|
4
|
+
name.split("::")[-1]
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.url_version
|
8
|
+
return "v1"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.client
|
12
|
+
@client ||= DockHealthApi::Client.active_client
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.resource_url
|
16
|
+
if self == Resource
|
17
|
+
raise NotImplementedError,
|
18
|
+
"Resource is an abstract class. You should perform actions " \
|
19
|
+
"on its subclasses (e.g. Patient)"
|
20
|
+
end
|
21
|
+
|
22
|
+
"#{client.config.resource_url}/api/#{url_version}/#{class_name.downcase}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.headers
|
26
|
+
{"Content-Type": "application/json", "x-api-key": client.config.api, "x-user-id": client.config.user_id, "x-organization-id": client.config.org_id}
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.execute_request(method, url, params: {}, headers: {}, body_params: nil)
|
30
|
+
client.token_connection.send(method, url, params: params, headers: headers, body: body_params.to_json)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DockHealthApi
|
2
|
+
class CustomField < Resource
|
3
|
+
extend DockHealthApi::Crud::Create
|
4
|
+
extend DockHealthApi::Crud::Delete
|
5
|
+
extend DockHealthApi::Crud::Get
|
6
|
+
extend DockHealthApi::Crud::Update
|
7
|
+
extend DockHealthApi::Crud::List
|
8
|
+
|
9
|
+
def self.resource_url
|
10
|
+
"#{client.config.resource_url}/api/#{url_version}/configuration/field"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.list(**params)
|
14
|
+
headers = {"x-api-key": "#{ENV["DOCK_HEALTH_API"]}", "x-user-id": "#{ENV["DOCK_USER"]}", "x-organization-id": "#{ENV["DOCK_ORG"]}"}
|
15
|
+
response = execute_request(:get, "#{resource_url}", headers: headers, params: params)
|
16
|
+
return response.parsed
|
17
|
+
new(response.parsed)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DockHealthApi
|
2
|
+
class Organization < Resource
|
3
|
+
extend DockHealthApi::Crud::Get
|
4
|
+
extend DockHealthApi::Crud::List
|
5
|
+
extend DockHealthApi::Crud::Create
|
6
|
+
extend DockHealthApi::Crud::Update
|
7
|
+
extend DockHealthApi::Crud::Delete
|
8
|
+
|
9
|
+
class User < Organization
|
10
|
+
def self.resource_url
|
11
|
+
"#{Organization.resource_url}/#{DockHealthApi.org_id}/user"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module DockHealthApi
|
2
|
+
class Task < Resource
|
3
|
+
extend DockHealthApi::Crud::Create
|
4
|
+
extend DockHealthApi::Crud::Delete
|
5
|
+
extend DockHealthApi::Crud::Get
|
6
|
+
extend DockHealthApi::Crud::Update
|
7
|
+
extend DockHealthApi::Crud::List
|
8
|
+
|
9
|
+
def self.list(**params)
|
10
|
+
headers = {"x-api-key": "#{ENV["DOCK_HEALTH_API"]}", "x-user-id": "#{ENV["DOCK_USER"]}", "x-organization-id": "#{ENV["DOCK_ORG"]}"}
|
11
|
+
response = execute_request(:get, "#{resource_url}", headers: headers, params: params)
|
12
|
+
return response.parsed
|
13
|
+
new(response.parsed)
|
14
|
+
end
|
15
|
+
|
16
|
+
class Group < Task
|
17
|
+
def self.resource_url
|
18
|
+
"#{Task.resource_url}/group"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module DockHealthApi
|
2
|
+
class TaskList < Resource
|
3
|
+
extend DockHealthApi::Crud::Create
|
4
|
+
extend DockHealthApi::Crud::Delete
|
5
|
+
extend DockHealthApi::Crud::Get
|
6
|
+
extend DockHealthApi::Crud::Update
|
7
|
+
extend DockHealthApi::Crud::List
|
8
|
+
|
9
|
+
def self.resource_url
|
10
|
+
"#{client.config.resource_url}/api/#{url_version}/list"
|
11
|
+
end
|
12
|
+
|
13
|
+
class User < TaskList
|
14
|
+
extend DockHealthApi::Crud::Put
|
15
|
+
|
16
|
+
def self.resource_url
|
17
|
+
"#{TaskList.resource_url}/user"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DockHealthApi
|
2
|
+
class Webhook < Resource
|
3
|
+
extend DockHealthApi::Crud::Create
|
4
|
+
extend DockHealthApi::Crud::Delete
|
5
|
+
extend DockHealthApi::Crud::Get
|
6
|
+
extend DockHealthApi::Crud::Put
|
7
|
+
extend DockHealthApi::Crud::List
|
8
|
+
|
9
|
+
def self.resource_url
|
10
|
+
"#{client.config.resource_url}/api/#{url_version}/developer/#{class_name.downcase}"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Ruby bindings
|
2
|
+
require "forwardable"
|
3
|
+
|
4
|
+
# Version
|
5
|
+
require "dock_health_api/version"
|
6
|
+
|
7
|
+
require "dock_health_api/crud/get"
|
8
|
+
require "dock_health_api/crud/create"
|
9
|
+
require "dock_health_api/crud/update"
|
10
|
+
require "dock_health_api/crud/put"
|
11
|
+
require "dock_health_api/crud/delete"
|
12
|
+
require "dock_health_api/crud/list"
|
13
|
+
|
14
|
+
require "dock_health_api/config"
|
15
|
+
|
16
|
+
module DockHealthApi
|
17
|
+
autoload :Client, "dock_health_api/client"
|
18
|
+
autoload :Error, "dock_health_api/error"
|
19
|
+
autoload :Object, "dock_health_api/object"
|
20
|
+
autoload :Resource, "dock_health_api/resource"
|
21
|
+
|
22
|
+
autoload :User, "dock_health_api/resources/user"
|
23
|
+
autoload :Task, "dock_health_api/resources/task"
|
24
|
+
autoload :TaskList, "dock_health_api/resources/tasklist"
|
25
|
+
autoload :Webhook, "dock_health_api/resources/webhook"
|
26
|
+
autoload :Patient, "dock_health_api/resources/patient"
|
27
|
+
autoload :Developer, "dock_health_api/resources/developer"
|
28
|
+
autoload :Organization, "dock_health_api/resources/organization"
|
29
|
+
autoload :CustomField, "dock_health_api/resources/customfield"
|
30
|
+
|
31
|
+
@config = DockHealthApi::Config.new
|
32
|
+
|
33
|
+
class << self
|
34
|
+
attr_reader :config
|
35
|
+
|
36
|
+
extend Forwardable
|
37
|
+
|
38
|
+
def_delegators :@config, :api_key, :api_key=
|
39
|
+
def_delegators :@config, :api_secret, :api_secret=
|
40
|
+
def_delegators :@config, :api_base, :api_base=
|
41
|
+
def_delegators :@config, :resource_url, :resource_url=
|
42
|
+
def_delegators :@config, :token_url, :token_url=
|
43
|
+
def_delegators :@config, :org_id, :org_id=
|
44
|
+
def_delegators :@config, :user_id, :user_id=
|
45
|
+
def_delegators :@config, :api, :api=
|
46
|
+
end
|
47
|
+
end
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'dock_health_api'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe DockHealthApi::Client do
|
5
|
+
let(:config) { DockHealthApi::Config.new }
|
6
|
+
|
7
|
+
it 'should be able to be initialized with a Config object' do
|
8
|
+
client = DockHealthApi::Client.new(config)
|
9
|
+
expect(client.config).to eq(config)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#active_client' do
|
13
|
+
it 'should config new client with standard config' do
|
14
|
+
expect(DockHealthApi::Client.active_client.config).to eq(DockHealthApi.config)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#connection" do
|
19
|
+
it 'should initialize an OAuth2::Client object' do
|
20
|
+
expect(DockHealthApi::Client.active_client.connection.is_a?(OAuth2::Client))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#token_connection" do
|
25
|
+
let (:token_connection) { DockHealthApi::Client.active_client.token_connection }
|
26
|
+
|
27
|
+
it 'should return a OAuth2::AccessToken object' do
|
28
|
+
expect(token_connection.is_a?(OAuth2::AccessToken))
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should return include a token' do
|
32
|
+
expect(token_connection.token).to_not be(nil)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'dock_health_api'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe DockHealthApi::CustomField do
|
5
|
+
|
6
|
+
let(:params) { {targetType: "PATIENT", fieldCategoryType: "PATIENT_PERSONAL", fieldType: "TEXT", name: "test1234"} }
|
7
|
+
id = ""
|
8
|
+
describe "#list" do
|
9
|
+
context "list all customfield" do
|
10
|
+
it 'should list all customfield' do
|
11
|
+
response = DockHealthApi::CustomField.list
|
12
|
+
expect(response.first.is_a?(DockHealthApi::CustomField))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#create" do
|
18
|
+
context "create a new customfield" do
|
19
|
+
it 'should create a new customfield' do
|
20
|
+
response = DockHealthApi::CustomField.create(params)
|
21
|
+
expect(response["name"]).to eq(params[:name])
|
22
|
+
id = response["id"]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#get" do
|
28
|
+
context "find a specific customfield" do
|
29
|
+
it 'should find the specific customfield' do
|
30
|
+
response = DockHealthApi::CustomField.get(id)
|
31
|
+
expect(response["name"]).to eq(params[:name])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#update" do
|
37
|
+
context "update customfield" do
|
38
|
+
it 'should update the customfield' do
|
39
|
+
response = DockHealthApi::CustomField.update(id: id, name: "update")
|
40
|
+
expect(response["name"]).to eq("update")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#delete" do
|
46
|
+
context "delete customfield" do
|
47
|
+
it 'should delete the customfield' do
|
48
|
+
response = DockHealthApi::CustomField.delete(id: id)
|
49
|
+
expect(response["id"]).to eq(id)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'dock_health_api'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe DockHealthApi::Developer do
|
5
|
+
describe '#list' do
|
6
|
+
context "list all developers" do
|
7
|
+
it 'should list all developer' do
|
8
|
+
response = DockHealthApi::Developer.list
|
9
|
+
expect(response.first.is_a?(DockHealthApi::Developer))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'dock_health_api'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
|
5
|
+
RSpec.describe DockHealthApi::Organization do
|
6
|
+
|
7
|
+
let (:organization) { {domain: "TestOrg",name:"TESTORG", identifier: "908"}}
|
8
|
+
let (:update_organization) { {domain: "TestOrg",name:"TESTORG!", identifier: "908"}}
|
9
|
+
let (:id) {"6ec62151-e64a-42b0-809a-9f5d7eecdae7"}
|
10
|
+
|
11
|
+
describe '#list' do
|
12
|
+
context "list all organizations" do
|
13
|
+
it 'should list all organization' do
|
14
|
+
response = DockHealthApi::Organization.list
|
15
|
+
expect(response.first.is_a?(DockHealthApi::Organization))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#create' do
|
21
|
+
context "create a new organization" do
|
22
|
+
xit 'should create a organization' do
|
23
|
+
response = DockHealthApi::Organization.create(organization)
|
24
|
+
expect(response["domain"]).to eq(organization[:domain])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#get' do
|
30
|
+
context "get a specfic organization" do
|
31
|
+
it 'should get the organization' do
|
32
|
+
response = DockHealthApi::Organization.get(id)
|
33
|
+
expect(response["domain"]).to eq(organization[:domain])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#update' do
|
39
|
+
context "update a specific organization" do
|
40
|
+
it 'should update the organization first name' do
|
41
|
+
params = update_organization.merge!({id:id})
|
42
|
+
revert = organization.merge!({id: id})
|
43
|
+
response = DockHealthApi::Organization.update(params)
|
44
|
+
expect(response["domain"]).to eq(update_organization[:domain])
|
45
|
+
DockHealthApi::Organization.update(revert)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#delete' do
|
51
|
+
context "delete a specific organization" do
|
52
|
+
xit 'should delete the organization' do
|
53
|
+
response = DockHealthApi::Organization.delete({id: id})
|
54
|
+
expect(response).to eq("")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'dock_health_api'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
|
5
|
+
RSpec.describe DockHealthApi::Patient do
|
6
|
+
|
7
|
+
let (:patient) { {firstName: "John",lastName:"Doe", mrn: "908"}}
|
8
|
+
let (:update_patient) { {firstName: "JOHN",lastName:"Doe", mrn: "908"}}
|
9
|
+
let (:id) {""}
|
10
|
+
|
11
|
+
describe '#list' do
|
12
|
+
context "list all patients" do
|
13
|
+
it 'should list all patients' do
|
14
|
+
response = DockHealthApi::Patient.list
|
15
|
+
expect(response.first.is_a?(DockHealthApi::Patient))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#create' do
|
21
|
+
context "create a new patient" do
|
22
|
+
it 'should create a patient' do
|
23
|
+
response = DockHealthApi::Patient.create(patient)
|
24
|
+
expect(response["firstName"]).to eq(patient[:firstName])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#get' do
|
30
|
+
context "get a specfic patient" do
|
31
|
+
it 'should get the patient' do
|
32
|
+
id = DockHealthApi::Patient.list.last["id"]
|
33
|
+
response = DockHealthApi::Patient.get(id)
|
34
|
+
expect(response["firstName"]).to eq(patient[:firstName])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#update' do
|
40
|
+
context "update a specific patient" do
|
41
|
+
it 'should update the patient first name' do
|
42
|
+
id = {id: DockHealthApi::Patient.list.last["id"]}
|
43
|
+
params = update_patient.merge!(id)
|
44
|
+
response = DockHealthApi::Patient.update(params)
|
45
|
+
expect(response["firstName"]).to eq(update_patient[:firstName])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#delete' do
|
51
|
+
context "delete a specific patient" do
|
52
|
+
it 'should delete the patient' do
|
53
|
+
id = {id: DockHealthApi::Patient.list.last["id"]}
|
54
|
+
response = DockHealthApi::Patient.delete(id)
|
55
|
+
expect(response["firstName"]).to eq(update_patient[:firstName])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|