Initial import
This commit is contained in:
@@ -0,0 +1,547 @@
|
||||
<?php
|
||||
class Sampleadm extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
|
||||
function getphotos($orderid,$sampletypeid){
|
||||
$rows = [];
|
||||
//print_r($_SERVER);
|
||||
$urlbase = 'http://'.$_SERVER['SERVER_NAME']."/one-media/one-image-nonlab/";
|
||||
$sql = "SELECT So_ImageUploadID as id,
|
||||
So_ImageUploadOldName as oldname,
|
||||
CONCAT('{$urlbase}',So_ImageUploadNewName) as newname
|
||||
FROM so_imageupload
|
||||
WHERE
|
||||
So_ImageUploadT_OrderHeaderID = {$orderid} AND So_ImageUploadT_SampleTypeID = {$sampletypeid} AND So_ImageUploadIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
function getdoctors($sampletypeid){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT M_DoctorID as id,
|
||||
CONCAT(M_DoctorPrefix,' ',M_DoctorName,' ',M_DoctorSufix) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID
|
||||
JOIN t_test ON T_TestT_SampleTypeID = {$sampletypeid} AND M_DoctorSONat_SubGroupID = T_TestNat_SubgroupID
|
||||
WHERE
|
||||
M_DoctorSOIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
function getsetdoctoraddress($doctorid){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressM_DoctorID = {$doctorid} AND M_DoctorAddressIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = $prm["name"];
|
||||
$nolab = $prm["nolab"];
|
||||
$stationid = $prm["stationid"];
|
||||
$statusid = $prm["statusid"];
|
||||
$where_status = '';
|
||||
|
||||
$sql_where = "WHERE T_OrderHeaderIsActive = 'Y' {$where_status}";
|
||||
|
||||
//$sql_param = array();
|
||||
if ($name != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientName like '%$name%' ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
if ($nolab != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_OrderHeaderLabNumber like '%$nolab%' ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT T_BarcodeLabID
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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 t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoFlag = 'V' AND
|
||||
(('{$statusid}' = 'R' AND T_SamplingSoFlagSend = 'R' AND T_SamplingSoM_DoctorID = 0 ) OR ('{$statusid}' = 'C' AND T_SamplingSoFlagSend = 'R' AND T_SamplingSoM_DoctorID <> 0 )) AND
|
||||
T_SamplingSoIsActive = 'Y'
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
) a
|
||||
";
|
||||
//echo $sql;
|
||||
$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 T_OrderHeaderID,T_BarcodeLabID,T_BarcodeLabBarcode,T_SampleTypeName,T_OrderHeaderLabNumber,
|
||||
IFNULL(M_PatientPhoto,'') as M_PatientPhotoThumb,
|
||||
M_SexName, M_TitleName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as patient_dob,
|
||||
T_SampleStationID, T_SampleTypeID,
|
||||
{$stationid} as stationid,
|
||||
T_SamplingSoID,
|
||||
T_SamplingSoFlagSend as status,
|
||||
fn_global_check_is_cito(T_OrderHeaderID) as iscito,
|
||||
IF(ISNULL(T_SamplingSoRequirementID),'X',T_SamplingSoRequirementStatus) as requirement_status,
|
||||
'' as requirements,
|
||||
IF(ISNULL(M_DoctorName),'-',CONCAT(M_DoctorPrefix,M_DoctorPrefix2,' ',M_DoctorName,'...')) as doctor_fullname,
|
||||
T_SamplingSoFlagDoctorInOffice as flagdoctorinoffice,
|
||||
T_SamplingSoM_DoctorID
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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
|
||||
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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 AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoFlag = 'V' AND
|
||||
(('{$statusid}' = 'R' AND T_SamplingSoFlagSend = 'R' AND T_SamplingSoM_DoctorID = 0 ) OR ('{$statusid}' = 'C' AND T_SamplingSoFlagSend = 'R' AND T_SamplingSoM_DoctorID <> 0 )) AND
|
||||
T_SamplingSoIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON T_SamplingSoM_DoctorID = M_DoctorID
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_SamplingSoRequirementT_SampletypeID = T_SampletypeID AND
|
||||
T_SamplingSoRequirementNat_PositionID = 9 AND
|
||||
T_SamplingSoRequirementIsActive = 'Y'
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
ORDER BY iscito DESC,T_SamplingSoReceiveAdmDate ASC, T_SamplingSoReceiveAdmTime ASC,T_OrderHeaderID ASC
|
||||
limit 0,20";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$zxprm = array();
|
||||
$zxprm['status'] = $v['status'];
|
||||
$zxprm['orderid'] = $v['T_OrderHeaderID'];
|
||||
$zxprm['sampletypeid'] = $v['T_SampleTypeID'];
|
||||
$rows[$k]['requirements'] = $this->getrequirements($zxprm);
|
||||
}
|
||||
}
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getrequirements($prm){
|
||||
|
||||
|
||||
$query =" SELECT Nat_RequirementID as id,
|
||||
Nat_RequirementName as name, '{$prm['status']}' as status,
|
||||
if(ISNULL(T_SamplingSoRequirementID),'N', if(json_contains(T_SamplingSoRequirementRequirements,Nat_RequirementID),'Y','N') ) as chex,
|
||||
Nat_RequirementPositionNat_PositionID as positionid
|
||||
FROM nat_requirement
|
||||
JOIN nat_testrequirement ON Nat_TestRequirementNat_RequirementID = Nat_RequirementID
|
||||
JOIN nat_requirementposition ON Nat_RequirementPositionNat_RequirementID = Nat_RequirementID AND Nat_RequirementPositionNat_PositionID = 9 AND
|
||||
Nat_RequirementPositionIsActive = 'Y'
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestRequirementNat_TestID
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = {$prm['orderid']} AND
|
||||
T_SamplingSoRequirementT_SampletypeID = {$prm['sampletypeid']} AND T_SamplingSoRequirementNat_PositionID = Nat_RequirementPositionNat_PositionID
|
||||
WHERE
|
||||
Nat_TestRequirementIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function getstationstatus(){
|
||||
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 = 'ELECTROMEDIS'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['statuses'] = array(array('id'=>'R','name'=>'Sudah Terima'),array('id'=>'C','name'=>'Selesai'));
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function search_patient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$stationid = $prm["stationid"];
|
||||
$statusid = $prm["statusid"];
|
||||
|
||||
$sql_where = "WHERE T_OrderHeaderLabNumber = '{$search}' AND T_OrderHeaderIsActive = 'Y'";
|
||||
$rows = [];
|
||||
$query = "SELECT T_OrderHeaderID,T_BarcodeLabID,T_BarcodeLabBarcode,T_SampleTypeName,T_OrderHeaderLabNumber,
|
||||
IFNULL(M_PatientPhoto,'') as M_PatientPhotoThumb,
|
||||
M_SexName, M_TitleName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as patient_dob,
|
||||
T_SampleStationID, T_SampleTypeID,
|
||||
{$stationid} as stationid,
|
||||
T_SamplingSoID,
|
||||
T_SamplingSoFlagSend as status,
|
||||
fn_global_check_is_cito(T_OrderHeaderID) as iscito,
|
||||
IF(ISNULL(T_SamplingSoRequirementID),'X',T_SamplingSoRequirementStatus) as requirement_status,
|
||||
'' as requirements,
|
||||
IF(ISNULL(M_DoctorName),'-',CONCAT(M_DoctorPrefix,M_DoctorPrefix2,' ',M_DoctorName,'...')) as doctor_fullname,
|
||||
T_SamplingSoFlagDoctorInOffice as flagdoctorinoffice,
|
||||
T_SamplingSoM_DoctorID
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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
|
||||
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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 AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoFlag = 'V' AND
|
||||
(('{$statusid}' = 'R' AND T_SamplingSoFlagSend = 'R' AND T_SamplingSoM_DoctorID = 0 ) OR ('{$statusid}' = 'C' AND T_SamplingSoFlagSend = 'R' AND T_SamplingSoM_DoctorID <> 0 )) AND
|
||||
T_SamplingSoIsActive = 'Y'
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_SamplingSoRequirementT_SampletypeID = T_SampletypeID AND
|
||||
T_SamplingSoRequirementNat_PositionID = 9 AND
|
||||
T_SamplingSoRequirementIsActive = 'Y'
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
ORDER BY iscito DESC,T_OrderPromiseDateTime ASC, T_OrderHeaderID ASC, T_SamplingSoID ASC
|
||||
limit 0,20";
|
||||
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdoctoraddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressM_DoctorID = {$prm['id']} AND M_DoctorAddressIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$samples = $prm['sample'];
|
||||
|
||||
if($prm['act'] == 'receive'){
|
||||
foreach($samples as $k=>$v){
|
||||
$sql = "UPDATE t_samplingso SET
|
||||
T_SamplingSoFlagSend = 'R',
|
||||
T_SamplingSoReceiveAdmDate = CURDATE(),
|
||||
T_SamplingSoReceiveAdmTime = CURTIME(),
|
||||
T_SamplingSoReceiveAdmUserID = {$userid},
|
||||
T_SamplingSoUserID = {$userid}
|
||||
WHERE
|
||||
T_SamplingSoID = {$v['T_SamplingSoID']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['act'] == 'cancel'){
|
||||
foreach($samples as $k=>$v){
|
||||
$sql = "UPDATE t_samplingso SET
|
||||
T_SamplingSoFlagSend = 'Y',
|
||||
T_SamplingSoReceiveAdmDate = NULL,
|
||||
T_SamplingSoReceiveAdmTime = NULL,
|
||||
T_SamplingSoReceiveAdmUserID = NULL,
|
||||
T_SamplingSoUserID = {$userid}
|
||||
WHERE
|
||||
T_SamplingSoID = {$v['T_SamplingSoID']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['act'] == 'reject'){
|
||||
foreach($samples as $k=>$v){
|
||||
$sql = "UPDATE t_samplingso SET
|
||||
T_SamplingSoFlagSend = 'N',
|
||||
T_SamplingSoSendAdmDate = NULL,
|
||||
T_SamplingSoSendAdmTime = NULL,
|
||||
T_SamplingSoSendAdmUserID = NULL,
|
||||
T_SamplingSoUserID = {$userid}
|
||||
WHERE
|
||||
T_SamplingSoID = {$v['T_SamplingSoID']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['act'] == 'removedoctor'){
|
||||
foreach($samples as $k => $v){
|
||||
$query =" UPDATE t_samplingso SET
|
||||
T_SamplingSoFlagDoctorInOffice = 'N',
|
||||
T_SamplingSoM_DoctorID = 0,
|
||||
T_SamplingSoM_DoctorAddressID = 0
|
||||
WHERE
|
||||
T_SamplingSoID = {$v['T_SamplingSoID']}";
|
||||
//echo $query;
|
||||
$savedoctor = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
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'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name, '' as address
|
||||
FROM m_doctor
|
||||
JOIN m_doctorso ON M_DoctorSOM_DoctorID = M_DoctorID AND M_DoctorSOIsActive = 'Y'
|
||||
JOIN t_test ON T_TestNat_SubgroupID = M_DoctorSONat_SubGroupID AND T_TestIsActive = 'Y'
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID AND T_SampleTypeIsActive = 'Y'
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID AND T_BahanIsActive = 'Y'
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$prm['stationid']}
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
GROUP BY M_DoctorID
|
||||
)xx";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_DoctorID as id, M_DoctorName, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,' ',M_DoctorName,' ',M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name, '' as address
|
||||
FROM m_doctor
|
||||
JOIN m_doctorso ON M_DoctorSOM_DoctorID = M_DoctorID AND M_DoctorSOIsActive = 'Y'
|
||||
JOIN t_test ON T_TestNat_SubgroupID = M_DoctorSONat_SubGroupID AND T_TestIsActive = 'Y'
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID AND T_SampleTypeIsActive = 'Y'
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID AND T_BahanIsActive = 'Y'
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$prm['stationid']}
|
||||
WHERE
|
||||
CONCAT(M_DoctorPrefix,M_DoctorPrefix2,' ',M_DoctorName,' ',M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) like ?
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
GROUP BY M_DoctorID
|
||||
ORDER BY M_DoctorName DESC
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['address'] = $this->db_onedev->query("SELECT * FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = {$v['id']} AND M_DoctorAddressIsActive = 'Y'")->result_array();
|
||||
}
|
||||
//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_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function savedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sel_patient = $prm['selected_patient'];
|
||||
$sel_doctor = $prm['selected_doctor'];
|
||||
$sel_doctor_address = $prm['selected_doctor_address'];
|
||||
$flagdoctorinoffice = $prm['flagdoctorinoffice'] == true ? 'Y':'N';
|
||||
foreach($sel_patient as $k => $v){
|
||||
$query =" UPDATE t_samplingso SET
|
||||
T_SamplingSoFlagDoctorInOffice = '{$flagdoctorinoffice}',
|
||||
T_SamplingSoM_DoctorID = {$sel_doctor['id']},
|
||||
T_SamplingSoM_DoctorAddressID = {$sel_doctor_address['M_DoctorAddressID']}
|
||||
WHERE
|
||||
T_SamplingSoID = {$v['T_SamplingSoID']}";
|
||||
//echo $query;
|
||||
$savedoctor = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($savedoctor){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db("doctor update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function deletephoto(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query =" UPDATE so_imageupload SET So_ImageUploadIsActive = 'N', So_ImageUploadUserID = {$userid} WHERE So_ImageUploadID = {$prm['id']}";
|
||||
//echo $query;
|
||||
$actdelete = $this->db_onedev->query($query);
|
||||
|
||||
if($actdelete){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db("so_imageupload delete", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
<?php
|
||||
class Samplereceivedadm extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
|
||||
function getphotos($orderid,$sampletypeid){
|
||||
$rows = [];
|
||||
//print_r($_SERVER);
|
||||
$urlbase = 'http://'.$_SERVER['SERVER_NAME']."/one-media/one-image-nonlab/";
|
||||
$sql = "SELECT So_ImageUploadID as id,
|
||||
So_ImageUploadOldName as oldname,
|
||||
CONCAT('{$urlbase}',So_ImageUploadNewName) as newname
|
||||
FROM so_imageupload
|
||||
WHERE
|
||||
So_ImageUploadT_OrderHeaderID = {$orderid} AND So_ImageUploadT_SampleTypeID = {$sampletypeid} AND So_ImageUploadIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
function getdoctors($sampletypeid){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT M_DoctorID as id,
|
||||
CONCAT(M_DoctorPrefix,' ',M_DoctorName,' ',M_DoctorSufix) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID
|
||||
JOIN t_test ON T_TestT_SampleTypeID = {$sampletypeid} AND M_DoctorSONat_SubGroupID = T_TestNat_SubgroupID
|
||||
WHERE
|
||||
M_DoctorSOIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
function getsetdoctoraddress($doctorid){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressM_DoctorID = {$doctorid} AND M_DoctorAddressIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = $prm["name"];
|
||||
$nolab = $prm["nolab"];
|
||||
$stationid = $prm["stationid"];
|
||||
$statusid = 'Y';
|
||||
$where_status = '';
|
||||
|
||||
$sql_where = "WHERE T_OrderHeaderIsActive = 'Y' {$where_status}";
|
||||
|
||||
//$sql_param = array();
|
||||
if ($name != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientName like '%$name%' ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
if ($nolab != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_OrderHeaderLabNumber like '%$nolab%' ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT T_BarcodeLabID
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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 t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoFlag = 'V' AND
|
||||
T_SamplingSoFlagSend = '{$statusid}' AND T_SamplingSoIsActive = 'Y'
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
) a
|
||||
";
|
||||
//echo $sql;
|
||||
$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 T_OrderHeaderID,T_BarcodeLabID,T_BarcodeLabBarcode,T_SampleTypeName,T_OrderHeaderLabNumber,
|
||||
IFNULL(M_PatientPhoto,'') as M_PatientPhotoThumb,
|
||||
M_SexName, M_TitleName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as patient_dob,
|
||||
T_SampleStationID, T_SampleTypeID,
|
||||
{$stationid} as stationid,
|
||||
T_SamplingSoID,
|
||||
T_SamplingSoFlagSend as status,
|
||||
fn_global_check_is_cito(T_OrderHeaderID) as iscito,
|
||||
IF(ISNULL(T_SamplingSoRequirementID),'X',T_SamplingSoRequirementStatus) as requirement_status,
|
||||
'' as requirements
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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
|
||||
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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 AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoFlag = 'V' AND
|
||||
T_SamplingSoFlagSend = '{$statusid}' AND T_SamplingSoIsActive = 'Y'
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_SamplingSoRequirementT_SampletypeID = T_SampletypeID AND
|
||||
T_SamplingSoRequirementNat_PositionID = 9 AND
|
||||
T_SamplingSoRequirementIsActive = 'Y'
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
ORDER BY iscito DESC,T_SamplingSoSendAdmDate ASC, T_SamplingSoSendAdmTime ASC, T_OrderHeaderID ASC
|
||||
limit 0,20";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$zxprm = array();
|
||||
$zxprm['status'] = $v['status'];
|
||||
$zxprm['orderid'] = $v['T_OrderHeaderID'];
|
||||
$zxprm['sampletypeid'] = $v['T_SampleTypeID'];
|
||||
$rows[$k]['requirements'] = $this->getrequirements($zxprm);
|
||||
}
|
||||
}
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getrequirements($prm){
|
||||
|
||||
|
||||
$query =" SELECT Nat_RequirementID as id,
|
||||
Nat_RequirementName as name, '{$prm['status']}' as status,
|
||||
if(ISNULL(T_SamplingSoRequirementID),'N', if(json_contains(T_SamplingSoRequirementRequirements,Nat_RequirementID),'Y','N') ) as chex,
|
||||
Nat_RequirementPositionNat_PositionID as positionid
|
||||
FROM nat_requirement
|
||||
JOIN nat_testrequirement ON Nat_TestRequirementNat_RequirementID = Nat_RequirementID
|
||||
JOIN nat_requirementposition ON Nat_RequirementPositionNat_RequirementID = Nat_RequirementID AND Nat_RequirementPositionNat_PositionID = 9 AND
|
||||
Nat_RequirementPositionIsActive = 'Y'
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestRequirementNat_TestID
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = {$prm['orderid']} AND
|
||||
T_SamplingSoRequirementT_SampletypeID = {$prm['sampletypeid']} AND T_SamplingSoRequirementNat_PositionID = Nat_RequirementPositionNat_PositionID
|
||||
WHERE
|
||||
Nat_TestRequirementIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function getstationstatus(){
|
||||
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 = 'ELECTROMEDIS'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['statuses'] = array(array('id'=>'Y','name'=>'Belum Terima'),array('id'=>'R','name'=>'Sudah Terima'));
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function search_patient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$stationid = $prm["stationid"];
|
||||
$statusid = 'Y';
|
||||
|
||||
$sql_where = "WHERE T_OrderHeaderLabNumber = '{$search}' AND T_OrderHeaderIsActive = 'Y'";
|
||||
$rows = [];
|
||||
$query = "SELECT T_OrderHeaderID,T_BarcodeLabID,T_BarcodeLabBarcode,T_SampleTypeName,T_OrderHeaderLabNumber,
|
||||
IFNULL(M_PatientPhoto,'') as M_PatientPhotoThumb,
|
||||
M_SexName, M_TitleName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as patient_dob,
|
||||
T_SampleStationID, T_SampleTypeID,
|
||||
{$stationid} as stationid,
|
||||
T_SamplingSoID,
|
||||
T_SamplingSoFlagSend as status,
|
||||
fn_global_check_is_cito(T_OrderHeaderID) as iscito,
|
||||
IF(ISNULL(T_SamplingSoRequirementID),'X',T_SamplingSoRequirementStatus) as requirement_status,
|
||||
'' as requirements
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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
|
||||
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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 AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoFlag = 'V' AND
|
||||
T_SamplingSoFlagSend = '{$statusid}' AND T_SamplingSoIsActive = 'Y'
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_SamplingSoRequirementT_SampletypeID = T_SampletypeID AND
|
||||
T_SamplingSoRequirementNat_PositionID = 9 AND
|
||||
T_SamplingSoRequirementIsActive = 'Y'
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
ORDER BY iscito DESC,T_OrderPromiseDateTime ASC, T_OrderHeaderID ASC, T_SamplingSoID ASC
|
||||
limit 0,20";
|
||||
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdoctoraddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressM_DoctorID = {$prm['id']} AND M_DoctorAddressIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$samples = $prm['sample'];
|
||||
|
||||
if($prm['act'] == 'receive'){
|
||||
foreach($samples as $k=>$v){
|
||||
$sql = "UPDATE t_samplingso SET
|
||||
T_SamplingSoFlagSend = 'R',
|
||||
T_SamplingSoReceiveAdmDate = CURDATE(),
|
||||
T_SamplingSoReceiveAdmTime = CURTIME(),
|
||||
T_SamplingSoReceiveAdmUserID = {$userid},
|
||||
T_SamplingSoUserID = {$userid}
|
||||
WHERE
|
||||
T_SamplingSoID = {$v['T_SamplingSoID']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['act'] == 'cancel'){
|
||||
foreach($samples as $k=>$v){
|
||||
$sql = "UPDATE t_samplingso SET
|
||||
T_SamplingSoFlagSend = 'Y',
|
||||
T_SamplingSoReceiveAdmDate = NULL,
|
||||
T_SamplingSoReceiveAdmTime = NULL,
|
||||
T_SamplingSoReceiveAdmUserID = NULL,
|
||||
T_SamplingSoUserID = {$userid}
|
||||
WHERE
|
||||
T_SamplingSoID = {$v['T_SamplingSoID']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['act'] == 'reject'){
|
||||
foreach($samples as $k=>$v){
|
||||
$sql = "UPDATE t_samplingso SET
|
||||
T_SamplingSoFlagSend = 'N',
|
||||
T_SamplingSoSendAdmDate = NULL,
|
||||
T_SamplingSoSendAdmTime = NULL,
|
||||
T_SamplingSoSendAdmUserID = NULL,
|
||||
T_SamplingSoUserID = {$userid}
|
||||
WHERE
|
||||
T_SamplingSoID = {$v['T_SamplingSoID']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletephoto(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query =" UPDATE so_imageupload SET So_ImageUploadIsActive = 'N', So_ImageUploadUserID = {$userid} WHERE So_ImageUploadID = {$prm['id']}";
|
||||
//echo $query;
|
||||
$actdelete = $this->db_onedev->query($query);
|
||||
|
||||
if($actdelete){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db("so_imageupload delete", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
class Samplesend extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = $prm["name"];
|
||||
$nolab = $prm["nolab"];
|
||||
$stationid = $prm["stationid"];
|
||||
$statusid = "V";
|
||||
|
||||
$sql_where = "WHERE T_OrderHeaderIsActive = 'Y'";
|
||||
|
||||
//$sql_param = array();
|
||||
if ($name != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientName like '%$name%' ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
if ($nolab != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_OrderHeaderLabNumber like '%$nolab%' ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT T_BarcodeLabID
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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 t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoFlag = '{$statusid}' AND T_SamplingSoIsActive = 'Y'
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
) a
|
||||
";
|
||||
//echo $sql;
|
||||
$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 T_OrderHeaderID,T_BarcodeLabID,T_BarcodeLabBarcode,T_SampleTypeName,T_OrderHeaderLabNumber,
|
||||
IFNULL(M_PatientPhoto,'') as M_PatientPhotoThumb,
|
||||
M_SexName, M_TitleName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as patient_dob,
|
||||
T_SampleStationID, T_SampleTypeID,
|
||||
{$stationid} as stationid,
|
||||
T_SamplingSoID,
|
||||
T_SamplingSoFlagSend as status,
|
||||
fn_global_check_is_cito(T_OrderHeaderID) as iscito,
|
||||
'N' as chex
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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
|
||||
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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 AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoFlag = '{$statusid}' AND T_SamplingSoFlagSend = 'N' AND T_SamplingSoIsActive = 'Y'
|
||||
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
ORDER BY iscito DESC,T_SamplingSoVerifyDate ASC,T_SamplingSoVerifyTime ASC, T_OrderHeaderID ASC
|
||||
limit 0,20";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N'){
|
||||
$rows[$k]['chex'] = false;
|
||||
}else{
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getrequirements($prm){
|
||||
|
||||
|
||||
$query =" SELECT Nat_RequirementID as id,
|
||||
Nat_RequirementName as name, '{$prm['status']}' as status,
|
||||
if(ISNULL(T_SamplingSoRequirementID),'N', if(json_contains(T_SamplingSoRequirementRequirements,Nat_RequirementID),'Y','N') ) as chex,
|
||||
Nat_RequirementPositionNat_PositionID as positionid
|
||||
FROM nat_requirement
|
||||
JOIN nat_testrequirement ON Nat_TestRequirementNat_RequirementID = Nat_RequirementID
|
||||
JOIN nat_requirementposition ON Nat_RequirementPositionNat_RequirementID = Nat_RequirementID AND Nat_RequirementPositionNat_PositionID = 9 AND
|
||||
Nat_RequirementPositionIsActive = 'Y'
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestRequirementNat_TestID
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = {$prm['orderid']} AND
|
||||
T_SamplingSoRequirementT_SampletypeID = {$prm['sampletypeid']} AND T_SamplingSoRequirementNat_PositionID = Nat_RequirementPositionNat_PositionID
|
||||
WHERE
|
||||
Nat_TestRequirementIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function getstationstatus(){
|
||||
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 = 'ELECTROMEDIS'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['statuses'] = array(array('id'=>'D','name'=>'Belum Verifikasi'),array('id'=>'V','name'=>'Sudah Verifikasi'));
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function search_patient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$stationid = $prm["stationid"];
|
||||
|
||||
$sql_where = "WHERE T_OrderHeaderLabNumber = '{$search}' AND T_OrderHeaderIsActive = 'Y'";
|
||||
$rows = [];
|
||||
$query = "SELECT T_OrderHeaderID,T_BarcodeLabID,T_BarcodeLabBarcode,T_SampleTypeName,T_OrderHeaderLabNumber,
|
||||
IFNULL(M_PatientPhoto,'') as M_PatientPhotoThumb,
|
||||
M_SexName, M_TitleName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as patient_dob,
|
||||
T_SampleStationID, T_SampleTypeID,
|
||||
{$stationid} as stationid,
|
||||
T_SamplingSoID,
|
||||
T_SamplingSoFlagSend as status,
|
||||
fn_global_check_is_cito(T_OrderHeaderID) as iscito,
|
||||
'Y' as chex
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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
|
||||
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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 AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoFlag = 'V' AND T_SamplingSoFlagSend = 'N' AND T_SamplingSoIsActive = 'Y'
|
||||
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
ORDER BY iscito DESC,T_OrderPromiseDateTime ASC, T_OrderHeaderID ASC, T_SamplingSoID ASC
|
||||
limit 0,20";
|
||||
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$samples = $prm['sample'];
|
||||
|
||||
if($prm['act'] == 'send'){
|
||||
foreach($samples as $k=>$v){
|
||||
$sql = "UPDATE t_samplingso SET
|
||||
T_SamplingSoFlagSend = 'Y',
|
||||
T_SamplingSoSendAdmDate = CURDATE(),
|
||||
T_SamplingSoSendAdmTime = CURTIME(),
|
||||
T_SamplingSoSendAdmUserID = {$userid},
|
||||
T_SamplingSoUserID = {$userid}
|
||||
WHERE
|
||||
T_SamplingSoID = {$v['T_SamplingSoID']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletephoto(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query =" UPDATE so_imageupload SET So_ImageUploadIsActive = 'N', So_ImageUploadUserID = {$userid} WHERE So_ImageUploadID = {$prm['id']}";
|
||||
//echo $query;
|
||||
$actdelete = $this->db_onedev->query($query);
|
||||
|
||||
if($actdelete){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db("so_imageupload delete", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,692 @@
|
||||
<?php
|
||||
class Samplingcall extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingcall API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function getsampletypes(){
|
||||
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$orderid = $prm['orderid'];
|
||||
$stationid = $prm['stationid'];
|
||||
$statusid = $prm['statusid'];
|
||||
$rows = array();
|
||||
|
||||
$sql = "SELECT T_OrderDetailID, T_OrderHeaderID,T_OrderDetailID as id,
|
||||
T_BarcodeLabID,
|
||||
T_BarcodeLabBarcode,
|
||||
T_OrderDetailT_TestCode,
|
||||
T_OrderDetailT_TestName,
|
||||
T_SampleTypeID,
|
||||
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,
|
||||
IF(ISNULL(T_SamplingSoRequirementID),'X',T_SamplingSoRequirementStatus) 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
|
||||
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_SampleTypeID = T_SampleTypeID AND T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoIsActive = 'Y'
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_SamplingSoID = T_SamplingSoID AND T_SamplingSoRequirementT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_SamplingSoRequirementT_SampletypeID = T_SampletypeID AND
|
||||
T_SamplingSoRequirementNat_PositionID = 8 AND
|
||||
T_SamplingSoRequirementIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderHeaderID = {$orderid} AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY T_SampleTypeID";
|
||||
//echo $sql;
|
||||
$rows['sampletypes'] = $this->db_onedev->query($sql)->result_array();
|
||||
if($rows){
|
||||
foreach($rows['sampletypes'] as $k => $v){
|
||||
$zxprm = array();
|
||||
$zxprm['status'] = $v['status'];
|
||||
$zxprm['orderdetailid'] = $v['T_OrderDetailID'];
|
||||
$zxprm['orderid'] = $v['T_OrderHeaderID'];
|
||||
$zxprm['sampletypeid'] = $v['T_SampleTypeID'];
|
||||
$rows['sampletypes'][$k]['requirements'] = $this->getrequirements($zxprm);
|
||||
}
|
||||
}
|
||||
$sql = "SELECT T_BahanID as id, T_BahanName,
|
||||
fn_sampling_receive_status_by_bahan_lab(T_OrderDetailT_OrderHeaderID, T_BarcodeLabID,T_SampleTypeID, IF(T_TestIsNonLab = '','Y','N')) as status_bahan
|
||||
FROM t_orderdetail
|
||||
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_OrderDetailT_OrderHeaderID AND T_BarcodeLabT_SampleTypeID = T_SampleTypeID
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderid}
|
||||
GROUP BY T_BahanID";
|
||||
//echo $sql;
|
||||
$rows['information_bahan'] = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = $prm["name"];
|
||||
$nolab = $prm["nolab"];
|
||||
$stationid = $prm["stationid"];
|
||||
$statusid = $prm["statusid"];
|
||||
$companyid = isset($prm["companyid"])?$prm["companyid"]:0;
|
||||
$search = isset($prm["searchx"])?$prm["searchx"]:'';
|
||||
$filter_companyid = '';
|
||||
if($companyid != 0 || $companyid != '0'){
|
||||
$filter_companyid = " AND M_CompanyID = {$companyid} ";
|
||||
}
|
||||
$where_status = '';
|
||||
if($statusid === 'NEW'){
|
||||
$where_status = "AND (ISNULL(T_SamplingQueueLastStatusID) OR T_SamplingQueueLastStatusT_SamplingQueueStatusID <> 5 )";
|
||||
}
|
||||
else{
|
||||
$where_status = "AND T_SamplingQueueLastStatusT_SamplingQueueStatusID = 5";
|
||||
}
|
||||
|
||||
// echo $norm;
|
||||
//$where_status = " AND {$where_status}";
|
||||
|
||||
$sql_where = "WHERE T_OrderHeaderIsActive = 'Y' {$where_status}";
|
||||
|
||||
//$sql_param = array();
|
||||
if ($name != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientName like '%$name%' ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
if ($nolab != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_OrderHeaderLabNumber like '%$nolab%' ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
if($search != ''){
|
||||
$sql_where = "WHERE T_OrderHeaderIsActive = 'Y' AND T_OrderHeaderLabNumber = '{$search}'";
|
||||
}
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT T_OrderHeaderID
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID $filter_companyid
|
||||
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 t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID AND ( Last_StatusM_StatusID = 3 OR Last_StatusM_StatusID = 5 )
|
||||
LEFT JOIN t_sampling_queue_last_status ON
|
||||
T_SamplingQueueLastStatusT_SampleStationID = T_SampleStationID AND
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_sampling_queue_status ON T_SamplingQueueLastStatusT_SamplingQueueStatusID = T_SamplingQueueStatusID
|
||||
LEFT JOIN t_ordersamplereq ON T_OrderSampleReqT_SampleStationID = T_SampleStationID AND T_OrderSampleReqT_OrderSampleID
|
||||
$sql_where
|
||||
GROUP BY T_OrderHeaderID
|
||||
) a
|
||||
";
|
||||
//echo $sql;
|
||||
$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 t_orderheader.*,m_patient.*, IFNULL(M_PatientPhoto,'') as M_PatientPhotoThumb,
|
||||
M_SexName, M_TitleName, CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname, M_CompanyName,
|
||||
IF(ISNULL(T_SamplingQueueLastStatusID), 'New',T_SamplingQueueStatusName) as status, DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as patient_dob,
|
||||
IF(ISNULL(T_SamplingQueueLastStatusID), 0,T_SamplingQueueLastStatusT_SamplingQueueStatusID) as statusid, T_SampleStationID, T_SampleTypeID,
|
||||
{$stationid} as stationid,
|
||||
T_OrderPromiseDateTime,
|
||||
fn_global_check_is_cito(T_OrderHeaderID) as iscito
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID $filter_companyid
|
||||
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
|
||||
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID AND ( Last_StatusM_StatusID = 3 OR Last_StatusM_StatusID = 5 )
|
||||
LEFT JOIN t_sampling_queue_last_status ON
|
||||
T_SamplingQueueLastStatusT_SampleStationID = T_SampleStationID AND
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_sampling_queue_status ON T_SamplingQueueLastStatusT_SamplingQueueStatusID = T_SamplingQueueStatusID
|
||||
LEFT JOIN t_ordersamplereq ON T_OrderSampleReqT_SampleStationID = T_SampleStationID AND T_OrderSampleReqT_OrderSampleID
|
||||
$sql_where
|
||||
GROUP BY T_OrderHeaderID
|
||||
ORDER BY iscito DESC,T_OrderHeaderID ASC,T_OrderPromiseDateTime ASC
|
||||
limit 0,20";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "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'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$rows = array('id'=>0,'name'=>'Semua');
|
||||
$sql = "
|
||||
SELECT 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 getstationstatus(){
|
||||
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 = 'ELECTROMEDIS'
|
||||
";
|
||||
//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 search_staff(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT M_StaffID as id, M_StaffName as name, M_StaffCode as code, M_UserID as userid
|
||||
FROM m_staff
|
||||
JOIN m_user ON M_UserM_StaffID = M_StaffID AND M_UserIsActive = 'Y'
|
||||
WHERE
|
||||
M_StaffIsActive = 'Y' AND M_StaffCode = '{$prm['search']}' LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->row_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function search_patient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$stationid = $prm["stationid"];
|
||||
$statusid = $prm["statusid"];
|
||||
$patients = $prm["patients"];
|
||||
$where_status = '';
|
||||
if($statusid === 'NEW'){
|
||||
$where_status = "AND (ISNULL(T_SamplingQueueLastStatusID) OR T_SamplingQueueLastStatusT_SamplingQueueStatusID <> 5 )";
|
||||
}
|
||||
else{
|
||||
$where_status = "AND T_SamplingQueueLastStatusT_SamplingQueueStatusID = 5";
|
||||
}
|
||||
|
||||
// echo $norm;
|
||||
//$where_status = " AND {$where_status}";
|
||||
|
||||
$sql_where = "WHERE T_OrderHeaderLabNumber = '{$search}' AND T_OrderHeaderIsActive = 'Y' {$where_status}";
|
||||
$rows = [];
|
||||
$query = "SELECT t_orderheader.*,m_patient.*, IFNULL(M_PatientPhoto,'') as M_PatientPhotoThumb,
|
||||
M_SexName, M_TitleName, CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname, M_CompanyName,
|
||||
IF(ISNULL(T_SamplingQueueLastStatusID), 'New',T_SamplingQueueStatusName) as status, DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as patient_dob,
|
||||
IF(ISNULL(T_SamplingQueueLastStatusID), 0,T_SamplingQueueLastStatusT_SamplingQueueStatusID) as statusid, T_SampleStationID, T_SampleTypeID,
|
||||
{$stationid} as stationid,
|
||||
fn_global_check_is_cito(T_OrderHeaderID) as iscito
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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 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
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = 'XRAY'
|
||||
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID AND ( Last_StatusM_StatusID = 3 OR Last_StatusM_StatusID = 5 )
|
||||
LEFT JOIN t_sampling_queue_last_status ON
|
||||
T_SamplingQueueLastStatusT_SampleStationID = T_SampleStationID AND
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_sampling_queue_status ON T_SamplingQueueLastStatusT_SamplingQueueStatusID = T_SamplingQueueStatusID
|
||||
LEFT JOIN t_ordersamplereq ON T_OrderSampleReqT_SampleStationID = T_SampleStationID AND T_OrderSampleReqT_OrderSampleID
|
||||
$sql_where
|
||||
GROUP BY T_OrderHeaderID
|
||||
ORDER BY T_OrderHeaderID DESC
|
||||
limit 1";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
/*function getrequirements($prm){
|
||||
|
||||
|
||||
$query =" SELECT Nat_RequirementID as id,
|
||||
Nat_RequirementName as name, '{$prm['status']}' as status,
|
||||
if(ISNULL(T_SamplingSoRequirementID),'N', if(json_contains(T_SamplingSoRequirementRequirements,Nat_RequirementID),'Y','N') ) as chex,
|
||||
Nat_RequirementPositionNat_PositionID as positionid
|
||||
FROM nat_requirement
|
||||
JOIN nat_testrequirement ON Nat_TestRequirementNat_RequirementID = Nat_RequirementID
|
||||
JOIN nat_requirementposition ON Nat_RequirementPositionNat_RequirementID = Nat_RequirementID AND Nat_RequirementPositionNat_PositionID = 8 AND
|
||||
Nat_RequirementPositionIsActive = 'Y'
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestRequirementNat_TestID
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = {$prm['orderid']} AND
|
||||
T_SamplingSoRequirementT_SampletypeID = {$prm['sampletypeid']} AND T_SamplingSoRequirementNat_PositionID = Nat_RequirementPositionNat_PositionID
|
||||
WHERE
|
||||
Nat_TestRequirementIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
return $rows;
|
||||
}*/
|
||||
|
||||
function getrequirements($prm){
|
||||
|
||||
$rows = array();
|
||||
$query = "
|
||||
SELECT Nat_RequirementID as id,
|
||||
Nat_RequirementName as name, 'P' as status,
|
||||
if(ISNULL(T_SamplingSoRequirementID),'N', if(json_contains(T_SamplingSoRequirementRequirements,Nat_RequirementID),'Y','N') ) as chex,
|
||||
Nat_RequirementPositionNat_PositionID as positionid
|
||||
FROM nat_requirement
|
||||
JOIN nat_testrequirement ON Nat_TestRequirementNat_RequirementID = Nat_RequirementID
|
||||
JOIN nat_requirementposition ON Nat_RequirementPositionNat_RequirementID = Nat_RequirementID AND Nat_RequirementPositionNat_PositionID = 8 AND
|
||||
Nat_RequirementPositionIsActive = 'Y'
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestRequirementNat_TestID
|
||||
JOIN t_barcodelab ON T_barcodeLabT_OrderHeaderID = {$prm['orderid']} AND T_BarcodeLabT_SampleTypeID = {$prm['sampletypeid']}
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = {$prm['orderid']} AND T_SamplingSoT_SampleTypeID = {$prm['sampletypeid']} AND
|
||||
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoIsActive = 'Y'
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_SamplingSoID = T_SamplingSoID AND T_SamplingSoRequirementT_OrderHeaderID = {$prm['orderid']} AND
|
||||
T_SamplingSoRequirementT_SampletypeID = {$prm['sampletypeid']} AND T_SamplingSoRequirementNat_PositionID = Nat_RequirementPositionNat_PositionID
|
||||
WHERE
|
||||
Nat_TestRequirementIsActive = 'Y'
|
||||
GROUP BY nat_requirementID
|
||||
";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function saverequirement(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query = " INSERT INTO t_samplingso_requirement (
|
||||
T_SamplingSoRequirementT_OrderHeaderID,
|
||||
T_SamplingSoRequirementT_SampleStationID,
|
||||
T_SamplingSoRequirementT_SampletypeID,
|
||||
T_SamplingSoRequirementStatus,
|
||||
T_SamplingSoRequirementRequirements,
|
||||
T_SamplingSoRequirementNote,
|
||||
T_SamplingSoRequirementNat_PositionID,
|
||||
T_SamplingSoRequirementUserID,
|
||||
T_SamplingSoRequirementCreated
|
||||
)VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
{$prm['stationid']},
|
||||
{$prm['sample']['T_SampleTypeID']},
|
||||
'N',
|
||||
|
||||
)";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rst_data = array('status'=>'OK');
|
||||
$status_call = array('status'=>'OK','data'=>array());
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($prm['staff']['id'] != 0 || $prm['staff']['id'] != '0' ){
|
||||
$userid = $prm['staff']['userid'];
|
||||
}
|
||||
|
||||
if($prm['act'] == 'call'){
|
||||
$sql = "SELECT if(fn_sampling_available_call({$prm['id']},{$prm['stationid']})=0,'Y','N') as status_call";
|
||||
$sql = "SELECT T_SamplingQueueLastStatusID, T_SamplingQueueStatusName, T_SampleStationName
|
||||
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 = {$prm['id']} AND
|
||||
T_SamplingQueueLastStatusT_SampleStationID <> {$prm['stationid']} AND
|
||||
T_SamplingQueueLastStatusT_SamplingQueueStatusID IN (1,3) LIMIT 1";
|
||||
$data_status_call = $this->db_onedev->query($sql)->row_array();
|
||||
if($data_status_call){
|
||||
$status_call = array('status'=>'NOTCALL','data'=>$data_status_call);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$next_status = $prm['statusnextid'];
|
||||
if($prm['act'] == 'process'){
|
||||
$sql = "SELECT T_OrderDetailID, T_OrderHeaderID,T_OrderDetailID as id,
|
||||
T_BarcodeLabID,
|
||||
T_BarcodeLabBarcode,
|
||||
T_OrderDetailT_TestCode,
|
||||
T_OrderDetailT_TestName,
|
||||
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
|
||||
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 = {$prm['stationid']}
|
||||
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND T_SamplingSoFlag <> 'D' AND T_SamplingSoIsActive = 'Y'
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_SamplingSoRequirementT_SampletypeID = T_SampletypeID AND
|
||||
T_SamplingSoRequirementIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['id']} AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY T_SampleTypeID";
|
||||
//echo $sql;
|
||||
$rows_all_sample = $this->db_onedev->query($sql)->result();
|
||||
if($rows_all_sample){
|
||||
foreach($rows_all_sample as $k => $v){
|
||||
$sql = "INSERT INTO t_samplingso (
|
||||
T_SamplingSoT_OrderHeaderID,
|
||||
T_SamplingSoT_SampleTypeID,
|
||||
T_SamplingSoT_BarcodeLabID,
|
||||
T_SamplingSoProcessDate,
|
||||
T_SamplingSoProcessTime,
|
||||
T_SamplingSoProcessUserID,
|
||||
T_SamplingSoCreated,
|
||||
T_SamplingSoUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['id']},
|
||||
{$v->T_SampleTypeID},
|
||||
{$v->T_BarcodeLabID},
|
||||
CURDATE(),
|
||||
CURTIME(),
|
||||
{$userid},
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoProcessDate = CURDATE(),
|
||||
T_SamplingSoProcessTime = CURTIME(),
|
||||
T_SamplingSoFlag = 'P',
|
||||
T_SamplingSoIsActive = 'Y',
|
||||
T_SamplingSoProcessUserID = {$userid},
|
||||
T_SamplingSoUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['act'] == 'samplingdone'){
|
||||
$sql = "INSERT INTO t_samplingso (
|
||||
T_SamplingSoT_OrderHeaderID,
|
||||
T_SamplingSoT_SampleTypeID,
|
||||
T_SamplingSoT_BarcodeLabID,
|
||||
T_SamplingSoDoneDate,
|
||||
T_SamplingSoDoneTime,
|
||||
T_SamplingSoDoneUserID,
|
||||
T_SamplingSoCreated,
|
||||
T_SamplingSoUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['sample']['T_OrderHeaderID']},
|
||||
{$prm['sample']['T_SampleTypeID']},
|
||||
{$prm['sample']['T_BarcodeLabID']},
|
||||
CURDATE(),
|
||||
CURTIME(),
|
||||
{$userid},
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoDoneDate = CURDATE(),
|
||||
T_SamplingSoDoneTime = CURTIME(),
|
||||
T_SamplingSoFlag = 'D',
|
||||
T_SamplingSoIsActive = 'Y',
|
||||
T_SamplingSoDoneUserID = {$userid},
|
||||
T_SamplingSoUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $sql;
|
||||
$xreq = $prm['sample']['requirements'];
|
||||
$arr_requirements = array();
|
||||
foreach($xreq as $k=>$v){
|
||||
if($v['chex'] == 'Y')
|
||||
array_push($arr_requirements,$v['id']);
|
||||
}
|
||||
$requirements = '['.join(',',$arr_requirements).']';
|
||||
|
||||
$sql = "INSERT INTO t_samplingso_requirement(
|
||||
T_SamplingSoRequirementT_OrderHeaderID,
|
||||
T_SamplingSoRequirementT_SampleStationID,
|
||||
T_SamplingSoRequirementT_SampletypeID,
|
||||
T_SamplingSoRequirementT_SamplingSoID,
|
||||
T_SamplingSoRequirementNat_PositionID,
|
||||
T_SamplingSoRequirementStatus,
|
||||
T_SamplingSoRequirementRequirements,
|
||||
T_SamplingSoRequirementUserID,
|
||||
T_SamplingSoRequirementCreated
|
||||
)
|
||||
VALUES(
|
||||
{$prm['sample']['T_OrderHeaderID']},
|
||||
{$prm['stationid']},
|
||||
{$prm['sample']['T_SampleTypeID']},
|
||||
{$prm['sample']['T_SamplingSoID']},
|
||||
{$prm['sample']['requirements'][0]['positionid']},
|
||||
'{$prm['sample']['requirement_status']}',
|
||||
'{$requirements}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoRequirementStatus = '{$prm['sample']['requirement_status']}',
|
||||
T_SamplingSoRequirementRequirements = '{$requirements}',
|
||||
T_SamplingSoRequirementUserID = {$userid}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$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 = {$prm['stationid']}
|
||||
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['id']} AND T_SamplingSoT_SampleTypeID <> {$prm['sample']['T_SampleTypeID']} AND
|
||||
(ISNULL(T_SamplingSoID) OR T_SamplingSoFlag = 'P') AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY T_BarcodeLabID ) xx";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->xcount;
|
||||
$rst_data = array('status'=>'PARTIAL');
|
||||
if($xcount == 0){
|
||||
$next_status = 5;
|
||||
$rst_data = array('status'=>'OK');
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['act'] !== 'samplingprocess' && $status_call['status'] == 'OK'){
|
||||
$dt_json = json_encode(array('T_SampleStationID'=>$prm['stationid'],'T_OrderHeaderID'=>$prm['id'],'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 = {$prm['stationid']} AND
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID = {$prm['id']} AND
|
||||
T_SamplingQueueLastStatusIsActive = 'Y'";
|
||||
$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(
|
||||
{$prm['stationid']},
|
||||
{$prm['id']},
|
||||
{$next_status},
|
||||
{$userid}) ON DUPLICATE KEY UPDATE T_SamplingQueueLastStatusT_SamplingQueueStatusID = {$next_status}";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($status_call['status'] == 'NOTCALL'){
|
||||
$rst_data = $status_call;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rst_data
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
class SamplingUpload extends MY_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
function get_userdatadir()
|
||||
{
|
||||
$r = $this->db_onedev->query('select S_SystemsUserdataUrl from s_systems where S_SystemsIsActive = "Y"')->row();
|
||||
|
||||
$q = preg_replace('/(smartlab\_)[a-zA-Z0-9]+/', $r->S_SystemsUserdataUrl, getcwd());
|
||||
return $q;
|
||||
}
|
||||
|
||||
function uploadimage(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$data = [];
|
||||
//print_r($_SERVER);
|
||||
$labnumber = $this->input->post('ordernumber');
|
||||
$orderid = $this->input->post('orderid');
|
||||
$sampletype = $this->input->post('sampletype');
|
||||
//$config['upload_path'] = 'assets/';
|
||||
|
||||
$path = '/home/one/project/one/one-media/one-image-nonlab/';
|
||||
//echo $path;
|
||||
$config['upload_path'] = $path;
|
||||
$config['allowed_types'] = 'jpg|jpeg|png|gif';
|
||||
|
||||
$config['max_size'] = '10000';
|
||||
$count = count($_FILES['photos']['name']);
|
||||
$this->load->library('upload',$config);
|
||||
|
||||
$error = [];
|
||||
for($i=0;$i<$count;$i++){
|
||||
|
||||
|
||||
|
||||
if(!empty($_FILES['photos']['name'][$i])){
|
||||
|
||||
|
||||
|
||||
$_FILES['file']['name'] = $_FILES['photos']['name'][$i];
|
||||
|
||||
$_FILES['file']['type'] = $_FILES['photos']['type'][$i];
|
||||
|
||||
$_FILES['file']['tmp_name'] = $_FILES['photos']['tmp_name'][$i];
|
||||
|
||||
$_FILES['file']['error'] = $_FILES['photos']['error'][$i];
|
||||
|
||||
$_FILES['file']['size'] = $_FILES['photos']['size'][$i];
|
||||
|
||||
|
||||
|
||||
$namex = $labnumber.'-'.$sampletype.'-'.$this->generateRandomString(5);
|
||||
//echo $namex;
|
||||
|
||||
$config['file_name'] = $namex;
|
||||
$this->upload->initialize($config);
|
||||
//echo $config['file_name'] ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($this->upload->do_upload('file')){
|
||||
|
||||
$uploadData = $this->upload->data();
|
||||
|
||||
$filename = $uploadData['file_name'];
|
||||
//echo $filename;
|
||||
|
||||
$sql = "INSERT INTO so_imageupload (
|
||||
So_ImageUploadT_SampleTypeID,
|
||||
So_ImageUploadT_OrderHeaderID,
|
||||
So_ImageUploadT_OrderHeaderLabNumber,
|
||||
So_ImageUploadOldName,
|
||||
So_ImageUploadNewName,
|
||||
So_ImageUploadCreated,
|
||||
So_ImageUploadUserID
|
||||
)
|
||||
VALUES(
|
||||
{$sampletype},
|
||||
{$orderid},
|
||||
'{$labnumber}',
|
||||
'{$_FILES['photos']['name'][$i]}',
|
||||
'{$filename}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
$doctorid = $this->input->post('doctorid');
|
||||
$doctoraddressid = $this->input->post('doctoraddressid');
|
||||
$sql = "UPDATE t_samplingso SET T_SamplingSoM_DoctorID = {$doctorid}, T_SamplingSoM_DoctorAddressID = {$doctoraddressid}
|
||||
WHERE T_SamplingSoT_OrderHeaderID = {$orderid} AND T_SamplingSoT_SampleTypeID = {$sampletype} AND T_SamplingSoIsActive = 'Y'";
|
||||
$this->db_onedev->query($sql);
|
||||
$data['totalFiles'][] = $filename;
|
||||
|
||||
}
|
||||
else{
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$result = array("total" =>count( $data['totalFiles']), "records" => $data['totalFiles'],'errors'=>$error);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
function xdo_upload()
|
||||
{
|
||||
$config['upload_path'] = 'assets/';
|
||||
$config['allowed_types'] = 'pdf|rar|jpg|png';
|
||||
$config['max_size'] = '5000';
|
||||
$config['file_name'] = date('YmdHis');
|
||||
|
||||
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
if ( ! $this->upload->do_upload('photos'))
|
||||
{
|
||||
$error = array('error' => $this->upload->display_errors());
|
||||
echo json_encode(array('status'=>$error));
|
||||
}
|
||||
else
|
||||
{
|
||||
print_r($this->upload->data());
|
||||
/*$lastUpdated = date('Y-m-d H:i:s');
|
||||
$sql ="UPDATE file_attachment SET File_AattachmentIsActive = 'N' WHERE File_AattachmentReffNumber = '{$this->input->post('trxnumber')}'";
|
||||
$this->db->query($sql);
|
||||
$sql = "INSERT INTO file_attachment (
|
||||
File_AattachmentReffNumber,
|
||||
File_AattachmentUrl,
|
||||
File_AattachmentIsActive,
|
||||
File_AattachmentLastUpdated
|
||||
)
|
||||
VALUES (
|
||||
'{$this->input->post('trxnumber')}',
|
||||
'{$this->upload->data('file_name')}',
|
||||
'Y',
|
||||
'{$lastUpdated}'
|
||||
|
||||
)";
|
||||
//echo $sql;
|
||||
$r = $this->db->query($sql);
|
||||
$data = $this->upload->data();
|
||||
print_r($this->upload->data();
|
||||
echo json_encode('Upload Success');*/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function generateRandomString($length = 10) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,484 @@
|
||||
<?php
|
||||
class Samplingverify extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
|
||||
function getphotos($orderid,$sampletypeid){
|
||||
$rows = [];
|
||||
//print_r($_SERVER);
|
||||
$urlbase = 'http://'.$_SERVER['SERVER_NAME']."/one-media/one-image-nonlab/";
|
||||
$sql = "SELECT So_ImageUploadID as id,
|
||||
So_ImageUploadOldName as oldname,
|
||||
CONCAT('{$urlbase}',So_ImageUploadNewName) as newname
|
||||
FROM so_imageupload
|
||||
WHERE
|
||||
So_ImageUploadT_OrderHeaderID = {$orderid} AND So_ImageUploadT_SampleTypeID = {$sampletypeid} AND So_ImageUploadIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
function getdoctors($sampletypeid){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT M_DoctorID as id,
|
||||
CONCAT(M_DoctorPrefix,' ',M_DoctorName,' ',M_DoctorSufix) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID
|
||||
JOIN t_test ON T_TestT_SampleTypeID = {$sampletypeid} AND M_DoctorSONat_SubGroupID = T_TestNat_SubgroupID
|
||||
WHERE
|
||||
M_DoctorSOIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
function getsetdoctoraddress($doctorid){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressM_DoctorID = {$doctorid} AND M_DoctorAddressIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = $prm["name"];
|
||||
$nolab = $prm["nolab"];
|
||||
$stationid = $prm["stationid"];
|
||||
$statusid = $prm["statusid"];
|
||||
$where_status = '';
|
||||
|
||||
$sql_where = "WHERE T_OrderHeaderIsActive = 'Y' {$where_status}";
|
||||
|
||||
//$sql_param = array();
|
||||
if ($name != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientName like '%$name%' ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
if ($nolab != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_OrderHeaderLabNumber like '%$nolab%' ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT T_BarcodeLabID
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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 t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoFlag = '{$statusid}' AND T_SamplingSoIsActive = 'Y'
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
) a
|
||||
";
|
||||
//echo $sql;
|
||||
$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 T_OrderHeaderID,T_BarcodeLabID,T_BarcodeLabBarcode,T_SampleTypeName,T_OrderHeaderLabNumber,
|
||||
IFNULL(M_PatientPhoto,'') as M_PatientPhotoThumb,
|
||||
M_SexName, M_TitleName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as patient_dob,
|
||||
T_SampleStationID, T_SampleTypeID,
|
||||
{$stationid} as stationid,
|
||||
T_SamplingSoID,
|
||||
T_SamplingSoFlag as status,
|
||||
fn_global_check_is_cito(T_OrderHeaderID) as iscito,
|
||||
IF(ISNULL(T_SamplingSoRequirementID),'X',T_SamplingSoRequirementStatus) as requirement_status,
|
||||
'' as requirements
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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
|
||||
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
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 AND T_BarcodeLabIsActive = 'Y'
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = 'ELECTROMEDIS'
|
||||
JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND T_SamplingSoT_SampleTypeID = T_SampleTypeID AND
|
||||
T_SamplingSoT_BarcodeLabID = T_BarcodeLabID AND T_SamplingSoFlag = '{$statusid}' AND T_SamplingSoIsActive = 'Y'
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_SamplingSoRequirementT_SampletypeID = T_SampletypeID AND
|
||||
T_SamplingSoRequirementNat_PositionID = 9 AND
|
||||
T_SamplingSoRequirementIsActive = 'Y'
|
||||
$sql_where
|
||||
GROUP BY T_BarcodeLabID
|
||||
ORDER BY iscito DESC,T_SamplingSoDoneDate ASC, T_SamplingSoDoneTime ASC, T_OrderHeaderID ASC
|
||||
limit 0,20";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$zxprm = array();
|
||||
$zxprm['status'] = $v['status'];
|
||||
$zxprm['orderid'] = $v['T_OrderHeaderID'];
|
||||
$zxprm['sampletypeid'] = $v['T_SampleTypeID'];
|
||||
$rows[$k]['requirements'] = $this->getrequirements($zxprm);
|
||||
}
|
||||
}
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getrequirements($prm){
|
||||
|
||||
|
||||
$query =" SELECT Nat_RequirementID as id,
|
||||
Nat_RequirementName as name, '{$prm['status']}' as status,
|
||||
if(ISNULL(T_SamplingSoRequirementID),'N', if(json_contains(T_SamplingSoRequirementRequirements,Nat_RequirementID),'Y','N') ) as chex,
|
||||
Nat_RequirementPositionNat_PositionID as positionid
|
||||
FROM nat_requirement
|
||||
JOIN nat_testrequirement ON Nat_TestRequirementNat_RequirementID = Nat_RequirementID
|
||||
JOIN nat_requirementposition ON Nat_RequirementPositionNat_RequirementID = Nat_RequirementID AND Nat_RequirementPositionNat_PositionID = 9 AND
|
||||
Nat_RequirementPositionIsActive = 'Y'
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestRequirementNat_TestID
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = {$prm['orderid']} AND
|
||||
T_SamplingSoRequirementT_SampletypeID = {$prm['sampletypeid']} AND T_SamplingSoRequirementNat_PositionID = Nat_RequirementPositionNat_PositionID
|
||||
WHERE
|
||||
Nat_TestRequirementIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function getstationstatus(){
|
||||
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 = 'ELECTROMEDIS'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['statuses'] = array(array('id'=>'D','name'=>'Belum Verifikasi'),array('id'=>'V','name'=>'Sudah Verifikasi'));
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdoctoraddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressM_DoctorID = {$prm['id']} AND M_DoctorAddressIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
//$next_status = $prm['statusnextid'];
|
||||
|
||||
if($prm['act'] == 'reject'){
|
||||
$sql = "INSERT INTO t_samplingso (
|
||||
T_SamplingSoT_OrderHeaderID,
|
||||
T_SamplingSoT_SampleTypeID,
|
||||
T_SamplingSoT_BarcodeLabID,
|
||||
T_SamplingSoUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['orderid']},
|
||||
{$prm['sampleid']},
|
||||
{$prm['barcodeid']},
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoDoneDate = NULL,
|
||||
T_SamplingSoDoneTime = NULL,
|
||||
T_SamplingSoDoneUserID = NULL,
|
||||
T_SamplingSoProcessDate = NULL,
|
||||
T_SamplingSoProcessTime = NULL,
|
||||
T_SamplingSoProcessUserID = NULL,
|
||||
T_SamplingSoFlag = 'X',
|
||||
T_SamplingSoIsActive = 'N',
|
||||
T_SamplingSoUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$next_status = 2;
|
||||
$dt_json = json_encode(array('T_SampleStationID'=>$prm['stationid'],'T_OrderHeaderID'=>$prm['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 = {$prm['stationid']} AND
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID = {$prm['orderid']} AND
|
||||
T_SamplingQueueLastStatusIsActive = 'Y'";
|
||||
$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(
|
||||
{$prm['stationid']},
|
||||
{$prm['orderid']},
|
||||
{$next_status},
|
||||
{$userid}) ON DUPLICATE KEY UPDATE T_SamplingQueueLastStatusT_SamplingQueueStatusID = {$next_status}";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
}
|
||||
|
||||
if($prm['act'] == 'verify'){
|
||||
$sql = "INSERT INTO t_samplingso (
|
||||
T_SamplingSoT_OrderHeaderID,
|
||||
T_SamplingSoT_SampleTypeID,
|
||||
T_SamplingSoT_BarcodeLabID,
|
||||
T_SamplingSoUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['orderid']},
|
||||
{$prm['sampleid']},
|
||||
{$prm['barcodeid']},
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoVerifyDate = CURDATE(),
|
||||
T_SamplingSoVerifyTime = CURTIME(),
|
||||
T_SamplingSoVerifyUserID = {$userid},
|
||||
T_SamplingSoFlag = 'V',
|
||||
T_SamplingSoIsActive = 'Y',
|
||||
T_SamplingSoUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$xreq = $prm['sample']['requirements'];
|
||||
$arr_requirements = array();
|
||||
foreach($xreq as $k=>$v){
|
||||
if($v['chex'] == 'Y')
|
||||
array_push($arr_requirements,$v['id']);
|
||||
}
|
||||
$requirements = '['.join(',',$arr_requirements).']';
|
||||
|
||||
$sql = "INSERT INTO t_samplingso_requirement(
|
||||
T_SamplingSoRequirementT_SamplingSoID,
|
||||
T_SamplingSoRequirementT_OrderHeaderID,
|
||||
T_SamplingSoRequirementT_SampleStationID,
|
||||
T_SamplingSoRequirementT_SampletypeID,
|
||||
T_SamplingSoRequirementNat_PositionID,
|
||||
T_SamplingSoRequirementStatus,
|
||||
T_SamplingSoRequirementRequirements,
|
||||
T_SamplingSoRequirementUserID,
|
||||
T_SamplingSoRequirementCreated
|
||||
)
|
||||
VALUES(
|
||||
{$prm['sample']['T_SamplingSoID']},
|
||||
{$prm['sample']['T_OrderHeaderID']},
|
||||
{$prm['stationid']},
|
||||
{$prm['sample']['T_SampleTypeID']},
|
||||
{$prm['sample']['requirements'][0]['positionid']},
|
||||
'{$prm['sample']['requirement_status']}',
|
||||
'{$requirements}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoRequirementStatus = '{$prm['sample']['requirement_status']}',
|
||||
T_SamplingSoRequirementRequirements = '{$requirements}',
|
||||
T_SamplingSoRequirementUserID = {$userid}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
}
|
||||
|
||||
/*if($prm['act'] == 'updatedoctor'){
|
||||
$sql = "INSERT INTO t_samplingso (
|
||||
T_SamplingSoT_OrderHeaderID,
|
||||
T_SamplingSoT_SampleTypeID,
|
||||
T_SamplingSoUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['orderid']},
|
||||
{$prm['sampleid']},
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoM_DoctorID = {$prm['doctor']['id']},
|
||||
T_SamplingSoM_DoctorAddressID = {$prm['doctoraddress']['id']},
|
||||
T_SamplingSoIsActive = 'Y',
|
||||
T_SamplingSoUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
}*/
|
||||
|
||||
if($prm['act'] == 'unverify'){
|
||||
$sql = "INSERT INTO t_samplingso (
|
||||
T_SamplingSoT_OrderHeaderID,
|
||||
T_SamplingSoT_SampleTypeID,
|
||||
T_SamplingSoT_BarcodeLabID,
|
||||
T_SamplingSoUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['orderid']},
|
||||
{$prm['sampleid']},
|
||||
{$prm['barcodeid']},
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoVerifyDate = NULL,
|
||||
T_SamplingSoVerifyTime = NULL,
|
||||
T_SamplingSoVerifyUserID = NULL,
|
||||
T_SamplingSoFlag = 'D',
|
||||
T_SamplingSoIsActive = 'Y',
|
||||
T_SamplingSoUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$sql = "INSERT INTO t_samplingso_requirement(
|
||||
T_SamplingSoRequirementT_SamplingSoID,
|
||||
T_SamplingSoRequirementT_OrderHeaderID,
|
||||
T_SamplingSoRequirementT_SampleStationID,
|
||||
T_SamplingSoRequirementT_SampletypeID,
|
||||
T_SamplingSoRequirementNat_PositionID,
|
||||
T_SamplingSoRequirementStatus,
|
||||
T_SamplingSoRequirementRequirements,
|
||||
T_SamplingSoRequirementUserID,
|
||||
T_SamplingSoRequirementCreated
|
||||
)
|
||||
VALUES(
|
||||
{$prm['sample']['T_SamplingSoID']},
|
||||
{$prm['sample']['T_OrderHeaderID']},
|
||||
{$prm['stationid']},
|
||||
{$prm['sample']['T_SampleTypeID']},
|
||||
{$prm['sample']['requirements'][0]['positionid']},
|
||||
'{$prm['sample']['requirement_status']}',
|
||||
'{$requirements}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)ON DUPLICATE KEY UPDATE
|
||||
T_SamplingSoRequirementStatus = 'X',
|
||||
T_SamplingSoRequirementRequirements = '[]',
|
||||
T_SamplingSoRequirementUserID = {$userid}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletephoto(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query =" UPDATE so_imageupload SET So_ImageUploadIsActive = 'N', So_ImageUploadUserID = {$userid} WHERE So_ImageUploadID = {$prm['id']}";
|
||||
//echo $query;
|
||||
$actdelete = $this->db_onedev->query($query);
|
||||
|
||||
if($actdelete){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db("so_imageupload delete", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user