733 lines
22 KiB
PHP
733 lines
22 KiB
PHP
<?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);
|
|
}
|
|
|
|
|
|
function add_verifications_label($orderid){
|
|
$query = " SELECT Result_VerificationsID as id,
|
|
IFNULL(Result_VerificationsValueID,0) as xid,
|
|
IFNULL(Result_VerificationsValueCheck,'N') as chex,
|
|
IF(ISNULL(Result_VerificationsValueID),'',Result_VerificationsValueNote) as note,
|
|
Result_VerificationsLabel as label
|
|
FROM result_verifications
|
|
LEFT JOIN result_verifications_value ON Result_VerificationsValueResult_VerificationsID = Result_VerificationsID AND
|
|
Result_VerificationsValueSo_ResultEntryID = $orderid
|
|
WHERE
|
|
Result_VerificationIsActive = 'Y'
|
|
GROUP BY Result_VerificationsID
|
|
";
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$nolab = $prm["nolab"];
|
|
$nama = $prm["name"];
|
|
//$startdate = $prm["startdate"];
|
|
//$enddate = $prm["enddate"];
|
|
$groupid = 3;
|
|
$subgroupid = $prm["subgroupid"];
|
|
$join_group = '';
|
|
|
|
if(!isset($prm['current_page']))
|
|
$prm['current_page'] = 1;
|
|
|
|
$sql_where = "";
|
|
$number_limit = 20;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
//$sql_param = array();
|
|
if ($nolab != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " T_OrderHeaderLabNumber like '%$nolab%' ";
|
|
}
|
|
|
|
if ($nama != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " M_PatientName like '%$nama%' ";
|
|
}
|
|
|
|
if($sql_where != "")
|
|
$sql_where = "WHERE ".$sql_where;
|
|
|
|
/*$sql = " SELECT count(*) as total
|
|
FROM (
|
|
SELECT Result_FrontOfficeID as xid,
|
|
T_OrderHeaderID as orderid,
|
|
T_OrderHeaderLabNumber as ordernumber,
|
|
UPPER(CONCAT(M_TitleName,' ',M_PatientName)) as patient_fullname,
|
|
Result_FrontOfficeTestName as test_name,
|
|
'N' as chex,
|
|
M_StaffName
|
|
FROM result_frontoffice
|
|
JOIN result_frontoffice_by_step ON Result_FrontOfficeByStepResult_FrontOfficeID = Result_FrontOfficeID AND
|
|
Result_FrontOfficeByStepStatus = 'R'
|
|
JOIN m_user ON Result_FrontOfficeByStepUserID = M_UserID
|
|
JOIN m_staff ON M_UserM_StaffID = M_StaffID
|
|
join t_orderheader ON Result_FrontOfficeT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND JSON_CONTAINS(Result_FrontOfficeIds, T_OrderDetailID)
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
$sql_where
|
|
GROUP BY Result_FrontOfficeID
|
|
) x";
|
|
|
|
$query = $this->db_onedev->query($sql);
|
|
$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("m_doctor count", $this->db_onedev);
|
|
exit;
|
|
}*/
|
|
|
|
$sql = "SELECT Result_FrontOfficeID as xid,
|
|
T_OrderHeaderID as orderid,
|
|
T_OrderHeaderLabNumber as ordernumber,
|
|
UPPER(CONCAT(M_TitleName,' ',M_PatientName)) as patient_fullname,
|
|
Result_FrontOfficeTestName as test_name,
|
|
'N' as chex,
|
|
T_OrderHeaderIsCito as iscito,
|
|
'' as sent_by,
|
|
'' as received_by
|
|
FROM result_frontoffice
|
|
JOIN result_frontoffice_by_step ON Result_FrontOfficeByStepResult_FrontOfficeID = Result_FrontOfficeID AND
|
|
Result_FrontOfficeByStepStatus = 'R'
|
|
JOIN m_user ON Result_FrontOfficeByStepUserID = M_UserID
|
|
join t_orderheader ON Result_FrontOfficeT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND JSON_CONTAINS(Result_FrontOfficeIds, T_OrderDetailID)
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
$sql_where
|
|
GROUP BY Result_FrontOfficeID
|
|
ORDER BY Result_FrontOfficeLastUpdated DESC
|
|
LIMIT 20
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$sql = "SELECT Result_FrontOfficeID as xid,
|
|
DATE_FORMAT(Result_FrontOfficeByStepDateTime,'%d-%m-%Y %H:%i') as xdatetime,
|
|
M_StaffName
|
|
FROM result_frontoffice
|
|
JOIN result_frontoffice_by_step ON Result_FrontOfficeByStepResult_FrontOfficeID = Result_FrontOfficeID AND
|
|
Result_FrontOfficeByStepStatus = 'S'
|
|
JOIN m_user ON Result_FrontOfficeByStepUserID = M_UserID
|
|
JOIN m_staff ON M_UserM_StaffID = M_StaffID
|
|
WHERE Result_FrontOfficeID = {$v['xid']}
|
|
ORDER BY Result_FrontOfficeByStepID DESC
|
|
LIMIT 1 ";
|
|
//echo $sql;
|
|
$xrst = $this->db_onedev->query($sql)->row();
|
|
$rows[$k]['send_by'] = $xrst;
|
|
$sql = "SELECT Result_FrontOfficeID as xid,
|
|
DATE_FORMAT(Result_FrontOfficeByStepDateTime,'%d-%m-%Y %H:%i') as xdatetime,
|
|
M_StaffName
|
|
FROM result_frontoffice
|
|
JOIN result_frontoffice_by_step ON Result_FrontOfficeByStepResult_FrontOfficeID = Result_FrontOfficeID AND
|
|
Result_FrontOfficeByStepStatus = 'R'
|
|
JOIN m_user ON Result_FrontOfficeByStepUserID = M_UserID
|
|
JOIN m_staff ON M_UserM_StaffID = M_StaffID
|
|
WHERE Result_FrontOfficeID = {$v['xid']}
|
|
ORDER BY Result_FrontOfficeByStepID DESC
|
|
LIMIT 1 ";
|
|
|
|
$xrst = $this->db_onedev->query($sql)->row();
|
|
$rows[$k]['received_by'] = $xrst;
|
|
}
|
|
}
|
|
|
|
$result = array("total" => 0, "records" => $rows, "sql"=> '');
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
try {
|
|
$xprm = $this->sys_input;
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$xuserid = $this->sys_user['M_UserID'];
|
|
//# ambil parameter input
|
|
|
|
//print_r($xprm);
|
|
$prm = $xprm['patient'];
|
|
$xstatus = $xprm['act'];
|
|
$fostatusid = 3;
|
|
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
|
$id = $prm['T_OrderHeaderID'];
|
|
echo $xstatus;
|
|
if($xstatus == 'N'){
|
|
$fostatusid = 4;
|
|
$fologcode = 'FO.VERIFICATION.REJECT';
|
|
}else{
|
|
|
|
$this->save_barcode_new($id);
|
|
}
|
|
|
|
|
|
//print_r($prm);
|
|
$xverificationnote = $prm['verification_note'];
|
|
//echo $xverificationnote;
|
|
|
|
$sql = "update t_orderheader
|
|
set
|
|
T_OrderHeaderVerificationNote = '{$xverificationnote}'
|
|
where
|
|
T_OrderHeaderID = $id";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
|
|
/*$xverification_patient = $this->saveverifications($id,$prm['verification_patient'],'PATIENT',$xuserid);
|
|
$xverification_doctor = $this->saveverifications($id,$prm['verification_doctor'],'DOCTOR',$xuserid);
|
|
$xverification_companymou = $this->saveverifications($id,$prm['verification_companymou'],'COMPANY',$xuserid);
|
|
$xverification_payment = $this->saveverifications($id,$prm['verification_payment'],'PAYMENT',$xuserid);
|
|
$xverification_info = $this->saveverifications($id,$prm['verification_info'],'INFO',$xuserid);
|
|
|
|
$xverification_delivery = $this->saveverification_delivery($id,$prm['verification_delivery'],$xuserid);
|
|
$xverification_px = $this->saveverification_px($id,$prm['verification_px'],$xuserid);*/
|
|
|
|
$sql = "insert into fo_status(
|
|
Fo_StatusDate,
|
|
Fo_StatusT_OrderHeaderID,
|
|
Fo_StatusM_StatusID,
|
|
Fo_StatusM_UserID,
|
|
Fo_StatusCreated,
|
|
Fo_StatusUpdated)
|
|
values( now(), ?, ?, ?, now(),now())";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$id,
|
|
$fostatusid,
|
|
$xuserid
|
|
)
|
|
);
|
|
|
|
if (!$query) {
|
|
$this->sys_error_db("fo_status insert");
|
|
exit;
|
|
}
|
|
|
|
|
|
$data_log = array();
|
|
$data_log['orderid'] = $id;
|
|
/*$data_log['verification_patient'] = $prm['verification_patient'];
|
|
$data_log['verification_doctor'] = $prm['verification_doctor'];
|
|
$data_log['verification_companymou'] = $prm['verification_companymou'];
|
|
$data_log['verification_payment'] = $prm['verification_payment'];
|
|
$data_log['verification_info'] = $prm['verification_info'];
|
|
$data_log['verification_px'] = $prm['verification_px'];
|
|
$data_log['verification_delivery'] = $prm['verification_delivery'];*/
|
|
|
|
$json_dt_log = json_encode($data_log);
|
|
$sql = "insert into one_log.log_fo(
|
|
Log_FoDate,
|
|
Log_FoCode,
|
|
Log_FoJson,
|
|
Log_FoUserID)
|
|
values( now(), ?, ?, ?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$fologcode,
|
|
$json_dt_log,
|
|
$xuserid
|
|
)
|
|
);
|
|
|
|
if (!$query) {
|
|
$this->sys_error_db("one_log.fo_log insert");
|
|
exit;
|
|
}
|
|
|
|
if($xstatus == 'Y'){
|
|
$msg = 'Verifikasi berhasil dilakukan';
|
|
}
|
|
else{
|
|
$msg = 'Tolak Verifikasi berhasil dilakukan';
|
|
$sql = "INSERT INTO t_ordermessage (
|
|
T_OrderMessageT_OrderHeaderID,
|
|
T_OrderMessageType,
|
|
T_OrderMessageMessage,
|
|
T_OrderMessageFromUserID,
|
|
T_OrderMessageCreated,
|
|
T_OrderMessageLastUpdated
|
|
)
|
|
VALUES(
|
|
{$id},
|
|
'FO.VERIFICATION.REJECT',
|
|
'{$xverificationnote}',
|
|
{$xuserid},
|
|
NOW(),
|
|
NOW()
|
|
)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("one_log.t_ordermessage insert");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
$rows = array('message'=>$msg);
|
|
$result = array ("total" => 0, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
|
|
function save_barcode_new($orderid){
|
|
$xuserid = $this->sys_user['M_UserID'];
|
|
|
|
$query =" SELECT T_SampleTypeID as id,
|
|
T_SampleTypeName as name,
|
|
'' as children
|
|
FROM t_orderheader
|
|
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
WHERE
|
|
T_OrderHeaderID = {$orderid}
|
|
GROUP BY T_SampleTypeID
|
|
";
|
|
//echo $query ;
|
|
$barcodes = $this->db_onedev->query($query)->result();
|
|
foreach($barcodes as $k => $v){
|
|
$query = "SELECT T_SampleTypeID as id, IFNULL(T_BarcodeLabID,0) as xid,
|
|
IF(ISNULL(T_BarcodeLabID),'Y',T_BarcodeLabIsActive) as chex,
|
|
T_TestName as testname,
|
|
T_SampleTypeName as samplename,
|
|
IF(ISNULL(T_BarcodeLabID),CONCAT(T_OrderHeaderLabNumber,'.',T_SampleTypeID,'.',1),T_BarcodeLabBarcode) as barcodenumber
|
|
FROM t_orderdetail
|
|
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
LEFT JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
|
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
|
WHERE
|
|
T_OrderDetailT_OrderHeaderID = {$orderid} AND T_SampleTypeID = {$v->id}
|
|
GROUP BY T_BarcodeLabID ";
|
|
$v->children = $this->db_onedev->query($query)->result_array();
|
|
//$v->children = $barcode_data;
|
|
foreach($v->children as $ki => $vi){
|
|
if($vi['chex'] == 'N')
|
|
$v->children[$ki]['chex'] = false;
|
|
else
|
|
$v->children[$ki]['chex'] = true;
|
|
$sql = "insert into t_barcodelab(
|
|
T_BarcodeLabT_OrderHeaderID,
|
|
T_BarcodeLabBarcode,
|
|
T_BarcodeLabT_SampleTypeID,
|
|
T_BarcodeLabCreated,
|
|
T_BarcodeLabLastUpdated,
|
|
T_BarcodeLabUserID)
|
|
values( ?, ?, ?, now(),now(),?)";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$orderid,
|
|
$v->children[$ki]['barcodenumber'],
|
|
$v->children[$ki]['id'],
|
|
$xuserid
|
|
)
|
|
);
|
|
// echo $this->db_onedev->last_query();
|
|
if (!$query) {
|
|
$this->sys_error_db("t_barcodelab insert");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
//insert log
|
|
$supplies = array();
|
|
$query =" SELECT M_SuppliesID as id,
|
|
IFNULL(T_OrderSuppliesID,0) as xid,
|
|
IF(ISNULL(T_OrderSuppliesID),'N',T_OrderSuppliesIsActive) as chex,
|
|
IFNULL(T_OrderSuppliesQty,1) as qty,
|
|
M_SuppliesName as name,
|
|
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as lastupdated,
|
|
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as tx_lastupdated
|
|
FROM m_supplies
|
|
JOIN t_ordersupplies ON T_OrderSuppliesT_OrderHeaderID = $orderid AND T_OrderSuppliesM_SuppliesID = M_SuppliesID
|
|
WHERE
|
|
M_SuppliesIsActive = 'Y'
|
|
";
|
|
//echo $query ;
|
|
$supplies = $this->db_onedev->query($query)->result_array();
|
|
|
|
foreach($supplies as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$supplies[$k]['chex'] = false;
|
|
else
|
|
$supplies[$k]['chex'] = true;
|
|
}
|
|
|
|
$dt_log = array('orderid'=>$orderid,'supplies'=>$supplies,'barcode'=>$barcodes);
|
|
$fologcode = 'FO.Verification.BarcodeSupplies';
|
|
$json_dt_log = json_encode($dt_log);
|
|
$sql = "insert into one_log.log_supplies_barcode(
|
|
Log_SuppliesBarcodeDate,
|
|
Log_SuppliesBarcodeCode,
|
|
Log_SuppliesBarcodeJson,
|
|
Log_SuppliesBarcodeUserID)
|
|
values( now(), ?, ?, ?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$fologcode,
|
|
$json_dt_log,
|
|
$xuserid
|
|
)
|
|
);
|
|
|
|
if (!$query) {
|
|
$this->sys_error_db("one_log.log_supplies_barcode insert");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function saveverifications($id,$verifications,$type,$userid)
|
|
{
|
|
try {
|
|
//$xverificationtypeid = $this->db_onedev->query("SELECT * FROM fo_verificationtype WHERE Fo_VerificationTypeGroup = '{$type}' AND Fo_VerificationTypeIsActive = 'Y'")->row()->Fo_VericationTypeID;
|
|
//echo $xverificationtypeid;
|
|
//print_r($verifications);
|
|
foreach($verifications as $k => $v){
|
|
//print_r($v);
|
|
if(intval($v['xid']) == 0){
|
|
$sql = "insert into fo_verification(
|
|
Fo_VerificationT_OrderHeaderID,
|
|
Fo_VerificationFo_VericationTypeID,
|
|
Fo_VerificationIsOK,
|
|
Fo_VerificationReason,
|
|
Fo_VerificationCreated,
|
|
Fo_VerificationLastUpdated,
|
|
Fo_VerificationUserID)
|
|
values( ?, ?, ?, ?, now(),now(),?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$id,
|
|
$v['id'],
|
|
$v['chex'] == true ?'Y':'N',
|
|
$v['note'],
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("fo_verification insert");
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function saveverification_delivery($id,$deliveries,$userid)
|
|
{
|
|
try {
|
|
foreach($deliveries as $k => $v){
|
|
if($v['id'] === 0){
|
|
$sql = "insert into fo_verification_delivery_add(
|
|
Fo_VerificationDeliveryAddT_OrderHeaderID,
|
|
Fo_VerificationDeliveryAddM_DeliveryID,
|
|
Fo_VerificationDeliveryAddM_DeliveryTypeID,
|
|
Fo_VerificationDeliveryAddDestination,
|
|
Fo_VerificationDeliveryAddAddressID,
|
|
Fo_VerificationDeliveryAddM_KelurahanID,
|
|
Fo_VerificationDeliveryAddOK,
|
|
Fo_VerificationDeliveryAddReason,
|
|
Fo_VerificationDeliveryAddCreated,
|
|
Fo_VerificationDeliveryAddLastUpdated,
|
|
Fo_VerificationDeliveryAddUserID)
|
|
values( ?, ?, ?, ?,?,?,?,?, now(),now(),?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$id,
|
|
$v['deliveryid'],
|
|
$v['typedeliveryid'],
|
|
$v['destination'],
|
|
$v['addressid'],
|
|
$v['vilageid'],
|
|
$v['chex'] == true ?'Y':'N',
|
|
$v['note'],
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
echo $this->db_onedev->last_query();
|
|
$this->sys_error_db("fo_verification_delivery_add insert");
|
|
exit;
|
|
}
|
|
|
|
}else{
|
|
$sql = "insert into fo_verification_delivery(
|
|
Fo_VerificationDeliveryT_OrderHeaderID,
|
|
Fo_VerificationDeliveryT_OrderDeliveryID,
|
|
Fo_VerificationDeliveryIsOK,
|
|
Fo_VerificationDeliveryReason,
|
|
Fo_VerificationDeliveryCreated,
|
|
Fo_VerificationDeliveryLastUpdated,
|
|
Fo_VerificationDeliveryUserID)
|
|
values( ?, ?, ?, ?, now(),now(),?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$id,
|
|
$v['id'],
|
|
$v['chex'] == true ?'Y':'N',
|
|
$v['note'],
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
echo $this->db_onedev->last_query();
|
|
$this->sys_error_db("fo_verification_delivery insert");
|
|
exit;
|
|
}
|
|
//echo $this->db_onedev->last_query();
|
|
}
|
|
}
|
|
return true;
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
|
|
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_BarcodeLabID,T_BarcodeLabBarcode, T_BarcodeLabCounter, T_SampleTypeName, 'N' as chex
|
|
FROM t_barcodelab
|
|
JOIN t_sampletype ON T_BarcodeLabT_SampleTypeID = T_SampleTypeID
|
|
WHERE
|
|
T_BarcodeLabT_OrderHeaderID = {$prm['ohid']} AND T_BarcodeLabIsActive = 'Y'
|
|
UNION
|
|
SELECT T_OrderHeaderID as id, 'formulir' as type, 0,T_OrderHeaderLabNumber as T_BarcodeLabBarcode, 1, 'Formulir' as T_SampleTypeName, 'N' as chex
|
|
FROM t_orderheader
|
|
WHERE
|
|
T_OrderHeaderID = {$prm['ohid']}
|
|
";
|
|
//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 saveverification_px($id,$pxs,$userid)
|
|
{
|
|
try {
|
|
foreach($pxs as $k => $v){
|
|
|
|
if(intval($v['id']) == 0){
|
|
$cxh = $v['chex'] == true ?'Y':'N';
|
|
$sql = "insert into fo_verification_test_add(
|
|
Fo_VerificationTestAddT_OrderHeaderID,
|
|
Fo_VerificationTestAddT_TestID,
|
|
Fo_VerificationTestAddBruto,
|
|
Fo_VerificationTestAddDiscount,
|
|
Fo_VerificationTestAddTotal,
|
|
Fo_VerificationTestAddIsOK,
|
|
Fo_VerificationTestAddIsCito,
|
|
Fo_VerificationTestAddCreated,
|
|
Fo_VerificationTestAddLastUpdated,
|
|
Fo_VerificationTestAddUserID)
|
|
values( $id, {$v['pxid']}, {$v['bruto']}, {$v['discount']},{$v['total']},'{$cxh}','{$v['flagcito']}',now(),now(),{$userid})";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
//echo $this->db_onedev->last_query();
|
|
if (!$query) {
|
|
$this->sys_error_db("fo_verification_test_add insert");
|
|
exit;
|
|
}
|
|
}else{
|
|
$sql = "insert into fo_verification_test(
|
|
Fo_VerificationTestT_OrderHeaderID,
|
|
Fo_VerificationTestT_OrderDetailID,
|
|
Fo_VerificationTestIsOK,
|
|
Fo_VerificationTestReason,
|
|
Fo_VerificationTestCreated,
|
|
Fo_VerificationTestLastUpdated,
|
|
Fo_VerificationTestUserID)
|
|
values( ?, ?, ?, ?, now(),now(),?)";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$id,
|
|
$v['id'],
|
|
$v['chex'] == true ?'Y':'N',
|
|
$v['note'],
|
|
$userid
|
|
)
|
|
);
|
|
//echo $this->db_onedev->last_query();
|
|
if (!$query) {
|
|
$this->sys_error_db("fo_verification_test insert");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
return true;
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function verify(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$xstatus = $prm['act'];
|
|
if($xstatus == 'Y'){
|
|
$msg = "Berhasil melakukan verifikasi";
|
|
$query =" INSERT INTO result_verifications_value (
|
|
Result_VerificationsValueSo_ResultEntryID,
|
|
Result_VerificationsValueResult_VerificationsID,
|
|
Result_VerificationsValueCheck,
|
|
Result_VerificationsValueNote,
|
|
Result_VerificationsValueUserID,
|
|
Result_VerificationsValueCreated
|
|
)
|
|
SELECT {$prm['trx_id']},
|
|
Result_VerificationsID,
|
|
'Y',
|
|
'',
|
|
{$userid},
|
|
NOW()
|
|
FROM result_verifications
|
|
WHERE
|
|
Result_VerificationIsActive = 'Y'
|
|
ON DUPLICATE KEY UPDATE
|
|
Result_VerificationsValueCheck = 'Y',
|
|
Result_VerificationsValueNote = '',
|
|
Result_VerificationsValueUserID = {$userid},
|
|
Result_VerificationsValueLastUpdated = NOW()
|
|
";
|
|
//echo $query;
|
|
$this->db_onedev->query($query);
|
|
$sql = "UPDATE so_resultentry SET So_ResultEntryStatus = 'VAL2' , So_ResultEntryValidation2 = 'Y' WHERE So_ResultEntryID = {$prm['trx_id']}";
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
else{
|
|
$msg = "Tolak untuk perbaikan";
|
|
$verifications = $prm['verifications'];
|
|
foreach($verifications as $k => $v){
|
|
$chx = $v['chex'] == true ?'Y':'N';
|
|
$query =" INSERT INTO result_verifications_value (
|
|
Result_VerificationsValueSo_ResultEntryID,
|
|
Result_VerificationsValueResult_VerificationsID,
|
|
Result_VerificationsValueCheck,
|
|
Result_VerificationsValueNote,
|
|
Result_VerificationsValueUserID,
|
|
Result_VerificationsValueCreated
|
|
)
|
|
values( {$prm['trx_id']},
|
|
{$v['id']},
|
|
'{$chx}',
|
|
'{$v['note']}',
|
|
{$userid},
|
|
NOW()
|
|
)
|
|
ON DUPLICATE KEY UPDATE
|
|
Result_VerificationsValueCheck = '{$chx}',
|
|
Result_VerificationsValueNote = '{$v['note']}',
|
|
Result_VerificationsValueUserID = {$userid},
|
|
Result_VerificationsValueLastUpdated = NOW()
|
|
";
|
|
//echo $query;
|
|
$this->db_onedev->query($query);
|
|
}
|
|
}
|
|
|
|
|
|
$result = array ("total" => 0, "records" => array('status'=>'OK','message'=>$msg));
|
|
$this->sys_ok($result);
|
|
}
|
|
|
|
}
|