272 lines
9.3 KiB
PHP
272 lines
9.3 KiB
PHP
<?php
|
|
class Receiveruploadlogconfirm extends MY_Controller
|
|
{
|
|
var $max_limit = 20;
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
// db wilayah contoh surabaya
|
|
$this->db_regional = $this->load->database("regional", true);
|
|
|
|
// string database
|
|
$this->db_str_doctor = 'one_doctor';
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
echo "RECEIVER UPLOAD LOG API";
|
|
}
|
|
|
|
function get_param_z()
|
|
{
|
|
$body_z = file_get_contents("php://input");
|
|
$body = gzuncompress($body_z);
|
|
return json_decode($body, true);
|
|
}
|
|
|
|
function reply($resp)
|
|
{
|
|
echo json_encode($resp);
|
|
}
|
|
|
|
function reply_gz($resp)
|
|
{
|
|
//echo json_encode($resp);
|
|
echo gzcompress(json_encode($resp));
|
|
}
|
|
|
|
public function r_upload_log_confirm()
|
|
{
|
|
$this->db->trans_begin();
|
|
$param = $this->get_param_z();
|
|
|
|
|
|
if(count($param['data']) > 0){
|
|
$order_patient_id_array = [];
|
|
foreach($param['data'] as $key)
|
|
{
|
|
$order_patient_id_array[] = intval($key['order_patient_id']);
|
|
}
|
|
|
|
// $implode_order_patient_id = implode(",",$order_patient_id_array);
|
|
$str_order_patient_id = implode(",",$order_patient_id_array);
|
|
|
|
// print_r($str_order_patient_id);
|
|
// exit;
|
|
|
|
// update isconfirmed di orderpatient
|
|
// sql_update
|
|
$sql_update_is_confirm_Y = "UPDATE $this->db_str_doctor.order_patient
|
|
SET OrderPatientIsConfirmed = 'Y'
|
|
WHERE OrderPatientID IN ($str_order_patient_id)";
|
|
|
|
// print_r($sql_update_is_confirm_Y);
|
|
// exit;
|
|
|
|
$qry_update = $this->db_regional->query($sql_update_is_confirm_Y);
|
|
if(!$qry_update){
|
|
$this->db->trans_rollback();
|
|
$this->sys_error_db(["status" => "ERR", "message" => "update data order_patient Y error | " .
|
|
$this->db->error()["message"], "debug" => $this->db_regional->last_query()]);
|
|
exit;
|
|
}
|
|
|
|
$this->db->trans_commit();
|
|
// $this->db->trans_rollback();
|
|
|
|
$this->reply(
|
|
[
|
|
"status" => "OK",
|
|
"message" => "update",
|
|
"order_patient_id" => $order_patient_id_array,
|
|
"sql" => $sql_update_is_confirm
|
|
]
|
|
);
|
|
}
|
|
|
|
else
|
|
{
|
|
$this->reply(
|
|
[
|
|
"status" => "ERR",
|
|
"message" => "".$this->db_regional->last_query(),
|
|
"order_patient_id" => $order_patient_id_array,
|
|
"sql" => $sql_update_is_confirm
|
|
]
|
|
);
|
|
}
|
|
|
|
// foreach($param['data'] as $key)
|
|
// {
|
|
// $order_patient_id_array[] = intval($key['order_patient_id']);
|
|
// }
|
|
|
|
|
|
|
|
// print_r($param);
|
|
// exit;
|
|
// print_r;
|
|
|
|
// echo json_decode($param);
|
|
|
|
// print_r($prm);
|
|
|
|
// $order_patient_id_array = [];
|
|
// $data_json_result = [];
|
|
// $data_json = [];
|
|
|
|
// $str_order_patient_id = "";
|
|
|
|
// foreach($param['data'] as $key)
|
|
// {
|
|
// $order_patient_id_array[] = intval($key['order_patient_id']);
|
|
// }
|
|
|
|
// // $implode_order_patient_id = implode(",",$order_patient_id_array);
|
|
// $str_order_patient_id = implode(",",$order_patient_id_array);
|
|
// if($str_order_patient_id == ""){
|
|
// $str_order_patient_id = "0";
|
|
// }
|
|
|
|
// $sql_cek_one_result = "select oneResultOrderPatientID,
|
|
// oneResultOrderM_BranchID,
|
|
// oneResultOrderM_BranchCode,
|
|
// oneResultJson
|
|
// from $this->db_str_doctor.one_result
|
|
// WHERE oneResultOrderPatientID IN ($str_order_patient_id)";
|
|
|
|
// // echo $sql_cek_one_result;
|
|
// $query_cek = $this->db->query($sql_cek_one_result);
|
|
|
|
// if(!$query_cek){
|
|
// $this->db->trans_rollback();
|
|
// $this->sys_error_db(["status" => "ERR", "message" => "select cek one_result | " .
|
|
// $this->db->error()["message"], "debug" => $this->db->last_query()]);
|
|
// exit;
|
|
// }
|
|
|
|
// $rows_cek = $query_cek->result_array();
|
|
// $index = 0;
|
|
// // if(count($rows_cek) == 0)
|
|
// // {
|
|
// // insert one_result
|
|
|
|
// $data_order_patient_id_one_result = [];
|
|
// foreach($rows_cek as $key => $val)
|
|
// {
|
|
// $data_order_patient_id_one_result[] = $val['oneResultOrderPatientID'];
|
|
// }
|
|
|
|
// // foreach($result['data'] as $key)
|
|
|
|
// $order_patient_result = [];
|
|
// // $index = 0;
|
|
|
|
// // print_r($param['data']);
|
|
// // print_r($data_order_patient_id_one_result);
|
|
// foreach($param['data'] as $key)
|
|
// {
|
|
// if(in_array($key['order_patient_id'], $data_order_patient_id_one_result)){
|
|
// // $order_patient_result[] = $key['order_patient_id'];
|
|
// // continue;
|
|
|
|
// // jk sudah ada data di one_result maka update
|
|
|
|
// $data_json_update =
|
|
// [
|
|
// "order_patient_id" => $key['order_patient_id'],
|
|
// "T_OrderHeaderLabNumberExt" => $key['T_OrderHeaderLabNumberExt'],
|
|
// "T_OrderHeaderDate" => $key['T_OrderHeaderDate'],
|
|
// "T_OrderHeaderID" => $key['T_OrderHeaderID'],
|
|
// "T_OrderHeaderSenderM_DoctorID" => $key['T_OrderHeaderSenderM_DoctorID'],
|
|
// "M_BranchID" => $key['M_BranchID'],
|
|
// "M_BranchCode" => $key['M_BranchCode'],
|
|
// "patient" => $key['patient'],
|
|
// "result" => $key['result'],
|
|
// "sample" => $key['sample']
|
|
// ];
|
|
|
|
// $this->update_one_result_by_order_patient_id(
|
|
// $key['order_patient_id'],
|
|
// $key['M_BranchID'],
|
|
// $key['M_BranchCode'],
|
|
// $data_json_update,
|
|
// $key['patient'][0]
|
|
// );
|
|
|
|
// $order_patient_result[] = $key['order_patient_id'];
|
|
|
|
// }
|
|
|
|
// // jk tidak ada mk insert baru
|
|
// else
|
|
// {
|
|
// $data_json =
|
|
// [
|
|
// "order_patient_id" => $key['order_patient_id'],
|
|
// "T_OrderHeaderLabNumberExt" => $key['T_OrderHeaderLabNumberExt'],
|
|
// "T_OrderHeaderDate" => $key['T_OrderHeaderDate'],
|
|
// "T_OrderHeaderID" => $key['T_OrderHeaderID'],
|
|
// "T_OrderHeaderSenderM_DoctorID" => $key['T_OrderHeaderSenderM_DoctorID'],
|
|
// "M_BranchID" => $key['M_BranchID'],
|
|
// "M_BranchCode" => $key['M_BranchCode'],
|
|
// "patient" => $key['patient'],
|
|
// "result" => $key['result'],
|
|
// "sample" => $key['sample']
|
|
// ];
|
|
|
|
// $this->insert_one_result(
|
|
// $key['order_patient_id'],
|
|
// $key['M_BranchID'],
|
|
// $key['M_BranchCode'],
|
|
// $data_json,
|
|
// $key['patient'][0]
|
|
// );
|
|
|
|
// $order_patient_result[] = $key['order_patient_id'];
|
|
// }
|
|
|
|
|
|
// // $index++;
|
|
// }
|
|
|
|
// $this->db->trans_commit();
|
|
// // $this->db->trans_rollback();
|
|
// $this->reply(
|
|
// [
|
|
// "status" => "OK",
|
|
// "message" => "Data berhasil ditambahkan ke one_result",
|
|
// "order_patient_id" => $order_patient_result,
|
|
// ]);
|
|
|
|
// // return json_encode(
|
|
// // array(
|
|
// // "status" => "OK",
|
|
// // "message" => "Data berhasil ditambahkan ke one_result",
|
|
// // "order_patient_id" => $str_order_patient_id
|
|
// // )
|
|
// // );
|
|
// // }
|
|
|
|
// // else
|
|
// // {
|
|
// // // sudah ditambahkan
|
|
// // // return json_encode(
|
|
// // // array(
|
|
// // // 'status' => 'ERR',
|
|
// // // 'message' => 'Data Sudah Ditambahkan'
|
|
// // // )
|
|
// // // );
|
|
|
|
// // $this->db->trans_rollback();
|
|
// // $this->reply(
|
|
// // [
|
|
// // "status" => "ERR",
|
|
// // "message" => "Data sudah ditambahkan ke one_result",
|
|
// // "order_patient_id" => $str_order_patient_id
|
|
// // ]);
|
|
// // }
|
|
|
|
}
|
|
}
|
|
?>
|