aqua-api-library-php
Official Aqua-io API library client for PHP. Currently covers Aqua.io's ICD-9 and ICD-10 APIs., (*1)
Getting Started
To use the Aqua.io API, you need to have proper API credentials, which you can get for free by signing up., (*2)
You may also want to read up on the API documentation., (*3)
This library is generated by alpaca, (*4)
Installation
Make sure you have composer installed., (*5)
Add the following to your composer.json, (*6)
{
"require": {
"aquaio/aqua-io": "*"
}
}
Update your dependencies, (*7)
$ php composer.phar update
This package follows the PSR-4
convention names for its classes, which means you can easily integrate these classes loading in your own autoloader., (*8)
Versions
Works with [ 5.4 / 5.5 ], (*9)
Usage
<?php
// This file is generated by Composer
require_once 'vendor/autoload.php';
// Then we instantiate a client (as shown below)
Build a client
Get an access token using your aqua.io credentials
$auth = array('client_id' => '09a8b7', 'client_secret' => '1a2b3');
$client = new AquaIo\Client($auth, $clientOptions);
$token = $client->accessToken()->retrieve()->body['access_token']
All other API calls require an access token
$client = new AquaIo\Client($token, $clientOptions);
Client Options
The following options are available while instantiating a client:, (*10)
-
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
All the callbacks provided to an api call will receive the response as shown below, (*11)
$response = $client->klass('args')->method('args', $methodOptions);
$response->code;
// >>> 200
$response->headers;
// >>> array('x-server' => 'apache')
JSON response
When the response sent by server is json, it is decoded into an array, (*12)
$response->body;
// >>> array('user' => 'pksunkara')
Method Options
The following options are available while calling a method of an api:, (*13)
-
headers: Headers for the request
-
query: Query parameters for the url
-
body: Body of the request
-
request_type: Format of the request body
ICD-9 api
Returns an ICD-9 code., (*14)
$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., (*15)
$response = $icd9->topLevelCodes($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'), (*16)
The following arguments are required:, (*17)
$response = $icd9->singleCode("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., (*18)
The following arguments are required:, (*19)
-
query: the search query string
$response = $icd9->searchByName("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., (*20)
The following arguments are required:, (*21)
-
query: the search query string
$response = $icd9->searchByDescription("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., (*22)
The following arguments are required:, (*23)
-
query: the search query string
$response = $icd9->searchByNameOrDescription("west nile", $options);
ICD-10 api
Returns an ICD-10 code., (*24)
$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., (*25)
$response = $icd10->topLevelCodes($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'), (*26)
The following arguments are required:, (*27)
$response = $icd10->singleCode("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., (*28)
The following arguments are required:, (*29)
-
query: the search query string
$response = $icd10->searchByName("b05", $options);
Search for codes by description. (GET codes/v1/icd10?q[description_cont]=:query)
Returns all codes whose description contains the search string., (*30)
The following arguments are required:, (*31)
-
query: the search query string
$response = $icd10->searchByDescription("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., (*32)
The following arguments are required:, (*33)
-
query: the search query string
$response = $icd10->searchByNameOrDescription("rubella", $options);
Contributors
Here is a list of Contributors, (*34)
TODO
License
MIT, (*35)
Bug Reports
Report here., (*36)
Michael Carroll at Aqua.io, (*37)
michael@aqua.io, (*38)
@aqua_io, (*39)
This library initially generated by alpaca., (*40)