Files
2026-04-15 15:23:57 +07:00

392 lines
14 KiB
PHP

<?php
class Patient extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "DOCTORSO API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
function getdistrict(){
$prm = $this->sys_input;
$query =" SELECT *
FROM nat_district
WHERE
Nat_DistrictIsActive = 'Y' AND Nat_DistrictNat_CityID = ?
";
//echo $query;
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function getkelurahan(){
$prm = $this->sys_input;
$query =" SELECT *
FROM nat_kelurahan
WHERE
Nat_KelurahanIsActive = 'Y' AND Nat_KelurahanNat_DistrictID = ?
";
//echo $query;
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function getTopStocks() {
$prm = $this->sys_input;
// Set default dates to today if not provided
$start_date = isset($prm['start_date']) ? $prm['start_date'] : date('Y-m-d');
$end_date = isset($prm['end_date']) ? $prm['end_date'] : date('Y-m-d');
$page = isset($prm['page']) ? $prm['page'] : 1;
// API URL
$url = "https://exodus.stockbit.com/order-trade/top-stock";
// Query parameters
$params = http_build_query([
'start' => $start_date,
'end' => $end_date,
'investor_type' => 'INVESTOR_TYPE_FOREIGN',
'market_type' => 'MARKET_TYPE_REGULER',
'value_type' => 'VALUE_TYPE_NET',
'page' => $page
]);
// Initialize cURL
$ch = curl_init($url . '?' . $params);
// Set cURL options
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPGET => true,
CURLOPT_HTTPHEADER => [
'accept: application/json, text/plain, */*',
'accept-language: en-US,en;q=0.9',
'authorization: Bearer ' . $prm['token'],
'cache-control: no-cache',
'origin: https://stockbit.com',
'pragma: no-cache',
'referer: https://stockbit.com/',
'sec-ch-ua: "Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134"',
'sec-ch-ua-mobile: ?0',
'sec-ch-ua-platform: "macOS"',
'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0'
],
CURLOPT_SSL_VERIFYPEER => false
]);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check for errors
if (curl_errno($ch)) {
$error = curl_error($ch);
curl_close($ch);
$this->sys_error("cURL Error: " . $error);
exit;
}
curl_close($ch);
// Check response code
if ($http_code !== 200) {
$this->sys_error("API Error: HTTP Code " . $http_code);
exit;
}
// Decode JSON response
$result = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
$this->sys_error("JSON Decode Error: " . json_last_error_msg());
exit;
}
$this->sys_ok($result);
exit;
}
function getPopulerBranch() {
try {
$prm = $this->sys_input;
// API URL
$url = "https://devregonline.pramita.co.id/one_api_coba/mobile/choosebranch/getPopuler";
// Request body
$data = array(
"lat" => isset($prm['lat']) ? $prm['lat'] : "",
"lng" => isset($prm['lng']) ? $prm['lng'] : "",
"province" => isset($prm['province']) ? $prm['province'] : "",
"regional_id" => isset($prm['regional_id']) ? $prm['regional_id'] : "",
"regional_name" => isset($prm['regional_name']) ? $prm['regional_name'] : "",
"distance" => isset($prm['distance']) ? $prm['distance'] : "",
"photo" => isset($prm['photo']) ? $prm['photo'] : "",
"photox" => isset($prm['photox']) ? $prm['photox'] : "",
"code" => isset($prm['code']) ? $prm['code'] : "",
"id" => isset($prm['id']) ? $prm['id'] : "",
"name" => isset($prm['name']) ? $prm['name'] : "",
"address" => isset($prm['address']) ? $prm['address'] : "",
"fcm" => isset($prm['fcm']) ? $prm['fcm'] : "",
"token" => isset($prm['token']) ? $prm['token'] : ""
);
// Initialize cURL
$ch = curl_init($url);
// Set cURL options
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
'Accept: application/json, text/plain, */*',
'Accept-Language: en-US,en;q=0.9',
'Cache-Control: no-cache',
'Connection: keep-alive',
'Content-Type: application/json;charset=UTF-8',
'Origin: https://devregonline.pramita.co.id',
'Pragma: no-cache',
'Referer: https://devregonline.pramita.co.id/',
'Sec-Fetch-Dest: empty',
'Sec-Fetch-Mode: cors',
'Sec-Fetch-Site: same-origin',
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0',
'sec-ch-ua: "Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134"',
'sec-ch-ua-mobile: ?0',
'sec-ch-ua-platform: "macOS"'
],
CURLOPT_SSL_VERIFYPEER => false
]);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check for errors
if (curl_errno($ch)) {
$error = curl_error($ch);
curl_close($ch);
throw new Exception("cURL Error: " . $error);
}
curl_close($ch);
// Check response code
if ($http_code !== 200) {
throw new Exception("API Error: HTTP Code " . $http_code);
}
// Decode JSON response
$result = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception("JSON Decode Error: " . json_last_error_msg());
}
$this->sys_ok($result);
exit;
} catch (Exception $e) {
$this->sys_error("Error: " . $e->getMessage());
exit;
}
}
function getPatients() {
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$md5_token = md5('mobile'.$prm['hp'].date('Y-m-d').'pramita');
$hp = isset($prm['hp']) ? $prm['hp'] : "";
if($hp != ''){
// API URL
$url = "https://mobile.pramita.co.id/one_api_coba/mobile/localbrg/get_Patients";
// Request body
$data = array(
"token" => $md5_token,
"hp" => $hp
);
// Initialize cURL
$ch = curl_init($url);
// Set cURL options
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
'Accept: application/json, text/plain, */*',
'Accept-Language: en-US,en;q=0.9',
'Cache-Control: no-cache',
'Connection: keep-alive',
'Content-Type: application/json;charset=UTF-8',
'Origin: https://mobile.pramita.co.id',
'Pragma: no-cache',
'Referer: https://mobile.pramita.co.id/',
'Sec-Fetch-Dest: empty',
'Sec-Fetch-Mode: cors',
'Sec-Fetch-Site: same-origin',
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0',
'sec-ch-ua: "Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134"',
'sec-ch-ua-mobile: ?0',
'sec-ch-ua-platform: "macOS"'
],
CURLOPT_SSL_VERIFYPEER => false
]);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check for errors
if (curl_errno($ch)) {
$error = curl_error($ch);
curl_close($ch);
throw new Exception("cURL Error: " . $error);
}
curl_close($ch);
// Check response code
if ($http_code !== 200) {
throw new Exception("API Error: HTTP Code " . $http_code);
}
// Decode JSON response
$result = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception("JSON Decode Error: " . json_last_error_msg());
}
}
$this->sys_ok($result);
exit;
} catch (Exception $e) {
$this->sys_error("Error: " . $e->getMessage());
exit;
}
}
function updateSelectedPatient() {
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$md5_token = md5('mobile'.$prm['hp'].date('Y-m-d').'pramita');
$prm['token'] = $md5_token;
// API URL
$url = "https://mobile.pramita.co.id/one_api_coba/mobile/localbrg/update_SelectedPatient";
// Request body
$data = $prm;
// Initialize cURL
$ch = curl_init($url);
// Set cURL options
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
'Accept: application/json, text/plain, */*',
'Accept-Language: en-US,en;q=0.9',
'Cache-Control: no-cache',
'Connection: keep-alive',
'Content-Type: application/json;charset=UTF-8',
'Origin: https://mobile.pramita.co.id',
'Pragma: no-cache',
'Referer: https://mobile.pramita.co.id/',
'Sec-Fetch-Dest: empty',
'Sec-Fetch-Mode: cors',
'Sec-Fetch-Site: same-origin',
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0',
'sec-ch-ua: "Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134"',
'sec-ch-ua-mobile: ?0',
'sec-ch-ua-platform: "macOS"'
],
CURLOPT_SSL_VERIFYPEER => false
]);
// Execute cURL request
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check for errors
if (curl_errno($ch)) {
$error = curl_error($ch);
curl_close($ch);
throw new Exception("cURL Error: " . $error);
}
curl_close($ch);
// Check response code
if ($http_code !== 200) {
throw new Exception("API Error: HTTP Code " . $http_code);
}
// Decode JSON response
$result = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception("JSON Decode Error: " . json_last_error_msg());
}
$this->sys_ok($result);
exit;
} catch (Exception $e) {
$this->sys_error("Error: " . $e->getMessage());
exit;
}
}
}