Initial import
This commit is contained in:
194
application/controllers/lis/listpatient/Patient.php
Normal file
194
application/controllers/lis/listpatient/Patient.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function add_notes($orderid){
|
||||
$sql = " SELECT F_PaymentT_OrderHeaderID as note_order_id,
|
||||
F_PaymentID as note_id,
|
||||
F_PaymentDate as note_date,
|
||||
F_PaymentNumber as note_number,
|
||||
GROUP_CONCAT(M_PaymentTypeName separator ' , ') as paymenttypes_name,
|
||||
SUM(F_PaymentDetailAmount) as note_amount,
|
||||
M_UserUsername as note_user,
|
||||
F_PaymentDetailIsActive as note_active
|
||||
FROM f_payment
|
||||
JOIN f_paymentdetail ON F_PaymentDetailF_PaymentID = F_PaymentID
|
||||
JOIN m_paymenttype ON F_PaymentDetailM_PaymentTypeID = M_PaymentTypeID
|
||||
LEFT JOIN m_user ON F_PaymentDetailUserID = M_UserID
|
||||
WHERE
|
||||
F_PaymentT_OrderHeaderID = {$orderid}
|
||||
GROUP BY F_PaymentID";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
return $rows;
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("get notes", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$startdate = $prm['startdate'];
|
||||
//$enddate = $prm['enddate'] ;
|
||||
$search = $prm["search"];
|
||||
$status = $prm["status"];
|
||||
$filter_company = isset($prm["CorporateID"])?$prm["CorporateID"]:0;
|
||||
$and_corporate = "";
|
||||
if(intval($filter_company) > 0){
|
||||
$and_corporate = " AND T_OrderHeaderCorporateID = {$filter_company}";
|
||||
}
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT T_OrderHeaderLabNumber
|
||||
FROM t_orderheader
|
||||
LEFT JOIN api_push ON Api_PushT_OrderHeaderLabNumber = T_OrderHeaderLabNumber AND
|
||||
( ? = 'A' OR Api_PushStatus = ? ) $and_corporate
|
||||
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN m_patient ON T_orderHeaderM_PatientID = M_PatientID AND
|
||||
(Api_PushT_OrderHeaderLabNumber LIKE CONCAT('%',?,'%') OR M_PatientName Like CONCAT('%',?,'%'))
|
||||
WHERE T_OrderHeaderIsActive = 'Y' AND DATE(T_OrderHeaderDate) = ?
|
||||
) x";
|
||||
$query = $this->db_onedev->query($sql, array($status,$status,$search,$search,$startdate));
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("t_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT T_OrderHeaderID,T_OrderHeaderLabNumber,
|
||||
M_PatientName,
|
||||
M_PatientNoReg,
|
||||
CorporateName,
|
||||
DATE_FORMAT(Api_PushDateTime,'%d-%m-%Y') as push_date,
|
||||
Api_PushParams,
|
||||
Api_PushResponse,
|
||||
Api_PushRetry,
|
||||
Api_PushLISLabNumber,
|
||||
IFNULL(Api_PushStatus,'') as Api_PushStatus,
|
||||
if(M_PatientIdentifierValue <> '',M_PatientIdentifierValue, M_PatientNIP) as nik
|
||||
FROM t_orderheader
|
||||
LEFT JOIN api_push ON Api_PushT_OrderHeaderLabNumber = T_OrderHeaderLabNumber AND
|
||||
( ? = 'A' OR Api_PushStatus = ? ) $and_corporate
|
||||
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN m_patient ON T_orderHeaderM_PatientID = M_PatientID AND
|
||||
(Api_PushT_OrderHeaderLabNumber LIKE CONCAT('%',?,'%') OR M_PatientName Like CONCAT('%',?,'%'))
|
||||
WHERE T_OrderHeaderIsActive = 'Y' AND DATE(T_OrderHeaderDate) = ?
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
//echo $this->db_onedev->last_query();
|
||||
$query = $this->db_onedev->query($sql, array($status,$status,$search,$search,$startdate));
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function rePushOrder(){
|
||||
$prm = $this->sys_input;
|
||||
$this->load->library('Apilis');
|
||||
$kesimpulan = $this->apilis->GetOrderDetail($prm['T_OrderHeaderLabNumber']);
|
||||
if($kesimpulan){
|
||||
$this->sys_ok(array("status" => "OK", "message" => "success"));
|
||||
}else{
|
||||
$this->sys_error(array("status" => "ERR", "message" => "failed"));
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function searchcompany(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM corporate
|
||||
WHERE
|
||||
CorporateName like ?
|
||||
AND CorporateIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$rows = array('id'=>0,'name'=>'Semua');
|
||||
$sql = "
|
||||
SELECT CorporateID as id, CorporateName as name
|
||||
FROM corporate
|
||||
WHERE
|
||||
CorporateName like ?
|
||||
AND CorporateIsActive = 'Y'
|
||||
ORDER BY CorporateName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
array_push($rows,array('id'=>0,'name'=>'Semua'));
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user