771 lines
26 KiB
Plaintext
771 lines
26 KiB
Plaintext
<?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_v2()
|
|
{
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$filter = $prm['filter'];
|
|
$search = $prm["search"];
|
|
$status = $prm["status"];
|
|
$number_limit = 20;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
$where = "";
|
|
if($search != '')
|
|
$where .= "( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND ";
|
|
|
|
if($filter == 'day')
|
|
$where .= " DATE(T_OrderHeaderDate) = CURDATE() AND ";
|
|
if($filter == 'notsampled')
|
|
$where .= " Last_StatusM_StatusID < 7 AND ";
|
|
|
|
$sql = " SELECT count(*) as total
|
|
FROM(
|
|
SELECT T_OrderHeaderID
|
|
FROM t_orderheader
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
|
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
|
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
|
|
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
|
|
JOIN t_orderdetail on T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y' aND T_OrderDetailT_TestIsPrice = 'Y'
|
|
left join t_orderpromise on T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
|
join t_orderdelivery on T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID AND T_OrderDeliveryIsActive = 'Y'
|
|
join m_delivery on T_OrderDeliveryM_DeliveryID = M_DeliveryID AND M_DeliveryIsActive = 'Y'
|
|
|
|
|
|
WHERE
|
|
$where
|
|
(
|
|
('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL))
|
|
OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y')
|
|
OR '{$status}' = 'A'
|
|
)
|
|
group by T_OrderHeaderID
|
|
)x";
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
|
|
|
|
$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;
|
|
}
|
|
$janji = T_OrderPromiseDateTime;
|
|
$janji_hasil = Date_format($janji, "d-m-Y H:i:s");
|
|
|
|
$sql ="
|
|
set @counter = 0;
|
|
SELECT @counter := @counter +1 no_urut,
|
|
t_orderheader.*,T_OrderHeaderIsCito as cito,
|
|
M_PatientNoReg,
|
|
concat(M_TitleName,'. ',M_PatientName) as M_PatientName,
|
|
M_CompanyName,
|
|
M_MouName,
|
|
DATE(T_OrderHeaderDate) as order_date,
|
|
T_OrderHeaderTotal as totalbill,
|
|
IFNULL(Last_StatusPaymentPaid,0) as paid,
|
|
IFNULL(Last_StatusPaymentUnpaid,T_OrderHeaderTotal)as unpaid,
|
|
Last_StatusPaymentIsLunas as flaglunas,
|
|
Last_StatusM_StatusID as last_status,
|
|
'' as notes,
|
|
M_MouMinDP as mindp_percent,
|
|
GROUP_CONCAT(distinct concat(T_OrderDetailT_TestName,'^',T_OrderDetailIsCito) SEPARATOR ',') as test ,
|
|
fn_report_promise_list(T_OrderHeaderID) as janji,
|
|
(M_MouMinDP/100) * T_OrderHeaderTotal as mindp_amount,
|
|
case
|
|
when Last_StatusPaymentPaid = '0' then 'BELUM BAYAR'
|
|
when Last_StatusPaymentIsLunas = 'Y' then 'LUNAS'
|
|
when Last_StatusPaymentIsLunas = 'N' then 'BELUM LUNAS' ELSE ''
|
|
END as status,
|
|
GROUP_CONCAT(distinct M_DeliveryName SEPARATOR ' , ') as delivery
|
|
FROM t_orderheader
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
|
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
|
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
|
|
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
|
|
JOIN t_orderdetail on T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y' aND T_OrderDetailT_TestIsPrice = 'Y'
|
|
join t_orderpromise on T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
|
join t_orderdelivery on T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID AND T_OrderDeliveryIsActive = 'Y'
|
|
join m_delivery on T_OrderDeliveryM_DeliveryID = M_DeliveryID AND M_DeliveryIsActive = 'Y'
|
|
|
|
|
|
WHERE
|
|
$where
|
|
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y')
|
|
OR '{$status}' = 'A'
|
|
)
|
|
group by T_OrderHeaderID
|
|
ORDER BY `fn_get_cito`(T_OrderHeaderID),T_OrderPromiseDateTime asc
|
|
limit $number_limit offset $number_offset";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$rows = $query->result_array();
|
|
/*if($rows){
|
|
foreach($rows as $k => $v){
|
|
$sql = "SELECT * FROM t_orderpromise WHERE T_OrderPromiseT_OrderHeaderID";
|
|
$rows[$k]['result_promise'] = $this->add_notes($v['T_OrderHeaderID']);
|
|
}
|
|
}*/
|
|
|
|
|
|
$result = array("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$companyid = $prm['companyid'];
|
|
$filter_doctor = '';
|
|
$filter_doctor_code_count = '';
|
|
$filter_company = '';
|
|
$startdate = $prm['startdate'];
|
|
$enddate = $prm['enddate'];
|
|
$search = $prm["search"];
|
|
$status = $prm["status"];
|
|
$number_limit = 20;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
$filter_date = " AND DATE(T_OrderHeaderDate) BETWEEN '{$startdate}' AND '{$enddate}'";
|
|
if($search != '' || ($doctorid != 0 || $doctorid != '0')){
|
|
$prev_date = date('Y-m-d', strtotime('-30 day',strtotime($xdate)));
|
|
//echo $prev_date;
|
|
//$filter_date = " AND DATE(T_OrderHeaderDate) BETWEEN '{$prev_date}' AND '{$xdate}'";
|
|
}
|
|
|
|
$where = " T_OrderHeaderIsActive = 'Y' $filter_date ";
|
|
|
|
if($search != '')
|
|
$where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' )";
|
|
|
|
$filter_doctor_code_search = '';
|
|
|
|
|
|
if($companyid != 0 || $companyid != '0'){
|
|
$filter_company = " AND T_OrderHeaderM_CompanyID = {$companyid}";
|
|
}
|
|
|
|
$sql = " SELECT count(*) as total
|
|
FROM(
|
|
SELECT T_OrderHeaderID
|
|
FROM t_orderheader
|
|
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_OrderDetailIsActive = 'Y'
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsPrice = 'Y'
|
|
JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
|
WHERE
|
|
Nat_TestCode IN ('10634900','10635000','10813100') AND
|
|
$where $filter_company
|
|
group by T_OrderHeaderID
|
|
)x";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
|
|
|
|
$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 *
|
|
FROM (
|
|
SELECT T_OrderHeaderID,
|
|
IFNULL(T_OrderHeaderFoNote,'') as note,
|
|
T_OrderHeaderLabNumber,
|
|
M_PatientNoReg,
|
|
concat(M_TitleName,'. ',M_PatientName) as patient_fullname,
|
|
M_CompanyName,
|
|
DATE(T_OrderHeaderDate) as order_date,
|
|
T_TestName as test,
|
|
Nat_TestID,
|
|
T_TestSasCode,
|
|
T_OrderHeaderLabNumberExt as external_numbering,
|
|
IFNULL(LetterOtherID,0) as xid,
|
|
IFNULL(LetterOtherPekerjaan,'') as pekerjaan,
|
|
IFNULL(LetterOtherNumber,'') as xnumber
|
|
FROM t_orderheader
|
|
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_OrderDetailIsActive = 'Y'
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsPrice = 'Y'
|
|
JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
|
LEFT JOIN letter_other ON LetterOtherT_OrderHeaderID = T_OrderHeaderID AND LetterOtherNat_TestID = Nat_TestID AND
|
|
LetterOtherIsActive = 'Y'
|
|
WHERE
|
|
Nat_TestCode IN ('10634900','10635000','10813100') AND
|
|
$where $filter_company
|
|
group by T_OrderHeaderID
|
|
) x
|
|
ORDER BY T_OrderHeaderID ASC
|
|
limit $number_limit offset $number_offset
|
|
";
|
|
//echo $sql;
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$rows = $query->result_array();
|
|
|
|
//print_r($rows);
|
|
|
|
$result = array("total" => $tot_page,"total_all"=>$tot_count, "total_filter"=>count($rows),"records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
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'] == '')
|
|
{
|
|
|
|
$rows = array(array('id'=>0,'name'=>'Semua'));
|
|
$result = array("total" => 1, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
$sql = "
|
|
SELECT M_CompanyID as id, M_CompanyName as name
|
|
FROM m_company
|
|
WHERE
|
|
M_CompanyName like ?
|
|
AND M_CompanyIsActive = 'Y'
|
|
ORDER BY M_CompanyName DESC
|
|
";
|
|
$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;
|
|
}
|
|
}
|
|
}
|
|
|
|
function searchdoctor(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] == '')
|
|
{
|
|
|
|
$rows = array(array('id'=>0,'name'=>'Semua'));
|
|
$result = array("total" => 1, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
$sql = "
|
|
SELECT M_DoctorID as id, M_DoctorCode as code,CONCAT(M_DoctorPrefix,M_DoctorPrefix2,' ',M_DoctorName,' ',M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
|
FROM m_doctor
|
|
WHERE
|
|
M_DoctorName like ?
|
|
AND M_DoctorIsActive = 'Y'
|
|
ORDER BY M_DoctorName ASC, M_DoctorName DESC
|
|
";
|
|
//echo $sql;
|
|
$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;
|
|
}
|
|
}
|
|
}
|
|
|
|
function lookup_promises(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$xuserid = $this->sys_user['M_UserID'];
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "
|
|
SELECT T_OrderPromiseID as id,
|
|
DATE_FORMAT(T_OrderPromiseDateTime,'%d%m%Y') as xdate,
|
|
TIME_FORMAT(T_OrderPromiseDateTime,'%H%i') as xtime,
|
|
GROUP_CONCAT(T_TestName SEPARATOR ' , ') as tests
|
|
FROM t_orderdetail
|
|
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
|
WHERE
|
|
T_OrderDetailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND T_OrderDetailIsActive = 'Y'
|
|
GROUP BY T_OrderPromiseID
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql)->result_array();
|
|
if (!$query) {
|
|
$this->sys_error_db("f_paymentdetail delete");
|
|
exit;
|
|
}
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $query
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function lookup_barcodes()
|
|
{
|
|
try {
|
|
$prm = $this->sys_input;
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$sql = "SELECT T_BarcodeLabID as id,
|
|
'barcode' as type,
|
|
T_SampleTypeID,
|
|
T_BarcodeLabID,
|
|
T_BarcodeLabBarcode,
|
|
T_BarcodeLabT_OrderHeaderID as orderid,
|
|
T_BarcodeLabCounter,
|
|
T_SampleTypeName,
|
|
'N' as chex
|
|
FROM t_barcodelab
|
|
JOIN t_sampletype ON T_BarcodeLabT_SampleTypeID = T_SampleTypeID
|
|
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
|
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationIsNonLab = ''
|
|
WHERE
|
|
T_BarcodeLabT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND T_BarcodeLabIsActive = 'Y'
|
|
UNION
|
|
SELECT T_OrderHeaderID as id, 'formulir' as type, 0 as T_SampleTypeID,0 as T_BarcodeLabID,T_OrderHeaderLabNumber as T_BarcodeLabBarcode,{$prm['T_OrderHeaderID']}, 1, 'Formulir' as T_SampleTypeName, 'N' as chex
|
|
FROM t_orderheader
|
|
WHERE
|
|
T_OrderHeaderID = {$prm['T_OrderHeaderID']}
|
|
UNION
|
|
SELECT T_TestID as id,
|
|
'nonlab' as type,
|
|
T_OrderDetailID as detail_id,
|
|
'' as xxx,
|
|
'-' as T_BarcodeLabBarcode,
|
|
T_OrderHeaderID as order_id,
|
|
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as order_date,
|
|
T_TestName as T_SampleTypeName,
|
|
'N' as chex
|
|
FROM t_orderheader
|
|
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
|
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
|
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName <> 'lab'
|
|
WHERE
|
|
T_OrderHeaderID = {$prm['T_OrderHeaderID']}
|
|
GROUP BY T_TestID
|
|
UNION
|
|
SELECT T_OrderDetailID as id,
|
|
'nonlab_group' as type,
|
|
T_OrderDetailID as detail_id,
|
|
'' as xxx,
|
|
GROUP_CONCAT(T_TestName separator ' , ') as T_BarcodeLabBarcode,
|
|
T_OrderHeaderID as order_id,
|
|
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as order_date,
|
|
'Amplop Besar' as T_SampleTypeName,
|
|
'N' as chex
|
|
FROM t_orderheader
|
|
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
|
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
|
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName <> 'lab'
|
|
WHERE
|
|
T_OrderHeaderID = {$prm['T_OrderHeaderID']}
|
|
GROUP BY T_OrderHeaderID
|
|
";
|
|
//echo $sql;
|
|
|
|
$rows = $this->db_onedev->query($sql)->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
}
|
|
}
|
|
$result = array ("total" => 0, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function getdatadob()
|
|
{
|
|
try {
|
|
$prm = $this->sys_input;
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$status = 'N';
|
|
$sql = "SELECT COUNT(*) as xcount
|
|
FROM t_ordersample
|
|
WHERE
|
|
T_OrderSampleT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
|
T_OrderSampleReceive = 'Y' AND
|
|
T_OrderSampleIsActive = 'Y'";
|
|
$c_sampling = $this->db_onedev->query($sql)->row()->xcount;
|
|
if($c_sampling > 0){
|
|
$status = 'Y';
|
|
}
|
|
$sql = "SELECT m_patient.*, DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as dob
|
|
FROM m_patient
|
|
WHERE
|
|
M_PatientNoReg = '{$prm['M_PatientNoReg']}'";
|
|
//echo $sql;
|
|
$row = $this->db_onedev->query($sql)->row_array();
|
|
$result = array ("total"=>0,"records"=>$row,"status"=>$status);
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function saveformletter(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$xuserid = $this->sys_user['M_UserID'];
|
|
$prm = $this->sys_input;
|
|
$xid = $prm['xid'];
|
|
if($xid == '0'){
|
|
$sql = "INSERT INTO letter_other (
|
|
LetterOtherT_OrderHeaderID,
|
|
LetterOtherNat_TestID,
|
|
LetterOtherPekerjaan,
|
|
LetterOtherT_TestSasCode,
|
|
LetterOtherNumber,
|
|
LetterOtherUserID,
|
|
LetterOtherCreated
|
|
)
|
|
VALUES(
|
|
{$prm['T_OrderHeaderID']},
|
|
{$prm['Nat_TestID']},
|
|
'{$prm['pekerjaan']}',
|
|
'{$prm['T_TestSasCode']}',
|
|
'{$prm['xnumber']}',
|
|
{$xuserid},
|
|
NOW()
|
|
)";
|
|
}
|
|
else{
|
|
$sql = "UPDATE letter_other SET
|
|
LetterOtherT_OrderHeaderID = {$prm['T_OrderHeaderID']},
|
|
LetterOtherNat_TestID = {$prm['Nat_TestID']},
|
|
LetterOtherPekerjaan = '{$prm['pekerjaan']}',
|
|
LetterOtherNumber = '{$prm['xnumber']}',
|
|
LetterOtherT_TestSasCode = '{$prm['T_TestSasCode']}',
|
|
LetterOtherUserID = {$xuserid}
|
|
WHERE
|
|
LetterOtherID = {$xid}
|
|
";
|
|
}
|
|
$this->db_onedev->query($sql);
|
|
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $prm
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
function updatedob(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$xuserid = $this->sys_user['M_UserID'];
|
|
$prm = $this->sys_input;
|
|
$x_dob = $prm['dob'];
|
|
//$x_dob = str_replace("-","",$x_dob);
|
|
$updated_dob = substr($x_dob, 0,2).'-'.substr($x_dob, 2,2).'-'.substr($x_dob, 4,4);
|
|
$xxdob = date("Y-m-d", strtotime($updated_dob));
|
|
|
|
$sql = "SELECT * FROM m_patient WHERE M_PatientID = {$prm['M_PatientID']}";
|
|
$old_patient = $this->db_onedev->query($sql)->row_array();
|
|
|
|
$old_dob = date("Y-m-d", strtotime($old_patient['M_PatientDOB']));
|
|
$x_json = json_encode(
|
|
array(
|
|
'old' => array('id' => $old_patient['M_PatientID'],'name'=> $old_dob),
|
|
'new' => array('id' => $prm['M_PatientID'],'name'=> $xxdob)
|
|
)
|
|
);
|
|
|
|
if($prm['status'] == 'N'){
|
|
$sql = "UPDATE m_patient SET M_PatientDOB = '{$xxdob}'
|
|
WHERE
|
|
M_PatientID = {$prm['M_PatientID']}";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
|
|
$sql = "CALL sp_recount_age({$prm['orderid']})";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
|
|
$log_attr_type = 'change_dob';
|
|
}
|
|
else{
|
|
$sql = "UPDATE m_patient SET M_PatientDOB = '{$xxdob}'
|
|
WHERE
|
|
M_PatientID = {$prm['M_PatientID']}";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
$sql = "UPDATE t_orderheaderaddon SET
|
|
T_OrderHeaderAddOnRequestDOB = '{$xxdob}',
|
|
T_OrderHeaderAddOnRequestChangeDOB = '{$prm['status']}'
|
|
WHERE
|
|
T_OrderHeaderAddOnT_OrderHeaderID = {$prm['orderid']}";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
|
|
$log_attr_type = 'req_change_dob';
|
|
}
|
|
|
|
$sql = "INSERT INTO order_attr (
|
|
orderAttrT_OrderHeaderID,
|
|
orderAttrType,
|
|
orderAttrJson,
|
|
orderAttrUserID
|
|
)
|
|
VALUES(
|
|
{$prm['orderid']},
|
|
'{$log_attr_type}',
|
|
'{$x_json}',
|
|
'{$xuserid}'
|
|
)";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $prm
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
function gettimelinedelivery(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
|
|
//# ambil parameter input
|
|
$xuserid = $this->sys_user['M_UserID'];
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "
|
|
SELECT * FROM (
|
|
SELECT CONCAT('dibuat spk : ',Result_CourierSPKNumbering) as status,
|
|
DATE_FORMAT(Result_CourierDetailStepByStepLastUpdated,'%d.%m.%Y %H:%i') as xtime,
|
|
M_UserUsername as username,
|
|
'' as xperson,
|
|
'' as xnote,
|
|
Result_CourierSPKDetailID as xid
|
|
FROM result_courierspk_detail_step_by_step
|
|
JOIN result_courierspk_detail ON Result_CourierDetailStepByStepResult_CourierSPKDetailID = Result_CourierSPKDetailID
|
|
JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
|
JOIN m_user ON Result_CourierDetailStepByStepUserID = M_UserID
|
|
WHERE
|
|
Result_CourierSPKDetailT_OrderDeliveryID = {$prm['xid']} AND
|
|
Result_CourierDetailStepByStepStatus = 'N'
|
|
UNION
|
|
SELECT CONCAT('dikonfirmasi spv : ',Result_CourierSPKNumbering) as status,
|
|
DATE_FORMAT(Result_CourierDetailStepByStepLastUpdated,'%d.%m.%Y %H:%i') as xtime,
|
|
M_UserUsername as username,
|
|
'' as xperson,
|
|
'' as xnote,
|
|
Result_CourierSPKDetailID as xid
|
|
FROM result_courierspk_detail_step_by_step
|
|
JOIN result_courierspk_detail ON Result_CourierDetailStepByStepResult_CourierSPKDetailID = Result_CourierSPKDetailID
|
|
JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
|
JOIN m_user ON Result_CourierDetailStepByStepUserID = M_UserID
|
|
WHERE
|
|
Result_CourierSPKDetailT_OrderDeliveryID = {$prm['xid']} AND
|
|
Result_CourierDetailStepByStepStatus = 'O'
|
|
UNION
|
|
SELECT 'dikonfirmasi spv' as status,
|
|
DATE_FORMAT(Result_CourierDetailStepByStepLastUpdated,'%d.%m.%Y %H%i') as xtime,
|
|
M_UserUsername as username,
|
|
'' as xperson,
|
|
'' as xnote,
|
|
Result_CourierSPKDetailID as xid
|
|
FROM result_courierspk_detail_step_by_step
|
|
JOIN result_courierspk_detail ON Result_CourierDetailStepByStepResult_CourierSPKDetailID = Result_CourierSPKDetailID
|
|
JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
|
JOIN m_user ON Result_CourierDetailStepByStepUserID = M_UserID
|
|
WHERE
|
|
Result_CourierSPKDetailT_OrderDeliveryID = {$prm['xid']} AND
|
|
Result_CourierDetailStepByStepStatus = 'X'
|
|
UNION
|
|
SELECT CONCAT('diserahkan ke kurir : ',Result_CourierSPKNumbering) as status,
|
|
DATE_FORMAT(Result_CourierDetailStepByStepLastUpdated,'%d.%m.%Y %H:%i') as xtime,
|
|
M_UserUsername as username,
|
|
'' as xperson,
|
|
'' as xnote,
|
|
Result_CourierSPKDetailID as xid
|
|
FROM result_courierspk_detail_step_by_step
|
|
JOIN result_courierspk_detail ON Result_CourierDetailStepByStepResult_CourierSPKDetailID = Result_CourierSPKDetailID
|
|
JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
|
JOIN m_user ON Result_CourierDetailStepByStepUserID = M_UserID
|
|
WHERE
|
|
Result_CourierSPKDetailT_OrderDeliveryID = {$prm['xid']} AND
|
|
Result_CourierDetailStepByStepStatus = 'S'
|
|
UNION
|
|
SELECT CONCAT('selesai : ',Result_CourierSPKNumbering) as status,
|
|
DATE_FORMAT(Result_CourierDetailStepByStepLastUpdated,'%d.%m.%Y %H:%i') as xtime,
|
|
M_UserUsername as username,
|
|
Result_CourierComingHomeDetailsReceiver as xperson,
|
|
UPPER(M_CourierStatusReceiveName) as xnote,
|
|
Result_CourierSPKDetailID as xid
|
|
FROM result_courierspk_detail_step_by_step
|
|
JOIN result_courierspk_detail ON Result_CourierDetailStepByStepResult_CourierSPKDetailID = Result_CourierSPKDetailID
|
|
JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
|
JOIN result_couriercominghome_details ON Result_CourierComingHomeDetailsResult_CourierSPKDetailID = Result_CourierSPKDetailID
|
|
JOIN m_user ON Result_CourierDetailStepByStepUserID = M_UserID
|
|
JOIN m_courierstatusreceive ON Result_CourierComingHomeDetailsM_CourierStatusReceiveID = M_CourierStatusReceiveID
|
|
WHERE
|
|
Result_CourierSPKDetailT_OrderDeliveryID = {$prm['xid']} AND
|
|
Result_CourierDetailStepByStepStatus = 'D'
|
|
) x
|
|
GROUP BY xid,status
|
|
ORDER BY xtime ASC
|
|
|
|
";
|
|
//echo $sql;
|
|
$rst = $this->db_onedev->query($sql)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $rst
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
}
|