Official Aqua.io API library client for Ruby (covers ICD-9 and ICD-10)
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
LICENSE
README.md
aqua-io.gemspec

README.md

aqua-io-ruby

Official Aqua.io API library client for Ruby. Currently covers Aqua.io's ICD-9 and ICD-10 APIs.

Getting Started

To use the Aqua.io API, you need to have proper API credentials, which you can get for free by signing up.

You may also want to read up on the API documentation.

Installation

Versions

Works with Ruby [ 1.8.6 / 1.8.7 / 1.9.1 / 1.9.2 / 1.9.3 / 2.0.0 / 2.1.0 / 2.1.1 ]

Ruby on Rails

gem 'aqua-io',		'~> 0.1.0'

Other Ruby Projects

Make sure you have rubygems installed

$ gem install aqua-io

Then in your project:

require "aqua-io"

Usage

Build a client

Get an access token using your aqua.io credentials
client = AquaIo::Client.new({ client_id: '09a8b7', client_secret: '1a2b3' }, client_options)

token = client.access_token.retrieve

access_token = {access_token: token.body['access_token']}
All other API calls require an access token
client = AquaIo::Client.new(access_token, client_options)

Client Options

The following options are available while instantiating a client:

  • base: Base url for the api
  • user_agent: Default user-agent for all requests
  • headers: Default headers for all requests
  • request_type: Default format of the request body

Response information

All the callbacks provided to an api call will receive the response as shown below

response = client.icd9.top_level_codes

response.code
# >>> 200

response.headers
# >>> {'x-server' => 'nginx/1.6.2', ...}
JSON response

When the response sent by server is json, it is decoded into a hash

response.body
#=> [{'short_description': 'INFECTIOUS AND PARASIT...', 'api_path': 'icd9/001-139', 'name': '001-139', 'description': 'INFECTIOUS AND PARASITIC DISEASES (001-139)'},  ... ]

Method Options

The following options are available while calling a method of an api:

  • headers: Headers for the request
  • query: Query parameters for the url
  • body: Body of the request
  • request_type: Format of the request body

Request body information

Set request_type in options to modify the body accordingly

RAW request

When the value is set to raw, don't modify the body at all.

JSON request

When the value is set to json, JSON encode the body.

ICD-9 api

Returns an ICD-9 code.

icd9 = client.icd9
All top-level codes (GET codes/v1/icd9)

Returns all top-level ICD-9 codes. Useful for helping a user navigate down the ICD-9 hierarchy to find a code.

response = icd9.top_level_codes(options)
Retrieve a single code. (GET codes/v1/icd9/:code_name)

Returns a single code matching the name, if any exists. Replace periods with hypens (e.g. '066-4' for '066.4')

The following arguments are required:

  • code_name: name of code
response = icd9.single_code("066-4", options)
Search for codes by name. (GET codes/v1/icd9?q[name_cont]=:query)

Returns all codes whose name contains the search string.

The following arguments are required:

  • query: the search query string
response = icd9.search_by_name("082-2", options)
Search for codes by description. (GET codes/v1/icd9?q[description_cont]=:query)

Returns all codes whose description contains the search string.

The following arguments are required:

  • query: the search query string
response = icd9.search_by_description("eastern equine", options)
Search for codes by name or description. (GET codes/v1/icd9?q[name_or_description_cont]=:query)

Returns all codes whose name or description contains the search string.

The following arguments are required:

  • query: the search query string
response = icd9.search_by_name_or_description("west nile", options)

ICD-10 api

Returns an ICD-10 code.

icd10 = client.icd10
All top-level codes (GET codes/v1/icd10)

Returns all top-level ICD-10 codes. Useful for helping a user navigate down the ICD-10 hierarchy to find a code.

response = icd10.top_level_codes(options)
Retrieve a single code. (GET codes/v1/icd10/:code_name)

Returns a single code matching the name, if any exists. Replace periods with hypens (e.g. 'R50-9' for 'R50.9')

The following arguments are required:

  • code_name: name of code
response = icd10.single_code("R50-9", options)
Search for codes by name. (GET codes/v1/icd10?q[name_cont]=:query)

Returns all codes whose name contains the search string.

The following arguments are required:

  • query: the search query string
response = icd10.search_by_name("b05", options)
Search for codes by description. (GET codes/v1/icd10?q[description_cont]=:query)

Returns all codes whose description contains the search string.

The following arguments are required:

  • query: the search query string
response = icd10.search_by_description("mumps", options)
Search for codes by name or description. (GET codes/v1/icd10?q[name_or_description_cont]=:query)

Returns all codes whose name or description contains the search string.

The following arguments are required:

  • query: the search query string
response = icd10.search_by_name_or_description("rubella", options)

Contributors

Here is a list of Contributors

TODO

  • Other code sets

License

MIT

Bug Reports

Report here.

Contact

Michael Carroll at Aqua.io

michael@aqua.io

@aqua_io

This library initially generated by alpaca.