wecuro_blog/application/helpers/npiapi_helper.php

77 lines
2.1 KiB
PHP
Executable File

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if (!function_exists('npinumber_checking')){
function npinumber_checking($npinumber){
$url = "https://npiregistry.cms.hhs.gov/api/?number=".$npinumber."&enumeration_type=&taxonomy_description=&first_name=&use_first_name_alias=&last_name=&organization_name=&address_purpose=&city=&state=&postal_code=&country_code=&limit=&skip=&version=2.1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$responseJson = curl_exec($ch);
curl_close($ch);
$response = json_decode($responseJson);
$resp = array();
//return $response;
if(isset($response->results)){
return $response;
}else{
$resp = array(
"status_code" => 404,
"status" => "failed",
"error" => "Not Found"
);
return $resp;
}
// $address_info=$response->usgeocoder->address_info;
// $geo_info=$response->usgeocoder->geo_info;
// $resp = array();
// //geo Info
// if ($geo_info->geo_status == 'Match Found') {
// $latitude = $geo_info->latitude;
// $longitude = $geo_info->longitude;
// $resp['geo_info'] = array(
// "status_code" => 200,
// "status" => "success",
// "latlong" => array("Latitude" => $latitude , "Longitude" => $longitude),
// );
// } else {
// $resp['geo_info'] = array(
// "status_code" => 404,
// "status" => "failed",
// "error" => "Not Found"
// );
// }
// //Address Info
// if ($address_info->address_status == 'Match Found') {
// $city = $address_info->city;
// $county = $address_info->county;
// $state = $address_info->state;
// $resp['address_info'] = array(
// "status_code" => 200,
// "status" => "success",
// "address" => array("city" => $city , "county" => $county, "state" => $state),
// );
// } else {
// $resp['address_info'] = array(
// "status_code" => 404,
// "status" => "failed",
// "error" => "Not Found"
// );
// }
//return $response;
}
}
?>