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'))
]);
$response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$err = curl_error($curl);
curl_close($curl);
$array_response = json_decode($response, true);
$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())));
$ci->db->where('ID', $id)->update('USERS', $data_token);
......@@ -476,31 +477,31 @@ if ( ! function_exists('get_data_satu_sehat'))
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);
curl_close($curl);
$array_response = json_decode($response, true);
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'])));
$ci->db->where('NO_KTP', $nik)->update('PASIEN', $data);
}
else if($tipe == 'pegawai'){
$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);
if($http_code == 200 && $array_response['total'] > 0){
if($tipe == 'pasien'){
$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);
}
else if($tipe == 'pegawai'){
$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);
}
}
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);
}
......
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