8.8 KiB
Dokumentasi API Wynacom
Base URL dev:
https://devcpone.aplikasi.web.id/one-api/tools/wynacom
Semua response API menggunakan format standar:
{
"status": "OK",
"data": {}
}
Jika gagal:
{
"status": "ERR",
"message": "Pesan error"
}
Alur Integrasi
- Wynacom memanggil
generate_token. - Wynacom menyimpan
access_tokendari response. - Wynacom memanggil
sampling_timestampdengan headerAuthorization: Bearer {access_token}. - Jika token expired/tidak aktif, Wynacom memanggil
generate_tokenlagi.
Token disimpan di tabel api_wynacom_token. Jika masih ada token aktif dan belum expired, generate_token akan mengembalikan token aktif tersebut, bukan membuat token baru.
Generate Token
Endpoint:
POST /generate_token
Request body:
{}
Contoh curl:
curl -X POST "https://devcpone.aplikasi.web.id/one-api/tools/wynacom/generate_token" \
-H "Content-Type: application/json" \
-d '{}'
Contoh PHP curl_init():
<?php
$baseUrl = 'https://devcpone.aplikasi.web.id/one-api/tools/wynacom';
$ch = curl_init($baseUrl . '/generate_token');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array()));
$response = curl_exec($ch);
if (curl_errno($ch)) {
die('Curl error: ' . curl_error($ch));
}
curl_close($ch);
$tokenResponse = json_decode($response, true);
if (!isset($tokenResponse['status']) || $tokenResponse['status'] !== 'OK') {
die('Generate token failed: ' . $response);
}
$accessToken = $tokenResponse['data']['access_token'];
Contoh response:
{
"status": "OK",
"data": {
"access_token": "TOKEN_VALUE",
"token_type": "Bearer",
"expired_at": "2026-06-21 10:00:00",
"expired_days": 3,
"expires_in": 259200
}
}
Catatan:
expired_daysmengikuti settingtoken_expired_days.- Jika token aktif masih ada, response mengembalikan token aktif dan
expires_insisa detik sampai expired.
Check Token
Endpoint:
POST /check_token
Header:
Authorization: Bearer {access_token}
Contoh curl:
curl -X POST "https://devcpone.aplikasi.web.id/one-api/tools/wynacom/check_token" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN_VALUE" \
-d '{}'
Contoh response valid:
{
"status": "OK",
"data": {
"valid": true,
"token_id": 1,
"expired_at": "2026-06-21 10:00:00"
}
}
Contoh response token tidak valid/expired:
{
"status": "ERR",
"message": "Token tidak valid atau sudah expired"
}
Jika token tidak dikirim:
{
"status": "ERR",
"message": "Token wajib diisi"
}
Get Token Setting
Endpoint:
POST /token_setting
Request body:
{}
Contoh curl:
curl -X POST "https://devcpone.aplikasi.web.id/one-api/tools/wynacom/token_setting" \
-H "Content-Type: application/json" \
-d '{}'
Contoh response:
{
"status": "OK",
"data": {
"token_expired_days": 3,
"expires_in": 259200
}
}
Save Token Setting
Endpoint:
POST /save_token_setting
Request body:
{
"token_expired_days": 10
}
Contoh curl:
curl -X POST "https://devcpone.aplikasi.web.id/one-api/tools/wynacom/save_token_setting" \
-H "Content-Type: application/json" \
-d '{"token_expired_days":10}'
Validasi:
- Minimal
1hari. - Maksimal
365hari. - Setting berlaku untuk token baru. Token aktif yang sudah ada tetap berlaku sampai expired/nonaktif.
Sampling Timestamp
Endpoint:
POST /sampling_timestamp
Header:
Authorization: Bearer {access_token}
Request body:
{
"T_OrderHeaderLabNumber": "R2606110001"
}
Alias parameter yang juga diterima:
orderNumbernolab
Contoh curl:
curl -X POST "https://devcpone.aplikasi.web.id/one-api/tools/wynacom/sampling_timestamp" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN_VALUE" \
-d '{"T_OrderHeaderLabNumber":"R2606110001"}'
Contoh PHP curl_init() lengkap dari generate token sampai ambil data sampling:
<?php
$baseUrl = 'https://devcpone.aplikasi.web.id/one-api/tools/wynacom';
function postJson($url, $payload, $headers = array())
{
$defaultHeaders = array('Content-Type: application/json');
$headers = array_merge($defaultHeaders, $headers);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
$response = curl_exec($ch);
if (curl_errno($ch)) {
$error = curl_error($ch);
curl_close($ch);
throw new Exception('Curl error: ' . $error);
}
curl_close($ch);
$decoded = json_decode($response, true);
if (!is_array($decoded)) {
throw new Exception('Invalid JSON response: ' . $response);
}
return $decoded;
}
// 1. Generate token
$tokenResponse = postJson($baseUrl . '/generate_token', array());
if ($tokenResponse['status'] !== 'OK') {
throw new Exception('Generate token failed: ' . $tokenResponse['message']);
}
$accessToken = $tokenResponse['data']['access_token'];
// 2. Ambil data sampling timestamp
$samplingResponse = postJson(
$baseUrl . '/sampling_timestamp',
array(
'T_OrderHeaderLabNumber' => 'R2606110001'
),
array(
'Authorization: Bearer ' . $accessToken
)
);
if ($samplingResponse['status'] !== 'OK') {
throw new Exception('Get sampling failed: ' . $samplingResponse['message']);
}
print_r($samplingResponse['data']);
Contoh response:
{
"status": "OK",
"data": [
{
"sample_station_name": "Sample Station Phlebotomy",
"location_name": "R. SAMPLING",
"cpone_test_code": "10530100",
"cpone_test_name": "Ureum",
"lis_test_code": "00000112",
"sampling_check_in_datetime": "2026-06-11 08:34:26",
"sampling_check_in_userid": "123",
"sampling_check_out_datetime": "2026-06-11 08:40:00",
"sampling_check_out_userid": "123"
}
]
}
Data sampling_timestamp adalah gabungan UNION ALL dari:
- nonlab:
t_samplingso - lab:
t_ordersample
Kolom sample_station_name diambil lewat relasi:
t_sampletype -> t_bahan -> t_samplestation
Kolom kode:
cpone_test_code: 8 digit depan dariT_TestSasCode.lis_test_code:nat_testmap.Nat_TestMapCode.
Untuk lab, jika test adalah anak panel, data dinaikkan ke parent:
child_test.T_TestParentT_TestID != 0 -> pakai parent test
Contoh: anak Hematologi Lengkap akan digabung sebagai parent Hematologi Lengkap.
Glucose Result
Endpoint:
POST /glucose
Header:
Authorization: Bearer {access_token}
Request body:
{
"T_OrderHeaderLabNumber": "R2606110001"
}
Contoh curl:
curl -X POST "https://devcpone.aplikasi.web.id/one-api/tools/wynacom/glucose" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN_VALUE" \
-d '{"T_OrderHeaderLabNumber":"R2606110001"}'
Contoh PHP curl_init():
<?php
$baseUrl = 'https://devcpone.aplikasi.web.id/one-api/tools/wynacom';
$accessToken = 'TOKEN_VALUE';
$ch = curl_init($baseUrl . '/glucose');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer ' . $accessToken
));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array(
'T_OrderHeaderLabNumber' => 'R2606110001'
)));
$response = curl_exec($ch);
if (curl_errno($ch)) {
die('Curl error: ' . curl_error($ch));
}
curl_close($ch);
$glucoseResponse = json_decode($response, true);
print_r($glucoseResponse);
Contoh response:
{
"status": "OK",
"data": [
{
"cpone_test_code": "10530200",
"cpone_test_name": "Glukosa Darah 2 Jam PP",
"lis_test_code": "00000251",
"result_glucosa": "120"
}
]
}
Sumber data:
order_glucose.OrderGlucoseResultsebagairesult_glucosat_test.T_TestSasCodesebagaicpone_test_code, dipotong 8 digit dari depant_test.T_TestNamesebagaicpone_test_namenat_testmap.Nat_TestMapCodesebagailis_test_code
Error Umum
Token tidak dikirim:
{
"status": "ERR",
"message": "Token wajib diisi"
}
Token tidak valid atau expired:
{
"status": "ERR",
"message": "Token tidak valid atau sudah expired"
}
Nomor order kosong:
{
"status": "ERR",
"message": "Parameter T_OrderHeaderLabNumber wajib diisi"
}
Nomor order tidak ditemukan:
{
"status": "ERR",
"message": "Order tidak ditemukan: R2606110001"
}