antech_rb 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +59 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +6 -0
- data/antech_rb.gemspec +36 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/antech.rb +4 -0
- data/lib/antech/client.rb +42 -0
- data/lib/antech/resources/base_resource.rb +40 -0
- data/lib/antech/resources/lab_result.rb +43 -0
- data/lib/antech/resources/test.rb +46 -0
- data/lib/antech/version.rb +3 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8b3f83a708342bc385ba738f7514ab37f590c218bf2f2b80330c00287a5a9f26
|
4
|
+
data.tar.gz: 67124a937ac91580f6180e4a415b0a1b26f4e4bc4e9409bfc6065ee7ce2c88f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a685aaf06439764ee9809f6114c1409149015aaa824f43bfaa77098062d3daa66e5880e95a3e903ee227fcd23687a596bf60c11e30dd83fe2c342488e21ed09
|
7
|
+
data.tar.gz: 01c0fe2a5980f50bc071e04d51adc4a01a3bb818c82ce10ff470b501eec6d6f15da60b5d5a4aabb9df735095a60727cbfbefffac9d5de1af2fbc1e8228893b6e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
antech_rb (0.0.1)
|
5
|
+
rest-client (< 3.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.2)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
domain_name (0.5.20190701)
|
13
|
+
unf (>= 0.0.5, < 1.0.0)
|
14
|
+
http-accept (1.7.0)
|
15
|
+
http-cookie (1.0.3)
|
16
|
+
domain_name (~> 0.5)
|
17
|
+
method_source (0.9.2)
|
18
|
+
mime-types (3.3.1)
|
19
|
+
mime-types-data (~> 3.2015)
|
20
|
+
mime-types-data (3.2019.1009)
|
21
|
+
netrc (0.11.0)
|
22
|
+
pry (0.12.2)
|
23
|
+
coderay (~> 1.1.0)
|
24
|
+
method_source (~> 0.9.0)
|
25
|
+
rake (10.5.0)
|
26
|
+
rest-client (2.1.0)
|
27
|
+
http-accept (>= 1.7.0, < 2.0)
|
28
|
+
http-cookie (>= 1.0.2, < 2.0)
|
29
|
+
mime-types (>= 1.16, < 4.0)
|
30
|
+
netrc (~> 0.8)
|
31
|
+
rspec (3.9.0)
|
32
|
+
rspec-core (~> 3.9.0)
|
33
|
+
rspec-expectations (~> 3.9.0)
|
34
|
+
rspec-mocks (~> 3.9.0)
|
35
|
+
rspec-core (3.9.1)
|
36
|
+
rspec-support (~> 3.9.1)
|
37
|
+
rspec-expectations (3.9.0)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.9.0)
|
40
|
+
rspec-mocks (3.9.1)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.9.0)
|
43
|
+
rspec-support (3.9.2)
|
44
|
+
unf (0.1.4)
|
45
|
+
unf_ext
|
46
|
+
unf_ext (0.0.7.6)
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
ruby
|
50
|
+
|
51
|
+
DEPENDENCIES
|
52
|
+
antech_rb!
|
53
|
+
bundler (~> 1.17)
|
54
|
+
pry (~> 0.12.2)
|
55
|
+
rake (~> 10.0)
|
56
|
+
rspec (~> 3.0)
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Stephen Kiningham
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# AntechRb
|
2
|
+
|
3
|
+
Ruby wrapper for the ANTECH Diagnostics API. This gem is unaffiliated with ANTECH Diagnostics, and documentation of the API is not available publicly (as far as I know). This is a work-in-progress.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'antech_rb'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install antech_rb
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/skiningham/antech_rb.
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/antech_rb.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "antech/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "antech_rb"
|
8
|
+
spec.version = Antech::VERSION
|
9
|
+
spec.authors = ["Stephen Kiningham"]
|
10
|
+
spec.email = ["stephen.kiningham@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby wrapper for ANTECH Diagnostics web service.}
|
13
|
+
spec.homepage = "https://github.com/skiningham/antech_rb"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
if spec.respond_to?(:metadata)
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/skiningham/antech_rb"
|
19
|
+
end
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "rest-client", "< 3.0"
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
spec.add_development_dependency "pry", "~> 0.12.2"
|
36
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "antech"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
data/bin/setup
ADDED
data/lib/antech.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'antech/resources/lab_result'
|
2
|
+
require 'antech/resources/test'
|
3
|
+
require 'rest-client'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Antech
|
7
|
+
class Client
|
8
|
+
attr_reader :auth_token
|
9
|
+
|
10
|
+
def initialize(credentials = nil)
|
11
|
+
raise ArgumentError.new 'Credentials are required to initialize the client' if credentials.nil?
|
12
|
+
|
13
|
+
[:clinic_id, :username, :password].each do |key|
|
14
|
+
raise ArgumentError.new ":#{key} is required to initialize the client" if credentials[key].nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
@auth_token = login(credentials)
|
18
|
+
end
|
19
|
+
|
20
|
+
def lab_results
|
21
|
+
Antech::Resources::LabResult.new(auth_token)
|
22
|
+
end
|
23
|
+
|
24
|
+
def tests
|
25
|
+
Antech::Resources::Test.new(auth_token)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def login(credentials)
|
31
|
+
response = RestClient.post(
|
32
|
+
'https://onlineapi.antechdiagnostics.com/api/v1.1/Users/Login',
|
33
|
+
{
|
34
|
+
ClinicID: credentials[:clinic_id],
|
35
|
+
UserName: credentials[:username],
|
36
|
+
Password: credentials[:password]
|
37
|
+
}
|
38
|
+
)
|
39
|
+
JSON.parse(response)['Token']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module Antech
|
6
|
+
module Resources
|
7
|
+
class BaseResource
|
8
|
+
attr_reader :auth_token
|
9
|
+
|
10
|
+
def initialize(auth_token)
|
11
|
+
@auth_token = auth_token
|
12
|
+
end
|
13
|
+
|
14
|
+
def base_url
|
15
|
+
'https://onlineapi.antechdiagnostics.com/api'
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def submit(request)
|
21
|
+
url = request[:url]
|
22
|
+
method = request[:method]
|
23
|
+
body = request[:body] || {}
|
24
|
+
query = request[:query] || {}
|
25
|
+
|
26
|
+
query = query.merge(accessToken: auth_token)
|
27
|
+
|
28
|
+
url = "#{url}?#{URI.encode_www_form(query)}"
|
29
|
+
|
30
|
+
response = if method == :get
|
31
|
+
RestClient.send(method, url)
|
32
|
+
else
|
33
|
+
RestClient.send(method, url, body)
|
34
|
+
end
|
35
|
+
|
36
|
+
JSON.parse(response)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'antech/resources/base_resource'
|
2
|
+
|
3
|
+
module Antech
|
4
|
+
module Resources
|
5
|
+
class LabResult < Antech::Resources::BaseResource
|
6
|
+
def initialize(auth_token)
|
7
|
+
super(auth_token)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Required query params:
|
11
|
+
# startDate, endDate
|
12
|
+
#
|
13
|
+
# Optional query params:
|
14
|
+
# petName, ownerName, doctorName, labAccessionID
|
15
|
+
def list(query = {})
|
16
|
+
request = {
|
17
|
+
method: :get,
|
18
|
+
url: "#{base_url}/v2.0/LabResults",
|
19
|
+
query: query
|
20
|
+
}
|
21
|
+
|
22
|
+
submit(request)
|
23
|
+
end
|
24
|
+
|
25
|
+
def find(lab_accession_id)
|
26
|
+
request = {
|
27
|
+
method: :get,
|
28
|
+
url: "#{base_url}/v1.1/LabResults/#{lab_accession_id}/Details"
|
29
|
+
}
|
30
|
+
|
31
|
+
submit(request)
|
32
|
+
end
|
33
|
+
|
34
|
+
def history(accession_result_id)
|
35
|
+
request = {
|
36
|
+
method: :get,
|
37
|
+
url: "#{base_url}/v2.0/LabResults/History",
|
38
|
+
query: { accessionResultId: accession_result_id }
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'antech/resources/base_resource'
|
2
|
+
|
3
|
+
module Antech
|
4
|
+
module Resources
|
5
|
+
class Test < Antech::Resources::BaseResource
|
6
|
+
def initialize(auth_token)
|
7
|
+
super(auth_token)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Query params unknown
|
11
|
+
def list(query = {})
|
12
|
+
# Mystery magic params
|
13
|
+
query.merge!({
|
14
|
+
labID: 1,
|
15
|
+
searchType: 6,
|
16
|
+
orderCode: nil
|
17
|
+
})
|
18
|
+
|
19
|
+
request = {
|
20
|
+
method: :get,
|
21
|
+
url: "#{base_url}/v1.1/Tests",
|
22
|
+
query: query
|
23
|
+
}
|
24
|
+
|
25
|
+
submit(request)
|
26
|
+
end
|
27
|
+
|
28
|
+
def find(code, code_id, lab_id)
|
29
|
+
query = {
|
30
|
+
testName: code,
|
31
|
+
labID: lab_id,
|
32
|
+
unitCode: code_id,
|
33
|
+
searchType: 'OrderCode' # Mystery magic param
|
34
|
+
}
|
35
|
+
|
36
|
+
request = {
|
37
|
+
method: :get,
|
38
|
+
url: "#{base_url}/v1.1/Tests/Details",
|
39
|
+
query: query
|
40
|
+
}
|
41
|
+
|
42
|
+
submit(request).first
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: antech_rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stephen Kiningham
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "<"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "<"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.17'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.17'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.12.2
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.12.2
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- stephen.kiningham@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- antech_rb.gemspec
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- lib/antech.rb
|
101
|
+
- lib/antech/client.rb
|
102
|
+
- lib/antech/resources/base_resource.rb
|
103
|
+
- lib/antech/resources/lab_result.rb
|
104
|
+
- lib/antech/resources/test.rb
|
105
|
+
- lib/antech/version.rb
|
106
|
+
homepage: https://github.com/skiningham/antech_rb
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata:
|
110
|
+
homepage_uri: https://github.com/skiningham/antech_rb
|
111
|
+
source_code_uri: https://github.com/skiningham/antech_rb
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.7.6
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Ruby wrapper for ANTECH Diagnostics web service.
|
132
|
+
test_files: []
|