· 6 years ago · Dec 05, 2019, 08:40 AM
1$dt = new DateTime("now", new DateTimeZone($this->session->userdata('timezone')));
2$postdata = array (
3 "PASIEN" => array(
4 "NORM" => $this->input->post('nrm'),
5 "NIK" => $this->input->post('nik'),
6 "NO_KARTU_JKN" => $this->input->post('no_bpjs'),
7 "NAMA" => $this->input->post('nama'),
8 "JENIS_KELAMIN" => $this->input->post('jenis_kelamin'),
9 "TANGGAL_LAHIR" => $this->input->post('tanggal_lahir'),
10 "TEMPAT_LAHIR" => $this->input->post('tempat_lahir'),
11 "ALAMAT" => $this->input->post('alamat'),
12 "KONTAK" => $this->input->post('kontak')
13 ),
14 "RUJUKAN" => array(
15 "JENIS_RUJUKAN" => $this->input->post('jenis_rujukan'),
16 "PELAYANAN" => 'LY012',
17 "NO_RUJUKAN_BPJS" => $this->input->post('no_rujukan_bpjs'),
18 "KRITERIA" => array(
19 "KRITERIA_RUJUKAN" => '305',
20 "KRITERIA_KHUSUS" => '1',
21 "SDM" => '01',
22 "PELAYANAN" => 'XXI',
23 "KELAS_PERAWATAN" => '1',
24 "JENIS_PERAWATAN" => '21',
25 "ALAT" => 'AD',
26 "SARANA" => '1'
27 ),
28 "TANGGAL" => $dt->format('Y-m-d H:i:s'),
29 "FASKES_TUJUAN" => $this->input->post('faskes'),
30 "ALASAN" => $this->input->post('alasan_rujukan'),
31 "ALASAN_LAINNYA" => $this->input->post('alasan_lainnya'),
32 "DIAGNOSA" => $this->input->post('diagnosa'),
33 "DOKTER" => array(
34 "NIK" => $this->input->post('nik_dokter'),
35 "NAMA" => $this->input->post('nama_dokter')
36 ),
37 "PETUGAS" => array(
38 "NIK" => $this->input->post('nik_petugas'),
39 "NAMA" => $this->input->post('nama_petugas')
40 )
41 ),
42 "KONDISI_UMUM" => array(
43 "ANAMNESIS_DAN_PEMERIKSAAN_FISIK" => $this->input->post('anamnesa'),
44 "KESADARAN" => $this->input->post('kesadaran'),
45 "TEKANAN_DARAH" => $this->input->post('tekanan_darah'),
46 "FREKUENSI_NADI" => $this->input->post('nadi'),
47 "SUHU" => $this->input->post('suhu_badan'),
48 "PERNAPASAN" => $this->input->post('nafas'),
49 "KEADAAN_UMUM" => $this->input->post('keadaan_umum'),
50 "NYERI" => $this->input->post('nyeri'),
51 "ALERGI" => $this->input->post('alergi')
52 ),
53 "PENUNJANG" => array(
54 "LABORATORIUM" => $this->input->post('lab'),
55 "RADIOLOGI" => $this->input->post('rad'),
56 "TERAPI_ATAU_TINDAKAN" => $this->input->post('terapi_tindakan')
57 )
58);
59
60$postdata = json_encode($postdata);
61
62/*Id & Password yang diberikan kemkes*/
63$id = "__kode__rs__"; // id/kode rs dari kemenkes
64$pass = md5("__pass__rs__"); // password rs dari kemenkes
65
66//Get Timestamp
67$dt = new DateTime(null, new DateTimeZone("UTC"));
68$timestamp = $dt->getTimestamp();
69
70/*Generate Signature*/
71$key = $id."&".$timestamp;
72$signature = base64_encode(hash_hmac("sha256", utf8_encode($key), utf8_encode($pass), true));
73$method = "GET"; /*POST / PUT / DELETE*/
74
75// format tanggal rujukan yyyy-mm-dd
76$method = "POST";
77$url = "https://api.sisrute.kemkes.go.id/rujukan";
78$headers = [
79 "X-cons-id: ".$id,
80 "X-Timestamp: ".$timestamp,
81 "X-signature: ".$signature,
82 "Content-type: application/json",
83 "Content-length: ".strlen($postdata)
84];
85
86/*Gunakan curl untuk mengakses/merequest alamat api*/
87$curl = curl_init();
88curl_setopt($curl, CURLOPT_URL, $url);
89curl_setopt($curl, CURLOPT_HEADER, false);
90curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
91curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
92curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
93curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
94curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
95curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
96curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
97
98$result = curl_exec($curl);
99curl_close($curl);
100// echo $url;
101// echo '<pre>';
102// print_r(json_decode($result, true));
103// echo '</pre>';
104
105$res = json_decode($result, true);
106
107echo $res['detail'].'<br>(status:'.$res['status'].')';