Just Another Blogger

Friday, April 7, 2017

Bridging SEP BPJS dengan Visual Basic 6 Dengan Perantara SLIM PHP Microframework PART 1

Artikel ini Bagian 1 dari 2 bagian


Beberapa waktu lalu saya pernah berbagi aplikasi bridging INA-CBG dengan visual basic 6 dengan web service. Kalau lupa linknya bisa diklik disini.


Sekarang dengan cara yang sama saya akan berbagi pengalaman dan teknik bridging dengan SEP BPJS. 

Aplikasi Bridging SEP ini juga menggunakan SLIM PHP Micro Framework sebagai penengahnya. Sebenarnya VB6 bisa dipakai untuk enkripsi HMAC SHA-1 yang dipakai oleh BPJS. Tetapi karena kemalasan saya. Saya tidak membuatnya. Tetapi kalau kamu tertarik mendevelop ke VB 6, kamu bisa mengunjungi ke trit ini 



Bridging bisa diartikan dengan membangun jembatan antara dua sistem yang berbeda. 
Biasanya salah satu atau dua-duanya menyediakan layanan yang bisa diakses oleh sistem lain.  Dari judul artikel ini Bridging SEP BPJS, berarti sudah jelas yang mau ditulis disini adalah tentang komunikasi system SIMRS dengan SEP BPJS.
BPJS sudah menyediakan API yang bisa digunakan untuk mengirim data maupun mengambil data SEP dari BPJS. API ini dibuat dengan teknology web service sehingga bisa diakses dari mana saja dan kapan saja.
Teknologi yang digunakan adalah REST Service dengan menggunakan enkripsi di header.

alamat manual web servicenya bisa dibuka disini

Disana sudah ada juga contoh koneksi dengan beragam bahasa pemrograman yang umum dipakai (kecuali visual basic 6).

Sebagai programmer Visual Basic 6 saya sudah mawas diri kalau BPJS tidak akan membuatkan contoh koneksi API SEP dengan Visual Basic 6. Namun saya tidak meyerah begitu saja pada nasib. Saya yakin diluar sana ada orang yang bisa melakukannya. Dan nantinya salah satunya adalah saya.

Berhubung ilmu koding saya yang sangat pas-pasan. Saya sempat bingung karena belum menemukan cara untuk terhubung dengan API BPJS. Saat itu yang terfikirkan adalah membuat aplikasi baru dengan PHP. Dan akhirnya saya memang membuat bridging API BPJS dengan PHP. Namun PHP ini saya jadikan perantara. Istilahnya membangun jembatan diantaran jembatan.

Langsung saja ke pokok bahasan, karena saya sendiri tidak begitu tahu teori-teori pemrograman, jadi kita langsung saja bikin programnya.

Alat alat yang dibutuhkan

Web Service Jembatan
1. Web server, saya merekomendasikan XAMPP supaya lebih mudah. Saya pribadi memakai ubuntu server, biar kekinian.
2. Slim Micro Framework. Kalian pasti kenal dengan Code Igniter atau laravel. Slim ini juga framework PHP seperti CI dan Laravel. Tetapi sesuai namanya "Micro Framework". Kemampuan Slim hanya sebatas membuat Web Service. 


Modul-modul untuk Visual Basic 6
1. VB JSON Parser. Thanks to yang membuat tool ini, Matur Suwun, Terima kasih, karena modul yang sampeyan buat ini sangat membantu saya dan banyak orang lainnya. 
silahkan download saja disini



Membuat WEB SERVICE

Langkah-langkah membuat web service seperti berikut:

1. Download dulu slim microframeworknya, cara installnya lihat saja di webnya, kalau nggak salah pakai composer.
2. Buka Folder Slim Microframeworknya, kemudian buka file index.php


Sebelumnya saya terangkan terlebih dahulu. Web service yang saya buat disini semuanya menggunakan method "POST". Kenapa saya memakai method "POST", jawabannya adalah "karena bagus :))".

Bridging ini saya buat sejak jaman masih API 2.0 Api 2.0 itu menurut saya API hode, Hasilnya json, tapi inputnya masih pakai xml. Kemudian muncul API baru (2.1) yang sudah full JSON.
di sourcenya nanti bisa dilihat  yang nama servicenya pakai "21" berarti itu web API 2.1 yang tidak ada "2.1" nya berarti Web Service 2.0 kebawah.

Oke, this is the code, cekidot

<?php
require 'vendor/autoload.php';
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\App;


$app = new Slim\App();


$app->get('/', 'Depan');
$app->post('/GetByNoKartu', 'GetByNoKartu');
$app->post('/GetByNoKartu21', 'GetByNoKartu21');
$app->post('/GetByNoRujukan', 'GetNoRujukan');
$app->post('/GetDetailSEP', 'GetDetailSEP');
$app->post('/GetDetailSEP21', 'GetDetailSEP21');
$app->post('/UpdateTglPulang', 'UpdateTglPulang');
$app->post('/UpdateTglPulang21', 'UpdateTglPulang21');
$app->post('/CreateSEP', 'CreateSEP');
$app->post('/HapusSEP', 'HapusSEP');
$app->post('/mapnopen', 'mapnopen');
$app->post('/Get10RiwayatSEP', 'Get10RiwayatSEP');
$app->post('/Get10RiwayatSEP21', 'Get10RiwayatSEP21');
$app->post('/CreateSEP21', 'CreateSEP21');
$app->post('/UpdateSEP21', 'UpdateSEP21');
$app->post('/HapusSEP21', 'HapusSEP21');
$app->post('/mapnopen21', 'mapnopen21');
$app->post('/CariRujukanPickare21', 'CariRujukanPickare21');
$app->post('/CariRujukanPickare21ByNo', 'CariRujukanPickare21ByNo');
$app->post('/CariRujukanRS21', 'CariRujukanRS21');
$app->post('/GetPoli21', 'GetPoli21');
$app->run();


/* METHOD GET DISINI */
/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
function Depan() {
  echo "Halaman Depan";
}

function GetByNoKartu21($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoKartu = $request->getParsedBody()['nokartu'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$Turl = $Url.'/'.$NoKartu;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Turl);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);
curl_close($curl);
//echo $result;

$response->write($result);
return $response;
}


function GetByNoKartu($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoKartu = $request->getParsedBody()['nokartu'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$Turl = $Url.'/'.$NoKartu;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Turl);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);
curl_close($curl);
//echo $result;

$response->write($result);
return $response;
}

function GetNoRujukan($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoRujukan = $request->getParsedBody()['norujukan'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$Turl = $Url.'/'.$NoRujukan;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Turl);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);
curl_close($curl);
//echo $result;

$response->write($result);
return $response;
}

function GetDetailSEP($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoSEP = $request->getParsedBody()['nosep'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$Turl = $Url.'/'.$NoSEP;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Turl);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);
curl_close($curl);
//echo $result;

$response->write($result);
return $response;
}

function Get10RiwayatSEP($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoKartu = $request->getParsedBody()['nokartu'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$Turl = $Url.'/'.$NoKartu;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Turl);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);

curl_close($curl);
//echo $result;
$result = json_decode($result, true);
$totalrow=$result['response']['count'];
   
//echo $result['response']['list'][0]['biayaTagihan'];
//print_r($result);
//foreach ($result as $row){
// echo $result['response']['list'][0]['biayaTagihan'];
// echo $result['response']['list'][0]['noSEP'];
//}
//echo $totalrow;
$x = 0;
echo '<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
            <s:Schema id="RowsetSchema">
            <s:ElementType name="row" content="eltOnly">            
            <s:AttributeType name="NoPendaftaran" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>

            <s:AttributeType name="NoCM" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>

            <s:AttributeType name="NamaPasien" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
            <s:AttributeType name="tglSEP" rs:number="1" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
                    <s:AttributeType name="NoSEP" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
                        <s:AttributeType name="jnsPelayanan" rs:number="3" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
            <s:AttributeType name="tglPulang" rs:number="4" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
                    <s:AttributeType name="BiayaTagihan" rs:number="5" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
                        <s:AttributeType name="KdPoli" rs:number="3" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
            <s:extends type="rs:rowbase"/>
            </s:ElementType>
            </s:Schema>
            <rs:data>';

while ($x <= ($totalrow - 1)) {
echo '<z:row NoPendaftaran="" NoCM="" NamaPasien="" tglSEP="' . $result['response']['list'][$x]['tglSEP'] . '" NoSEP="' . $result['response']['list'][$x]['noSEP'] . '" jnsPelayanan="' . $result['response']['list'][$x]['jnsPelayanan'] . '" tglPulang="' . $result['response']['list'][$x]['tglPulang'] . '" BiayaTagihan="' . $result['response']['list'][$x]['biayaTagihan'] . '" KdPoli="' . $result['response']['list'][$x]['poliTujuan']['kdPoli'] .'" />';
$x++;
}          
echo '</rs:data></xml>';


//$response->write($result);

//$response->write("olaaa");
return $response;
}

function HapusSEP($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$xml = $request->getParsedBody()['xml'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $Url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$result = curl_exec($curl);
curl_close($curl);
//echo $result;
$response->write($result);
return $response;
}


function daftarpasienonline($request, $response, $args){
$sql = "SELECT * FROM ngi_pasien_online where tglpendaftaran between ('" .$args['tgl1']."') and ('".$args['tgl2']."')";
try{
$db = getConnectionpendaftaranonline();
        $stmt = $db->query($sql);
        $data = $stmt->fetchAll (PDO::FETCH_ASSOC);
        $db = null;
        $data = json_encode($data);  
        $response->write($data);
//$response = $sql;
return $response;
}catch (PDOException $e) {
       echo '{"error":{"text":'. $e->getMessage() .'}}';
      }
  }



//====================================================================================================================================================*/

function UpdateTglPulang($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoSEP = $request->getParsedBody()['nosep'];
$TglPulang = $request->getParsedBody()['tglpulang'];
$NoPPK = $request->getParsedBody()['noppk'];


// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );

$xml = '<request>
<data>
<t_sep>
<noSep>'.$NoSEP.'</noSep>
<tglPlg>>'.$TglPulang.'</tglPlg>
<ppkPelayanan>'.$NoPPK.'</ppkPelayanan>
</t_sep>
</data>
</request>';


$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $Url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$result = curl_exec($curl);
curl_close($curl);
//echo $result;
$response->write($result);
return $response;
}



function CreateSEP($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$xmld = $request->getParsedBody()['xmls'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$xml = $xmld;


$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $Url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$result = curl_exec($curl);
curl_close($curl);
//echo $result;
$response->write($result);
return $response;
}



//Numpang Pasien Online
function mappingpasienonline($request, $response, $args){
$sql = "Update ngi_pasien_online where NoBooking = '" .$args[nobooking];
//$sql = "SELECT * FROM ngi_pasien_online where tglpendaftaran between ('" .$args['tgl1']."') and ('".$args['tgl2']."')";
try{
$db = getConnectionpendaftaranonline();
        $stmt = $db->query($sql);
        $data = $stmt->fetchAll (PDO::FETCH_ASSOC);
        $db = null;
        $data = json_encode($data);  
        $response->write($data);
//$response = $sql;
return $response;
}catch (PDOException $e) {
       echo '{"error":{"text":'. $e->getMessage() .'}}';
      }
  }


function mapnopen($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoSEP = $request->getParsedBody()['nosep'];
$NoTrans = $request->getParsedBody()['notrans'];
$NoPPK = $request->getParsedBody()['noppk'];


// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );

$xml = '<request>
<data>
<t_map_sep>
<noSep>'.$NoSEP.'</noSep>
<noTrans>>'.$NoTrans.'</noTrans>
<ppkPelayanan>'.$NoPPK.'</ppkPelayanan>
</t_map_sep>
</data>
</request>';


$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $Url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$result = curl_exec($curl);
curl_close($curl);
//echo $result;
$response->write($result);
return $response;
}



function CreateSEP21($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
//$xmld = $request->getParsedBody()['xmls'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );



    $xml = '{
            "request":
             {
            "t_sep":
                {
                    "noKartu":"'.$request->getParsedBody()['noKartu'].'",
                    "tglSep":"'.$request->getParsedBody()['tglSep'].'",
                    "tglRujukan":"'.$request->getParsedBody()['tglRujukan'].'",
                    "noRujukan":"'.$request->getParsedBody()['noRujukan'].'",
                    "ppkRujukan":"'.$request->getParsedBody()['ppkRujukan'].'",
                    "ppkPelayanan":"'.$request->getParsedBody()['ppkPelayanan'].'",
                    "jnsPelayanan":"'.$request->getParsedBody()['jnsPelayanan'].'",
                    "catatan":"'.$request->getParsedBody()['catatan'].'",
                    "diagAwal":"'.$request->getParsedBody()['diagAwal'].'",
                    "poliTujuan":"'.$request->getParsedBody()['poliTujuan'].'",
                    "klsRawat":"'.$request->getParsedBody()['klsRawat'].'",
                    "lakaLantas":"'.$request->getParsedBody()['lakaLantas'].'",
                    "lokasiLaka":"'.$request->getParsedBody()['lokasiLaka'].'",
                    "user":"'.$request->getParsedBody()['user'].'",
                    "noMr":"'.$request->getParsedBody()['noMr'].'"
                }
             }
        }';
//$xml = $xmld;


$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $Url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$result = curl_exec($curl);
curl_close($curl);
//echo $result;
$response->write($result);
return $response;
}


function UpdateSEP21($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
//$xmld = $request->getParsedBody()['xmls'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );



    $json = '{
            "request":
             {
            "t_sep":
                {
                    "noSep":"'.$request->getParsedBody()['noSEP'].'",
                    "noKartu":"'.$request->getParsedBody()['noKartu'].'",
                    "tglSep":"'.$request->getParsedBody()['tglSep'].'",
                    "tglRujukan":"'.$request->getParsedBody()['tglRujukan'].'",
                    "noRujukan":"'.$request->getParsedBody()['noRujukan'].'",
                    "ppkRujukan":"'.$request->getParsedBody()['ppkRujukan'].'",
                    "ppkPelayanan":"'.$request->getParsedBody()['ppkPelayanan'].'",
                    "jnsPelayanan":"'.$request->getParsedBody()['jnsPelayanan'].'",
                    "catatan":"'.$request->getParsedBody()['catatan'].'",
                    "diagAwal":"'.$request->getParsedBody()['diagAwal'].'",
                    "poliTujuan":"'.$request->getParsedBody()['poliTujuan'].'",
                    "klsRawat":"'.$request->getParsedBody()['klsRawat'].'",
                    "lakaLantas":"'.$request->getParsedBody()['lakaLantas'].'",
                    "lokasiLaka":"Semarang",
                    "user":"'.$request->getParsedBody()['user'].'",
                    "noMr":"'.$request->getParsedBody()['noMr'].'"
                }
             }
        }';

$response->write($json);
return $response;
}


function Get10RiwayatSEP21($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoKartu = $request->getParsedBody()['nokartu'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$Turl = $Url.'/'.$NoKartu;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Turl);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);

curl_close($curl);
//echo $result;
$result = json_decode($result, true);
$totalrow=$result['response']['count'];
   
//echo $result['response']['list'][0]['biayaTagihan'];
//print_r($result);
//foreach ($result as $row){
// echo $result['response']['list'][0]['biayaTagihan'];
// echo $result['response']['list'][0]['noSEP'];
//}
//echo $totalrow;
$x = 0;
echo '<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
            <s:Schema id="RowsetSchema">
            <s:ElementType name="row" content="eltOnly">
           
            <s:AttributeType name="tglSEP" rs:number="1" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
                    <s:AttributeType name="NoSEP" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
                        <s:AttributeType name="jnsPelayanan" rs:number="3" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
            <s:AttributeType name="tglPulang" rs:number="4" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
                    <s:AttributeType name="BiayaTagihan" rs:number="5" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
                        <s:AttributeType name="KdPoli" rs:number="3" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>
            <s:extends type="rs:rowbase"/>
            </s:ElementType>
            </s:Schema>
            <rs:data>';

while ($x <= ($totalrow - 1)) {
echo '<z:row tglSEP="' . $result['response']['list'][$x]['tglSEP'] . '" NoSEP="' . $result['response']['list'][$x]['noSEP'] . '" jnsPelayanan="' . $result['response']['list'][$x]['jnsPelayanan'] . '" tglPulang="' . $result['response']['list'][$x]['tglPulang'] . '" BiayaTagihan="' . $result['response']['list'][$x]['biayaTagihan'] . '" KdPoli="' . $result['response']['list'][$x]['poliTujuan']['kdPoli'] .'" />';
$x++;
}          
echo '</rs:data></xml>';


//$response->write($result);

//$response->write("olaaa");
return $response;
}

function GetDetailSEP21($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoSEP = $request->getParsedBody()['nosep'];

// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$Turl = $Url.'/'.$NoSEP;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Turl);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);
curl_close($curl);
//echo $result;

$response->write($result);
return $response;
}

function mapnopen21($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoSEP = $request->getParsedBody()['nosep'];
$NoTrans = $request->getParsedBody()['notrans'];
$NoPPK = $request->getParsedBody()['noppk'];


// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );

$xml = '  {
        "request":
       {
        "t_map_sep":
       {
       "noSep":"'.$NoSEP.'",
       "noTrans":"'.$NoTrans.'",
       "ppkPelayanan":"'.$NoPPK.'"
       }
       }
        }            ';


$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $Url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$result = curl_exec($curl);
curl_close($curl);
//echo $result;
$response->write($result);
return $response;
}

function HapusSEP21($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoSEP = $request->getParsedBody()['NoSEP'];
$PPKPelayanan=$request->getParsedBody()['PPKPelayanan'];


  $xml = '{
            "request":
             {
            "t_sep":
                {
                    "noSep":"'.$NoSEP.'",
                    "ppkPelayanan":"'.$PPKPelayanan.'"
                }
             }
        }';
             

// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $Url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$result = curl_exec($curl);
curl_close($curl);
//echo $result;
$response->write($result);
return $response;
}

function UpdateTglPulang21($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoSEP = $request->getParsedBody()['nosep'];
$TglPulang = $request->getParsedBody()['tglpulang'];
$NoPPK = $request->getParsedBody()['noppk'];


// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );

$json = '{
            "request":
                {  
                "t_sep":
                    {
                        "noSep":"'.$NoSEP.'",
                        "tglPlg":"'.$TglPulang.'",
                        "ppkPelayanan":"'.$NoPPK.'"
                    }
                }
        }       ';


$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $Url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$result = curl_exec($curl);
curl_close($curl);
//echo $result;
$response->write($result);
return $response;
}

function GetPoli21($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


//$Turl = $Url.'/'.$NoKartu;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Url);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);

curl_close($curl);
//echo $result;
$result = json_decode($result, true);
$totalrow=$result['response']['count'];
   
//echo $result['response']['list'][0]['biayaTagihan'];
//print_r($result);
//foreach ($result as $row){
// echo $result['response']['list'][0]['biayaTagihan'];
// echo $result['response']['list'][0]['noSEP'];
//}
//echo $totalrow;
$x = 0;
echo '<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
            <s:Schema id="RowsetSchema">
            <s:ElementType name="row" content="eltOnly">            
            <s:AttributeType name="kdPoli" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>

            <s:AttributeType name="nmPoli" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
            <s:datatype dt:type="string" dt:maxLength="50"/>
            </s:AttributeType>

           
            <s:extends type="rs:rowbase"/>
            </s:ElementType>
            </s:Schema>
            <rs:data>';

while ($x <= ($totalrow - 1)) {
echo '<z:row  kdPoli="' . $result['response']['list'][$x]['kdPoli'] . '" nmPoli="'. $result['response']['list'][$x]['nmPoli'] .'" />';
$x++;
}          
echo '</rs:data></xml>';


//$response->write($result);

//$response->write("olaaa");
return $response;
}


function GetNoRujukan21($request, $response, $args) {
    $ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoRujukan = $request->getParsedBody()['norujukan'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$Turl = $Url.'/'.$NoRujukan;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Turl);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);
curl_close($curl);
//echo $result;

$response->write($result);
return $response;
}


function CariRujukanPickare21($request, $response, $args) {
$ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoRujukan = $request->getParsedBody()['norujukan'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$Turl = $Url.'/'.$NoRujukan;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Turl);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);
curl_close($curl);
//echo $result;

$response->write($result);
return $response;
}


function CariRujukanPickare21ByNo($request, $response, $args) {
$ConsId = $request->getParsedBody()['consid'];
$SecretKey = $request->getParsedBody()['secretkey'];
$Url = $request->getParsedBody()['url'];
$NoRujukan = $request->getParsedBody()['nokartu'];



// Computes the timestamp
        date_default_timezone_set('UTC');
        $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));    
        $signature = hash_hmac('sha256', $ConsId."&".$tStamp, $SecretKey, true);
   
        $encodedSignature = base64_encode($signature);

   
    $curl = curl_init();

    $arrheader =  array(
         'X-cons-id: '.$ConsId,
         'X-timestamp: '.$tStamp,
         'X-signature: '.$encodedSignature      
      );


$Turl = $Url.'/'.$NoRujukan;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$Turl);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $arrheader);


$result = curl_exec($curl);
curl_close($curl);
//echo $result;

$response->write($result);
return $response;
}


function CariRujukanRS21($request, $response, $args) {
$hasil = ' {
       "metadata":
       {
       "code": "200"
       "message": "OK"
       }
       "response":
       {
       "item":
       {
       "catatan": null
       "diagnosa":
       {
       "kdDiag": "H259"
       "nmDiag": null
       }
       "keluhan": null
       "noKunjungan": "0312R0010715A000058"
       "pemFisikLain": null
       "peserta":
       {
       "jenisPeserta":
       {
       "kdJenisPeserta": null
       "nmJenisPeserta": null
       }
       "kelasTanggungan":
       {
       "kdKelas": null
       "nmKelas": null
       }
       "nama": "RIMBAR YUNUS, IR"
       "nik": null
       "noKartu": "0000033420148"
       "noMr": null
       "pisa": "1"
       "provUmum":
       {
       "kdCabang": null
       "kdProvider": null
       "nmCabang": null
       "nmProvider": null
       }
       "sex": null
       "statusPeserta": null
       "tglCetakKartu": ""
       "tglLahir": null
       "tglTAT": null
       "tglTMT": null
       "umur": null
       }
       "poliRujukan":
       {
       "kdPoli": "MAT"
       "nmPoli": "Poli Mata"
       }
       "provKunjungan":
       {
       "kdCabang": null
       "kdProvider": "0312R001"
       "nmCabang": null
       "nmProvider": "RSU DR ADNAN WD"
       }
       "provRujukan":
       {
       "kdCabang": null
       "kdProvider": null
       "nmCabang": null
       "nmProvider": null
       }
       "tglKunjungan": "2015-07-14"
       }
       }
        }';
        $response->write($hasil);
}
?>


Ke PART 2

28 comments:

  1. Saya baca masih bingung, mungkin karena diriku bukah ahli programer.

    ReplyDelete
  2. Aku juga bukan ahli mas, ini masih web service perantaranya. Coba artikel bridging dengan inacbg, konsepnya sama, cm beda kegunaan. Terima kasih sudah mampir

    ReplyDelete
  3. Bagusnya diupload juga demonya, biar lebih mantap

    ReplyDelete
  4. Rencananya sprt itu, tp blum sempat. InsyaAllah kalau ada wkt longgar aku selesein artikelnya

    ReplyDelete
  5. Replies
    1. belum pak, belum sempat misahin koding di production. Insya Allah secepatnya, tapi nggak janji

      Delete
    2. ditunggu pak, part 2 dan 3nya hehhe terima kasih.

      Delete
  6. Wah...mantap, tapi saya masih bingung, mencobanya. Diketik banyak banget, wkwkwkwk...

    ReplyDelete
    Replies
    1. saran saya sih tetap diketik pak, biar paham dengan perintah-perintahnya. Tapi kalau mau donload matengannya sudah sy sediakan di akhir artikel. Terima kasih sudah mampir. Semoga bermanfaat

      Delete
    2. Terima kasih mas, atas ilmunya... akan saya coba ketik dan pelajari.

      Delete
    3. Sama-sama mas, kalau ada bug atau kurang beruntung di bridgingnya jangan segan2 menghubungi saya

      Delete
  7. selamat siang pak martin eko setiawan terima kasih banyak ilmunya, source codenya kenapa tidak bisa didownload ya pak terima kasih

    ReplyDelete
    Replies
    1. silahkan dicoba lagi pak, sudah bisa diunduh

      Delete
    2. terima kasih banyak pak martin sangat membantu saya coba lagi

      Delete
  8. mas martin, waktu saya compile vbnya ada error di line Dim dictVars As New Dictionary, jadi gak bisa di compile, kira2 kenapa ya mas??? mohon petunjuk

    ReplyDelete
    Replies
    1. referensi vb6nya ada yang kurang mas, coba tambahkan Microsoft Scripting Runtime di referencenya

      Delete
  9. Wah.. luar biasa. Makasih banyak Pak Eko :)

    ReplyDelete
    Replies
    1. Sama2 pak, semoga bermanfaat, insyaallah jika ada kesulitan sy siap membantu

      Delete
  10. Replies
    1. silahkan pak, jangan sungkan menghubungi saya jika ada masalah

      Delete
  11. mas mau nanya, untuk install web service apakah berbeda PC dengan SEP dan SERVER SIMRS nya? maaf mas saya pemula masih bingung dan untuk install Web Service menggunakan apa ya mas, terimaskih

    ReplyDelete
    Replies
    1. maaf baru balas mas, kalau bisa berbeda PC saja mas, untuk memudahkan maintenance, server bisa pakai linux yang lebih teruji untuk web server dan lebih minim perawatan

      Delete
  12. Mantab Djiwa... Thx to mas Martin,....
    Semoga menjadi amal jenengan, dan dibalas dengan pahala yg banyak oleh Allah SWT... Amiin...

    ReplyDelete
    Replies
    1. Amin, terimas kasih doanya mas, semoga artikel ini bermanfaat

      Delete
  13. Alhamdulillah sedikit ada pencerahaan dari artikel ini..terima kasih pak Martin

    ReplyDelete
    Replies
    1. Sama2 mas, semoga bermanfaat dan bridgingnya berhasil

      Delete