Initial import
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Handling_patient 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"] . '%';
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and m_statussamplecode = 'SAMPLING.Verification.Verify'
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber lab, T_OrderHeaderDate `date`,
|
||||
M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) name,
|
||||
T_OrderSampleBarcode sid, '' status, last_statussampleid id
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and m_statussamplecode = 'SAMPLING.Verification.Verify'
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $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 search_sent()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and (m_statussamplecode = 'SAMPLING.Verification.To.Handling' or m_statussamplecode = 'SAMPLING.Handling.From.Verification')
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber lab, T_OrderHeaderDate `date`,
|
||||
M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) name,
|
||||
T_OrderSampleBarcode sid, m_statussamplecode status, last_statussampleid id
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and (m_statussamplecode = 'SAMPLING.Verification.To.Handling' or m_statussamplecode = 'SAMPLING.Handling.From.Verification')
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $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;
|
||||
}
|
||||
}
|
||||
|
||||
function send()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_sampling_verification_send_to_handling('{$prm['ids']}')";
|
||||
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("verification send handling", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function remove()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_sampling_verification_remove_from_handling('{$prm['id']}')";
|
||||
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("verification remove handling", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Receive_patient 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"] . '%';
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and m_statussamplecode = 'SAMPLING.Sampling.To.Verification'
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber lab, T_OrderHeaderDate `date`,
|
||||
M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) name,
|
||||
T_OrderSampleBarcode sid, '' status, last_statussampleid id
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and m_statussamplecode = 'SAMPLING.Sampling.To.Verification'
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $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 search_sent()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and m_statussamplecode = 'SAMPLING.Verification.From.Sampling'
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber lab, T_OrderHeaderDate `date`,
|
||||
M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) name,
|
||||
T_OrderSampleBarcode sid, m_statussamplecode status, last_statussampleid id
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and (m_statussamplecode = 'SAMPLING.Verification.From.Sampling')
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $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;
|
||||
}
|
||||
}
|
||||
|
||||
function receive()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_sampling_verification_receive('{$prm['ids']}')";
|
||||
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("verification receive", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Verification_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
var $nat_pos;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->nat_pos = 'SPEC.VER';
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and m_statussamplecode = 'SAMPLING.Verification.From.Sampling'
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$p = $this->db_smartone->query("SELECT Nat_PositionID id FROM nat_position WHERE Nat_PositionCode = '{$this->nat_pos}'")
|
||||
->row();
|
||||
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber lab, T_OrderHeaderDate `date`,
|
||||
M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) name,
|
||||
T_OrderSampleBarcode sid, '' status, last_statussampleid id, t_sampletypename sample_name,
|
||||
T_OrderSampleID order_sample_id, t_sampletypeid sample_id,
|
||||
json_object('quality', IFNULL(T_OrderSampleAddonVerificationQuality, 'N'),
|
||||
'quantity', IFNULL(T_OrderSampleAddonVerificationQuantity, 'N'),
|
||||
'sample', IFNULL(T_OrderSampleAddonVerificationSampleType, 'N'),
|
||||
'quality_note', IFNULL(T_OrderSampleAddonVerificationQualityNote, ''),
|
||||
'quantity_note', IFNULL(T_OrderSampleAddonVerificationQuantityNote, ''),
|
||||
'sample_note', IFNULL(T_OrderSampleAddonVerificationSampleTypeNote, ''),
|
||||
'note', IFNULL(T_OrderSampleAddonVerificationNote, '')) data,
|
||||
if (T_OrderSampleReceiveDate is not null and T_OrderSampleReceiveTime is not null,
|
||||
timediff(now(), concat(T_OrderSampleReceiveDate, ' ', T_OrderSampleReceiveTime) ), '00:00:00') sampling_duration,
|
||||
ifnull (ua.M_UserFullName, '-') user_sampling,
|
||||
ifnull (ub.M_UserFullName, '-') user_receive,
|
||||
IFNULL(T_OrderSampleReqStatus, 'X') req_status, IFNULL(T_OrderSampleReqs, '[]') selected_reqs
|
||||
from t_ordersample
|
||||
join t_sampletype on t_ordersamplet_sampletypeid = t_sampletypeid
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and m_statussamplecode = 'SAMPLING.Verification.From.Sampling'
|
||||
left join t_ordersampleaddon on t_ordersampleid = t_ordersampleaddont_ordersampleid
|
||||
left join m_user ua on T_OrderSampleSamplingUserID = ua.M_UserID
|
||||
left join m_user ub on T_OrderSampleReceiveUserID = ub.M_UserID
|
||||
left join t_ordersamplereq on T_OrderSampleReqT_OrderHeaderID = T_OrderHeaderID
|
||||
and T_OrderSampleReqNat_PositionID = ?
|
||||
and T_OrderSampleReqT_OrderSampleID = T_OrderSampleID
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($p->id, $nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['reqs'] = [];
|
||||
$sql = "SELECT fn_specimen_get_requirement(?, ?, ?) as x";
|
||||
$query = $this->db_smartone->query($sql, [$v['T_OrderHeaderID'], $v['sample_id'], $this->nat_pos]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows[$k]['reqq'] = $this->db_smartone->last_query();
|
||||
$rowss = $query->row();
|
||||
if ($rowss->x != null)
|
||||
$rows[$k]['reqs'] = json_decode($rowss->x);
|
||||
}
|
||||
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$rows[$k]['selected_reqs'] = json_decode($v['selected_reqs']);
|
||||
}
|
||||
|
||||
$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 search_sent()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and m_statussamplecode = 'SAMPLING.Verification.From.Sampling'
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber lab, T_OrderHeaderDate `date`,
|
||||
M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) name,
|
||||
T_OrderSampleBarcode sid, m_statussamplecode status, last_statussampleid id
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and (m_statussamplecode = 'SAMPLING.Verification.From.Sampling')
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $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;
|
||||
}
|
||||
}
|
||||
|
||||
function verify()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = json_encode($prm['data']);
|
||||
$sql = "CALL sp_sampling_verification_verify('{$prm['orderid']}', '{$prm['laststatusid']}', '{$data}', '{$this->sys_user['M_UserID']}')";
|
||||
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("verification verify", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function reject()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = json_encode($prm['data']);
|
||||
$sql = "CALL sp_sampling_verification_reject('{$prm['orderid']}', '{$prm['laststatusid']}', '{$data}')";
|
||||
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("verification verify", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_requirement()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT fn_specimen_get_requirement(?, ?, ?) as x";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'], $prm['sample_id'], $this->nat_pos]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
$y = [];
|
||||
if ($rows->x != null)
|
||||
$y = json_decode($rows->x);
|
||||
$this->sys_ok($y);
|
||||
}
|
||||
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'];
|
||||
$reqs = $prm['reqs'];
|
||||
$status = $prm['status'];
|
||||
$sample_id = $prm['sample_id'];
|
||||
|
||||
$pos_code = $this->nat_pos;
|
||||
|
||||
// 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_OrderSampleID = ?
|
||||
AND T_OrderSampleReqIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$pos_code, $order_id, $sample_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_OrderSampleID, T_OrderSampleReqStatus, T_OrderSampleReqs, T_OrderSampleReqNat_PositionID)
|
||||
VALUES(?, ?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$order_id, $sample_id, $status, $reqs, $p->id]);
|
||||
if ($query)
|
||||
{
|
||||
$this->sys_ok($this->db_smartone->insert_id());
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Sample verification Req", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user