dev-master
9999999-devOPTretina SDK is a PHP client library to work with OPTRETINA REST API
The Requires
api php sdk
OPTretina SDK is a PHP client library to work with OPTRETINA REST API
, (*1)
The OPTRETINA REST API package is meant to provide you, the developer, with a set of tools to help you easily and quickly build your own system based in our API. Remember the the API still won't cover all situations and features that our platform offers., (*2)
This package provides tools for the following:, (*3)
Install the latest version with, (*4)
$ composer require optretina/optretina-php-sdk
The OAuth2 authorization method., (*5)
#!bash curl -H 'Content-Type: application/json' -X POST -d '{"client_id": "XXXXX", "client_secret": "XXXX", "grant_type":"client_credentials"}' https://api.optretina.com/authorize
#!php define("CLIENT_ID", "CLIENT_ID_XXX"); define("CLIENT_SECRET", "CLIENT_SECRET_XXX"); $client = new Optretina\Api\Client(CLIENT_ID, CLIENT_SECRET);
Retrieve all cases., (*6)
#!php define("CLIENT_ID", "CLIENT_ID_XXX"); define("CLIENT_SECRET", "CLIENT_SECRET_XXX"); $client = new Optretina\Api\Client(CLIENT_ID, CLIENT_SECRET); $response = $client->getCases();
Get a particular case, (*7)
#!php define("CLIENT_ID", "CLIENT_ID_XXX"); define("CLIENT_SECRET", "CLIENT_SECRET_XXX"); define("CASE_ID", "XXXX"); $client = new Optretina\Api\Client(CLIENT_ID, CLIENT_SECRET); $response = $client->getCase(CASE_ID);
Get a report for a specific case. Output as code string in base64., (*8)
#!php define("CLIENT_ID", "CLIENT_ID_XXX"); define("CLIENT_SECRET", "CLIENT_ID_XXX"); define("CASE_ID", 'XXXX'); $client = new Optretina\Api\Client(CLIENT_ID, CLIENT_SECRET); $response = $client->getReport(CASE_ID); /* Response: - success: true or false - content: if success = true -> File source decode in base64 . Otherwise error message. */ if ($response->success) { header('Content-Type: application/pdf'); header('Cache-Control: public, must-revalidate, max-age=0'); header('Pragma: public'); header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); echo base64_decode($response->content); die(); }
Create a new case., (*9)
#!php define("CLIENT_ID", "CLIENT_ID_XXX"); define("CLIENT_SECRET", "CLIENT_SECRET_XXX"); define("MALE", 0); define("FEMALE", 1); $client = new Optretina\Api\Client(CLIENT_ID, CLIENT_SECRET); $response = $client->createCase([ 'history_number' => 31415, 'first_name' => 'API Name', 'last_name' => 'Last Name', 'gender' => FEMALE, // 0: MALE, 1: FEMALE 'age' => 30, 'diabetes' => 1, // 0: no, 1: yes 'visit_date' => (new \DateTime('now'))->format('Y-m-d'), // A date accepted by PHP DateTime constructor 'visit_reason' => 'Patient with regular headaches when reading', 'ophthalmic_antecedents' => 'Relevant antecedents', 'other_relevant_info' => 'Other', 'retinologist_notes' => 'Internal notes for the retinologist', 'od_iop' => 16, 'od_va' => 0.5, 'od_axis' => 15, 'od_cylinder' => -1, 'od_sphere' => -1.25, 'od_add' => 3.5, 'od_prism' => 0.5, 'od_prism_base' => 0, // 0: down, 1: up 'os_iop' => 16, 'os_va' => 0.5, 'os_axis' => 15, 'os_cylinder' => -1, 'os_sphere' => -1.25, 'os_add' => 3.5, 'os_prism' => 0.5, 'os_prism_base' => 0, 'description' => 'campoNoMapeado1: valorCampo1; campoNoMapeado2: valorCampo2; campoNoMapeado3: valorCampo3;', 'callback_url' => 'http://localhost.com/optretina-php-sdk/example/callback.php', // POST CALL when case is reported or rejected 'images' => array( './images/2.jpg', //Local path ) ]);
A good way to get informed about different case status is to use a callback URL when case is created., (*10)
All notifications come in as a POST request., (*11)
#!php $_POST['status'] contains the new status, could be "reported" or "reject" $_POST['caso'] contains the caso id. $_POST['derivation'] values normal, routine, preferential, urgent
We've done our best to write the OPTRETINA API documentation to make integrating with it as simple as possible. Should you have questions, contact us., (*12)
Please tell us how we can make the API better. If you have a specific feature request or if you found a bug, please use GitHub issues., (*13)
OPTretina SDK is a PHP client library to work with OPTRETINA REST API
api php sdk