Initial import
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
class Delivery extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = " SELECT M_DeliveryID as id,
|
||||
M_DeliveryTypeID as typeid,
|
||||
M_DeliveryTypeCode as type,
|
||||
M_DeliverySource as source,
|
||||
M_DeliveryName as name
|
||||
FROM
|
||||
m_deliverytype
|
||||
JOIN m_delivery ON M_DeliveryM_DeliveryTypeID = M_DeliveryTypeID AND M_DeliveryIsActive = 'Y'
|
||||
WHERE
|
||||
M_DeliveryTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
339
one-api/application/controllers/mockup/fo/verification/Done.php
Normal file
339
one-api/application/controllers/mockup/fo/verification/Done.php
Normal file
@@ -0,0 +1,339 @@
|
||||
<?php
|
||||
class Done extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search = $prm["search"];
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql_where = "WHERE (T_OrderHeaderDate BETWEEN CONCAT('{$start_date}',' ','00:00:00') AND CONCAT('{$end_date}',' ','23:59:59')) AND T_OrderHeaderIsActive = 'Y'";
|
||||
if($search != ''){
|
||||
$sql_where = "WHERE (T_OrderHeaderLabNumber LIKE '%{$search}%' OR M_PatientName LIKE '%{$search}%' ) AND T_OrderHeaderIsActive = 'Y'";
|
||||
}
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM(
|
||||
SELECT
|
||||
T_OrderHeaderID,
|
||||
fn_fo_verification_last_status(T_OrderHeaderID,3) as check_status,
|
||||
fn_fo_verification_status_done(T_OrderHeaderID) as check_status_spv
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
LEFT JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN m_status ON Last_StatusM_StatusID = M_StatusID
|
||||
LEFT JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressNote = 'utama'
|
||||
LEFT JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
LEFT JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
LEFT JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID
|
||||
JOIN m_doctoraddress ON T_OrderHeaderSenderM_DoctorAddressID = M_DoctorAddressID
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
$sql_where
|
||||
HAVING check_status > 0 OR check_status_spv > 0
|
||||
ORDER BY T_OrderHeaderID ASC
|
||||
) x
|
||||
";
|
||||
//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("t_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
M_PatientNoReg,
|
||||
fn_fo_verification_get_paid(T_OrderHeaderID) as paid,
|
||||
T_OrderHeaderTotal,
|
||||
M_MouIsBill,
|
||||
IF(M_MouIsBill = 'N','Tidak ditagihkan','Ditagihkan') as texttagihan,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as M_PatientName,
|
||||
M_PatientHP,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
||||
M_PatientAddressDescription as M_PatientAddress,
|
||||
M_CityName as CityUtama,
|
||||
M_PatientNote,
|
||||
M_PatientHP,
|
||||
M_DoctorHP,
|
||||
T_OrderHeaderID as ohid,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderDate,
|
||||
IF(M_StatusID = 2,'Baru',IF(M_StatusID = 3,'Verified','Ditolak')) as M_StatusName,
|
||||
T_OrderHeaderID, M_SexName,
|
||||
M_CompanyName,
|
||||
T_OrderHeaderM_CompanyID,
|
||||
T_OrderHeaderM_MouID,
|
||||
CONCAT(M_MouName,' ( ',DATE_FORMAT(M_MouStartDate,'%d-%m-%Y') ,' s/d ' , DATE_FORMAT(M_MouEndDate,'%d-%m-%Y'),' )') as mou,
|
||||
M_DoctorName,
|
||||
M_DoctorAddressDescription as M_DoctorAddress,
|
||||
T_OrderHeaderVerificationNote as verification_note,
|
||||
fn_fo_verification_last_status(T_OrderHeaderID,3) as check_status,
|
||||
fn_fo_verification_status_done(T_OrderHeaderID) as check_status_spv,
|
||||
T_OrderHeaderDate as orderdate
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
LEFT JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN m_status ON Last_StatusM_StatusID = M_StatusID
|
||||
LEFT JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressNote = 'utama'
|
||||
LEFT JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
LEFT JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
LEFT JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID
|
||||
JOIN m_doctoraddress ON T_OrderHeaderSenderM_DoctorAddressID = M_DoctorAddressID
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
$sql_where
|
||||
HAVING check_status > 0 OR check_status_spv > 0
|
||||
ORDER BY T_OrderHeaderID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $sql;
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
JOIN t_orderheader ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
1284
one-api/application/controllers/mockup/fo/verification/Patient.php
Normal file
1284
one-api/application/controllers/mockup/fo/verification/Patient.php
Normal file
File diff suppressed because it is too large
Load Diff
133
one-api/application/controllers/mockup/fo/verification/Px.php
Normal file
133
one-api/application/controllers/mockup/fo/verification/Px.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
class Px extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Px API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
$orderdate = $prm['orderdate'];
|
||||
$cito = $prm['cito'] == true ?'Y':'N';
|
||||
$mouid = $prm['mouid'];
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_price
|
||||
JOIN t_test ON T_PriceT_TestID = T_TestID
|
||||
JOIN m_mou ON M_MouID = T_PriceM_MouID
|
||||
AND M_MouStartDate <= ?
|
||||
AND M_MouEndDate >= ?
|
||||
WHERE
|
||||
|
||||
T_PriceIsCito = ?
|
||||
AND T_PriceM_MouID = ?
|
||||
AND T_TestName like ?
|
||||
|
||||
AND T_PriceIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,array($orderdate,$orderdate,$cito,$mouid,$q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT T_PriceT_TestID as id,
|
||||
T_TestCode as pxcode,
|
||||
T_TestName as pxname,
|
||||
T_TestIsResult as isresult,
|
||||
T_PriceAmount as bruto,
|
||||
T_PriceDisc as discount,
|
||||
T_PriceDiscRp as discountrp,
|
||||
((T_PriceDisc / 100) * T_PriceAmount) - T_PriceDiscRp as discounttotal,
|
||||
( T_PriceAmount - ((T_PriceDisc / 100) * T_PriceAmount) - T_PriceDiscRp ) as total,
|
||||
T_PriceIsCito as flagcito
|
||||
FROM t_price
|
||||
JOIN t_test ON T_PriceT_TestID = T_TestID
|
||||
JOIN m_mou ON M_MouID = T_PriceM_MouID
|
||||
AND M_MouStartDate <= ?
|
||||
AND M_MouEndDate >= ?
|
||||
WHERE
|
||||
|
||||
T_PriceIsCito = ?
|
||||
AND T_PriceM_MouID = ?
|
||||
AND T_TestName like ?
|
||||
|
||||
AND T_PriceIsActive = 'Y'
|
||||
ORDER BY T_PricePriority DESC
|
||||
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($orderdate,$orderdate,$cito,$mouid,$q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->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_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$sql_param = array("%$search%");
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_patienttype
|
||||
where
|
||||
M_PatientTypeName like ? and
|
||||
M_PatientTypeIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patienttype count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select M_PatientTypeID, M_PatientTypeName
|
||||
from
|
||||
m_patienttype
|
||||
where
|
||||
M_PatientTypeName like ? and
|
||||
M_PatientTypeIsActive = 'Y'
|
||||
limit 0,10";
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
$rows = $query->result_array();
|
||||
$this->_add_mou($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class Status extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
public function lookup()
|
||||
{
|
||||
$status = array(
|
||||
array("id"=>2,"code"=>"FO.Verification","name" => "Baru" ),
|
||||
array("id"=>3,"code"=>"FO.Verification.Confirm","name" => "Verified"),
|
||||
array("id"=>4,"code"=>"FO.Verification.Reject","name" => "Ditolak")
|
||||
);
|
||||
$result = array(
|
||||
"total" => count($status) ,
|
||||
"records" => $status,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
class Supplies extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$orderid = $prm['orderid'];
|
||||
$supplies = $prm['supplies'];
|
||||
$barcodes = $prm['barcode'];
|
||||
$dt_log = array('orderid'=>$orderid,'supplies'=>$supplies,'barcode'=>$barcode);
|
||||
$fologcode = 'FO.Verification.BarcodeSupplies';
|
||||
$json_dt_log = json_encode($dt_log);
|
||||
$sql = "insert into one_log.log_supplies_barcode(
|
||||
Log_SuppliesBarcodeDate,
|
||||
Log_SuppliesBarcodeCode,
|
||||
Log_SuppliesBarcodeJson,
|
||||
Log_SuppliesBarcodeUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.log_supplies_barcode insert");
|
||||
exit;
|
||||
}
|
||||
//print_r($supplies);
|
||||
foreach($supplies as $k => $v){
|
||||
if(intval($v['xid']) == 0 && $v['chex'] == true){
|
||||
$sql = "insert into t_ordersupplies(
|
||||
T_OrderSuppliesT_OrderHeaderID,
|
||||
T_OrderSuppliesM_SuppliesID,
|
||||
T_OrderSuppliesQty,
|
||||
T_OrderSuppliesCreated,
|
||||
T_OrderSuppliesLastUpdated,
|
||||
T_OrderSuppliesUserID)
|
||||
values( ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid,
|
||||
$v['id'],
|
||||
$v['qty'],
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_ordersupplies insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if(intval($v['xid']) > 0 && $v['chex'] == true){
|
||||
$sql = "update t_ordersupplies
|
||||
set
|
||||
T_OrderSuppliesQty = {$v['qty']},
|
||||
T_OrderSuppliesLastUpdated = now(),
|
||||
T_OrderSuppliesUserID = {$xuserid}
|
||||
where
|
||||
T_OrderSuppliesID = ?
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$v['xid']
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_ordersupplies update");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if(intval($v['xid']) > 0 && $v['chex'] == false){
|
||||
$sql = "update t_ordersupplies
|
||||
set
|
||||
T_OrderSuppliesIsActive = 'N' ,
|
||||
T_OrderSuppliesLastUpdated = now(),
|
||||
T_OrderSuppliesUserID = $xuserid
|
||||
where
|
||||
T_OrderSuppliesID = ?
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$v['xid']
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_ordersupplies update");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "UPDATE t_barcodelab SET T_BarcodeLabIsActive = 'N' WHERE T_BarcodeLabT_OrderHeaderID = {$orderid}";
|
||||
$updatex = $this->db_onedev->query($sql);
|
||||
|
||||
foreach($barcodes as $i => $barcode){
|
||||
$children = $barcode['children'];
|
||||
foreach($children as $k => $v){
|
||||
if(intval($v['xid']) == 0){
|
||||
$sql = "insert into t_barcodelab(
|
||||
T_BarcodeLabT_OrderHeaderID,
|
||||
T_BarcodeLabBarcode,
|
||||
T_BarcodeLabT_SampleTypeID,
|
||||
T_BarcodeLabCreated,
|
||||
T_BarcodeLabLastUpdated,
|
||||
T_BarcodeLabUserID)
|
||||
values( ?, ?, ?, now(),now(),?)";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid,
|
||||
$v['barcodenumber'],
|
||||
$v['id'],
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_barcodelab insert");
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$sql = "UPDATE t_barcodelab SET T_BarcodeLabIsActive = 'Y' WHERE T_BarcodeLabID = {$v['xid']} ";
|
||||
$updatex = $this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sql = "select M_SuppliesID as id,
|
||||
IFNULL(T_OrderSuppliesID,0) as xid,
|
||||
IF(ISNULL(T_OrderSuppliesID),'N',T_OrderSuppliesIsActive) as chex,
|
||||
IFNULL(T_OrderSuppliesQty,1) as qty,
|
||||
M_SuppliesName as name,
|
||||
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as lastupdated,
|
||||
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as tx_lastupdated
|
||||
from m_supplies
|
||||
left join t_ordersupplies ON
|
||||
T_OrderSuppliesT_OrderHeaderID = ? AND
|
||||
T_OrderSuppliesM_SuppliesID = M_SuppliesID
|
||||
WHERE
|
||||
M_SuppliesIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows_supplies = $query->result_array();
|
||||
foreach($rows_supplies as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows_supplies[$k]['chex'] = false;
|
||||
else
|
||||
$rows_supplies[$k]['chex'] = true;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("t_ordersupplies select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$query =" SELECT T_SampleTypeID as id,
|
||||
T_SampleTypeName as name,
|
||||
'' as children
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
T_OrderHeaderID = {$orderid}
|
||||
GROUP BY T_SampleTypeID
|
||||
";
|
||||
// echo $query ;
|
||||
$rows_barcode = $this->db_onedev->query($query)->result();
|
||||
foreach($rows_barcode as $k => $v){
|
||||
$query = "SELECT T_SampleTypeID as id, IFNULL(T_BarcodeLabID,0) as xid,
|
||||
IF(ISNULL(T_BarcodeLabID),'Y',T_BarcodeLabIsActive) as chex,
|
||||
T_TestName as testname,
|
||||
T_SampleTypeName as samplename,
|
||||
IF(ISNULL(T_BarcodeLabID),CONCAT(T_OrderHeaderLabNumber,'.',T_SampleTypeID,'.',1),T_BarcodeLabBarcode) as barcodenumber
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderid} AND T_SampleTypeID = {$v->id}
|
||||
GROUP BY T_BarcodeLabID ";
|
||||
$v->children = $this->db_onedev->query($query)->result_array();
|
||||
foreach($v->children as $ki => $vi){
|
||||
if($vi['chex'] == 'N')
|
||||
$v->children[$ki]['chex'] = false;
|
||||
else
|
||||
$v->children[$ki]['chex'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = array ("total" => count($rows), "records" => array('supplies'=>$rows_supplies,'barcode'=>$rows_barcode));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class Verificationdoctor extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("smartone", true);
|
||||
}
|
||||
public function lookup()
|
||||
{
|
||||
$verification_doctor= array(
|
||||
array('id'=>1,'check'=>true,'note'=>'','label'=>'Nama dokter sudah sesuai'),
|
||||
array('id'=>2,'check'=>true,'note'=>'','label'=>'Alamat dokter sudah sesuai')
|
||||
);
|
||||
$result = array(
|
||||
"records" => $verification_doctor
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
class Vilage extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Vilage API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_kelurahan
|
||||
where M_KelurahanIsActive = 'Y'
|
||||
and M_KelurahanName like ?";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_count = 4;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_kelurahan count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_KelurahanID as id, M_KelurahanName as name
|
||||
from m_kelurahan
|
||||
where M_KelurahanIsActive = 'Y'
|
||||
and M_KelurahanName like ?";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_kelurahan rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user