Files
BE_CPONE/application/controllers/v1/su/Barcode.php
2026-04-27 10:26:26 +07:00

587 lines
23 KiB
PHP

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
class Barcode extends CI_Controller
{
function formulir()
{
$orderId = $this->input->get("orderId");
$this->db_onedev = $this->load->database("onedev", true);
if ($orderId == "") $orderId = "'0'";
$sql = "select
DATE_FORMAT(T_OrderHeaderDate, '%d-%m-%Y ')as datereg,
T_OrderHeaderLabNumber as nolab,
M_PatientNoReg as noreg,
CONCAT(IFNULL(M_TitleName,''),'. ',ifnull(M_PatientPrefix,'') , ' ' ,M_PatientName,' ' , ifnull(M_PatientSuffix,'')) AS M_PatientName,
T_OrderHeaderM_PatientAge as age,
DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') AS M_PatientDOB,
M_PatientAddress AS alamat,
'' as city,
'' AS M_DoctorName,
group_concat(distinct T_TestName) as test,
IF(M_PatientGender = 'male','L','P') as sexcode,
CorporateName as patienttype
from t_orderheader
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
join t_orderdetail on T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
join t_test on T_OrderDetailT_TestID = T_TestID
join m_title on M_PatientM_TitleID = M_TitleID
left join corporate ON T_OrderHeaderCorporateID = CorporateID AND CorporateIsActive = 'Y'
where T_OrderHeaderID = {$orderId}
group by T_OrderHeaderID ";
$query = $this->db_onedev->query($sql);
$rows = $query->result_array();
$data = array();
if (count($rows) > 0) $data = $rows[0];
echo json_encode(array(
"status" => "OK",
"message" => "",
"rows" => $data
));
}
function so_group()
{
$orderId = $this->input->get("orderId");
$this->db_onedev = $this->load->database("onedev", true);
if ($orderId == "") $orderId = "'0'";
$sql = "select
DATE_FORMAT(T_OrderHeaderDate, '%d-%m-%Y ')as datereg,
fn_lookup_external(T_OrderHeaderLabNumber,'L') as nolab,
M_PatientNoReg as noreg,
CONCAT(M_TitleName,'. ',ifnull(M_PatientPrefix,'') , ' ' ,M_PatientName,' ' , ifnull(M_PatientSuffix,'')) AS M_PatientName,
T_OrderHeaderM_PatientAge as age,
DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') AS M_PatientDOB,
(SELECT M_PatientAddressDescription from m_patientaddress AS p
WHERE M_PatientAddressM_PatientID = M_PatientID
ORDER BY M_PatientAddressM_PatientID
LIMIT 1) AS alamat,
M_CityName as city,
CONCAT(M_DoctorPrefix,' ',M_DoctorName,' ',M_DoctorSufix) AS M_DoctorName,
group_concat(distinct T_TestName separator ', ') as test ,
M_SexCode as sexcode, M_CompanyName as patienttype
from t_orderheader
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
join t_orderdetail on T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
join t_test on T_OrderDetailT_TestID = T_TestID
join so_resultentry on T_OrderDetailID = So_ResultEntryT_OrderDetailID
join m_title on M_PatientM_TitleID = M_TitleID
left join m_sex ON M_PatientM_SexID = M_SexID AND M_SexIsActive = 'Y'
left join m_company ON T_OrderHeaderM_CompanyID = M_CompanyID AND M_CompanyIsActive = 'Y'
left join m_mou ON T_OrderHeaderM_MouID = M_MouID AND M_MouIsActive = 'Y'
left join m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID AND M_DoctorIsActive = 'Y'
left join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID
left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID
left join m_district on M_KelurahanM_DistrictID = M_DistrictID
left join m_city on M_DistrictM_CityID = M_CityID
where T_OrderHeaderID = $orderId and T_TestIsResult ='y' and T_TestIsNonLab <> ''
group by T_OrderHeaderID ";
$query = $this->db_onedev->query($sql);
$rows = $query->result_array();
$data = array();
if (count($rows) > 0) $data = $rows[0];
echo json_encode(array(
"status" => "OK",
"message" => "",
"rows" => $data
));
}
/*
//+ "^FT5,200^A0N,23,24^FH\^FD"+ data.city+"^FS"+ "\n"
//+ "^FT5,175^A0N,23,24^FH\^FD" + data.address + "^FS"+ "\n"
//+ "^FT3,150^A0N,28,28^FH\^FD"+ data.title+" "+ data.patientName +"^FS"+ "\n"
//+ "^BY3,3,45^FT22,70^BCN,,Y,N"+ "\n"
//+ "^FD>;" + xbarcodeId + "^FS"+ "\n"
//+ "^FT5,225^A0N,23,24^FH\^FD"+ data.patienttype +"^FS"+ "\n"
//+ "^PQ1,0,1,Y^XZ"+ "\n"
*/
function so()
{
$orderId = $this->input->get("orderId");
$this->db_onedev = $this->load->database("onedev", true);
if ($orderId == "") $orderId = "'0'";
// orderId = order detail id
$sql = "select
DATE_FORMAT(T_OrderHeaderDate, '%d-%m-%Y ')as datereg,
T_OrderHeaderLabNumber as nolab,
M_PatientNoReg as noreg,
CONCAT(IF(M_TitleName IS NULL,'',CONCAT(M_TitleName,'. ')),ifnull(M_PatientPrefix,'') , ' ' ,M_PatientName,' ' , ifnull(M_PatientSuffix,'')) AS M_PatientName,
T_OrderHeaderM_PatientAge as age,
DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') AS M_PatientDOB,
M_PatientAddress AS alamat,
M_PatientAddressCity as city,
'' AS M_DoctorName,
T_TestName as test,
IF(M_PatientGender = 'male','L','P') as sex_code, CorporateName as patienttype
from t_orderheader
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
join t_orderdetail on T_OrderHeaderID = T_OrderDetailT_OrderHeaderID and T_OrderHeaderID = $orderId
join t_test on T_OrderDetailT_TestID = T_TestID
left join m_title on M_PatientM_TitleID = M_TitleID
left join corporate ON T_OrderHeaderCorporateID = CorporateID AND CorporateIsActive = 'Y'
";
$query = $this->db_onedev->query($sql);
//echo $sql;
$rows = $query->result_array();
foreach ($rows as $key => $value) {
$oldage = explode("tahun", $value['age']);
$rows[$key]['age'] = $oldage[0] . ' Tahun';
}
echo json_encode(array(
"status" => "OK",
"message" => "",
"rows" => $rows
));
}
function fix_double_order($order_id){
$this->db_onedev = $this->load->database("onedev", true);
$sql = " SELECT
GROUP_CONCAT(T_OrderDetailOrderID) as unik_id,
T_OrderDetailOrderT_OrderHeaderID,
T_OrderDetailOrderT_TestID,
T_OrderDetailOrderT_PacketID,
COUNT(*) as jumlah_duplikat
FROM
t_orderdetailorder
WHERE
T_OrderDetailOrderT_OrderHeaderID = ? AND
T_OrderDetailOrderIsActive = 'Y'
GROUP BY
T_OrderDetailOrderT_OrderHeaderID,
T_OrderDetailOrderT_TestID,
T_OrderDetailOrderT_PacketID
HAVING
COUNT(*) > 1";
$query = $this->db_onedev->query($sql,array($order_id));
//echo $this->db_onedev->last_query();
$rows = $query->result_array();
if(count($rows) == 0) return true;
foreach($rows as $row){
$a_id = explode(",",$row['unik_id']);
$keep_id = $a_id[0];
$delete_id = implode(",",array_slice($a_id,1));
$sql = "UPDATE t_orderdetailorder SET T_OrderDetailOrderIsActive = 'N',
T_OrderDetailOrderDeleted = NOW(),
T_OrderDetailOrderDeletedUserID = 51512
WHERE
T_OrderDetailOrderID IN ($delete_id) ";
$this->db_onedev->query($sql);
$sql = "UPDATE t_orderdetail SET T_OrderDetailIsActive = 'N',
T_OrderDetailDeleted = NOW(),
T_OrderDetailDeletedUserID = 51512
WHERE
T_OrderDetailT_OrderDetailOrderID IN ($delete_id) ";
$this->db_onedev->query($sql);
}
return true;
}
function sov1()
{
$this->db_onedev = $this->load->database("onedev", true);
$orderId = $this->input->get("orderId");
$orderdetail_id = 0;
if ($orderId == "") $orderId = "'0'";
// orderId = order detail id
$a_bcodes = explode(",", $orderId);
$s_bcode = "";
foreach ($a_bcodes as $b) {
if ($s_bcode != "") $s_bcode .= ",";
$s_bcode .= "'$b'";
$orderdetail_id = $b;
}
$sql = "SELECT *
FROM t_orderdetail
WHERE
T_OrderDetailID = ? ";
$query = $this->db_onedev->query($sql,array($orderdetail_id));
$dt_order_detail = $query->result_array();
$header_id = $dt_order_detail[0]['T_OrderDetailT_OrderHeaderID'];
$this->fix_double_order($header_id);
$sql = "select
DATE_FORMAT(T_OrderHeaderDate, '%d-%m-%Y ')as datereg,
T_OrderHeaderLabNumber as nolab,
M_PatientNoReg as noreg,
CONCAT(IF(M_TitleName IS NULL,'',CONCAT(M_TitleName,'. ')),ifnull(M_PatientPrefix,'') , ' ' ,M_PatientName,' ' , ifnull(M_PatientSuffix,'')) AS M_PatientName,
T_OrderHeaderM_PatientAge as age,
DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') AS M_PatientDOB,
M_PatientAddress AS alamat,
M_PatientAddressCity as city,
'' AS M_DoctorName,
T_TestName as test,
IF(M_PatientGender = 'male','L','P') as sex_code, CorporateName as patienttype,M_PatientNIP
from t_orderheader
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
join t_orderdetail on T_OrderHeaderID = T_OrderDetailT_OrderHeaderID and T_OrderDetailID IN ($s_bcode)
join t_test on T_OrderDetailT_TestID = T_TestID
left join m_title on M_PatientM_TitleID = M_TitleID
left join corporate ON T_OrderHeaderCorporateID = CorporateID AND CorporateIsActive = 'Y'
";
$query = $this->db_onedev->query($sql);
//echo $sql;
$lstQry = $this->db_onedev->last_query();
$rows = $query->result_array();
foreach ($rows as $key => $value) {
$oldage = explode("tahun", $value['age']);
$rows[$key]['age'] = $oldage[0] . ' Tahun';
}
echo json_encode(array(
"status" => "OK",
"message" => "",
"qry" => $lstQry,
"rows" => $rows
));
}
function duplicateDataByOrderId($prm, $data)
{
// Hitung jumlah kemunculan setiap elemen dalam array prm
$orderCounts = array_count_values($prm);
// Array baru untuk menyimpan hasil duplikasi
$result = [];
// Loop melalui setiap objek di data JSON
foreach ($data as $item) {
$orderId = $item['T_OrderDetailID'];
// Jika ada dalam orderCounts, duplikasi data sesuai jumlah kemunculan
if (isset($orderCounts[$orderId])) {
for ($i = 0; $i < $orderCounts[$orderId]; $i++) {
$result[] = $item; // Tambahkan data ke hasil
}
} else {
$result[] = $item; // Jika tidak ada dalam orderCounts, tambahkan satu kali
}
}
return $result;
}
function sov2()
{
$orderId = $this->input->get("orderId");
$this->db_onedev = $this->load->database("onedev", true);
if ($orderId == "") $orderId = "'0'";
// orderId = order detail id
$a_bcodes = explode(",", $orderId);
$s_bcode = "";
foreach ($a_bcodes as $b) {
if ($s_bcode != "") $s_bcode .= ",";
$s_bcode .= "'$b'";
}
$sql = "SELECT
T_OrderDetailID,
DATE_FORMAT(T_OrderHeaderDate, '%d-%m-%Y ')as datereg,
T_OrderHeaderLabNumber as nolab,
M_PatientNoReg as noreg,
CONCAT(IF(M_TitleName IS NULL,'',CONCAT(M_TitleName,'. ')),ifnull(M_PatientPrefix,'') , ' ' ,M_PatientName,' ' , ifnull(M_PatientSuffix,'')) AS M_PatientName,
T_OrderHeaderM_PatientAge as age,
DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') AS M_PatientDOB,
M_PatientAddress AS alamat,
M_PatientAddressCity as city,
'' AS M_DoctorName,
T_TestName as test,
IF(M_PatientGender = 'male','L','P') as sex_code, CorporateName as patienttype
from t_orderheader
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
join t_orderdetail on T_OrderHeaderID = T_OrderDetailT_OrderHeaderID and T_OrderDetailID IN ($s_bcode)
join t_test on T_OrderDetailT_TestID = T_TestID
left join m_title on M_PatientM_TitleID = M_TitleID
left join corporate ON T_OrderHeaderCorporateID = CorporateID AND CorporateIsActive = 'Y'
";
$query = $this->db_onedev->query($sql);
// echo $sql;
$lstQry = $this->db_onedev->last_query();
$rows = $query->result_array();
foreach ($rows as $key => $value) {
$oldage = explode("tahun", $value['age']);
$rows[$key]['age'] = $oldage[0] . ' Tahun';
}
$updatedData = $this->duplicateDataByOrderId($a_bcodes, $rows);
echo json_encode(array(
"status" => "OK",
"message" => "",
"a_bcodes" => $a_bcodes,
"lstQry" => $lstQry,
"coba" => array_count_values($a_bcodes),
"rows" => $updatedData
));
}
function so_label()
{
$orderId = $this->input->get("orderId");
$this->db_onedev = $this->load->database("onedev", true);
if ($orderId == "") $orderId = "'0'";
$sql = "select
CONCAT(M_TitleName,'. ',ifnull(M_PatientPrefix,'') , ' ' ,M_PatientName,' ' , ifnull(M_PatientSuffix,'')) AS M_PatientName,
concat(M_PatientKedudukan ,' / ',M_PatientNIK ) as nrp,
M_PatientJob,
M_PatientJabatan ,
concat(DATE_FORMAT(M_PatientDOB, '%d/%m/%Y') , ' (',TIMESTAMPDIFF(YEAR, M_PatientDOB, CURDATE()) ,' th) ', M_SexName , ', ',ifnull(M_ReligionName,'')) as tgllahir,
(SELECT concat(M_PatientAddressDescription , ' ' , M_KelurahanName)
from m_patientaddress AS p
left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID
left join m_district on M_KelurahanM_DistrictID = M_DistrictID
left join m_city on M_DistrictM_CityID = M_CityID
WHERE M_PatientAddressM_PatientID = M_PatientID
ORDER BY M_PatientAddressM_PatientID
LIMIT 1) AS alamat,
M_PatientHP,
concat(T_OrderHeaderLabNumber,' / ', DATE_FORMAT(T_OrderHeaderDate, '%d/%m/%Y ')) as lab,
DATE_FORMAT(T_OrderHeaderDate, '%d-%m-%Y ')as datereg,
fn_lookup_external(T_OrderHeaderLabNumber,'L') as nolab,
M_PatientNoReg as noreg, M_CompanyName as patienttype,
M_PatientPJ ,
M_PatientLocation ,
M_PatientIDNumber
from t_orderheader
left join m_patient on T_OrderHeaderM_PatientID = M_PatientID
left join m_title on M_PatientM_TitleID = M_TitleID
left join m_religion on M_PatientM_ReligionID = M_ReligionID
left join m_sex ON M_PatientM_SexID = M_SexID AND M_SexIsActive = 'Y'
left join m_company ON T_OrderHeaderM_CompanyID = M_CompanyID AND M_CompanyIsActive = 'Y'
left join m_mou ON T_OrderHeaderM_MouID = M_MouID AND M_MouIsActive = 'Y'
where T_OrderHeaderID = $orderId
group by T_OrderHeaderID ";
$query = $this->db_onedev->query($sql);
$rows = $query->result_array();
$data = array();
if (count($rows) > 0) $data = $rows[0];
echo json_encode(array(
"status" => "OK",
"message" => "",
"rows" => $data
));
}
function formulir_khusus()
{
$orderId = $this->input->get("orderId");
$this->db_onedev = $this->load->database("onedev", true);
if ($orderId == "") $orderId = "'0'";
$sql = "select
DATE_FORMAT(T_OrderHeaderDate, '%d-%m-%Y ')as datereg,
T_OrderHeaderLabNumber as nolab,
M_PatientNoReg as noreg,
CONCAT(M_TitleName,'. ',ifnull(M_PatientPrefix,'') , ' ' ,M_PatientName,' ' , ifnull(M_PatientSuffix,'')) AS M_PatientName,
T_OrderHeaderM_PatientAge as age,
concat(M_PatientKedudukan ,' / ',M_PatientNIK ) as nrp,
M_PatientJob,
M_PatientJabatan ,
concat( ' (',TIMESTAMPDIFF(YEAR, M_PatientDOB, CURDATE()) ,' th) ', M_SexCode ) as tgllahir,
DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') AS M_PatientDOB,
(SELECT M_PatientAddressDescription from m_patientaddress AS p
WHERE M_PatientAddressM_PatientID = M_PatientID
ORDER BY M_PatientAddressM_PatientID
LIMIT 1) AS alamat,
M_CityName as city,
CONCAT(M_DoctorPrefix,' ',M_DoctorName,' ',M_DoctorSufix) AS M_DoctorName,
group_concat(distinct T_TestName) as test ,
M_SexCode as sexcode, M_CompanyName as patienttype
from t_orderheader
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
join t_orderdetail on T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
join t_test on T_OrderDetailT_TestID = T_TestID
join m_title on M_PatientM_TitleID = M_TitleID
left join m_religion on M_PatientM_ReligionID = M_ReligionID
left join m_sex ON M_PatientM_SexID = M_SexID AND M_SexIsActive = 'Y'
left join m_company ON T_OrderHeaderM_CompanyID = M_CompanyID AND M_CompanyIsActive = 'Y'
left join m_mou ON T_OrderHeaderM_MouID = M_MouID AND M_MouIsActive = 'Y'
left join m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID AND M_DoctorIsActive = 'Y'
left join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID
left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID
left join m_district on M_KelurahanM_DistrictID = M_DistrictID
left join m_city on M_DistrictM_CityID = M_CityID
where T_OrderHeaderID = $orderId
group by T_OrderHeaderID ";
$query = $this->db_onedev->query($sql);
$rows = $query->result_array();
$data = array();
if (count($rows) > 0) $data = $rows[0];
echo json_encode(array(
"status" => "OK",
"message" => "",
"rows" => $data
));
}
function pk()
{
$barcodeId = $this->input->get("barcodeId");
$this->db_onedev = $this->load->database("onedev", true);
if ($barcodeId == "") $barcodeId = "'0'";
$a_bcodes = explode(",", $barcodeId);
$s_bcode = "";
foreach ($a_bcodes as $b) {
if ($s_bcode != "") $s_bcode .= ",";
$s_bcode .= "'$b'";
}
$sql = "select
RIGHT(T_OrderHeaderLabNumber,7 ) T_OrderHeaderLabNumber ,
T_OrderHeaderLabNumber Full_T_OrderHeaderLabNumber,
T_SampleTypeName,
left(T_BarcodeLabBarcode ,13) T_BarcodeLabBarcode ,
CONCAT(M_TitleName,'. ',ifnull(M_PatientPrefix,'') , ' ' ,M_PatientName,' ' , ifnull(M_PatientSuffix,'')) M_PatientName,
M_PatientNoReg,
T_OrderHeaderM_PatientAge,
DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') AS M_PatientDOB,
if(M_PatientGender = 'male' , 'L' , 'P') as Gender,
CorporateName,M_PatientNIP,
DATE_FORMAT(T_OrderHeaderDate,'%d/%m/%Y') T_OrderHeaderDate,
case
when M_PatientGender = 'male' then 'M'
when M_PatientGender = 'female' then 'F'
end Sex,
T_SampleTypeSuffix
from t_barcodelab
join t_sampletype on T_BarcodeLabT_SampleTypeID = T_SampleTypeID
join t_orderheader on T_BarcodeLabT_OrderHeaderID = T_OrderHeaderID
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
join m_title on M_PatientM_TitleID = M_TitleID
left join corporate on T_OrderHeaderCorporateID = CorporateID and CorporateIsActive = 'Y'
where T_BarcodeLabBarcode in ( $s_bcode ) ";
$query = $this->db_onedev->query($sql);
//echo $sql;
$rows = $query->result_array();
$rst = [];
foreach ($rows as $key => $value) {
$rst[] = $value;
if ($value['T_SampleTypeSuffix'] == 'UK') {
$rst[] = $value;
}
}
echo json_encode(array(
"status" => "OK",
"message" => "",
"rows" => $rst
));
}
function duplicateDataByBarcode($prm, $data)
{
// Hitung jumlah kemunculan setiap elemen dalam array prm
$barcodeCounts = array_count_values($prm);
// Array baru untuk menyimpan hasil duplikasi
$result = [];
// Loop melalui setiap objek di data JSON
foreach ($data as $item) {
$barcode = $item['Full_T_BarcodeLabBarcode'];
// Jika ada dalam barcodeCounts, duplikasi data sesuai jumlah kemunculan
if (isset($barcodeCounts[$barcode])) { // Menambahkan '1' karena sesuai contoh data di prm
for ($i = 0; $i < $barcodeCounts[$barcode]; $i++) {
$result[] = $item; // Tambahkan data ke hasil
}
} else {
$result[] = $item; // Jika tidak ada dalam barcodeCounts, tambahkan satu kali
}
}
return $result;
}
function pkv2()
{
$barcodeId = $this->input->get("barcodeId");
$this->db_onedev = $this->load->database("onedev", true);
if ($barcodeId == "") $barcodeId = "'0'";
$a_bcodes = explode(",", $barcodeId);
$s_bcode = "";
foreach ($a_bcodes as $b) {
if ($s_bcode != "") $s_bcode .= ",";
$s_bcode .= "'$b'";
}
$sql = "SELECT
RIGHT(T_OrderHeaderLabNumber,7 ) T_OrderHeaderLabNumber ,
T_OrderHeaderLabNumber Full_T_OrderHeaderLabNumber,
T_SampleTypeName,
left(T_BarcodeLabBarcode ,13) T_BarcodeLabBarcode ,
T_BarcodeLabBarcode Full_T_BarcodeLabBarcode ,
CONCAT(M_TitleName,'. ',ifnull(M_PatientPrefix,'') , ' ' ,M_PatientName,' ' , ifnull(M_PatientSuffix,'')) M_PatientName,
M_PatientNoReg,
T_OrderHeaderM_PatientAge,
DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') AS M_PatientDOB,
if(M_PatientGender = 'male' , 'L' , 'P') as Gender,
CorporateName,M_PatientNIP,
DATE_FORMAT(T_OrderHeaderDate,'%d/%m/%Y') T_OrderHeaderDate,
case
when M_PatientGender = 'male' then 'M'
when M_PatientGender = 'female' then 'F'
end Sex,
T_SampleTypeSuffix
from t_barcodelab
join t_sampletype on T_BarcodeLabT_SampleTypeID = T_SampleTypeID
join t_orderheader on T_BarcodeLabT_OrderHeaderID = T_OrderHeaderID
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
join m_title on M_PatientM_TitleID = M_TitleID
left join corporate on T_OrderHeaderCorporateID = CorporateID and CorporateIsActive = 'Y'
where T_BarcodeLabBarcode in ( $s_bcode ) ";
$query = $this->db_onedev->query($sql);
//echo $sql;
$rows = $query->result_array();
$rst = [];
foreach ($rows as $key => $value) {
$rst[] = $value;
// if ($value['T_SampleTypeSuffix'] == 'UK') {
// $rst[] = $value;
// }
}
$updatedData = $this->duplicateDataByBarcode($a_bcodes, $rst);
echo json_encode(array(
"status" => "OK",
"message" => "",
"rows" => $updatedData
));
}
}