· 5 years ago · Feb 26, 2020, 01:48 AM
1<?php
2defined('BASEPATH') or exit('No direct script access allowed');
3
4
5use GuzzleHttp\Client;
6
7
8class Vclaim_model extends CI_Model
9{
10 private $_client;
11 private $_header;
12 private $_dataid = "";
13 private $_secretKey = "";
14 private $_url = "https://new-api.bpjs-kesehatan.go.id:8080/new-vclaim-rest/";
15
16 public function __construct()
17 {
18 parent::__construct();
19 $this->_client = new Client();
20
21 date_default_timezone_set('UTC');
22 $dataid = $this->_dataid;
23 $secretKey = $this->_secretKey;
24
25 $tStamp = strval(time() - strtotime('1970-01-01 00:00:00'));
26 $signature = hash_hmac('sha256', $dataid . "&" . $tStamp, $secretKey, true);
27 $encodedSignature = base64_encode($signature);
28 //$urlencodedSignature = urlencode($encodedSignature);
29
30 $this->_header = [
31 'x-cons-id' => $dataid,
32 'x-timestamp' => $tStamp,
33 'x-signature' => $encodedSignature,
34 'Content-Type' => 'application/x-www-form-urlencoded',
35 'Accept' => 'application/json',
36 ];
37 }
38
39 public function detailKepesertaan($type, $noKartu)
40 {
41 if (!$type || !$noKartu) {
42 return null;
43 }
44
45 if ($type == 1) {
46 //KTP
47 $method = 'Peserta/nik/' . $noKartu . '/tglSEP/' . date("Y-m-d") . '';
48 } else {
49 //NO kartu BPJS
50 $method = 'Peserta/nokartu/' . $noKartu . '/tglSEP/' . date("Y-m-d") . '';
51 }
52 $response = $this->_client->request('GET', $method, [
53 'base_uri' => $this->_url,
54 'headers' => $this->_header,
55 'verify' => false,
56 ]);
57 $result = json_decode($response->getBody()->getContents(), true);
58 return $result;
59 }
60
61
62 public function newSEP($data)
63 {
64 $method = 'SEP/1.1/insert';
65 $response = $this->_client->request('POST', $method, [
66 'base_uri' => $this->_url,
67 'headers' => $this->_header,
68 'verify' => false,
69 'json' => $data,
70 ]);
71 $result = json_decode($response->getBody()->getContents(), true);
72 return $result;
73 }
74
75 public function detailSEP($noSEP)
76 {
77 $method = 'SEP/' . $noSEP;
78 $response = $this->_client->request('GET', $method, [
79 'base_uri' => $this->_url,
80 'headers' => $this->_header,
81 'verify' => false,
82 ]);
83 $result = json_decode($response->getBody()->getContents(), true);
84 return $result;
85 }
86
87 public function cariRujukanByNorujukan($faskes, $norujukan)
88 {
89 if (!$faskes || !$norujukan) {
90 return null;
91 }
92 if ($faskes == 1) {
93 //KTP
94 $method = 'Rujukan/' . $norujukan . '';
95 } else {
96 //NO kartu BPJS
97 $method = 'Rujukan/RS/' . $norujukan . '';
98 }
99
100 $response = $this->_client->request('GET', $method, [
101 'base_uri' => $this->_url,
102 'headers' => $this->_header,
103 'verify' => false,
104 ]);
105 $result = json_decode($response->getBody()->getContents(), true);
106 return $result;
107 }
108
109
110 public function listRujukanByNoka($faskes, $noka)
111 {
112 if (!$faskes || !$noka) {
113 return null;
114 }
115 if ($faskes == 1) {
116 //KTP
117 $method = 'Rujukan/List/Peserta/' . $noka . '';
118 } else {
119 //NO kartu BPJS
120 $method = 'Rujukan/RS/List/Peserta/' . $noka . '';
121 }
122
123 $response = $this->_client->request('GET', $method, [
124 'base_uri' => $this->_url,
125 'headers' => $this->_header,
126 'verify' => false,
127 ]);
128 $result = json_decode($response->getBody()->getContents(), true);
129 return $result;
130 }
131
132 public function detailrujukanByNoKa($faskes, $noka)
133 {
134 if ($faskes == 1) {
135 //KTP
136 $method = 'Rujukan/Peserta/' . $noka . '';
137 } else {
138 //NO kartu BPJS
139 $method = 'Rujukan/RS/Peserta/' . $noka . '';
140 }
141
142 $response = $this->_client->request('GET', $method, [
143 'base_uri' => $this->_url,
144 'headers' => $this->_header,
145 'verify' => false,
146 ]);
147 $result = json_decode($response->getBody()->getContents(), true);
148 return $result;
149 }
150
151
152 public function historyPelayananPeserta($noKa, $tglMulai, $tglAkhir)
153 {
154 $method = 'monitoring/HistoriPelayanan/NoKartu/' . $noKa . '/tglAwal/' . $tglMulai . '/tglAkhir/' . $tglAkhir . '';
155 $response = $this->_client->request('GET', $method, [
156 'base_uri' => $this->_url,
157 'headers' => $this->_header,
158 'verify' => false,
159 ]);
160 $result = json_decode($response->getBody()->getContents(), true);
161 return $result;
162 }
163
164
165 public function searchDiagnosa($keyword)
166 {
167 $method = 'referensi/diagnosa/' . $keyword . '';
168 $response = $this->_client->request('GET', $method, [
169 'base_uri' => $this->_url,
170 'headers' => $this->_header,
171 'verify' => false,
172 ]);
173 $result = json_decode($response->getBody()->getContents(), true);
174 return $result;
175 }
176
177
178 public function searchPoli($keyword)
179 {
180 $method = 'referensi/poli/' . $keyword . '';
181 $response = $this->_client->request('GET', $method, [
182 'base_uri' => $this->_url,
183 'headers' => $this->_header,
184 'verify' => false,
185 ]);
186 $result = json_decode($response->getBody()->getContents(), true);
187 return $result;
188 }
189
190 public function searchDPJP($jenispelayanan = 1, $tanggal, $spesialisasi)
191 {
192 $method = 'referensi/dokter/pelayanan/' . $jenispelayanan . '/tglPelayanan/' . $tanggal . '/Spesialis/' . $spesialisasi . '';
193 $response = $this->_client->request('GET', $method, [
194 'base_uri' => $this->_url,
195 'headers' => $this->_header,
196 'verify' => false,
197 ]);
198 $result = json_decode($response->getBody()->getContents(), true);
199 return $result;
200 }
201
202
203 public function asalfaskesrujukan()
204 {
205 $faskes = [
206 ["id" => "1", "faskes" => "Faskes Tingkat 1 (PCARE/PUSKESMAS/DR KELUARGA)"],
207 ["id" => "2", "faskes" => "Faskes Tingkat 2 (RUMAH SAKIT)"]
208 ];
209 return $faskes;
210 }
211 public function statuskecelakaan()
212 {
213 // $statuskecelakaan = [
214 // ["id" => "0", "status" => "Bukan Kecelakaan"],
215 // ["id" => "1", "status" => "Kecelakaan Lalulintas dan bukan kecelakaan kerja"],
216 // ["id" => "2", "status" => "Kecelakaan Lalulintas dan kecelakaan kerja"],
217 // ["id" => "3", "status" => "Kecelakaan Kerja"]
218 // ];
219
220 $statuskecelakaan = [
221 ["id" => "0", "status" => "Bukan Kecelakaan"]
222 ];
223 return $statuskecelakaan;
224 }
225
226 private function _listRujukanPcareByNoka($noka)
227 {
228 $method = 'Rujukan/List/Peserta/' . $noka . '';
229 $response = $this->_client->request('GET', $method, [
230 'base_uri' => $this->_url,
231 'headers' => $this->_header,
232 'verify' => false,
233 ]);
234 $result = json_decode($response->getBody()->getContents(), true);
235 return $result;
236 }
237
238 private function _listRujukanRSByNoka($noka)
239 {
240 $method = 'Rujukan/RS/List/Peserta/' . $noka . '';
241 $response = $this->_client->request('GET', $method, [
242 'base_uri' => $this->_url,
243 'headers' => $this->_header,
244 'verify' => false,
245 ]);
246 $result = json_decode($response->getBody()->getContents(), true);
247 return $result;
248 }
249
250 public function getAllRujukanBynoka($noka)
251 {
252 $pcare = $this->_listRujukanPcareByNoka($noka);
253 $rs = $this->_listRujukanRSByNoka($noka);
254
255 $peserta = $this->detailKepesertaan(2, $noka);
256
257 $lastpcare = $this->detailrujukanByNoKa(1, $noka);
258 $lastrs = $this->detailrujukanByNoKa(2, $noka);
259
260 $list = [
261 'peserta' => $peserta,
262 'pcare' => $pcare,
263 'lastpcare' => $lastpcare,
264 'rs' => $rs,
265 'lastrs' => $lastrs
266 ];
267 return $list;
268 }
269
270 public function newPengajuanSEP($data)
271 {
272 $method = 'Sep/pengajuanSEP';
273 $response = $this->_client->request('POST', $method, [
274 'base_uri' => $this->_url,
275 'headers' => $this->_header,
276 'verify' => false,
277 'json' => $data,
278 ]);
279 $result = json_decode($response->getBody()->getContents(), true);
280 return $result;
281 }
282
283
284 public function approvalSEP($data)
285 {
286 $method = 'Sep/aprovalSEP';
287 $response = $this->_client->request('POST', $method, [
288 'base_uri' => $this->_url,
289 'headers' => $this->_header,
290 'verify' => false,
291 'json' => $data,
292 ]);
293 $result = json_decode($response->getBody()->getContents(), true);
294 return $result;
295 }
296
297
298 public function updateTanggalPulangSEP($data)
299 {
300 $method = 'Sep/updtglplg';
301 $response = $this->_client->request('PUT', $method, [
302 'base_uri' => $this->_url,
303 'headers' => $this->_header,
304 'verify' => false,
305 'json' => $data,
306 ]);
307 $result = json_decode($response->getBody()->getContents(), true);
308 return $result;
309 }
310
311 public function dataKunjunganPasienBPJS($tanggalSEP, $JnsPelayanan)
312 {
313 $method = 'Monitoring/Kunjungan/Tanggal/' . $tanggalSEP . '/JnsPelayanan/' . $JnsPelayanan . '';
314 $response = $this->_client->request('GET', $method, [
315 'base_uri' => $this->_url,
316 'headers' => $this->_header,
317 'verify' => false
318 ]);
319 $result = json_decode($response->getBody()->getContents(), true);
320 return $result;
321 }
322}