Flatten mockup repo
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/*
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Patient_list extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$status = $prm["status"];
|
||||
$station = $prm["station"];
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
$q_sst = "";
|
||||
if ($status == 'N')
|
||||
$q_sst = "AND (helper_sststatus = 'N' OR helper_sststatus = 'X')";
|
||||
elseif ($status == 'Y')
|
||||
$q_sst = "AND (helper_sststatus = 'Y')";
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_orderheader
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join helper_sst on t_orderheaderid = helper_sstt_orderheaderid
|
||||
and ((helper_sstt_samplestationid = ? and ? <> 0) or ? = 0)
|
||||
{$q_sst}
|
||||
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
and ((M_PatientDOB LIKE ? and M_PatientDOB IS NOT NULL) OR M_PatientDOB IS NULL)";
|
||||
$query = $this->db_smartone->query($sql, array($station, $station, $station,
|
||||
|
||||
$nolab, $search, $search, $search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// join last_status on Last_StatusT_OrderHeaderID = T_OrderHeaderID
|
||||
// join m_status on Last_StatusM_StatusID = M_StatusID
|
||||
// and (M_StatusCode = 'FO.Verification.Confirm'
|
||||
// OR M_StatusCode = 'FO.Verification.Spv.Confirm'
|
||||
// OR M_StatusCode = 'SAMPLING.Sampling.Partial'
|
||||
// OR M_StatusCode = 'SAMPLING.Sampling.Full')
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderM_PatientAge,
|
||||
M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
M_PatientHP, M_PatientDOB, M_PatientNote, M_PatientPhoto,
|
||||
concat(M_PatientAddressDescription, '\n\n', m_kelurahanname, ', ', m_districtname,
|
||||
'\n', m_cityname, ', ', m_provincename) as M_PatientAddress,
|
||||
M_PatientNote, Helper_SstStatus, T_OrderHeaderFoNote, T_OrderHeaderSamplingNote,
|
||||
Helper_OrderSamplingVerificationPhoto ver_photo,
|
||||
Helper_OrderSamplingVerificationPhotoNote ver_photo_note,
|
||||
T_OrderMessageMessage note_supervisor,
|
||||
T_SamplingQueueStatusID call_status_id, T_SamplingQueueStatusCode call_status_code,
|
||||
Helper_SstStatus status_code,
|
||||
IFNULL(T_OrderSampleReqStatus, 'X') req_status, IFNULL(T_OrderSampleReqs, '[]') reqs,
|
||||
T_OrderHeaderM_PatientAge, M_SexName
|
||||
from t_orderheader
|
||||
left join helper_order on helper_ordert_orderheaderid = t_orderheaderid
|
||||
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 helper_sst on t_orderheaderid = helper_sstt_orderheaderid
|
||||
and ((helper_sstt_samplestationid = ? and ? <> 0) or ? = 0)
|
||||
{$q_sst}
|
||||
|
||||
left join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID and M_PatientAddressIsActive = 'Y'
|
||||
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
|
||||
left join m_province on m_citym_provinceid = m_provinceid
|
||||
left join t_ordermessage on t_ordermessaget_orderheaderid = t_orderheaderid
|
||||
left join t_sampling_queue_last_status on T_SamplingQueueLastStatusT_OrderHeaderID = t_orderheaderid
|
||||
and T_SamplingQueueLastStatusT_SampleStationID = ?
|
||||
and T_SamplingQueueLastStatusIsActive = 'Y'
|
||||
left join t_sampling_queue_status on T_SamplingQueueStatusID = T_SamplingQueueLastStatusT_SamplingQueueStatusID
|
||||
left join t_ordersamplereq on T_OrderSampleReqT_OrderHeaderID = T_OrderHeaderID
|
||||
AND T_OrderSampleReqT_SampleStationID = ? AND T_OrderSampleReqIsActive = 'Y'
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and ( M_PatientName LIKE ?
|
||||
or ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
or ((M_PatientDOB LIKE ? and M_PatientDOB IS NOT NULL) OR M_PatientDOB IS NULL) )
|
||||
group by t_orderheaderid
|
||||
order by t_orderheaderlabnumber desc
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($station, $station, $station,
|
||||
$station, $station, $nolab, $search, $search, $search));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_stations()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$uid = $this->sys_user['M_UserID'];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_samplestation
|
||||
join m_user on m_userid = ?
|
||||
and ((m_userdefaultt_samplestationid = t_samplestationid and m_userdefaultt_samplestationid <> 0)
|
||||
or m_userdefaultt_samplestationid = 0)
|
||||
where t_samplestationisactive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, array($uid));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("sample station count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select t_samplestationid id, t_samplestationname text
|
||||
from t_samplestation
|
||||
join m_user on m_userid = ?
|
||||
and ((m_userdefaultt_samplestationid = t_samplestationid and m_userdefaultt_samplestationid <> 0)
|
||||
or m_userdefaultt_samplestationid = 0)
|
||||
where t_samplestationisactive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, array($uid));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
// $rows = [['id'=>'0', 'text'=>'Semua Station']] + $rows;
|
||||
// array_unshift($rows, ['id'=>'0', 'text'=>'Semua Station']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("sample station rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
68
application/controllers/mockup/sampling/sampling/Queue.php
Normal file
68
application/controllers/mockup/sampling/sampling/Queue.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
class Queue extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Queue API";
|
||||
}
|
||||
|
||||
public function call_skip_process()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$order_id = $prm['order_id'];
|
||||
$station_id = $prm['station_id'];
|
||||
$act = $prm['act'];
|
||||
$uid = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql = "CALL sp_sampling_que_status('{$order_id}', '{$station_id}', '{$act}', '{$uid}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$x = $query->row();
|
||||
if ($x->status == "OK")
|
||||
{
|
||||
$this->sys_ok($x);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("SAMPLING QUE : " . $x->message, $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("SAMPLING QUE : " . $this->db_smartone->last_query(), $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function recall()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$order_id = $prm['order_id'];
|
||||
$station_id = $prm['station_id'];
|
||||
|
||||
$sql = "CALL sp_sampling_recall('{$order_id}', '{$station_id}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
if ($row->status == "OK")
|
||||
{
|
||||
$this->sys_ok($row);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Barcode ADD", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
242
application/controllers/mockup/sampling/sampling/Sampling.php
Normal file
242
application/controllers/mockup/sampling/sampling/Sampling.php
Normal file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
class Sampling extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Sampling API";
|
||||
}
|
||||
|
||||
public function get_samples()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$order_id = $prm['orderid'];
|
||||
$station_id = $prm['stationid'];
|
||||
|
||||
if ($order_id == null)
|
||||
$order_id = 0;
|
||||
|
||||
if ($station_id == null)
|
||||
$station_id = 0;
|
||||
|
||||
$sql = "CALL sp_sampling_get_samples('{$order_id}', '$station_id')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k => $v)
|
||||
$rows[$k]['reqs'] = json_decode($v['reqs']);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Get Samples rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_sample()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$order_id = $prm['orderid'];
|
||||
$sample_id = $prm['sampleid'];
|
||||
$barcode = $prm['barcode'];
|
||||
|
||||
if ($order_id == null)
|
||||
$order_id = 0;
|
||||
|
||||
if ($sample_id == null)
|
||||
$sample_id = 0;
|
||||
|
||||
$sql = "CALL sp_sampling_get_sample('{$order_id}', '{$sample_id}', '{$barcode}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
$rows->reqs = json_decode($rows->reqs);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Get Samples row", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$order_id = $prm['orderid'];
|
||||
$sample_id = $prm['sampleid'];
|
||||
$barcode = $prm['barcode'];
|
||||
$json = $prm['json_data'];
|
||||
|
||||
$json = json_encode($json);
|
||||
$sql = "CALL sp_sampling_save('{$order_id}', '{$sample_id}', '{$barcode}', '{$json}', '{$this->sys_user['M_UserID']}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
$rows->data = json_decode($rows->data);
|
||||
$this->sys_ok($rows);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Get Samples rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$order_id = $prm['orderid'];
|
||||
$sample_id = $prm['sampleid'];
|
||||
$barcode = $prm['barcode'];
|
||||
$json = $prm['json_data'];
|
||||
|
||||
$json = json_encode($json);
|
||||
$sql = "CALL sp_sampling_save_2('{$order_id}', '{$sample_id}', '{$barcode}', '{$json}', '{$this->sys_user['M_UserID']}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
$rows->data = json_decode($rows->data);
|
||||
$this->sys_ok($rows);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Get Samples rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_note_supervisor()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$order_id = $prm['orderid'];
|
||||
$message = $prm['message'];
|
||||
|
||||
$json = json_encode($json);
|
||||
$sql = "CALL sp_sampling_save_note_supervisor('{$order_id}', '{$message}', '{$this->sys_user['M_UserID']}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok($rows);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Note Supervisor rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function barcode_add()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$order_id = $prm['order_id'];
|
||||
$sample_id = $prm['sample_id'];
|
||||
|
||||
$sql = "CALL sp_sampling_barcode_add('{$order_id}', '{$sample_id}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
if ($row->status == "OK")
|
||||
{
|
||||
$row->data = json_decode($row->data);
|
||||
$this->sys_ok($row->data);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Barcode ADD", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function get_requirement()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_RequirementID, Nat_RequirementName FROM nat_requirement
|
||||
JOIN nat_requirementposition ON Nat_RequirementPositionNat_RequirementID = Nat_RequirementID
|
||||
AND Nat_RequirementPositionIsActive = 'Y'
|
||||
JOIN nat_position ON Nat_RequirementPositionNat_PositionID = Nat_PositionID
|
||||
AND Nat_PositionCode = 'SPEC.COL'";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok($rows);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Get Requirement row", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_requirement()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm['order_id'];
|
||||
$station_id = $prm['station_id'];
|
||||
$reqs = $prm['reqs'];
|
||||
$status = $prm['status'];
|
||||
|
||||
$pos_code = 'SPEC.COL';
|
||||
|
||||
// GET POSITION
|
||||
$p = $this->db_smartone->query("SELECT Nat_PositionID id FROM nat_position WHERE Nat_PositionCode = ?", [$pos_code])
|
||||
->row();
|
||||
|
||||
$sql = "SELECT T_OrderSampleReqID id FROM t_ordersamplereq
|
||||
JOIN nat_position on T_OrderSampleReqNat_PositionID = Nat_PositionID
|
||||
AND Nat_PositionCode = ?
|
||||
WHERE T_OrderSampleReqT_OrderHeaderID = ?
|
||||
AND T_OrderSampleReqT_SampleStationID = ?
|
||||
AND T_OrderSampleReqIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$pos_code, $order_id, $station_id]);
|
||||
$r = $query->row();
|
||||
|
||||
if ($r)
|
||||
{
|
||||
$sql = "UPDATE t_ordersamplereq
|
||||
SET T_OrderSampleReqStatus = ?, T_OrderSampleReqs = ?
|
||||
WHERE T_OrderSampleReqID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$status, $reqs, $r->id]);
|
||||
|
||||
$this->sys_ok($r->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "INSERT INTO t_ordersamplereq(T_OrderSampleReqT_OrderHeaderID, T_OrderSampleReqT_SampleStationID, T_OrderSampleReqStatus, T_OrderSampleReqs, T_OrderSampleReqNat_PositionID)
|
||||
VALUES(?, ?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$order_id, $station_id, $status, $reqs, $p->id]);
|
||||
if ($query)
|
||||
{
|
||||
$this->sys_ok($this->db_smartone->insert_id());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Sample Req", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user