986 lines
36 KiB
PHP
986 lines
36 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 getstations()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query = " SELECT T_SampleStationID as id, T_SampleStationName as name
|
|
FROM t_samplestation
|
|
WHERE
|
|
T_SampleStationIsActive = 'Y' AND T_SampleStationIsNonLab = 'OTHERS'
|
|
";
|
|
//echo $query;
|
|
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
|
$rows['statuses'] = array(array('id' => 'NEW', 'name' => 'New'), array('id' => 'DONE', 'name' => 'Done'));
|
|
|
|
$result = array(
|
|
"total" => count($rows),
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getlocation()
|
|
{
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$stationID = $prm['station_id'];
|
|
$rows = [];
|
|
$query = "SELECT M_LocationID AS locationID,
|
|
M_LocationName AS locationName
|
|
FROM m_location
|
|
WHERE M_LocationT_SampleStationID= ?
|
|
AND M_LocationIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$qry = $this->db_onedev->query($query, [$stationID]);
|
|
if (!$qry) {
|
|
$error = array(
|
|
"message" => $this->db_onedev->error()["message"],
|
|
|
|
);
|
|
$this->sys_error($error);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows),
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function scan_patient(){
|
|
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$data_patient = [];
|
|
$sql = "SELECT T_OrderHeaderID,DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y %H:%i') as order_date,
|
|
T_OrderHeaderLabNumber as labnumber,
|
|
T_OrderHeaderM_PatientAge as patient_age,
|
|
M_PatientName as patient_name,
|
|
M_PatientNoReg as noreg,
|
|
IF(M_PatientGender = 'male','Laki-laki','Perempuan') as gender,
|
|
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as dob,
|
|
M_PatientJob as job,
|
|
M_PatientPosisi as posisi,
|
|
IF(M_PatientDivisi = '','-',M_PatientDivisi) as divisi,
|
|
M_PatientHp as hp,
|
|
M_PatientEmail as email,
|
|
M_PatientPhoto as photo,
|
|
T_OrderHeaderID as xid
|
|
FROM t_orderheader
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
|
|
JOIN t_order_location ON T_OrderLocationT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_OrderLocationT_SampleStationID = {$prm['station_id']} AND
|
|
T_OrderLocationIsActive = 'Y' AND T_OrderLocationM_LocationID = {$prm['location_id']}
|
|
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_SamplingSoT_SampleStationID =T_OrderLocationT_SampleStationID AND
|
|
T_SamplingSoIsActive = 'Y' AND T_SamplingSoFlag <> 'D'
|
|
WHERE
|
|
T_OrderHeaderLabNumber = '{$prm['labnumber']}'";
|
|
/*$sql = "
|
|
SELECT DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y %H:%i') as order_date,
|
|
T_OrderHeaderLabNumber as labnumber,
|
|
T_OrderHeaderM_PatientAge as patient_age,
|
|
M_PatientName as patient_name,
|
|
M_PatientNoReg as noreg,
|
|
IF(M_PatientGender = 'male','Laki-laki','Perempuan') as gender,
|
|
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as dob,
|
|
M_PatientJob as job,
|
|
M_PatientPosisi as posisi,
|
|
IF(M_PatientDivisi = '','-',M_PatientDivisi) as divisi,
|
|
M_PatientHp as hp,
|
|
M_PatientEmail as email,
|
|
M_PatientPhoto as photo,
|
|
T_OrderHeaderID as xid
|
|
FROM t_orderheader
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_SamplingSoT_SampleStationID = {$prm['station_id']} AND
|
|
T_SamplingSoIsActive = 'Y'
|
|
JOIN t_order_location ON T_OrderLocationT_OrderHeaderID = T_SamplingSoT_OrderHeaderID AND
|
|
T_OrderLocationT_SampleStationID = T_SamplingSoT_SampleStationID AND
|
|
T_OrderLocationIsActive = 'Y' AND T_OrderLocationM_LocationID = {$prm['location_id']}
|
|
WHERE
|
|
T_OrderHeaderLabNumber = '{$prm['labnumber']}'
|
|
";*/
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data patient");
|
|
exit;
|
|
}
|
|
|
|
$data_patient = $query->row_array();
|
|
|
|
$data_sample_lab = [];
|
|
$sql = "SELECT T_TestName as sampletype_name,t_orderheaderid,
|
|
'' as barcode,
|
|
IF(ISNULL(T_SamplingSoID),'N',T_SamplingSoFlag) as status,
|
|
IF(ISNULL(T_SamplingSoProcessDate),'Belum dilakukan',DATE_FORMAT(T_SamplingSoProcessDate,'%d-%m-%Y')) as process_date,
|
|
IF(ISNULL(T_SamplingSoProcessTime),'',DATE_FORMAT(T_SamplingSoProcessTime,'%H:%i')) as process_time,
|
|
IF(ISNULL(T_SamplingSoDoneDate) OR T_SamplingSoFlag = 'P','Sedang Proses',DATE_FORMAT(T_SamplingSoDoneDate,'%d-%m-%Y')) as done_date,
|
|
IF(ISNULL(T_SamplingSoDoneTime) OR T_SamplingSoFlag = 'P','',DATE_FORMAT(T_SamplingSoDoneTime,'%H:%i')) as done_time
|
|
FROM t_orderdetail
|
|
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderHeaderLabNumber = '{$prm['labnumber']}'
|
|
JOIN t_order_location ON T_OrderLocationT_OrderHeaderID = T_OrderHeaderID AND T_OrderLocationT_SampleStationID = {$prm['station_id']} AND T_OrderLocationIsActive = 'Y'
|
|
JOIN m_location ON T_OrderLocationM_LocationID = M_LocationID AND M_LocationID = {$prm['location_id']}
|
|
JOIN t_test ON T_OrderDetailT_TEstID = T_TestID AND T_TestIsResult = 'Y'
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
|
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID =T_OrderLocationT_SampleStationID AND T_SampleStationIsNonLab = 'OTHERS'
|
|
LEFT JOIN t_samplingso ON T_OrderDetailT_TEstID = T_TEstID AND T_OrderHeaderID = T_SamplingSoT_OrderHeaderID AND T_SamplingSOIsActive ='Y'
|
|
WHERE
|
|
T_OrderDetailIsActive = 'Y'";
|
|
/*$sql = "
|
|
SELECT T_TestName as sampletype_name,
|
|
'' as barcode,
|
|
IF(ISNULL(T_SamplingSoID),'N',T_SamplingSoFlag) as status,
|
|
IF(ISNULL(T_SamplingSoProcessDate),'Belum dilakukan',DATE_FORMAT(T_SamplingSoProcessDate,'%d-%m-%Y')) as process_date,
|
|
IF(ISNULL(T_SamplingSoProcessTime),'',DATE_FORMAT(T_SamplingSoProcessTime,'%H:%i')) as process_time,
|
|
IF(ISNULL(T_SamplingSoDoneDate) OR T_SamplingSoFlag = 'P','Sedang Proses',DATE_FORMAT(T_SamplingSoDoneDate,'%d-%m-%Y')) as done_date,
|
|
IF(ISNULL(T_SamplingSoDoneTime) OR T_SamplingSoFlag = 'P','',DATE_FORMAT(T_SamplingSoDoneTime,'%H:%i')) as done_time
|
|
FROM t_orderdetail
|
|
LEFT JOIN t_samplingso ON T_OrderDetailT_TEstID = T_TEstID AND T_OrderSampleIsActive ='Y'
|
|
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderHeaderLabNumber = '{$prm['labnumber']}'
|
|
JOIN t_test ON T_OrderDetailT_TEstID = T_TestID
|
|
WHERE
|
|
T_OrderDetailIsActive = 'Y'
|
|
";*/
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data sample lab");
|
|
exit;
|
|
}
|
|
|
|
$data_sample_lab = $query->result_array();
|
|
|
|
$data_packet = [];
|
|
$sql = "
|
|
SELECT T_PacketName as packet_name,
|
|
T_PacketID as packet_id,
|
|
'' as active,
|
|
'' as details
|
|
FROM t_orderdetailorder
|
|
JOIN t_orderheader ON T_OrderDetailOrderT_OrderHeaderID = T_OrderHeaderID AND T_OrderHeaderLabNumber = '{$prm['labnumber']}'
|
|
JOIN t_packet ON T_OrderDetailOrderT_PacketID = T_PacketID
|
|
WHERE
|
|
T_OrderDetailOrderIsPacket = 'Y' AND
|
|
T_OrderDetailOrderIsActive = 'Y'
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data packet");
|
|
exit;
|
|
}
|
|
|
|
$data_packet = $query->result_array();
|
|
if($data_packet){
|
|
foreach ($data_packet as $key => $value) {
|
|
$data_packet[$key]['active'] = false;
|
|
$sql = "SELECT T_TestName as test_name
|
|
FROM t_packetdetail
|
|
JOIN t_test ON T_PacketDetailT_TestID = T_TestID
|
|
WHERE T_PacketDetailT_PacketID = {$value['packet_id']} AND T_PacketDetailIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data packet detail");
|
|
exit;
|
|
}
|
|
|
|
$data_packet_details = $query->result_array();
|
|
if(count($data_packet_details) > 0)
|
|
$data_packet[$key]['details'] = $data_packet_details;
|
|
else
|
|
$data_packet[$key]['details'] = [];
|
|
}
|
|
}
|
|
|
|
$data_tests = [];
|
|
$sql = "
|
|
SELECT T_TestName as test_name
|
|
FROM t_orderdetailorder
|
|
JOIN t_orderheader ON T_OrderDetailOrderT_OrderHeaderID = T_OrderHeaderID AND T_OrderHeaderLabNumber = '{$prm['labnumber']}'
|
|
JOIN t_test ON T_OrderDetailOrderT_TestID = T_TestID
|
|
WHERE
|
|
T_OrderDetailOrderIsPacket = 'N' AND
|
|
T_OrderDetailOrderIsActive = 'Y'
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data tests");
|
|
exit;
|
|
}
|
|
|
|
$data_tests = $query->result_array();
|
|
|
|
$act = "call";
|
|
$statusnextid = 1;
|
|
$stationid = $prm['station_id'];
|
|
$orderid = $data_patient['xid'];
|
|
$sampletypeid = 0;
|
|
$barcodelabid = 0;
|
|
$requirements = [];
|
|
$doaction_call = $this->doaction($act,$userid,$stationid,$orderid,$sampletypeid,$barcodelabid,$requirements,$statusnextid);
|
|
if($doaction_call){
|
|
$act = "process";
|
|
//echo $act;
|
|
$statusnextid = 3;
|
|
$stationid = $prm['station_id'];
|
|
$orderid = $data_patient['xid'];
|
|
$sampletypeid = 0;
|
|
$barcodelabid = 0;
|
|
$requirements = [];
|
|
$doaction_process = $this->doaction($act,$userid,$stationid,$orderid,$sampletypeid,$barcodelabid,$requirements,$statusnextid);
|
|
}
|
|
|
|
$result = array(
|
|
"data_patient" => $data_patient?$data_patient:[],
|
|
"data_sample_lab" => $data_sample_lab?$data_sample_lab:[],
|
|
"data_packet" => $data_packet? $data_packet:[],
|
|
"data_tests" => $data_tests?$data_tests:[],
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
|
|
}
|
|
|
|
function skipaction(){
|
|
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$act = "skip";
|
|
$statusnextid = 2;
|
|
$stationid = $prm['station_id'];
|
|
$orderid = $prm['order_id'];
|
|
$sampletypeid = 0;
|
|
$barcodelabid = 0;
|
|
$requirements = [];
|
|
$sql = "SELECT count(*) as xcount
|
|
FROM (SELECT *
|
|
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
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderHeaderID AND 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_SampleStationID = {$stationid}
|
|
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_SamplingSoT_TestID = T_SampleTypeID AND
|
|
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND
|
|
T_SamplingSoIsActive = 'Y'
|
|
WHERE
|
|
T_OrderHeaderID = {$orderid} AND
|
|
T_SamplingSoFlag = 'N' AND T_OrderHeaderIsActive = 'Y'
|
|
GROUP BY T_BarcodeLabID ) xx";
|
|
//echo $sql;
|
|
$xcount = $this->db_onedev->query($sql)->row()->xcount;
|
|
if($xcount > 0)
|
|
$doaction_call = $this->doaction($act,$userid,$stationid,$orderid,$sampletypeid,$barcodelabid,$requirements,$statusnextid);
|
|
else{
|
|
$statusnextid = 5;
|
|
$query = "INSERT INTO t_sampling_queue_last_status (
|
|
T_SamplingQueueLastStatusT_SampleStationID,
|
|
T_SamplingQueueLastStatusT_OrderHeaderID,
|
|
T_SamplingQueueLastStatusT_SamplingQueueStatusID,
|
|
T_SamplingQueueLastStatusUserID)
|
|
VALUES(
|
|
{$stationid},
|
|
{$orderid},
|
|
{$statusnextid},
|
|
{$userid}) ON DUPLICATE KEY UPDATE
|
|
T_SamplingQueueLastStatusT_SamplingQueueStatusID = {$statusnextid},
|
|
T_SamplingQueueLastStatusUserID = {$userid}";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
}
|
|
|
|
$result = array(
|
|
"order_id" => $orderid
|
|
);
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function scanbarcode(){
|
|
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$act = "samplingdone";
|
|
$statusnextid = 3;
|
|
$stationid = $prm['station_id'];
|
|
$orderid = $prm['patient']['xid'];
|
|
|
|
|
|
|
|
/*$sql = "SELECT *
|
|
FROM t_samplingso
|
|
JOIN t_orderheader ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_OrderHeaderLabNumber = '{$prm['barcode']}'
|
|
WHERE
|
|
T_SamplingSoT_OrderHeaderID = {$orderid} AND
|
|
T_SamplingSoT_SampleStationID = {$stationid} AND
|
|
T_SamplingSoIsActive = 'Y' AND T_SamplingSoFlag = 'P'";*/
|
|
$sql = "SELECT T_OrderDetailID, T_OrderHeaderID,T_OrderDetailID as id,
|
|
IFNULL(T_SamplingSoID,0) as T_BarcodeLabID,
|
|
T_TestName as T_BarcodeLabBarcode,
|
|
T_OrderDetailT_TestCode,
|
|
T_OrderDetailT_TestName,
|
|
T_TestID as test_id,
|
|
T_SampleTypeName,
|
|
T_BahanName,
|
|
IFNULL(T_SamplingSoID,0) as T_SamplingSoID,
|
|
IF(ISNULL(T_SamplingSoID),'N',T_SamplingSoFlag) as status,
|
|
IF(ISNULL(T_SamplingSoProcessDate),'00-00-0000',DATE_FORMAT(T_SamplingSoProcessDate,'%d-%m-%Y')) as process_date,
|
|
IF(ISNULL(T_SamplingSoProcessTime),'00:00',DATE_FORMAT(T_SamplingSoProcessTime,'%H:%i')) as process_time,
|
|
IF(ISNULL(T_SamplingSoDoneDate) OR T_SamplingSoFlag = 'P','00-00-0000',DATE_FORMAT(T_SamplingSoDoneDate,'%d-%m-%Y')) as done_date,
|
|
IF(ISNULL(T_SamplingSoDoneTime) OR T_SamplingSoFlag = 'P','00:00',DATE_FORMAT(T_SamplingSoDoneTime,'%H:%i')) as done_time,
|
|
'Y' as requirement_status,
|
|
'' as requirements
|
|
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 t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
|
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid}
|
|
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_TestID = T_TestID AND T_SamplingSoIsActive = 'Y'
|
|
|
|
WHERE
|
|
T_OrderHeaderLabNumber = '{$prm['barcode']}' AND T_OrderHeaderIsActive = 'Y'
|
|
GROUP BY T_TestID ";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("t_samplingso");
|
|
exit;
|
|
}
|
|
|
|
$ordersamples = $query->result_array();
|
|
|
|
//echo $this->db_onedev->last_query();
|
|
|
|
if($ordersamples){
|
|
foreach ($ordersamples as $key => $ordersample) {
|
|
//print_r($ordersample);
|
|
$sampletypeid = $ordersample['test_id'];
|
|
$barcodelabid = 0;
|
|
$requirements = [];
|
|
$doaction_call = $this->doaction($act,$userid,$stationid,$orderid,$sampletypeid,$barcodelabid,$requirements,$statusnextid);
|
|
}
|
|
|
|
$result = array(
|
|
"status_log" => "Y",
|
|
"order_id" => $orderid,
|
|
"isdone" => "Y"
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}else{
|
|
$result = array(
|
|
"status_log" => "N",
|
|
"order_id" => $orderid
|
|
);
|
|
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
}
|
|
|
|
function doaction($act,$userid,$stationid,$orderid,$sampletypeid,$barcodelabid,$requirements,$statusnextid)
|
|
{
|
|
|
|
$rst_data = array('status' => 'OK');
|
|
$status_call = array('status' => 'OK', 'data' => array());
|
|
|
|
//echo $stationid;
|
|
//echo $orderid;
|
|
|
|
$sql = "SELECT '' AS queueNumber ,
|
|
M_LocationID AS locationID,
|
|
M_LocationName AS locationName FROM t_orderheader
|
|
JOIN t_order_location ON T_OrderHeaderID = T_OrderLocationT_OrderHeaderID
|
|
JOIN m_location ON T_OrderLocationM_LocationID = M_LocationID
|
|
AND T_OrderLocationT_SampleStationID = ?
|
|
WHERE T_OrderHeaderID=?";
|
|
$location = $this->db_onedev->query($sql,array($stationid,$orderid))->row_array();
|
|
$locationID = $location['locationID'];
|
|
$locationName = $location['locationName'];
|
|
$queueNumber = $location['queueNumber'];
|
|
$splitedLocationName = explode(" ", $locationName);
|
|
$locationName = $splitedLocationName[0];
|
|
|
|
|
|
|
|
if ($act == 'call') {
|
|
$sql = "SELECT T_SamplingQueueLastStatusID, T_SamplingQueueStatusName, T_SampleStationName, T_SampleStationID, T_SampleStationIsNonLab
|
|
FROM t_sampling_queue_last_status
|
|
JOIN t_sampling_queue_status ON T_SamplingQueueLastStatusT_SamplingQueueStatusID = T_SamplingQueueStatusID
|
|
JOIN t_samplestation ON T_SampleStationID = T_SamplingQueueLastStatusT_SampleStationID
|
|
WHERE
|
|
T_SamplingQueueLastStatusT_OrderHeaderID = {$orderid} AND
|
|
T_SamplingQueueLastStatusT_SampleStationID <> {$stationid} AND
|
|
T_SamplingQueueLastStatusT_SamplingQueueStatusID IN (1,3) LIMIT 1";
|
|
//echo $sql;
|
|
$data_status_call = $this->db_onedev->query($sql)->row_array();
|
|
if ($data_status_call) {
|
|
$status_call = array('status' => 'NOTCALL', 'data' => $data_status_call);
|
|
$check_valid = false;
|
|
|
|
$sql = "SELECT SUM(countx) as xcount
|
|
FROM (
|
|
SELECT COUNT(*) as countx
|
|
FROM t_orderdetail
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
|
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND
|
|
T_SampleStationID = {$data_status_call['T_SampleStationID']}
|
|
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
|
T_SamplingSoT_TestID = T_TestID AND
|
|
T_SamplingSoIsActive = 'Y'
|
|
WHERE
|
|
T_OrderDetailT_OrderHeaderID = {$orderid} AND T_OrderDetailIsActive = 'Y' AND
|
|
ISNULL(T_SamplingSoDoneDate)
|
|
|
|
) x";
|
|
$not_sampled = $this->db_onedev->query($sql)->row_array();
|
|
|
|
if (intval($not_sampled['xcount']) == 0) {
|
|
$sql = "UPDATE t_sampling_queue_last_status
|
|
SET T_SamplingQueueLastStatusT_SamplingQueueStatusID = 5
|
|
WHERE
|
|
T_SamplingQueueLastStatusT_OrderHeaderID = {$orderid} AND
|
|
T_SamplingQueueLastStatusT_SampleStationID = {$data_status_call['T_SampleStationID']}";
|
|
$this->db_onedev->query($sql);
|
|
$status_call = array('status' => 'OK', 'data' => array());
|
|
}
|
|
}
|
|
}
|
|
|
|
$next_status = $statusnextid;
|
|
if ($act == 'process') {
|
|
$sql = "SELECT
|
|
T_OrderHeaderID,
|
|
T_OrderDetailID as id,
|
|
T_OrderDetailT_TestCode,
|
|
T_OrderDetailT_TestName,
|
|
T_TestID as test_id,
|
|
IFNULL(T_SamplingSoID,0) as samplingso_id,
|
|
T_BahanName
|
|
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 t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
|
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid}
|
|
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_SamplingSoT_TestID = T_TestID AND
|
|
T_SamplingSoIsActive = 'Y'
|
|
|
|
WHERE
|
|
T_OrderHeaderID = {$orderid} AND T_OrderHeaderIsActive = 'Y' AND
|
|
(ISNULL(T_SamplingSoFlag) OR T_SamplingSoFlag = 'P' OR T_SamplingSoFlag = 'X')
|
|
GROUP BY T_TestID";
|
|
/*$sql = "SELECT T_OrderDetailID, T_OrderHeaderID,T_OrderDetailID as id,
|
|
0 T_BarcodeLabID,
|
|
'' T_BarcodeLabBarcode,
|
|
T_OrderDetailT_TestCode,
|
|
T_OrderDetailT_TestName,
|
|
T_TestID,
|
|
T_SampleTypeID,
|
|
T_SampleTypeName,
|
|
T_BahanName
|
|
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
|
|
LEFT JOIN t_samplingso ON
|
|
T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_SamplingSoIsActive = 'Y' AND T_SamplingSoFlag = 'N'
|
|
JOIN t_sampletype ON T_SampleTypeID = T_SamplingSoT_TestID
|
|
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
|
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid}
|
|
WHERE
|
|
T_OrderHeaderID = {$orderid} AND (T_SamplingSoFlag = 'N' OR T_SamplingSoFlag = 'X') AND T_OrderHeaderIsActive = 'Y'
|
|
GROUP BY T_TestID";*/
|
|
//echo $sql;
|
|
$rows_all_sample = $this->db_onedev->query($sql)->result();
|
|
if ($rows_all_sample) {
|
|
foreach ($rows_all_sample as $k => $v) {
|
|
/*$sql = "UPDATE t_samplingso SET
|
|
T_SamplingSoFlag = 'P',
|
|
T_SamplingSoFlagDate = CURDATE(),
|
|
T_SamplingSoFlagTime = CURTIME(),
|
|
T_SamplingSoFlagUserID = {$userid},
|
|
T_SamplingSoIsActive = 'Y',
|
|
T_SamplingSoUserID = {$userid}
|
|
WHERE
|
|
T_SamplingSoT_OrderHeaderID = {$orderid} AND
|
|
T_SamplingSoT_TestID = {$v->T_TestID}
|
|
|
|
";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);*/
|
|
if($v->samplingso_id == 0){
|
|
$sql = "INSERT INTO t_samplingso (
|
|
T_SamplingSoT_SampleStationID,
|
|
T_SamplingSoT_OrderHeaderID,
|
|
T_SamplingSoT_TestID,
|
|
T_SamplingSoProcessDate,
|
|
T_SamplingSoProcessTime,
|
|
T_SamplingSoProcessUserID,
|
|
T_SamplingSoCreated,
|
|
T_SamplingSoCreatedUserID
|
|
)
|
|
VALUES(
|
|
{$stationid},
|
|
{$orderid},
|
|
{$v->test_id},
|
|
CURDATE(),
|
|
CURTIME(),
|
|
{$userid},
|
|
NOW(),
|
|
{$userid}
|
|
) ";
|
|
//echo $sql;
|
|
|
|
}else{
|
|
$sql = "UPDATE t_samplingso SET
|
|
T_SamplingSoProcessDate = CURDATE(),
|
|
T_SamplingSoProcessTime = CURTIME(),
|
|
T_SamplingSoFlag = 'P',
|
|
T_SamplingSoIsActive = 'Y',
|
|
T_SamplingSoProcessUserID = {$userid},
|
|
T_SamplingSoLastUpdatedUserID = {$userid},
|
|
T_SamplingSoLastUpdated = NOW()
|
|
WHERE
|
|
T_SamplingSoID = {$v->samplingso_id}";
|
|
//echo $sql;
|
|
}
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
//$this->broadcast("specimen-col-process");
|
|
}
|
|
}
|
|
|
|
$isdone = "X";
|
|
if ($act == 'samplingdone') {
|
|
//echo "insert samplingdone";
|
|
$sql = "UPDATE t_samplingso SET
|
|
T_SamplingSoDoneDate = CURDATE(),
|
|
T_SamplingSoDoneTime = CURTIME(),
|
|
T_SamplingSoDoneUserID = {$userid},
|
|
T_SamplingSoFlag = 'D',
|
|
T_SamplingSoIsActive = 'Y',
|
|
T_SamplingSoLastUpdatedUserID = {$userid},
|
|
T_SamplingSoLastUpdated = NOW()
|
|
WHERE
|
|
T_SamplingSoT_OrderHeaderID = {$orderid} AND
|
|
T_SamplingSoT_TestID = {$sampletypeid}";
|
|
$this->db_onedev->query($sql);
|
|
//echo $sql;
|
|
|
|
|
|
$sql = "SELECT t_sampletype.* FROM t_test
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID WHERE T_TestID = {$sampletypeid}";
|
|
$dt_sampletype = $this->db_onedev->query($sql)->row();
|
|
|
|
$xreq = $requirements;
|
|
$arr_requirements = array();
|
|
foreach ($xreq as $k => $v) {
|
|
if ($v['chex'] == 'Y')
|
|
array_push($arr_requirements, $v['id']);
|
|
}
|
|
$requirements = '[' . join(',', $arr_requirements) . ']';
|
|
|
|
|
|
|
|
$sql = "SELECT count(*) as xcount
|
|
FROM (SELECT *
|
|
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
|
|
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
|
|
T_SamplingSoIsActive = 'Y'
|
|
LEFT JOIN t_sampletype ON T_SampleTypeID = T_SamplingSoT_TestID
|
|
LEFT JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
|
LEFT JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND
|
|
T_SampleStationID = {$stationid}
|
|
|
|
WHERE
|
|
T_OrderHeaderID = {$orderid} AND
|
|
T_SamplingSoFlag <> 'D'
|
|
AND T_OrderHeaderIsActive = 'Y'
|
|
GROUP BY T_TestID ) xx";
|
|
//echo $sql;
|
|
$xcount = $this->db_onedev->query($sql)->row()->xcount;
|
|
$rst_data = array('status' => 'PARTIAL','isdone' => "N");
|
|
$isdone = "N";
|
|
//echo $this->db_onedev->last_query();
|
|
if ($xcount == 0) {
|
|
$isdone = "Y";
|
|
$next_status = 5;
|
|
$rst_data = array('status' => 'OK','isdone' => "Y");
|
|
}
|
|
//$this->broadcast("specimen-col-receive");
|
|
}
|
|
|
|
if ($act !== 'samplingprocess' && $status_call['status'] == 'OK') {
|
|
$dt_json = json_encode(array('T_SampleStationID' => $stationid, 'T_OrderHeaderID' => $orderid, 'T_SamplingQueueStatusID' => $next_status));
|
|
$query = "INSERT INTO one_log.log_sampling_queue (Log_SamplingQueueDate,Log_SamplingQueueJSON,Log_SamplingQueueUserID)
|
|
VALUES(NOW(),'{$dt_json}',{$userid})";
|
|
//echo $query;
|
|
//$rows = $this->db_onedev->query($query);
|
|
$sql = "SELECT *
|
|
FROM t_sampling_queue_last_status
|
|
WHERE
|
|
T_SamplingQueueLastStatusT_SampleStationID = {$stationid} AND
|
|
T_SamplingQueueLastStatusT_OrderHeaderID = {$orderid} AND
|
|
T_SamplingQueueLastStatusIsActive = 'Y'";
|
|
//echo $sql;
|
|
$data_last = $this->db_onedev->query($sql)->row();
|
|
|
|
$query = "INSERT INTO t_sampling_queue_last_status (
|
|
T_SamplingQueueLastStatusT_SampleStationID,
|
|
T_SamplingQueueLastStatusT_OrderHeaderID,
|
|
T_SamplingQueueLastStatusT_SamplingQueueStatusID,
|
|
T_SamplingQueueLastStatusUserID)
|
|
VALUES(
|
|
{$stationid},
|
|
{$orderid},
|
|
{$next_status},
|
|
{$userid}) ON DUPLICATE KEY UPDATE
|
|
T_SamplingQueueLastStatusT_SamplingQueueStatusID = {$next_status},
|
|
T_SamplingQueueLastStatusUserID = {$userid}";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
}
|
|
|
|
|
|
|
|
if ($status_call['status'] == 'NOTCALL') {
|
|
$rst_data = $status_call;
|
|
}
|
|
|
|
if ($act == 'skip' || $status_call['status'] == 'NOTCALL') {
|
|
$skip_time = date('Y-m-d H:i:s', strtotime($prm['skiptime'])+10);
|
|
$sql = "UPDATE antrian_samplestation SET AntrianSampleStationIsActive = 'N'
|
|
WHERE
|
|
AntrianSampleStationT_OrderLocationID = ?";
|
|
//$query = $this->db_onedev->query($sql,array($prm['orderlocationid']));
|
|
/* start dipaggil 3 kali skpi ururtan jd ke bawah */
|
|
/*$sql = "SELECT COUNT(*) as x_count
|
|
FROM antrian_samplestation
|
|
WHERE AntrianSampleStationT_OrderLocationID = ? AND
|
|
AntrianSampleStationIsActive = 'N' AND
|
|
DATE(AntrianSampleStationTime) = DATE(NOW())";
|
|
$query = $this->db_onedev->query($sql,array($prm['orderlocationid']));
|
|
$xcount_skip = $query->row()->x_count;
|
|
|
|
$modby3 = $xcount_skip % 2;
|
|
if($xcount_skip > 0 && $modby3 == 0){
|
|
$skip_time = date('Y-m-d H:i:s', strtotime($prm['last_skiptime'])+1);
|
|
}*/
|
|
/* end dipaggil 3 kali skpi ururtan jd ke bawah */
|
|
$sql = "INSERT INTO antrian_samplestation(
|
|
AntrianSampleStationT_OrderLocationID,
|
|
AntrianSampleStationTime,
|
|
AntrianSampleStationUserID,
|
|
AntrianSampleStationCreated
|
|
)
|
|
VALUES(
|
|
?,?,?,NOW()
|
|
)";
|
|
//$query = $this->db_onedev->query($sql,array($prm['orderlocationid'],$skip_time,$userid));
|
|
|
|
}
|
|
|
|
$result = array(
|
|
"total" => 1,
|
|
"records" => $rst_data,
|
|
"nextstatus" => $next_status,
|
|
"isdone" => $isdone
|
|
);
|
|
return $result;
|
|
}
|
|
|
|
|
|
function search_patient(){
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
|
|
$data_patient = [];
|
|
$sql = "
|
|
SELECT DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y %H:%i') as order_date,
|
|
T_OrderHeaderLabNumber as labnumber,
|
|
T_OrderHeaderM_PatientAge as patient_age,
|
|
M_PatientName as patient_name,
|
|
M_PatientNoReg as noreg,
|
|
IF(M_PatientGender = 'male','Laki-laki','Perempuan') as gender,
|
|
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as dob,
|
|
M_PatientJob as job,
|
|
M_PatientPosisi as posisi,
|
|
IF(M_PatientDivisi = '','-',M_PatientDivisi) as divisi,
|
|
M_PatientHp as hp,
|
|
M_PatientEmail as email,
|
|
M_PatientPhoto as photo
|
|
FROM t_orderheader
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
WHERE
|
|
T_OrderHeaderID = {$prm['order_id']} AND T_OrderHeaderLabNumber = '{$prm['noreg']}'
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data patient");
|
|
exit;
|
|
}
|
|
|
|
$data_patient = $query->row_array();
|
|
|
|
$data_packet = [];
|
|
$sql = "
|
|
SELECT T_PacketName as packet_name,
|
|
T_PacketID as packet_id,
|
|
'' as active,
|
|
'' as details
|
|
FROM t_orderdetailorder
|
|
JOIN t_packet ON T_OrderDetailOrderT_PacketID = T_PacketID
|
|
WHERE
|
|
T_OrderDetailOrderT_OrderHeaderID = {$prm['order_id']} AND
|
|
T_OrderDetailOrderIsPacket = 'Y' AND
|
|
T_OrderDetailOrderIsActive = 'Y'
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data packet");
|
|
exit;
|
|
}
|
|
|
|
$data_packet = $query->result_array();
|
|
if($data_packet){
|
|
foreach ($data_packet as $key => $value) {
|
|
$data_packet[$key]['active'] = false;
|
|
$sql = "SELECT T_TestName as test_name
|
|
FROM t_packetdetail
|
|
JOIN t_test ON T_PacketDetailT_TestID = T_TestID
|
|
WHERE T_PacketDetailT_PacketID = {$value['packet_id']} AND T_PacketDetailIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data packet detail");
|
|
exit;
|
|
}
|
|
|
|
$data_packet_details = $query->result_array();
|
|
if(count($data_packet_details) > 0)
|
|
$data_packet[$key]['details'] = $data_packet_details;
|
|
else
|
|
$data_packet[$key]['details'] = [];
|
|
}
|
|
}
|
|
|
|
$data_tests = [];
|
|
$sql = "
|
|
SELECT T_TestName as test_name
|
|
FROM t_orderdetailorder
|
|
JOIN t_test ON T_OrderDetailOrderT_TestID = T_TestID
|
|
WHERE
|
|
T_OrderDetailOrderT_OrderHeaderID = {$prm['order_id']} AND
|
|
T_OrderDetailOrderIsPacket = 'N' AND
|
|
T_OrderDetailOrderIsActive = 'Y'
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data tests");
|
|
exit;
|
|
}
|
|
|
|
$data_tests = $query->result_array();
|
|
|
|
$data_sample_lab = [];
|
|
$sql = "
|
|
SELECT T_SampleTypeName as sampletype_name,
|
|
T_SamplingSoBarcode as barcode,
|
|
IF(ISNULL(T_SamplingSoFlagDate),'Belum diambil',DATE_FORMAT(T_SamplingSoFlagDate,'%d-%m-%Y')) as sampling_date,
|
|
IF(ISNULL(T_SamplingSoFlagTime),'',T_SamplingSoFlagTime) as sample_time,
|
|
IF(ISNULL(T_SamplingSoFlagDate),'Belum dilakukan',DATE_FORMAT(T_SamplingSoFlagDate,'%d-%m-%Y')) as receive_date,
|
|
IF(ISNULL(T_SamplingSoFlagTime),'',DATE_FORMAT(T_SamplingSoFlagTime,'%H:%i')) as receive_time,
|
|
T_SamplingSoFlag as is_sampling,
|
|
T_SamplingSoFlag as is_received
|
|
FROM t_samplingso
|
|
JOIN t_sampletype ON T_SamplingSoT_TestID = T_SampleTypeID
|
|
WHERE
|
|
T_SamplingSoT_OrderHeaderID = {$prm['order_id']} AND
|
|
T_SamplingSoIsActive = 'Y'
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data sample lab");
|
|
exit;
|
|
}
|
|
|
|
$data_sample_lab = $query->result_array();
|
|
|
|
$data_sample_radiodiagnostic = [];
|
|
$sql = "
|
|
SELECT T_TestName as sampletype_name,
|
|
T_OrderHeaderLabNumber as barcode,
|
|
IF(ISNULL(T_SamplingSoProcessDate),'Belum dilakukan',DATE_FORMAT(T_SamplingSoProcessDate,'%d-%m-%Y')) as sampling_date,
|
|
IF(ISNULL(T_SamplingSoProcessTime),'',T_SamplingSoProcessTime) as sample_time,
|
|
IF(ISNULL(T_SamplingSoDoneDate),'Belum dilakukan',DATE_FORMAT(T_SamplingSoDoneDate,'%d-%m-%Y')) as receive_date,
|
|
IF(ISNULL(T_SamplingSoDoneTime),'',DATE_FORMAT(T_SamplingSoDoneTime,'%H:%i')) as receive_time,
|
|
IF(ISNULL(T_SamplingSoFlag),'N','Y') as is_sampling,
|
|
IF(ISNULL(T_SamplingSoFlag) OR T_SamplingSoFlag <> 'D','N','Y') as is_received
|
|
FROM t_orderdetail
|
|
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
|
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND
|
|
T_SampleStationIsNonLab = 'RADIODIAGNOSTIC'
|
|
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
|
T_SamplingSoT_TestID = T_TestID
|
|
WHERE
|
|
T_OrderDetailT_OrderHeaderID = {$prm['order_id']} AND
|
|
T_OrderDetailIsActive = 'Y'
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data sample radiodiagnostic");
|
|
exit;
|
|
}
|
|
|
|
$data_sample_radiodiagnostic = $query->result_array();
|
|
|
|
$data_sample_electromedic = [];
|
|
$sql = "
|
|
SELECT T_TestName as sampletype_name,
|
|
T_OrderHeaderLabNumber as barcode,
|
|
IF(ISNULL(T_SamplingSoProcessDate),'Belum dilakukan',DATE_FORMAT(T_SamplingSoProcessDate,'%d-%m-%Y')) as sampling_date,
|
|
IF(ISNULL(T_SamplingSoProcessTime),'',T_SamplingSoProcessTime) as sample_time,
|
|
IF(ISNULL(T_SamplingSoDoneDate),'Belum dilakukan',DATE_FORMAT(T_SamplingSoDoneDate,'%d-%m-%Y')) as receive_date,
|
|
IF(ISNULL(T_SamplingSoDoneTime),'',DATE_FORMAT(T_SamplingSoDoneTime,'%H:%i')) as receive_time,
|
|
IF(ISNULL(T_SamplingSoFlag),'N','Y') as is_sampling,
|
|
IF(ISNULL(T_SamplingSoFlag) OR T_SamplingSoFlag <> 'D','N','Y') as is_received
|
|
FROM t_orderdetail
|
|
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
|
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND
|
|
T_SampleStationIsNonLab = 'ELEKTROMEDIS'
|
|
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
|
T_SamplingSoT_TestID = T_TestID
|
|
WHERE
|
|
T_OrderDetailT_OrderHeaderID = {$prm['order_id']} AND
|
|
T_OrderDetailIsActive = 'Y'
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data sample electromedis");
|
|
exit;
|
|
}
|
|
|
|
$data_sample_electromedic = $query->result_array();
|
|
|
|
$data_sample_other = [];
|
|
$sql = "
|
|
SELECT T_TestName as sampletype_name,
|
|
T_OrderHeaderLabNumber as barcode,
|
|
IF(ISNULL(T_SamplingSoProcessDate),'Belum dilakukan',DATE_FORMAT(T_SamplingSoProcessDate,'%d-%m-%Y')) as sampling_date,
|
|
IF(ISNULL(T_SamplingSoProcessTime),'',T_SamplingSoProcessTime) as sample_time,
|
|
IF(ISNULL(T_SamplingSoDoneDate),'Belum dilakukan',DATE_FORMAT(T_SamplingSoDoneDate,'%d-%m-%Y')) as receive_date,
|
|
IF(ISNULL(T_SamplingSoDoneTime),'',DATE_FORMAT(T_SamplingSoDoneTime,'%H:%i')) as receive_time,
|
|
IF(ISNULL(T_SamplingSoFlag),'N','Y') as is_sampling,
|
|
IF(ISNULL(T_SamplingSoFlag) OR T_SamplingSoFlag <> 'D','N','Y') as is_received
|
|
FROM t_orderdetail
|
|
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
|
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
|
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
|
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND
|
|
T_SampleStationIsNonLab = 'OTHERS'
|
|
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
|
T_SamplingSoT_TestID = T_TestID
|
|
WHERE
|
|
T_OrderDetailT_OrderHeaderID = {$prm['order_id']} AND
|
|
T_OrderDetailIsActive = 'Y'
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
if (!$query) {
|
|
$this->sys_error_db("data sample other");
|
|
exit;
|
|
}
|
|
|
|
$data_sample_other = $query->result_array();
|
|
|
|
|
|
|
|
$result = array(
|
|
"data_patient" => $data_patient?$data_patient:[],
|
|
"data_packet" => $data_packet? $data_packet:[],
|
|
"data_tests" => $data_tests?$data_tests:[],
|
|
"data_sample_lab" => $data_sample_lab?$data_sample_lab:[],
|
|
"data_sample_radiodiagnostic" => $data_sample_radiodiagnostic?$data_sample_radiodiagnostic:[],
|
|
"data_sample_electromedic" => $data_sample_electromedic?$data_sample_electromedic:[],
|
|
"data_sample_other" => $data_sample_other?$data_sample_other:[]
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
|
|
}
|