1. Go to this page and download the library: Download virusphp/bridging-satusehat 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/ */
// Example Controller bridging to SATUSEHAT (Laravel 7 ke atas)
use Virusphp\BridgingSatusehat\Bridge\BridgeBase;
Class SomeController
{
protected $bridging;
public function __construct()
{
$this->bridging = new BridgeBase();
}
// Example To use get Patient
// Name of Method example
public function getPatient($nik)
{
$endpoint = 'Practitioner?identifier=https://fhir.kemkes.go.id/id/nik|'. $nik;
return $this->bridging->getRequest($endpoint);
}
}
// Example Controller bridging to KYC (PHP 8 & LARAVEL 8 Keatas)
use Virusphp\BridgingSatusehat\Bridge\BridgeKyc;
use Virusphp\BridgingSatusehat\Foundation\Handler\KYCgenerator;
Class KYCController
{
use KYCgenerator;
protected $bridgingKYC;
public function __construct()
{
$this->bridgingKYC = new BridgeKyc();
}
// Example To use KYC
// Name of Method example
public function generateKYC()
{
$keyPair = $this->generateRSAKeyPair();
$publicKey = $keyPair['publicKey'];
$privateKey = $keyPair['privateKey'];
$data['agent_name'] = "Admin";
$data['agent_nik'] = "3375030xxxxxxxx";
$data['public_key'] = $publicKey;
$jsonData = json_encode($data);
$pubPEM = "-----BEGIN PUBLIC KEY-----
// SEUAIKAN KEY PUBLIC DARI SATUSEHAT KYC
-----END PUBLIC KEY-----"
$encryptedPayload = $this->encryptMessage($jsonData, $pubPEM);
$endpoint = "generate-url";
$response = $this->satusehat->postRequest($endpoint, $encryptedPayload);
$result = $this->decryptMessage($response, $privateKey);
return $result;
}
}