optretina / optretina-php-sdk
本包的最新版本(dev-master)没有可用的许可信息。
OPTretina SDK 是一个用于与 OPTRETINA REST API 一起工作的 PHP 客户端库
dev-master
2017-08-11 08:53 UTC
Requires
- league/oauth2-client: 0.3.*
This package is not auto-updated.
Last update: 2024-09-14 18:58:35 UTC
README
OPTRETINA REST API 包旨在为开发者提供一组工具,以帮助您轻松快速地基于我们的 API 构建自己的系统。请记住,API 仍然无法涵盖我们平台提供的所有情况和功能。
功能
本包提供以下工具
- 身份验证
- 检索案例列表
- 获取单个案例
- 获取特定案例的报告
- 创建新案例
安装
使用以下命令安装最新版本
$ composer require optretina/optretina-php-sdk
身份验证
OAuth2 授权方法。
请求
- HTTP 方法:POST
- URL:https://api.optretina.com/authorize
- 参数:[ client_id, client_secret, grant_type="client_credentials" ]
- 返回:access_token
示例
#!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
使用 SDK 的示例
#!php
define("CLIENT_ID", "CLIENT_ID_XXX");
define("CLIENT_SECRET", "CLIENT_SECRET_XXX");
$client = new Optretina\Api\Client(CLIENT_ID, CLIENT_SECRET);
文档
案例列表
检索所有案例。
请求
- 需要身份验证
- HTTP 方法:GET
- URL:https://api.optretina.com/cases
示例
#!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();
获取案例
获取特定案例
请求
- 需要身份验证
- HTTP 方法:GET
- URL:https://api.optretina.com/cases/{id}
示例
#!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);
获取报告
获取特定案例的报告。以 base64 编码的代码字符串输出。
请求
- 需要身份验证
- HTTP 方法:GET
- URL:https://api.optretina.com/cases/report/{id}
示例
#!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();
}
创建案例
创建新案例。
请求
- 需要身份验证
- HTTP 方法:POST
- URL:https://api.optretina.com/cases
示例
#!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' => 'https://.com/optretina-php-sdk/example/callback.php', // POST CALL when case is reported or rejected
'images' => array(
'./images/2.jpg', //Local path
)
]);
回调和通知
创建案例时使用回调 URL 是了解不同案例状态的好方法。
所有通知都作为 POST 请求到来。
可用通知
- 当案例被通知时
- 当案例被通知但报告已修改时
- 当案例被拒绝时
#!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
获取帮助
我们已经尽力编写了 OPTRETINA API 文档,以使其尽可能简单。如果您有任何问题,请联系我们。
帮助我们改进
请告诉我们如何使 API 更好。如果您有特定的功能请求或发现了错误,请使用 GitHub 问题报告。