cover_my_meds 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +27 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +137 -0
- data/Rakefile +2 -0
- data/cover_my_meds.gemspec +36 -0
- data/lib/cover_my_meds.rb +26 -0
- data/lib/cover_my_meds/api_request.rb +46 -0
- data/lib/cover_my_meds/client.rb +44 -0
- data/lib/cover_my_meds/client/credentials.rb +32 -0
- data/lib/cover_my_meds/client/drugs.rb +18 -0
- data/lib/cover_my_meds/client/forms.rb +18 -0
- data/lib/cover_my_meds/client/indicators.rb +24 -0
- data/lib/cover_my_meds/client/pharmacies.rb +20 -0
- data/lib/cover_my_meds/client/request_pages.rb +15 -0
- data/lib/cover_my_meds/client/requests.rb +121 -0
- data/lib/cover_my_meds/client/tokens.rb +24 -0
- data/lib/cover_my_meds/error.rb +20 -0
- data/lib/cover_my_meds/meta.rb +1 -0
- data/lib/cover_my_meds/meta/host_and_path.rb +58 -0
- data/lib/cover_my_meds/version.rb +3 -0
- data/lib/covermymeds_api/railtie.rb +32 -0
- metadata +287 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 082fbde241727d5bfd3f5e8f5055eb8d068da50e
|
4
|
+
data.tar.gz: b9d375f48722e57b11f5ee72065dcd85ea519ceb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f821a21e5c3646593d9431124daefc5574963c67cc1c800dd0de66486f084ba9ce6e3f5eca3cf44cfbe8b6fe482bb16697607668bfa4bd8af4f3027492dbd87c
|
7
|
+
data.tar.gz: c4bc0d421a2f33048199371d49c8eed02e045cd368b6ebefe12efb2d9712b8f69bb055811cc6bc96fbe31c09665ff0391f29e3b032d86cd0e57fc95b47f22c62
|
data/.gitignore
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
coverage
|
6
|
+
InstalledFiles
|
7
|
+
lib/bundler/man
|
8
|
+
pkg
|
9
|
+
rdoc
|
10
|
+
spec/reports
|
11
|
+
test/tmp
|
12
|
+
test/version_tmp
|
13
|
+
tmp
|
14
|
+
Gemfile.lock
|
15
|
+
.ruby-gemset
|
16
|
+
|
17
|
+
# YARD artifacts
|
18
|
+
.yardoc
|
19
|
+
_yardoc
|
20
|
+
doc/
|
21
|
+
quickfix.out
|
22
|
+
*.swp
|
23
|
+
*.swo
|
24
|
+
.env
|
25
|
+
|
26
|
+
# to keep out api keys and secrets
|
27
|
+
spec/support/cassettes/**
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
# CoverMyMeds API
|
2
|
+
|
3
|
+
CoverMyApi is a gem that provides a Ruby client for api.covermymeds.com
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cover_my_meds'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```
|
16
|
+
bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
*For general API documentation see: https://api.covermymeds.com*
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
Fork the repo, make changes, and submit a pull request.
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
You can use the CoverMyApi client to retrieve drugs, forms, pa requests, access tokens and create requests.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'cover_my_meds' # not needed in a rails app
|
31
|
+
```
|
32
|
+
|
33
|
+
## Getting Started
|
34
|
+
|
35
|
+
### Default Client
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
CoverMyMeds.default_client
|
39
|
+
```
|
40
|
+
|
41
|
+
This will set up a new client with a default host of
|
42
|
+
`https://api.covermymeds.com` and all the default paths. It will look for an API
|
43
|
+
key and secret in the `CMM_API_ID` and `CMM_API_SECRET` environment variables
|
44
|
+
respectively.
|
45
|
+
|
46
|
+
### Rails
|
47
|
+
|
48
|
+
In Rails, the default client will also check `Rails.application.secrets` for a
|
49
|
+
`cmm_api_id` and `cmm_api_secret` before falling back to the environment
|
50
|
+
variables.
|
51
|
+
|
52
|
+
The gem also includes a Railtie to allow simple configuration in
|
53
|
+
`Rails.application.configure` blocks typically found in environment files like
|
54
|
+
`config/environments/development.rb` etc. Usage is similar to the standard
|
55
|
+
configuration.
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
Rails.application.configure do
|
59
|
+
config.cover_my_meds.default_host = 'https://master-api.integration.covermymeds.com'
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
This will configure the default client retrieved through
|
64
|
+
`CoverMyMeds.default_client`. If you want to pass your own API key and secret,
|
65
|
+
you can call `CoverMyMeds.configured_client(api_id, api_secret)` which will use
|
66
|
+
the same configuration, but the passed ID/secret.
|
67
|
+
|
68
|
+
### Without Rails
|
69
|
+
|
70
|
+
Before anything else, create a new client:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
client = CoverMyMeds::Client.new(your_api_id, your_api_secret) do |client|
|
74
|
+
client.default_host = 'https://api.covermymeds.com'
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
## Drug Search
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
drugs = client.drug_search 'Boniva'
|
82
|
+
|
83
|
+
drugs # => array of drugs
|
84
|
+
drug = drug.first
|
85
|
+
drug.name # => 'Boniva'
|
86
|
+
```
|
87
|
+
|
88
|
+
## Form Search
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
forms = client.form_search('Blue Cross', drug.id, 'oh')
|
92
|
+
|
93
|
+
forms # => array of forms
|
94
|
+
form = form.first
|
95
|
+
form.name # => 'blue_cross_blue_shield_georgia_general'
|
96
|
+
```
|
97
|
+
|
98
|
+
## Get Request(s)
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
# Get a single request
|
102
|
+
request = client.get_request('NT5HL9')
|
103
|
+
request.id # => 'NT5HL9'
|
104
|
+
|
105
|
+
# Get many requests
|
106
|
+
requests = client.get_requests(['DS2FD3', 'FD6FD1'])
|
107
|
+
requests # => array of requests
|
108
|
+
```
|
109
|
+
|
110
|
+
## Create Request
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
new_request = client.request_data
|
114
|
+
request_data.patient.first_name = 'John'
|
115
|
+
|
116
|
+
request = client.create_request new_request
|
117
|
+
request.patient.first_name # => 'Jonhn'
|
118
|
+
```
|
119
|
+
|
120
|
+
|
121
|
+
## Create access tokens
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
token = client.create_access_token('DS3SE1')
|
125
|
+
token.id # => 'nhe44fu4g22upqqgstea'
|
126
|
+
```
|
127
|
+
|
128
|
+
## Get Request Pages
|
129
|
+
```ruby
|
130
|
+
request_page = client.get_request_page('NT5HL9','nhe44fu4g22upqqgstea')
|
131
|
+
request_page.keys # => values corresponding to a request page
|
132
|
+
|
133
|
+
Or to save remote_user attributes to the request audit trail:
|
134
|
+
request_page = client.get_request_page('NT5HL9','nhe44fu4g22upqqgstea', { remote_user_key: 'remote_user_value' })
|
135
|
+
request_page.keys # => values corresponding to a request page
|
136
|
+
```
|
137
|
+
e.g ["data", "forms", "actions", "provided_coded_references", "validations"]
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cover_my_meds/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cover_my_meds"
|
8
|
+
spec.version = CoverMyMeds::VERSION
|
9
|
+
spec.authors = ["Justin Rolston", "Mark Lorenz", "Dan Sajner", "Chad Cunningham", "Mike Gee", "Brandon Joyce", "Ryan Kowalick", "Shaun Hardin", "Jay Bobo", "Zach Serafini", "Rachel Twyford", "Ryan Stocker", "Corey Woodcox", "Nathan Demick"]
|
10
|
+
spec.email = ["jrolston@covermymeds.com", "mlorenz@covermymeds.com", "dsajner@covermymeds.com", "ccunningham@covermymeds.com", "mgee@covermymeds.com", "bjoyce@covermymeds.com", "rkowalick@covermymeds.com", "shardin@covermymeds.com", "jbobo@covermymeds.com", "zserafini@covermymeds.com", "rtwyford@covermymeds.com", "rstocker@covermymeds.com", "cwoodcox@covermymeds.com", "ndemick@covermymeds.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{CoverMyMeds Public API}
|
13
|
+
spec.description = %q{The public version of CoverMyMeds API}
|
14
|
+
spec.homepage = "https://github.com/covermymeds/cover_my_meds"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
23
|
+
spec.add_development_dependency "rspec-junklet", "~> 2.0"
|
24
|
+
spec.add_development_dependency "webmock", "~> 1.11"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "pry"
|
27
|
+
spec.add_development_dependency "vcr"
|
28
|
+
spec.add_development_dependency "dotenv"
|
29
|
+
spec.add_development_dependency "simplecov"
|
30
|
+
spec.add_development_dependency "railties"
|
31
|
+
|
32
|
+
spec.add_runtime_dependency "rest-client", "~> 1.6"
|
33
|
+
spec.add_runtime_dependency "hashie", "~> 2.0.2"
|
34
|
+
spec.add_runtime_dependency "settingslogic"
|
35
|
+
spec.add_runtime_dependency "activesupport"
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "cover_my_meds/version"
|
2
|
+
require_relative 'cover_my_meds/meta'
|
3
|
+
require_relative 'cover_my_meds/client'
|
4
|
+
|
5
|
+
require 'covermymeds_api/railtie' if defined?(Rails)
|
6
|
+
|
7
|
+
module CoverMyMeds
|
8
|
+
|
9
|
+
GET = 'get'.freeze
|
10
|
+
POST = 'post'.freeze
|
11
|
+
PUT = 'put'.freeze
|
12
|
+
DELETE = 'delete'.freeze
|
13
|
+
|
14
|
+
def self.version
|
15
|
+
"CoverMyMeds version #{CoverMyMeds::VERSION}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.default_client
|
19
|
+
# Delegate to the Railtie if it's there
|
20
|
+
if defined?(Railtie)
|
21
|
+
Railtie.instance.default_client
|
22
|
+
else
|
23
|
+
Client.new ENV['CMM_API_ID'], ENV['CMM_API_SECRET']
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
require 'hashie'
|
4
|
+
require 'active_support/core_ext/object/to_param'
|
5
|
+
require 'active_support/core_ext/object/to_query'
|
6
|
+
require 'cover_my_meds/error'
|
7
|
+
|
8
|
+
module CoverMyMeds
|
9
|
+
module ApiRequest
|
10
|
+
|
11
|
+
def request(http_method, host, path, params={}, auth_type = :basic, &block)
|
12
|
+
params = params.symbolize_keys
|
13
|
+
headers = params.delete(:headers) || {}
|
14
|
+
|
15
|
+
tail = case auth_type
|
16
|
+
when :basic
|
17
|
+
{ user: @username, password: @password, headers: headers }
|
18
|
+
when :bearer
|
19
|
+
{ headers: { "Authorization" => "Bearer #{@username}+#{params.delete(:token_id)}" }.merge(headers) }
|
20
|
+
else
|
21
|
+
{}
|
22
|
+
end
|
23
|
+
|
24
|
+
uri = api_uri(host, path, params)
|
25
|
+
rest_resource = RestClient::Resource.new(uri.to_s, tail)
|
26
|
+
|
27
|
+
response = call_api http_method, rest_resource, &block
|
28
|
+
return nil if response.body.empty?
|
29
|
+
return JSON.parse(response.body)
|
30
|
+
end
|
31
|
+
|
32
|
+
def call_api http_method, rest_resource
|
33
|
+
body = block_given? ? yield : {}
|
34
|
+
rest_resource.send http_method, body
|
35
|
+
rescue RestClient::Exception => e
|
36
|
+
raise Error::HTTPError.new(e.http_code, e.http_body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def api_uri host, path, params
|
40
|
+
URI.parse(host).tap do |uri|
|
41
|
+
uri.path = path
|
42
|
+
uri.query = params.to_param
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative 'api_request'
|
2
|
+
require_relative 'client/drugs'
|
3
|
+
require_relative 'client/forms'
|
4
|
+
require_relative 'client/requests'
|
5
|
+
require_relative 'client/tokens'
|
6
|
+
require_relative 'client/pharmacies'
|
7
|
+
require_relative 'client/credentials'
|
8
|
+
require_relative 'client/request_pages'
|
9
|
+
require_relative 'client/indicators'
|
10
|
+
|
11
|
+
module CoverMyMeds
|
12
|
+
class Client
|
13
|
+
include CoverMyMeds::ApiRequest
|
14
|
+
include CoverMyMeds::Drugs
|
15
|
+
include CoverMyMeds::Forms
|
16
|
+
include CoverMyMeds::Requests
|
17
|
+
include CoverMyMeds::Tokens
|
18
|
+
include CoverMyMeds::Pharmacies
|
19
|
+
include CoverMyMeds::Credentials
|
20
|
+
include CoverMyMeds::RequestPages
|
21
|
+
include CoverMyMeds::Indicators
|
22
|
+
|
23
|
+
# use the block to set module privided instance variables:
|
24
|
+
# ```ruby
|
25
|
+
# Client.new('mark') do |client|
|
26
|
+
# client.contacts_path = '/'
|
27
|
+
# client.contacts_host = 'http://contacts-api.dev'
|
28
|
+
# end
|
29
|
+
# ```
|
30
|
+
#
|
31
|
+
# Defaults are to proudction to make it easy for external gem consumers.
|
32
|
+
def initialize(username, password=nil)
|
33
|
+
@username = username
|
34
|
+
@password = password
|
35
|
+
yield(self) if block_given?
|
36
|
+
end
|
37
|
+
|
38
|
+
attr_writer :default_host
|
39
|
+
def default_host
|
40
|
+
@default_host ||= "https://api.covermymeds.com"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module CoverMyMeds
|
2
|
+
module Credentials
|
3
|
+
include HostAndPath
|
4
|
+
|
5
|
+
CURRENT_VERSION = 1
|
6
|
+
|
7
|
+
def create_credential npi: npi, callback_url: '', callback_verb: '', fax_numbers: fax_numbers, contact_hint: {}, version: CURRENT_VERSION
|
8
|
+
params = { v: version }
|
9
|
+
data = credentials_request POST, params: params do
|
10
|
+
{
|
11
|
+
credential: {
|
12
|
+
npi: npi,
|
13
|
+
callback_url: callback_url,
|
14
|
+
callback_verb: callback_verb,
|
15
|
+
fax_numbers: Array(fax_numbers),
|
16
|
+
contact_hint: contact_hint,
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
Hashie::Mash.new data['credential']
|
21
|
+
end
|
22
|
+
|
23
|
+
# Override the meta-programming in this oddball case
|
24
|
+
def credentials_path
|
25
|
+
@credentials_path || "/prescribers/credentials/"
|
26
|
+
end
|
27
|
+
|
28
|
+
def delete_credential(npi, version=CURRENT_VERSION)
|
29
|
+
data = credentials_request DELETE, path: npi, params: { v: version }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module CoverMyMeds
|
2
|
+
module Drugs
|
3
|
+
include HostAndPath
|
4
|
+
|
5
|
+
CURRENT_VERSION = 1
|
6
|
+
|
7
|
+
def drug_search drug, version=CURRENT_VERSION
|
8
|
+
params = {q: drug, v: version}
|
9
|
+
data = drugs_request GET, params: params
|
10
|
+
data['drugs'].map { |d| Hashie::Mash.new(d) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_drug drug_id, version = CURRENT_VERSION
|
14
|
+
data = drugs_request GET, params: { v: version }, path: drug_id
|
15
|
+
Hashie::Mash.new(data['drug'])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module CoverMyMeds
|
2
|
+
module Forms
|
3
|
+
include HostAndPath
|
4
|
+
|
5
|
+
CURRENT_VERSION = 1
|
6
|
+
|
7
|
+
def form_search form, drug_id, state, version=CURRENT_VERSION
|
8
|
+
params = {q: form, drug_id: drug_id, state: state, v: version}
|
9
|
+
data = forms_request GET, params: params
|
10
|
+
data['forms'].map { |d| Hashie::Mash.new(d) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_form form_id, version = CURRENT_VERSION
|
14
|
+
data = forms_request GET, params: { v: version }, path: form_id
|
15
|
+
Hashie::Mash.new(data['form'])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CoverMyMeds
|
2
|
+
module Indicators
|
3
|
+
include HostAndPath
|
4
|
+
|
5
|
+
CURRENT_VERSION = 1
|
6
|
+
|
7
|
+
def post_indicators(prescription: prescription, patient: patient, payer: {}, prescriber: {}, version: CURRENT_VERSION)
|
8
|
+
params = { prescription: prescription, prescriber: prescriber, patient: patient, payer: payer }
|
9
|
+
data = indicators_request POST, params: { v: version, headers: { content_type: :json } } do
|
10
|
+
params.to_json
|
11
|
+
end
|
12
|
+
Hashie::Mash.new(data)
|
13
|
+
end
|
14
|
+
|
15
|
+
def search_indicators(prescriptions: prescriptions, patient: {}, payer: {}, prescriber: {}, version: CURRENT_VERSION)
|
16
|
+
params = { prescriptions: Array(prescriptions), prescriber: prescriber, patient: patient, payer: payer }
|
17
|
+
data = indicators_request POST, path: 'search/', params: { v: version, headers: { content_type: :json } } do
|
18
|
+
params.to_json
|
19
|
+
end
|
20
|
+
Hashie::Mash.new(data)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module CoverMyMeds
|
2
|
+
module Pharmacies
|
3
|
+
include HostAndPath
|
4
|
+
|
5
|
+
CURRENT_VERSION = 1
|
6
|
+
|
7
|
+
def pharmacy_search params, version=CURRENT_VERSION
|
8
|
+
params.merge!(v: version)
|
9
|
+
data = pharmacies_request GET, params: params
|
10
|
+
data['pharmacies'].map do |d|
|
11
|
+
Hashie::Mash.new(d)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_pharmacy npi, version = CURRENT_VERSION
|
16
|
+
data = pharmacies_request GET, params: { v: version }, path: npi
|
17
|
+
Hashie::Mash.new(data['pharmacy'])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module CoverMyMeds
|
2
|
+
module RequestPages
|
3
|
+
include HostAndPath
|
4
|
+
|
5
|
+
CURRENT_VERSION = 1
|
6
|
+
|
7
|
+
def get_request_page request_id, token_id, remote_user = {}, version = CURRENT_VERSION
|
8
|
+
params = { token_id: token_id, v: version , remote_user: remote_user }
|
9
|
+
request_page = request_pages_request(
|
10
|
+
GET, params: params, path: request_id, auth: :bearer
|
11
|
+
)
|
12
|
+
Hashie::Mash.new(request_page["request_page"])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module CoverMyMeds
|
2
|
+
module Requests
|
3
|
+
include HostAndPath
|
4
|
+
|
5
|
+
CURRENT_VERSION = 1
|
6
|
+
|
7
|
+
def get_request token_id, version = CURRENT_VERSION
|
8
|
+
params = { v: version }
|
9
|
+
data = requests_request POST, params: params, path: "search/" do
|
10
|
+
"token_ids[]=#{token_id}"
|
11
|
+
end
|
12
|
+
Hashie::Mash.new(data['requests'].first)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_requests token_ids, version = CURRENT_VERSION
|
16
|
+
params = { 'token_ids' => token_ids, v: version }
|
17
|
+
data = requests_request POST, params: params, path: "search/"
|
18
|
+
data['requests'].map { |d| Hashie::Mash.new(d) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_request request_data,version = CURRENT_VERSION
|
22
|
+
data = requests_request POST, params: { v: version } do
|
23
|
+
{ 'request' => request_data.to_hash }
|
24
|
+
end
|
25
|
+
Hashie::Mash.new(data['request'])
|
26
|
+
end
|
27
|
+
|
28
|
+
def request_data
|
29
|
+
hash = JSON.parse @@json_string
|
30
|
+
Hashie::Mash.new hash['request']
|
31
|
+
end
|
32
|
+
|
33
|
+
@@json_string = <<-eof
|
34
|
+
{
|
35
|
+
"request": {
|
36
|
+
"urgent": "false",
|
37
|
+
"form_id": "",
|
38
|
+
"state": "",
|
39
|
+
"patient": {
|
40
|
+
"first_name": "",
|
41
|
+
"middle_name": "",
|
42
|
+
"last_name": "",
|
43
|
+
"date_of_birth": "",
|
44
|
+
"gender": "",
|
45
|
+
"email": "",
|
46
|
+
"member_id": "",
|
47
|
+
"phone_number": "",
|
48
|
+
"address": {
|
49
|
+
"street_1": "",
|
50
|
+
"street_2": "",
|
51
|
+
"city": "",
|
52
|
+
"state": "",
|
53
|
+
"zip": ""
|
54
|
+
}
|
55
|
+
},
|
56
|
+
"payer": {
|
57
|
+
"form_search_text": "",
|
58
|
+
"bin": "",
|
59
|
+
"pcn": "",
|
60
|
+
"group_id": "",
|
61
|
+
"medical_benefit_name": "",
|
62
|
+
"drug_benefit_name": ""
|
63
|
+
},
|
64
|
+
"prescriber": {
|
65
|
+
"npi": "",
|
66
|
+
"first_name": "",
|
67
|
+
"last_name": "",
|
68
|
+
"clinic_name": "",
|
69
|
+
"speciality": "",
|
70
|
+
"address": {
|
71
|
+
"street_1": "",
|
72
|
+
"street_2": "",
|
73
|
+
"city": "",
|
74
|
+
"state": "",
|
75
|
+
"zip": ""
|
76
|
+
},
|
77
|
+
"fax_number": "",
|
78
|
+
"phone_number": ""
|
79
|
+
},
|
80
|
+
"prescription": {
|
81
|
+
"drug_id": "",
|
82
|
+
"strength": "",
|
83
|
+
"frequency": "",
|
84
|
+
"enumerated_fields": "",
|
85
|
+
"refills": "",
|
86
|
+
"dispense_as_written": "",
|
87
|
+
"quantity": "",
|
88
|
+
"days_supply": ""
|
89
|
+
},
|
90
|
+
"pharmacy": {
|
91
|
+
"name": "",
|
92
|
+
"address": {
|
93
|
+
"street_1": "",
|
94
|
+
"street_2": "",
|
95
|
+
"city": "",
|
96
|
+
"state": "",
|
97
|
+
"zip": ""
|
98
|
+
},
|
99
|
+
"fax_number": "",
|
100
|
+
"phone_number": ""
|
101
|
+
},
|
102
|
+
"enumerated_fields": {
|
103
|
+
"icd9_0": "",
|
104
|
+
"icd9_1": "",
|
105
|
+
"icd9_2": "",
|
106
|
+
"failed_med_0": "",
|
107
|
+
"failed_med_1": "",
|
108
|
+
"failed_med_2": "",
|
109
|
+
"failed_med_3": "",
|
110
|
+
"failed_med_4": "",
|
111
|
+
"failed_med_5": "",
|
112
|
+
"failed_med_6": "",
|
113
|
+
"failed_med_7": "",
|
114
|
+
"failed_med_8": "",
|
115
|
+
"failed_med_9": ""
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
eof
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CoverMyMeds
|
2
|
+
module Tokens
|
3
|
+
include HostAndPath
|
4
|
+
|
5
|
+
CURRENT_VERSION = 1
|
6
|
+
|
7
|
+
def create_access_token request_id, version=CURRENT_VERSION
|
8
|
+
params = {'request_ids[]' => request_id, v: version}
|
9
|
+
data = tokens_request POST, params: params
|
10
|
+
Hashie::Mash.new data['tokens'].first
|
11
|
+
end
|
12
|
+
|
13
|
+
def revoke_access_token? token_id, version=CURRENT_VERSION
|
14
|
+
params = { v: version }
|
15
|
+
tokens_request DELETE, path: token_id, params: params
|
16
|
+
end
|
17
|
+
|
18
|
+
# Override the meta-programming in this oddball case
|
19
|
+
def tokens_path
|
20
|
+
@tokens_path || "/requests/tokens/"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module CoverMyMeds
|
2
|
+
module Error
|
3
|
+
class HTTPError < StandardError
|
4
|
+
|
5
|
+
def initialize status, message
|
6
|
+
@status = status
|
7
|
+
@error_json = message
|
8
|
+
end
|
9
|
+
|
10
|
+
def message
|
11
|
+
"#{@status}: #{@error_json}"
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :status, :error_json
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
CMMDuplicateEntityError = Class.new(StandardError)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "meta/host_and_path"
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Adds methods like this to your module:
|
2
|
+
#
|
3
|
+
# attr_writer :contacts_path
|
4
|
+
# def contacts_path
|
5
|
+
# @contacts_path || "/contacts/"
|
6
|
+
# end
|
7
|
+
#
|
8
|
+
# attr_writer :contacts_host
|
9
|
+
# def contacts_host
|
10
|
+
# @contacts_host || default_host
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# def contacts_request method, options={} &block
|
14
|
+
# options = options.symbolize_keys
|
15
|
+
# path = options[:path] || ""
|
16
|
+
# params = options[:params].merge({})
|
17
|
+
# full_path = contacts_path+path
|
18
|
+
#
|
19
|
+
# request method, contacts_host, full_path, params, &block
|
20
|
+
# end
|
21
|
+
|
22
|
+
require 'active_support/core_ext/string/inflections'
|
23
|
+
require 'active_support/core_ext/hash/conversions'
|
24
|
+
|
25
|
+
module CoverMyMeds
|
26
|
+
module HostAndPath
|
27
|
+
def self.included(base)
|
28
|
+
api_name = base.name.demodulize.underscore.downcase
|
29
|
+
|
30
|
+
base.instance_exec do
|
31
|
+
attr_writer "#{api_name}_path".to_sym
|
32
|
+
define_method "#{api_name}_path" do
|
33
|
+
instance_variable_get("@#{api_name}_path") || "/#{api_name.dasherize}/"
|
34
|
+
end
|
35
|
+
|
36
|
+
attr_writer "#{api_name}_host".to_sym
|
37
|
+
define_method "#{api_name}_host" do
|
38
|
+
instance_variable_get("@#{api_name}_host") || default_host
|
39
|
+
end
|
40
|
+
|
41
|
+
define_method "#{api_name}_request" do |method, options={}, &block|
|
42
|
+
options = options.symbolize_keys
|
43
|
+
path = options[:path] || ""
|
44
|
+
params = options[:params]
|
45
|
+
auth = options[:auth]
|
46
|
+
host_name = public_send("#{api_name}_host".to_sym)
|
47
|
+
full_path = public_send("#{api_name}_path".to_sym) + path
|
48
|
+
|
49
|
+
proxy_args = [ method, host_name, full_path, params, auth ]
|
50
|
+
fail ArgumentError, "method, host_name or full_path can not be nil" if proxy_args.take(3).any?(&:nil?)
|
51
|
+
|
52
|
+
request(*proxy_args.compact, &block)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module CoverMyMeds
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
config.cover_my_meds = ActiveSupport::OrderedOptions.new
|
4
|
+
|
5
|
+
config.cover_my_meds.default_host = "https://api.covermymeds.com/"
|
6
|
+
|
7
|
+
# Create (and cache) a configured API client instance using the id/secret
|
8
|
+
# stored in `Rails.application.secrets` and the configuration specified
|
9
|
+
# here and in `Rails.application.config.covermymeds_api`
|
10
|
+
def default_client
|
11
|
+
@client ||= configured_client *credentials
|
12
|
+
end
|
13
|
+
|
14
|
+
# Create a configured API client class with the configuration stored on the
|
15
|
+
# app. Useful if you want to use the same host/path configuration as the
|
16
|
+
# rest of the app, but a different id/secret pair
|
17
|
+
def configured_client(api_id, secret = nil)
|
18
|
+
CoverMyMeds::Client.new api_id, secret do |client|
|
19
|
+
config.cover_my_meds.each do |k,v|
|
20
|
+
client.send "#{k}=".to_sym, v
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def credentials
|
27
|
+
api_id = Rails.application.secrets.cmm_api_id || ENV['CMM_API_ID']
|
28
|
+
secret = Rails.application.secrets.cmm_api_secret || ENV['CMM_API_SECRET']
|
29
|
+
[ api_id, secret ]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,287 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cover_my_meds
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Rolston
|
8
|
+
- Mark Lorenz
|
9
|
+
- Dan Sajner
|
10
|
+
- Chad Cunningham
|
11
|
+
- Mike Gee
|
12
|
+
- Brandon Joyce
|
13
|
+
- Ryan Kowalick
|
14
|
+
- Shaun Hardin
|
15
|
+
- Jay Bobo
|
16
|
+
- Zach Serafini
|
17
|
+
- Rachel Twyford
|
18
|
+
- Ryan Stocker
|
19
|
+
- Corey Woodcox
|
20
|
+
- Nathan Demick
|
21
|
+
autorequire:
|
22
|
+
bindir: exe
|
23
|
+
cert_chain: []
|
24
|
+
date: 2015-06-18 00:00:00.000000000 Z
|
25
|
+
dependencies:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: bundler
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.3'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.3'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: rspec
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.2'
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.2'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: rspec-junklet
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2.0'
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2.0'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: webmock
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.11'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.11'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: rake
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: pry
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: vcr
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
type: :development
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: dotenv
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
name: simplecov
|
140
|
+
requirement: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
type: :development
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
- !ruby/object:Gem::Dependency
|
153
|
+
name: railties
|
154
|
+
requirement: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
type: :development
|
160
|
+
prerelease: false
|
161
|
+
version_requirements: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
- !ruby/object:Gem::Dependency
|
167
|
+
name: rest-client
|
168
|
+
requirement: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ~>
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '1.6'
|
173
|
+
type: :runtime
|
174
|
+
prerelease: false
|
175
|
+
version_requirements: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ~>
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '1.6'
|
180
|
+
- !ruby/object:Gem::Dependency
|
181
|
+
name: hashie
|
182
|
+
requirement: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ~>
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: 2.0.2
|
187
|
+
type: :runtime
|
188
|
+
prerelease: false
|
189
|
+
version_requirements: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - ~>
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: 2.0.2
|
194
|
+
- !ruby/object:Gem::Dependency
|
195
|
+
name: settingslogic
|
196
|
+
requirement: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - '>='
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0'
|
201
|
+
type: :runtime
|
202
|
+
prerelease: false
|
203
|
+
version_requirements: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - '>='
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
- !ruby/object:Gem::Dependency
|
209
|
+
name: activesupport
|
210
|
+
requirement: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - '>='
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0'
|
215
|
+
type: :runtime
|
216
|
+
prerelease: false
|
217
|
+
version_requirements: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
description: The public version of CoverMyMeds API
|
223
|
+
email:
|
224
|
+
- jrolston@covermymeds.com
|
225
|
+
- mlorenz@covermymeds.com
|
226
|
+
- dsajner@covermymeds.com
|
227
|
+
- ccunningham@covermymeds.com
|
228
|
+
- mgee@covermymeds.com
|
229
|
+
- bjoyce@covermymeds.com
|
230
|
+
- rkowalick@covermymeds.com
|
231
|
+
- shardin@covermymeds.com
|
232
|
+
- jbobo@covermymeds.com
|
233
|
+
- zserafini@covermymeds.com
|
234
|
+
- rtwyford@covermymeds.com
|
235
|
+
- rstocker@covermymeds.com
|
236
|
+
- cwoodcox@covermymeds.com
|
237
|
+
- ndemick@covermymeds.com
|
238
|
+
executables: []
|
239
|
+
extensions: []
|
240
|
+
extra_rdoc_files: []
|
241
|
+
files:
|
242
|
+
- .gitignore
|
243
|
+
- .rspec
|
244
|
+
- Gemfile
|
245
|
+
- README.md
|
246
|
+
- Rakefile
|
247
|
+
- cover_my_meds.gemspec
|
248
|
+
- lib/cover_my_meds.rb
|
249
|
+
- lib/cover_my_meds/api_request.rb
|
250
|
+
- lib/cover_my_meds/client.rb
|
251
|
+
- lib/cover_my_meds/client/credentials.rb
|
252
|
+
- lib/cover_my_meds/client/drugs.rb
|
253
|
+
- lib/cover_my_meds/client/forms.rb
|
254
|
+
- lib/cover_my_meds/client/indicators.rb
|
255
|
+
- lib/cover_my_meds/client/pharmacies.rb
|
256
|
+
- lib/cover_my_meds/client/request_pages.rb
|
257
|
+
- lib/cover_my_meds/client/requests.rb
|
258
|
+
- lib/cover_my_meds/client/tokens.rb
|
259
|
+
- lib/cover_my_meds/error.rb
|
260
|
+
- lib/cover_my_meds/meta.rb
|
261
|
+
- lib/cover_my_meds/meta/host_and_path.rb
|
262
|
+
- lib/cover_my_meds/version.rb
|
263
|
+
- lib/covermymeds_api/railtie.rb
|
264
|
+
homepage: https://github.com/covermymeds/cover_my_meds
|
265
|
+
licenses: []
|
266
|
+
metadata: {}
|
267
|
+
post_install_message:
|
268
|
+
rdoc_options: []
|
269
|
+
require_paths:
|
270
|
+
- lib
|
271
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
272
|
+
requirements:
|
273
|
+
- - '>='
|
274
|
+
- !ruby/object:Gem::Version
|
275
|
+
version: '0'
|
276
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
277
|
+
requirements:
|
278
|
+
- - '>='
|
279
|
+
- !ruby/object:Gem::Version
|
280
|
+
version: '0'
|
281
|
+
requirements: []
|
282
|
+
rubyforge_project:
|
283
|
+
rubygems_version: 2.4.6
|
284
|
+
signing_key:
|
285
|
+
specification_version: 4
|
286
|
+
summary: CoverMyMeds Public API
|
287
|
+
test_files: []
|