1. Go to this page and download the library: Download mdestafadilah/satusehat-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mdestafadilah / satusehat-sdk example snippets
use agumil\SatuSehatSDK\Auth\Oauth2;
use agumil\SatuSehatSDK\SSClient;
$ssclient = new SSClient(new Oauth2());
$response = $ssclient->getPractitioner([
'identifier' => 'https://fhir.kemkes.go.id/id/nakes-his-number|10009880728',
]);
use agumil\SatuSehatSDK\Auth\Oauth2;
use agumil\SatuSehatSDK\SSClient;
$config1['environment'] = 'development';
$config1['client_id'] = 'your_client_id';
$config1['client_secret'] = 'your_client_secret';
$config2['environment'] = 'development';
$ssclient = new SSClient(new Oauth2($config1), $config2);
$response = $ssclient->getPractitioner([
'identifier' => 'https://fhir.kemkes.go.id/id/nakes-his-number|10009880728',
]);
use agumil\SatuSehatSDK\Helper\BundleHelper;
use agumil\SatuSehatSDK\Helper\BundlePager;
$pager = new BundlePager(
fn (array $params) => $ssclient->getPatient($params),
['identifier' => 'https://fhir.kemkes.go.id/id/nik|9271060312000001', '_count' => 100]
);
while (($response = $pager->next()) !== null) {
foreach (BundleHelper::entries($response->getContentAsArray()) as $entry) {
echo $entry['resource']['id'] . PHP_EOL;
}
}
echo 'Halaman terambil: ' . $pager->page() . PHP_EOL;
BundleHelper::isBundle($content); // bool
BundleHelper::entries($bundle); // list entri, atau []
BundleHelper::total($bundle); // int|null
BundleHelper::nextUrl($bundle); // string|null
BundleHelper::nextParams($bundle); // array|null berisi query param
use agumil\SatuSehatSDK\Auth\Oauth2;
use agumil\SatuSehatSDK\SSClientKYC;
$kyc = new SSClientKYC(new Oauth2(), ['environment' => 'development']);
$url_response = $kyc->generateUrl($encrypted_message); // text/plain, masih ciphertext
$url_token = /* hasil dekripsi di sisi aplikasi */;
$response = $kyc->requestPerNik('3171022809990001', 'Budi Santoso', $url_token);
if ($response->getHttpCode() === 200) {
$data = $response->getContentAsObject()->data;
echo $data->ihs_number; // IHS Number pasien pemilik NIK
echo $data->challenge_code; // 6 digit
echo $data->expired_timestamp; // batas waktu challenge code
}
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
$logger = new Logger('satusehat');
$logger->pushHandler(new StreamHandler(__DIR__ . '/satusehat.log', Logger::DEBUG));
$ssclient = new SSClient(new Oauth2(), ['logger' => $logger]);
use agumil\SatuSehatSDK\Auth\FileTokenStore;
use agumil\SatuSehatSDK\Auth\Oauth2;
$oauth2 = new Oauth2([
'token_store' => new FileTokenStore(__DIR__ . '/storage/satusehat-token.json'),
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.