Initial import
This commit is contained in:
135
one-api/application/controllers/mockup/clinic/poly/Order.php
Normal file
135
one-api/application/controllers/mockup/clinic/poly/Order.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
class Order extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "ORDER API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("clinicdev", true);
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$prm['header']['complaint'] = str_replace(PHP_EOL, '<br>', $prm['header']['complaint']);
|
||||
$prm['header']['suggestion'] = str_replace(PHP_EOL, '<br>', $prm['header']['suggestion']);
|
||||
$header_json = json_encode($prm['header']);
|
||||
$header_json = str_replace("\\", "\\\\", "$header_json");
|
||||
$lab_json = json_encode($prm['lab']);
|
||||
$med_json = json_encode($prm['med']);
|
||||
|
||||
$server = "http";
|
||||
$uid = $this->sys_user['M_UserID'];
|
||||
$sql = "CALL sp_clinic_poly_save('{$prm['order_id']}', '{$header_json}', '{$med_json}', '{$lab_json}', '{$uid}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
|
||||
if ($rst->data->is_lab == "Y" && $rst->status == "OK")
|
||||
{
|
||||
// persiapkan curl
|
||||
$ch = curl_init();
|
||||
|
||||
// set url
|
||||
global $_SERVER;
|
||||
$current_host = $_SERVER["SERVER_ADDR"];
|
||||
if ($server == "https")
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_URL, "{$server}://{$current_host}:9090/ticket/UMUM");
|
||||
//file_put_contents("/xtmp/url", "{$server}://{$current_host}:9090/ticket/UMUM" );
|
||||
// return the transfer as a string
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
// $output contains the output string
|
||||
$output = json_decode(curl_exec($ch));
|
||||
|
||||
// tutup curl
|
||||
curl_close($ch);
|
||||
|
||||
// menampilkan hasil curl
|
||||
// echo $output;
|
||||
if ($output != null)
|
||||
if ($output->status == "OK") {
|
||||
$rst->data->queue = $output->data[0]->number;
|
||||
$x = json_encode($output->data[0]);
|
||||
|
||||
$sql = "CALL sp_clinic_fo_labqueue('{$rst->data->id}', '{$rst->data->queue}', '{$x}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function process()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_clinic_poly_process('{$prm['order_id']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function get_one()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select *
|
||||
from c_orderheader
|
||||
where C_OrderHeaderID = ?";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->row();
|
||||
$rows->C_OrderHeaderQueueJSON = json_decode($rows->C_OrderHeaderQueueJSON);
|
||||
|
||||
$result = $rows;
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient get",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function clean_mysqli_connection( $dbc )
|
||||
{
|
||||
while( mysqli_more_results($dbc) )
|
||||
{
|
||||
if(mysqli_next_result($dbc))
|
||||
{
|
||||
$result = mysqli_use_result($dbc);
|
||||
|
||||
unset($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user