100 lines
2.6 KiB
PHP
Executable File
100 lines
2.6 KiB
PHP
Executable File
<?php
|
|
|
|
|
|
|
|
function get_ICD_Info($code){
|
|
|
|
$uri = 'https://id.who.int/icd/entity/search?q='.$code;
|
|
|
|
//Create Token Start
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, ICD_TOKEN_ENPOINT);
|
|
curl_setopt($ch, CURLOPT_POST, TRUE);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
|
|
'client_id' => ICD_CLIENT_ID,
|
|
'client_secret' => ICD_CLIENT_SECRET,
|
|
'scope' => ICD_SCOPE,
|
|
'grant_type' => ICD_GRANT_TYPE
|
|
));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // set curl without result echo
|
|
$result = curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
$json_array = (json_decode($result, true));
|
|
$token = $json_array['access_token'];
|
|
$_SESSION['token'] = $token;
|
|
//Create Token END
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $uri);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
'Authorization: Bearer '.$token,
|
|
'Accept: application/json',
|
|
'Accept-Language: en',
|
|
'API-Version: v2'
|
|
));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // set curl without result echo
|
|
$api_response = curl_exec($ch);
|
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_close($ch);
|
|
|
|
//return $http_code;
|
|
$res=json_decode($api_response);
|
|
$i=0;
|
|
foreach($res->destinationEntities as $enty){
|
|
//print_r($enty);
|
|
|
|
$output[$i]['id']=$enty->id;
|
|
$output[$i]['title']=$enty->title;
|
|
$i++;
|
|
}
|
|
return $output;
|
|
//return $res;
|
|
//return $output->destinationEntities;
|
|
}
|
|
|
|
function get_ICD_ById($id){
|
|
|
|
|
|
$uri = 'https://id.who.int/icd/entity/'.$id;
|
|
|
|
//Create Token Start
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, ICD_TOKEN_ENPOINT);
|
|
curl_setopt($ch, CURLOPT_POST, TRUE);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
|
|
'client_id' => ICD_CLIENT_ID,
|
|
'client_secret' => ICD_CLIENT_SECRET,
|
|
'scope' => ICD_SCOPE,
|
|
'grant_type' => ICD_GRANT_TYPE
|
|
));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // set curl without result echo
|
|
$result = curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
$json_array = (json_decode($result, true));
|
|
$token = $json_array['access_token'];
|
|
$_SESSION['token'] = $token;
|
|
//Create Token END
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $uri);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
'Authorization: Bearer '.$token,
|
|
'Accept: application/json',
|
|
'Accept-Language: en',
|
|
'API-Version: v2'
|
|
));
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // set curl without result echo
|
|
$api_response = curl_exec($ch);
|
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_close($ch);
|
|
|
|
//return $http_code;
|
|
$res=json_decode($api_response);
|
|
//return $output;
|
|
$output=(array)$res->title;
|
|
//return $output->destinationEntities;
|
|
return $output['@value'];
|
|
}
|
|
?>
|