Commit 902fd007 authored by Deddy Vita Kurniawan's avatar Deddy Vita Kurniawan

* notif, mengikuti response code

parent 9b07727e
...@@ -431,13 +431,14 @@ if ( ! function_exists('get_access_token')) ...@@ -431,13 +431,14 @@ if ( ! function_exists('get_access_token'))
]); ]);
$response = curl_exec($curl); $response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$err = curl_error($curl); $err = curl_error($curl);
curl_close($curl); curl_close($curl);
$array_response = json_decode($response, true); $array_response = json_decode($response, true);
$access_token = isset($array_response['access_token']) ? $array_response['access_token'] : null; $access_token = isset($array_response['access_token']) ? $array_response['access_token'] : null;
//die(print_r($array_response));
$data_token = array('ACCESS_TOKEN'=>$access_token, 'EXPIRED_ACCESS'=>date('Y.m.d H:i:s', (strtotime($array_response['expires_in'])+time()))); $data_token = array('ACCESS_TOKEN'=>$access_token, 'EXPIRED_ACCESS'=>date('Y.m.d H:i:s', (strtotime($array_response['expires_in'])+time())));
$ci->db->where('ID', $id)->update('USERS', $data_token); $ci->db->where('ID', $id)->update('USERS', $data_token);
...@@ -476,15 +477,18 @@ if ( ! function_exists('get_data_satu_sehat')) ...@@ -476,15 +477,18 @@ if ( ! function_exists('get_data_satu_sehat'))
CURLOPT_HEADER => 0, CURLOPT_HEADER => 0,
]); ]);
$response = curl_exec($curl); $response = curl_exec($curl); //die(print_r(curl_getinfo($curl, CURLINFO_HTTP_CODE)));
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$err = curl_error($curl); $err = curl_error($curl);
curl_close($curl); curl_close($curl);
$array_response = json_decode($response, true); $array_response = json_decode($response, true);
if($http_code == 200 && $array_response['total'] > 0){
if($tipe == 'pasien'){ if($tipe == 'pasien'){
$array_response = json_decode($response, true);
$data = array('ID_PASIEN_SATSET'=>$array_response['entry'][0]['resource']['id'], 'NAMA_PASIEN_SATSET'=>$array_response['entry'][0]['resource']['name'][0]['text'], 'LASTUPDATE'=>date('d.m.Y.H.i.s', strtotime($array_response['entry'][0]['resource']['meta']['lastUpdated']))); $data = array('ID_PASIEN_SATSET'=>$array_response['entry'][0]['resource']['id'], 'NAMA_PASIEN_SATSET'=>$array_response['entry'][0]['resource']['name'][0]['text'], 'LASTUPDATE'=>date('d.m.Y.H.i.s', strtotime($array_response['entry'][0]['resource']['meta']['lastUpdated'])));
$ci->db->where('NO_KTP', $nik)->update('PASIEN', $data); $ci->db->where('NO_KTP', $nik)->update('PASIEN', $data);
} }
...@@ -492,15 +496,12 @@ if ( ! function_exists('get_data_satu_sehat')) ...@@ -492,15 +496,12 @@ if ( ! function_exists('get_data_satu_sehat'))
$data = array('ID_NAKES_SATSET'=>$array_response['entry'][0]['resource']['id'], 'LASTUPDATE'=>date('d.m.Y.H.i.s', strtotime($array_response['entry'][0]['resource']['meta']['lastUpdated']))); $data = array('ID_NAKES_SATSET'=>$array_response['entry'][0]['resource']['id'], 'LASTUPDATE'=>date('d.m.Y.H.i.s', strtotime($array_response['entry'][0]['resource']['meta']['lastUpdated'])));
$ci->db->where('NIK', $nik)->update('PEGAWAI', $data); $ci->db->where('NIK', $nik)->update('PEGAWAI', $data);
} }
if ($array_response['total'] > 0) {
$result['status'] = 200;
$result['message'] = 'Data berhasil disinkron';
} else {
$result['status'] = 400;
$result['message'] = 'Data gagal disinkron';
} }
$result['status'] = $http_code;
$message = $http_code == 200 ? ($array_response['total'] > 0?'Data berhasil disinkron':'Data tidak ditemukan') :$array_response['issue'][0]['details']['text'];
$result['message'] = $http_code.' - '.$message;
echo json_encode($result); echo json_encode($result);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment