Flatten mockup repo
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Company extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Company API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from corporate
|
||||
where CorporateName like ?
|
||||
and CorporateIsActive = 'Y'
|
||||
limit 0,30";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
$result = array("data" => $rows );
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Helper extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Helper API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function calc_age()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "call sp_recount_age(?)";
|
||||
$query = $this->db_smartone->query($sql, array($orderID));
|
||||
|
||||
if ($query) {
|
||||
$sql = "select T_OrderHeaderM_PatientAge, M_PatientDOB
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
and T_OrderHeaderID = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($orderID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$rst = $rows;
|
||||
if (count($rows) > 0)
|
||||
$rst = $rows[0];
|
||||
$this->sys_ok($rst);
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function check_status_print()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "SELECT GROUP_CONCAT(T_TestName SEPARATOR ',') as testname, concat( '[', group_concat( json_object('T_TestID', T_TestID, 'T_TestName',T_TestName) separator ',' ), ']' ) testall
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'
|
||||
AND (T_OrderDetailResult IS NULL OR T_OrderDetailResult = '')";
|
||||
$query = $this->db_smartone->query($sql, array($orderID));
|
||||
|
||||
if ($query) {
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['testall'] = json_decode($v['testall']);
|
||||
}
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
$rst = array("total" => $tot_count,
|
||||
"records" => $rows);
|
||||
if (count($rows) > 0)
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function insertlogprint()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$tests = json_encode($prm['tests']);
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "INSERT INTO log_printresultpartial(
|
||||
Log_PrintResultPartialT_OrderHeaderID,
|
||||
Log_PrintResultPartialTests,
|
||||
Log_PrintResultPartialUserID)
|
||||
VALUES ('{$prm['orderid']}','{$tests}','{$userid}')";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_printresultpartial end| " .
|
||||
$this->db_smartone->error()["message"], "debug" => $this->db_smartone->last_query()]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
$arr_code = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) {
|
||||
continue;
|
||||
}
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] ;
|
||||
if (is_numeric($result) ) {
|
||||
$dec = strlen(substr(strrchr($result, "."), 1));
|
||||
$result = number_format($result,$dec,".",",");
|
||||
}
|
||||
$result .= " ". $r["T_OrderDetailResultFlag"];
|
||||
|
||||
$px_code = $r["T_TestSasCode"];
|
||||
if(! isset($arr_code[$px_code]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_code[$px_code] = true;
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
$px_code = "";
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function old_search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
class Re_mbv extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo "Api: Training Playground";
|
||||
}
|
||||
function get_note()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT Other_MBVNoteName as name,
|
||||
Other_MBVNoteDescription as description
|
||||
FROM other_mbvnote";
|
||||
$qry = $this->db->query($sql, []);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$raw = $qry->result_array();
|
||||
$result = array("records" => $raw);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_doctors()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 7 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
} else {
|
||||
$this->sys_error_db("Rerun rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function get_result_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$sql = "SELECT Other_MBVT_OrderDetailID as detail_id,
|
||||
Other_MBVID as id,
|
||||
Other_MBVSkorNugent as skor_nugent,
|
||||
Other_MBVBahan as bahan,
|
||||
Other_MBVM_DoctorID as doctor_id,
|
||||
Other_MBVDetailsSumLp as sum_lp,
|
||||
Other_MBVDetailsSkor as skor
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN other_mbv
|
||||
ON T_OrderDetailID = Other_MBVT_OrderDetailID
|
||||
AND Other_MBVIsActive = 'Y'
|
||||
JOIN other_mbvdetails
|
||||
ON Other_MBVID = Other_MBVDetailsOther_MBVID
|
||||
AND Other_MBVDetailsIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
AND T_OrderHeaderIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [$id]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$result = $qry->result_array();
|
||||
$this->sys_ok(array("records" => $result));
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveresult_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// print_r(json_encode($prm['detail']));
|
||||
// exit;
|
||||
$doctor = 0;
|
||||
if (isset($prm['doctor'])) {
|
||||
$doctor = $prm['doctor'];
|
||||
}
|
||||
|
||||
$bahan = 0;
|
||||
if (isset($prm['bahan'])) {
|
||||
$bahan = $prm['bahan'];
|
||||
}
|
||||
|
||||
$data = 0;
|
||||
if (isset($prm['detail'])) {
|
||||
$data = $prm['detail'];
|
||||
}
|
||||
// print_r(json_encode($data));
|
||||
// exit;
|
||||
$skor_nugent = 0;
|
||||
if (isset($prm['skor_nugent'])) {
|
||||
$skor_nugent = $prm['skor_nugent'];
|
||||
}
|
||||
// print_r(json_encode(array("dktr" => $doctor, "dt" => $data, "bhn" => $bahan, "skr" => $skor_nugent,)));
|
||||
// exit;
|
||||
if ($data == 0 || $doctor == 0) {
|
||||
$this->sys_error("result, doctor & bahan are mandatory");
|
||||
// print_r(json_encode(array("dktr" => $doctor == 0, "dt" => $data == 0, "bhn" => $bahan == 0, "skr" => $skor_nugent == 0,)));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
for ($i = 0; $i < count($data); $i++) {
|
||||
if ($data[$i]["xid"] == "0" && $data[$i]["orderdetail_id"] != "0") {
|
||||
//insert other_fna
|
||||
$sql = "INSERT INTO other_mbv
|
||||
(Other_MBVT_OrderDetailID,
|
||||
Other_MBVSkorNugent,
|
||||
Other_MBVBahan,
|
||||
Other_MBVM_DoctorID,
|
||||
Other_MBVUserID,
|
||||
Other_MBVCreated)
|
||||
VALUES(?,?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["orderdetail_id"], $skor_nugent, $bahan,
|
||||
$doctor["id"], 3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$inserted_id = $this->db->insert_id();
|
||||
$sql = "INSERT INTO other_mbvdetails(
|
||||
Other_MBVDetailsOther_MBVID,
|
||||
Other_MBVDetailsSumLp,
|
||||
Other_MBVDetailsSkor,
|
||||
Other_MBVDetailsUserID,
|
||||
Other_MBVDetailsCreated)
|
||||
VALUES(?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$inserted_id,
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql = "UPDATE other_mbv SET Other_MBVSkorNugent =? ,
|
||||
Other_MBVBahan = ?,
|
||||
Other_MBVM_DoctorID = ?
|
||||
WHERE Other_MBVID = ? AND Other_MBVIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$skor_nugent,
|
||||
$bahan,
|
||||
intval($doctor["id"]),
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE other_mbvdetails SET Other_MBVDetailsSumLp = ?,
|
||||
Other_MBVDetailsSkor = ?
|
||||
WHERE Other_MBVDetailsOther_MBVID = ? AND Other_MBVDetailsIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("success");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class Re_normal extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$od_id = $prm["order_detail_id"];
|
||||
$sql = "call sp_re_update_normal(?)";
|
||||
$this->db_smartone->query($sql, array($od_id));
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNormalValueNote,
|
||||
Nat_MethodeName
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_methode on T_OrderDetailNat_MethodeID = Nat_MethodeID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
$qry = $this->db_smartone->query($sql_norm,array($od_id));
|
||||
if ( $qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) {
|
||||
$result = array("status"=>"OK","records" => $rows[0]);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
|
||||
// start fitri update unit
|
||||
$sql = "select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN nat_normalvalue ON Nat_NormalValueID = T_OrderDetailNat_NormalValueID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_NormalValueNat_UnitID
|
||||
where T_OrderDetailID = ?";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$unit_id = $rows[0]["Nat_UnitID"];
|
||||
$unit_name = $rows[0]["Nat_UnitName"];
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
|
||||
}else{
|
||||
$sqlunit = $this->db_smartone->query("select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN t_test ON T_TestID = T_OrderDetailT_TestID
|
||||
JOIN nat_test ON Nat_TestID = T_TestNat_TestID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_TestNat_UnitID
|
||||
where T_OrderDetailID = '{$prm["detail_id"]}'")->row();
|
||||
$unit_id = $sqlunit->Nat_UnitID;
|
||||
$unit_name = $sqlunit->Nat_UnitName;
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
}
|
||||
}
|
||||
// end fitri update unit
|
||||
|
||||
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,T_OrderDetailNat_UnitID,T_OrderDetailNat_UnitName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
$xdata["unit_id"] = $rows[0]["T_OrderDetailNat_UnitID"];
|
||||
$xdata["unit_name"] = $rows[0]["T_OrderDetailNat_UnitName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,263 @@
|
||||
<?php
|
||||
|
||||
class Re_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["start_date"] . '%';
|
||||
$edate = $prm["end_date"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id'])) $group_id = $prm['group_id'];
|
||||
|
||||
$company_id = 0;
|
||||
$q_company = "";
|
||||
if (isset($prm['company_id'])) {
|
||||
$company_id = $prm['company_id'];
|
||||
if ($company_id > 0 ) {
|
||||
$q_company = " and T_OrderHeaderCorporateID = $company_id ";
|
||||
}
|
||||
}
|
||||
$q_search = " and
|
||||
( M_PatientName LIKE ?
|
||||
or T_OrderHeaderLabNumber like ?
|
||||
)";
|
||||
if ($prm["search"] == "" ) $q_search = "";
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
$max_rst = 9999;
|
||||
$offset = 0;
|
||||
|
||||
$q_group = "";
|
||||
if ($group_id != 0 ) {
|
||||
$sql = "select T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = $group_id
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " and T_TestNat_TestID in ( $nat_test_ids ) ";
|
||||
}
|
||||
|
||||
//janji hasil hari ini T_OrderHeaderID
|
||||
/* $sql = "select T_OrderPromiseT_OrderHeaderID
|
||||
from t_orderpromise
|
||||
where T_OrderPromiseIsActive = 'Y' and date(T_OrderPromiseDateTime) = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate));
|
||||
$promise_ids = "0";
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderPromiseT_OrderHeaderID"];
|
||||
$promise_ids = join(",",$xids);
|
||||
}
|
||||
}
|
||||
*/
|
||||
$order_ids = 0;
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y' and date(T_OrderHeaderDate) BETWEEN ? AND ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate,$edate));
|
||||
$order_ids = $promise_ids;
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderHeaderID"];
|
||||
$order_ids = join(",",$xids);
|
||||
}else{
|
||||
$order_ids = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *,
|
||||
CONCAT('[', GROUP_CONCAT(DISTINCT CONCAT('\"', T_OrderHeaderDate, '\"') SEPARATOR ','), ']') order_promise
|
||||
FROM (
|
||||
select T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderDate,
|
||||
'' T_OrderHeaderLabNumberExt, T_OrderHeaderDiagnose,
|
||||
M_PatientID, M_PatientNoReg, fn_global_patient_name(M_PatientID) M_PatientName,
|
||||
M_PatientDOB, T_OrderHeaderM_PatientAge, M_PatientHP, M_PatientGender M_SexName, '' M_PatientNote,
|
||||
da.M_DoctorID doctor_pj_id, fn_get_doctor_fullname(da.M_DoctorID) doctor_pj_name,
|
||||
0 doctor_sender_id, '' doctor_sender_name,
|
||||
'' M_MouID, '' M_MouName, CorporateID, CorporateName,
|
||||
T_OrderHeaderFoNote, T_OrderHeaderSamplingNote, T_OrderHeaderResultNote,
|
||||
la.M_LangID M_LangID, la.M_LangCode M_LangCode, la.M_LangName M_LangName, '' T_OrderHeaderLangIsSI,
|
||||
la.M_LangID SecondM_LangID, la.M_LangCode SecondM_LangCode, la.M_LangName SecondM_LangName,
|
||||
'' T_OrderHeaderAddOnSecondLangIsSI,
|
||||
'N' T_OrderHeaderIsCito, '' as delivery,
|
||||
'' T_OrderPromiseDateTime, '' is_history,
|
||||
'N' T_OrderHeaderAddOnVerificationDone,
|
||||
'N' T_OrderHeaderAddOnValidationDone, '' T_OrderHeaderAddOnRequestChangeDOB
|
||||
from t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_orderheaderlang ON T_OrderHeaderLangT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
{$q_group}
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
left join m_doctor da on T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN corporate on T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN m_lang la ON T_OrderHeaderLangM_LangID = la.M_LangID
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
{$q_company}
|
||||
{$q_search}
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
) x
|
||||
GROUP BY T_OrderHeaderID
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
";
|
||||
if ($q_search == "" ) {
|
||||
$query = $this->db_smartone->query($sql);
|
||||
} else {
|
||||
$query = $this->db_smartone->query($sql, [ $search, $search]);
|
||||
}
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$tmp_ohnumber = [];
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$lang = [["id"=>0, "code"=>"ID", "is_si"=>"N"]];
|
||||
if ($v['M_LangCode'] != "ID")
|
||||
$lang[] = ["id"=>$v['M_LangID'], "code"=>$v['M_LangCode'], "is_si"=>$v['T_OrderHeaderLangIsSI']];
|
||||
$sqltotal = "SELECT COUNT(T_OrderDetailID) as cnt_rst_a,
|
||||
SUM(IF(T_OrderDetailResult <> '' AND T_OrderDetailResult IS NOT NULL, 1, 0)) as cnt_rst_b,
|
||||
SUM(IF(T_OrderDetailVerification = 'Y', 1, 0)) as cnt_ver_n,
|
||||
SUM(IF(T_OrderDetailValidation = 'Y', 1, 0)) as cnt_val_n
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = {$v['T_OrderHeaderID']}
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'";
|
||||
$sqltotal = $this->db_smartone->query($sqltotal)->row();
|
||||
|
||||
if($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b < $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'P';
|
||||
}elseif($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b == $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'Y';
|
||||
}
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$rows[$k]['lang'] = $lang;
|
||||
$rows[$k]['delivery'] = JSON_DECODE($v['delivery']);
|
||||
$rows[$k]['order_promise'] = JSON_DECODE($v['order_promise']);
|
||||
|
||||
foreach($rows[$k]['order_promise'] as $l => $w)
|
||||
$rows[$k]['order_promise'][$l] = date('d-m-Y H:i', strtotime($w));
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from t_orderheader
|
||||
JOIN corporate ON CorporateID = T_OrderHeaderCorporateID AND CorporateIsActive = 'Y'
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
GROUP BY CorporateID";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$crows = $query->result_array();
|
||||
$crows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count,
|
||||
"total_page" => ceil($tot_count/$max_rst),
|
||||
"cur_page" => $page,
|
||||
"records" => $rows,
|
||||
"total_display" => sizeof($rows),
|
||||
"q" => $this->db_smartone->last_query(),
|
||||
"companies"=>$crows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function history()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_history(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$history = json_decode($row->rst);
|
||||
|
||||
$this->sys_ok($history);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("RESULT HISTORY", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_note()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderheader SET T_OrderHeaderResultNote = ?, T_OrderHeaderResultNoteM_UserID = ?
|
||||
WHERE T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['note'], $this->sys_user['M_UserID'], $prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$this->sys_ok($prm['order_id']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT NOTE", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function info_req()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_reqs(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$s_data = $row->data;
|
||||
$s_data = str_replace("\n"," ",$s_data);
|
||||
$this->sys_ok(json_decode($s_data));
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT REQ", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,710 @@
|
||||
<?php
|
||||
|
||||
class Re_px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Px API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 99;
|
||||
|
||||
$id = $prm["order_id"];
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$tot_count = 0;
|
||||
$lq = "";
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id']))
|
||||
$group_id = $prm['group_id'];
|
||||
|
||||
if ($group_id != 0)
|
||||
{
|
||||
$sql = "select distinct T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = {$group_id}";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " ( $nat_test_ids ) ";
|
||||
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime, fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_test tcheck on tcheck.T_TestNat_TestID in {$q_group}
|
||||
and ( tx.T_TestID = tcheck.T_TestID or tx.T_TestSasCode like concat(tcheck.T_TestSasCode,'%'))
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime , fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
// file_put_contents("/xtmp/re-query.sql",$lq);
|
||||
|
||||
if ($query) {
|
||||
$rst = [];
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v)
|
||||
{
|
||||
|
||||
if ($v['is_result'] == "Y" && $v['is_quantitative'] == "N")
|
||||
{
|
||||
$v['template'] = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$v['t_testid']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$v['template'] = $x->result_array();
|
||||
}
|
||||
|
||||
// IF Rujukan, by pas Pre Analytik
|
||||
if ($v['ref'] == 'Y')
|
||||
$v['pre_analytic'] = 'Y';
|
||||
|
||||
$rst[] = $v;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rst, "total_display" => sizeof($rows), "q" => $lq);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RE Px rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
if ( $v->resultInstrumentID > 0 ) {
|
||||
$sql_i = "select T_ResultInstrumentNat_NormalValueID normalValueID
|
||||
from t_resultinstrument
|
||||
where T_ResultInstrumentID = ?";
|
||||
$qry_i = $this->db_smartone->query($sql_i, array($v->resultInstrumentID));
|
||||
if ($qry_i) {
|
||||
$rows_i = $qry_i->result_array();
|
||||
|
||||
if (count($rows_i) > 0 ) {
|
||||
$sql_iu = "update t_orderdetail, nat_normalvalue
|
||||
set T_OrderDetailMinValue = Nat_NormalValueMinValue,
|
||||
T_OrderDetailMinValueInclusive = Nat_NormalValueMinValueInclusive,
|
||||
T_OrderDetailMaxValue = Nat_NormalValueMaxValue ,
|
||||
T_OrderDetailMaxValueInclusive = Nat_NormalValueMaxValueInclusive,
|
||||
T_OrderDetailNormalValueNote = Nat_NormalValueNote,
|
||||
T_OrderDetailNormalValueDescription = Nat_NormalValueDescription,
|
||||
T_OrderDetailNat_NormalValueID = Nat_NormalValueID
|
||||
where T_OrderDetailID = ? and Nat_NormalValueID = ?
|
||||
";
|
||||
$this->db_smartone->query($sql_iu, array($v->id, $rows_i[0]["normalValueID"]));
|
||||
//file_put_contents("/xtmp/update-nilai-normal", $this->db_smartone->last_query() . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
$y = $this->db_smartone->query("SELECT fn_process_sample_handling_perfect('{$v->order_id}', '{$v->test_id}') c")
|
||||
->row();
|
||||
$req_status = $y->c;
|
||||
$qry_norm = $this->db_smartone->query($sql_norm,$v->id);
|
||||
$result_flag = "";
|
||||
if ($qry_norm) {
|
||||
$rows_norm = $qry_norm->result_array();
|
||||
if (count($rows_norm) > 0 ) {
|
||||
$r = $rows_norm[0];
|
||||
if (is_numeric($v->result)) {
|
||||
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "Y" && $v->result < $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "N" && $v->result <= $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "Y" && $v->result > $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "N" && $v->result >= $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($lang == $this->lang_default_code)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailResult', $v->result)
|
||||
->set('T_OrderDetailResultFlag', $result_flag)
|
||||
->set('T_OrderDetailNote', $v->note)
|
||||
->set('T_OrderDetailReqStatus', $req_status)
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailLangResult', $v->result)
|
||||
->set('T_OrderDetailLangNote', $v->note)
|
||||
->where('T_OrderDetailLangID', $v->id)
|
||||
->update('t_orderdetaillang');
|
||||
}
|
||||
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Entry')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', json_encode($data))
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
//auto calculation
|
||||
$this->load->library("Resultcalc");
|
||||
$rows = $this->resultcalc->auto($order->id);
|
||||
|
||||
try {
|
||||
foreach($ids as $id ) {
|
||||
$this->db_smartone->query("call sp_set_normal_value_flag($id)");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
|
||||
public function save_template()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$n = $this->db_smartone->select("COUNT(T_ResultTemplateID) n")
|
||||
->where("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->where("T_ResultTemplateIsActive", "Y")
|
||||
->where("T_ResultTemplateValue", $prm['value'])
|
||||
->get('t_resulttemplate')
|
||||
->row();
|
||||
if ($n->n > 0)
|
||||
{
|
||||
$this->sys_error_db("Insert Result Template", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$r = $this->db_smartone->set("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->set("T_ResultTemplateValue", $prm['value'])
|
||||
->insert('t_resulttemplate');
|
||||
if ($r)
|
||||
{
|
||||
$template = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$prm['test_id']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$template = $x->result_array();
|
||||
|
||||
$this->sys_ok($template);
|
||||
}
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_lang(?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'], $prm['lang_id'], $prm['is_si'], $this->sys_user['M_UserID']]);
|
||||
if ($query)
|
||||
{
|
||||
$r = $query->row();
|
||||
if ($r->status == "OK")
|
||||
{
|
||||
$this->sys_ok($r->data);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Message : " . $r->message, $this->db_smartone);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Lang Result", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_group()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 100;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_WorklistID group_id, T_WorklistName group_name
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$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("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_rerun()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["detail_id"];
|
||||
|
||||
$sql = "CALL sp_process_result_rerun(?)";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdoctorsfna()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getfnaresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_FNADetailsID as xid,
|
||||
Other_FNAT_OrderDetailID as orderdetail_id,
|
||||
Other_FNADetailsCode as code,
|
||||
Other_FNADetailsLabel as label,
|
||||
Other_FNADetailsResult as result,
|
||||
IFNULL(Other_FNAM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_FNAM_DoctorID) OR Other_FNAM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_fna
|
||||
JOIN other_fnadetails ON Other_FNADetailsOther_FNAID = Other_FNAID AND Other_FNADetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_FNAM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_FNAT_OrderDetailID = {$id} AND Other_FNAIsActive = 'Y'
|
||||
GROUP BY Other_FNADetailsID
|
||||
ORDER BY Other_FNADetailsCode ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getpapsmearresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_PapSmearDetailsID as xid,
|
||||
Other_PapSmearID as header_id,
|
||||
Other_PapSmearT_OrderDetailID as orderdetail_id,
|
||||
Other_PapSmearDetailsCode as code,
|
||||
Other_PapSmearDetailsLabel as label,
|
||||
Other_PapSmearDetailsResult as result,
|
||||
IFNULL(Other_PapSmearM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_PapSmearM_DoctorID) OR Other_PapSmearM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_papsmear
|
||||
JOIN other_papsmeardetails ON Other_PapSmearDetailsOther_PapSmearID = Other_PapSmearID AND Other_PapSmearDetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_PapSmearM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_PapSmearT_OrderDetailID = {$id} AND Other_PapSmearIsActive = 'Y'
|
||||
GROUP BY Other_PapSmearDetailsID
|
||||
ORDER BY Other_PapSmearDetailsCode ASC";
|
||||
//echo $sql;
|
||||
$rows = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$rows){
|
||||
$rows = array(
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'A',
|
||||
'label' => 'Makroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'B',
|
||||
'label' => 'Mikroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'C',
|
||||
'label' => 'Kesimpulan',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$header_id = $rows[0]['header_id'];
|
||||
$sql = "SELECT Other_PapSmearMaturasiID as xid,
|
||||
Other_PapSmearMaturasiValue as value
|
||||
FROM other_papsmearmaturasi
|
||||
WHERE
|
||||
Other_PapSmearMaturasiOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearMaturasiIsActive = 'Y'
|
||||
";
|
||||
$maturasi = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$maturasi){
|
||||
$maturasi = array('xid'=>'0','value'=>'//');
|
||||
}
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearBahanID,0) as xid,
|
||||
M_PapSmearBahanID as bahan_id,
|
||||
M_PapSmearBahanName as name
|
||||
FROM m_papsmearbahan
|
||||
LEFT JOIN other_papsmearbahan ON Other_PapSmearBahanM_PapSmearBahanID = M_PapSmearBahanID AND
|
||||
Other_PapSmearBahanOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearBahanIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearBahanIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$bahans = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapsmearCategoryID,0) as xid,
|
||||
M_PapSmearCategoryID as category_id,
|
||||
M_PapSmearCategoryName as name
|
||||
FROM m_papsmearcategory
|
||||
LEFT JOIN other_papsmearcategory ON Other_PapsmearCategoryM_PapSmearCategoryID = M_PapSmearCategoryID AND
|
||||
Other_PapsmearCategoryOther_PapSmearID = {$header_id} AND
|
||||
Other_PapsmearCategoryIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCategoryIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$categories = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearCheckID,0) as xid,
|
||||
M_PapSmearCheckID as check_id,
|
||||
M_PapSmearCheckLabel as name,
|
||||
Other_PapSmearCheckNote as note
|
||||
FROM m_papsmearcheck
|
||||
LEFT JOIN other_papsmearcheck ON Other_PapSmearCheckM_PapSmearCheckID = M_PapSmearCheckID AND
|
||||
Other_PapSmearCheckOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearCheckIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCheckIsActive = 'Y'
|
||||
";
|
||||
$checks = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'checks'=>$checks,'bahans'=>$bahans,'categories'=>$categories,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
|
||||
}
|
||||
|
||||
function saveresult_fna()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
$prm = $inp['results'];
|
||||
$doctor_id = $inp['doctor'];
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$header_id = 0;
|
||||
if($prm[0]['xid'] == '0'){
|
||||
$sql = "INSERT INTO other_fna(
|
||||
Other_FNAM_DoctorID,
|
||||
Other_FNAT_OrderDetailID,
|
||||
Other_FNAUserID,
|
||||
Other_FNACreated
|
||||
)
|
||||
VALUES(
|
||||
{$doctor_id},
|
||||
{$prm[0]['orderdetail_id']},
|
||||
{$userid},
|
||||
NOW()
|
||||
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_smartone->query($sql);
|
||||
$header_id = $this->db_smartone->insert_id();
|
||||
}
|
||||
foreach($prm as $k => $v){
|
||||
if($v['xid'] == '0'){
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "INSERT INTO other_fnadetails(
|
||||
Other_FNADetailsOther_FNAID ,
|
||||
Other_FNADetailsCode,
|
||||
Other_FNADetailsLabel,
|
||||
Other_FNADetailsResult,
|
||||
Other_FNADetailsCreated,
|
||||
Other_FNADetailsUserID
|
||||
)
|
||||
VALUES(
|
||||
{$header_id},
|
||||
'{$v['code']}',
|
||||
'{$v['label']}',
|
||||
'{$results}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
else{
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "UPDATE other_fnadetails SET
|
||||
Other_FNADetailsResult = '{$results}',
|
||||
Other_FNADetailsUserID = {$userid}
|
||||
WHERE
|
||||
Other_FNADetailsID = {$v['xid']}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => array(), "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,621 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_validation extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Result Validation API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function mr_state()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["order_id"];
|
||||
|
||||
$data = [
|
||||
"image" => "http://blog.aylien.com/wp-content/uploads/2016/07/Screen-Shot-2016-07-21-at-18.46.42.png",
|
||||
"note" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
"title" => "Multi Rule"
|
||||
];
|
||||
$this->sys_ok($data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
|
||||
if (sizeof($data) < 1) {
|
||||
$this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
exit;
|
||||
} else {
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v) {
|
||||
$mr_state = "X";
|
||||
if (isset($v->mr_state[0])) $mr_state = $v->mr_state[0];
|
||||
$qry = $this->db_smartone->set('T_OrderDetailValMRState', $mr_state)
|
||||
->set('T_OrderDetailValidation', $v->validation)
|
||||
->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation1', $v->validation)
|
||||
->set('T_OrderDetailValidation1Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation2', $v->validation)
|
||||
->set('T_OrderDetailValidation2Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
if (!$qry) {
|
||||
print_r($this->db_smartone->error());
|
||||
}
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$sql_order = "SELECT
|
||||
T_OrderDetailT_OrderHeaderID
|
||||
FROM t_orderdetail
|
||||
WHERE T_OrderDetailID = ? and T_OrderDetailIsActive = 'Y'";
|
||||
$qry_order = $this->db_smartone->query($sql_order, [$data[0]->id]);
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($qry_order) {
|
||||
$row = $qry_order->row_array();
|
||||
} else {
|
||||
$this->sys_error_db("select orderheader", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select
|
||||
T_OrderHeaderID,T_OrderHeaderLabNumber,
|
||||
T_TestName, T_OrderDetailID, T_OrderDetailResult, T_OrderDetailNat_MethodeID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,
|
||||
T_OrderDetailMinValue, T_OrderDetailMaxValue, T_OrderDetailMinValueInclusive,
|
||||
T_OrderDetailMaxValueInclusive,
|
||||
Mcu_SummaryLabID,
|
||||
Mcu_SummaryLabValue,
|
||||
Mcu_SummaryLabNat_MethodeID,
|
||||
Mcu_SummaryLabWithMethode,
|
||||
Mcu_SummaryLabType,
|
||||
Mcu_SummaryLabIsNormalValue,
|
||||
Mcu_KelainanID, Mcu_KelainanName, Mcu_KelainanClasification,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
mcu_kelainangroup.*
|
||||
from t_orderdetail
|
||||
join t_orderheader on T_OrderHeaderID = ?
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
join t_test
|
||||
on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
join mcu_summarylab on T_TestNat_TestID = Mcu_SummaryLabNat_TestID AND Mcu_SummaryLabIsActive = 'Y'
|
||||
join mcu_kelainan on Mcu_SummaryLabMcu_KelainanID = Mcu_KelainanID
|
||||
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID";
|
||||
$qry = $this->db_smartone->query($sql, array($row["T_OrderDetailT_OrderHeaderID"]));
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get order | " . $this->db_smartone->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
$results = [];
|
||||
|
||||
$sql_upd = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabIsActive = 'N',
|
||||
T_KelainanLabCreatedUserID = {$this->sys_user['M_UserID']}
|
||||
WHERE T_KelainanLabT_OrderHeaderID = {$rows[0]['T_OrderHeaderID']}";
|
||||
$qry_upd = $this->db_smartone->query($sql_upd);
|
||||
if (!$qry_upd) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$result_value = $r['T_OrderDetailResult'];
|
||||
|
||||
$value_comparison = 0;
|
||||
//echo $r['Mcu_SummaryLabIsNormalValue'];
|
||||
$kelainan = [];
|
||||
$notavailable = [];
|
||||
if (trim($result_value) == 'NA') {
|
||||
$notavailable = $r;
|
||||
} elseif ($r['Mcu_SummaryLabIsNormalValue'] == 'Y') {
|
||||
if ($r['Mcu_SummaryLabType'] == '<' || $r['Mcu_SummaryLabType'] == '<=') {
|
||||
$value_comparison = $r['T_OrderDetailMinValue'];
|
||||
}
|
||||
if ($r['Mcu_SummaryLabType'] == '>' || $r['Mcu_SummaryLabType'] == '>=') {
|
||||
$value_comparison = $r['T_OrderDetailMaxValue'];
|
||||
}
|
||||
//echo "Y";
|
||||
if ($r['Mcu_SummaryLabWithMethode'] == 'N' && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
$value_comparison = $r['Mcu_SummaryLabValue'];
|
||||
if ($r['Mcu_SummaryLabType'] == '!=' || $r['Mcu_SummaryLabType'] == '==') {
|
||||
if ($this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
if (is_numeric($result_value) && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($results) > 0) {
|
||||
|
||||
foreach ($results as $v_result) {
|
||||
$sql_kel_lab = "SELECT *
|
||||
FROM t_kelainan_lab
|
||||
WHERE T_KelainanLabIsActive = 'Y'
|
||||
AND T_KelainanLabT_OrderDetailID = ?";
|
||||
$qry_kel_lab = $this->db_smartone->query($sql_kel_lab, array($v_result['orderdetailID']));
|
||||
if ($qry_kel_lab) {
|
||||
$rows_kel = $qry_kel_lab->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select kelainan lab", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows_kel) > 0) {
|
||||
|
||||
// print_r($v_result['orderdetailID']);
|
||||
// exit;
|
||||
|
||||
$sql_update_kel = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabT_OrderDetailID = ?,
|
||||
T_KelainanLabT_OrderHeaderID = ?,
|
||||
T_KelainanLabNat_TestID = ?,
|
||||
T_KelainanLabMcu_SummaryLabID = ?,
|
||||
T_KelainanLabCreatedUserID = ?,
|
||||
T_KelainanLabCreated = NOW()
|
||||
WHERE T_KelainanLabID = ?";
|
||||
$qry_update_kel = $this->db_smartone->query($sql_update_kel, array(
|
||||
$v_result['orderdetailID'],
|
||||
$v_result['orderheaderID'],
|
||||
$v_result['nat_testID'],
|
||||
$v_result['mcu_summarylabID'],
|
||||
$this->sys_user['M_UserID'],
|
||||
$rows_kel[0]['T_KelainanLabID']
|
||||
));
|
||||
if (!$qry_update_kel) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// print_r('insert');
|
||||
// exit;
|
||||
$sql_insert_lab = "INSERT INTO t_kelainan_lab(
|
||||
T_KelainanLabT_OrderDetailID,
|
||||
T_KelainanLabT_OrderHeaderID,
|
||||
T_KelainanLabNat_TestID,
|
||||
T_KelainanLabMcu_SummaryLabID,
|
||||
T_KelainanLabCreatedUserID,
|
||||
T_KelainanLabCreated) VALUES(
|
||||
{$v_result['orderdetailID']},
|
||||
{$v_result['orderheaderID']},
|
||||
{$v_result['nat_testID']},
|
||||
{$v_result['mcu_summarylabID']},
|
||||
{$this->sys_user['M_UserID']},
|
||||
NOW())";
|
||||
$qry_insert_lab = $this->db_smartone->query($sql_insert_lab);
|
||||
|
||||
if (!$qry_insert_lab) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error insert kelainan lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// END OF Log Process
|
||||
//update validation multi
|
||||
//$this->load->library("Txbranchstatus");
|
||||
// $this->txbranchstatus->update_multi("VALIDATION",$ids,$this->sys_user['M_StaffName']);
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
}
|
||||
|
||||
function dynamic_comparison($varleft, $op, $varright)
|
||||
{
|
||||
|
||||
switch ($op) {
|
||||
case "=":
|
||||
return $varleft == $varright;
|
||||
case "!=":
|
||||
return $varleft != $varright;
|
||||
case ">=":
|
||||
return $varleft >= $varright;
|
||||
case "<=":
|
||||
return $varleft <= $varright;
|
||||
case ">":
|
||||
return $varleft > $varright;
|
||||
case "<":
|
||||
return $varleft < $varright;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// public function validate()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $data = json_decode($prm["data"]);
|
||||
|
||||
// if (sizeof($data) < 1)
|
||||
// {
|
||||
// $this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
// exit;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $ids = [];
|
||||
// foreach ($data as $k => $v)
|
||||
// {
|
||||
// $this->db_smartone->set('T_OrderDetailValMRState', $v->mr_state)
|
||||
// ->set('T_OrderDetailValidation', $v->validation)
|
||||
// ->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
// ->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
// ->where('T_OrderDetailID', $v->id)
|
||||
// ->update('t_orderdetail');
|
||||
// $ids[] = $v->id;
|
||||
// }
|
||||
|
||||
// // LOG Process
|
||||
// $order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
// ->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
// ->where('T_OrderDetailID', $data[0]->id)
|
||||
// ->get('t_orderdetail')
|
||||
// ->row();
|
||||
|
||||
// $dblog = $this->load->database("onelog", true);
|
||||
// $dblog->set('Log_ProcessCode', 'PROCESS.Result.Validation')
|
||||
// ->set('Log_ProcessOrderID', $order->id)
|
||||
// ->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
// ->set('Log_ProcessJson', json_encode($data))
|
||||
// ->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
// ->insert('log_process');
|
||||
// // END OF Log Process
|
||||
|
||||
// $this->sys_ok($ids);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
function print_count()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->firstprint();
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = T_OrderDetailPrintCount + 1
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailValidation = 'Y'
|
||||
AND T_OrderDetailIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query) {
|
||||
$this->sys_ok($this->db_smartone->last_query());
|
||||
} else
|
||||
$this->sys_error_db("Print Count", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function reject()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_validation_reject(?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['id'], $prm['action']]);
|
||||
|
||||
if ($query) {
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
} else {
|
||||
$this->sys_error_db("REJECT VALIDATION", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
|
||||
public function unvalidate()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm["order_id"];
|
||||
|
||||
$this->db_smartone->set('T_OrderDetailValidation', "N")
|
||||
->set('T_OrderDetailValDate', null)
|
||||
->set('T_OrderDetailValUserID', 0)
|
||||
->set('T_OrderDetailValidation1', "N")
|
||||
->set('T_OrderDetailValidation1Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->set('T_OrderDetailValidation2', "N")
|
||||
->set('T_OrderDetailValidation2Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->where('T_OrderDetailIsActive', 'Y')
|
||||
->where('T_OrderDetailValidation', 'Y')
|
||||
->update('t_orderdetail');
|
||||
|
||||
$q = $this->db_smartone->last_query();
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
/* $dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Unvalidation')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', '{}')
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
*/
|
||||
$this->sys_ok($q);
|
||||
}
|
||||
|
||||
// Copas Fajri
|
||||
function firstprint()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm['T_OrderHeaderID'] = $prm['order_id'];
|
||||
$datarows = [];
|
||||
$query = " SELECT T_OrderDetailID,T_TestName
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName = 'lab'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDetailValidation = 'Y' AND
|
||||
T_OrderDetailPrintCount = 0 AND
|
||||
T_OrderDetailT_OrderPromiseID <> 0 AND
|
||||
( T_OrderDetailResult <> '' OR T_OrderDetailResult IS NOT NULL ) AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_OrderDetailID";
|
||||
//echo $query;
|
||||
$datarows = $this->db_smartone->query($query)->result_array();
|
||||
$ids = array();
|
||||
$testname = array();
|
||||
if ($datarows) {
|
||||
foreach ($datarows as $k => $v) {
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = 1 WHERE T_OrderDetailID = {$v['T_OrderDetailID']}";
|
||||
$this->db_smartone->query($sql);
|
||||
array_push($ids, $v['T_OrderDetailID']);
|
||||
array_push($testname, $v['T_TestName']);
|
||||
}
|
||||
}
|
||||
$join_ids = "[" . join(",", $ids) . "]";
|
||||
$join_testname = "[" . join(",", $testname) . "]";
|
||||
|
||||
$sql = "SELECT t_orderdelivery.*, M_DeliveryTypeCode as code
|
||||
FROM t_orderdelivery
|
||||
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
";
|
||||
//echo $sql;
|
||||
$result_delivery = $this->db_smartone->query($sql)->result_array();
|
||||
$arr_deliveryid = array();
|
||||
foreach ($result_delivery as $i => $j) {
|
||||
array_push($arr_deliveryid, $j["T_OrderDeliveryM_DeliveryID"]);
|
||||
}
|
||||
|
||||
foreach ($result_delivery as $k => $v) {
|
||||
|
||||
if ($v['code'] == 'PICKUP') {
|
||||
$sql = "INSERT INTO result_frontoffice(
|
||||
Result_FrontOfficeT_OrderHeaderID,
|
||||
Result_FrontOfficeIds,
|
||||
Result_FrontOfficeStatus,
|
||||
Result_FrontOfficeType,
|
||||
Result_FrontOfficeTestName,
|
||||
Result_FrontOfficeCreated,
|
||||
Result_FrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_FrontOfficeStatus = 'P',
|
||||
Result_FrontOfficeUserID = {$userid}
|
||||
";
|
||||
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_frontoffice
|
||||
WHERE Result_FrontOfficeT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_FrontOfficeIds = '{$join_ids}' AND
|
||||
Result_FrontOfficeType = 'lab'";
|
||||
$rst_log = $this->db_smartone->query($sql)->result_array();
|
||||
$dt_log = json_encode($rst_log);
|
||||
$sql = "INSERT INTO one_log.log_result_front_office(
|
||||
Log_ResultFrontOfficeDateTime,
|
||||
Log_ResultFrontOfficeJson,
|
||||
Log_ResultFrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'EMAIL') {
|
||||
$type = "MANUAL";
|
||||
if (in_array(1, $arr_deliveryid) && (in_array(3, $arr_deliveryid) || in_array(5, $arr_deliveryid) || in_array(11, $arr_deliveryid))) {
|
||||
$type = "FO";
|
||||
}
|
||||
$sql = "INSERT INTO result_sendemail(
|
||||
Result_SendEmailT_OrderHeaderID,
|
||||
Result_SendEmailActionBy,
|
||||
Result_SendEmailIds,
|
||||
Result_SendEmailT_OrderDeliveryID,
|
||||
Result_SendEmailStatus,
|
||||
Result_SendEmailType,
|
||||
Result_SendEmailT_TestName,
|
||||
Result_SendEmailCreated,
|
||||
Result_SendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$type}',
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendEmailStatus = 'P',
|
||||
Result_SendEmailUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendemail
|
||||
WHERE
|
||||
Result_SendEmailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendEmailIds = '{$join_ids}' AND
|
||||
Result_SendEmailT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendEmailType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendemail (
|
||||
Log_ResultSendEmailDatetime,
|
||||
Log_ResultSendEmailJson,
|
||||
Log_ResultSendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'ADDRESS') {
|
||||
$sql = "INSERT INTO result_sendcourier(
|
||||
Result_SendCourierT_OrderHeaderID,
|
||||
Result_SendCourierIds,
|
||||
Result_SendCourierT_OrderDeliveryID,
|
||||
Result_SendCourierStatus,
|
||||
Result_SendCourierType,
|
||||
Result_SendCourierT_TestName,
|
||||
Result_SendCourierCreated,
|
||||
Result_SendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendCourierStatus = 'P',
|
||||
Result_SendCourierUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendcourier
|
||||
WHERE
|
||||
Result_SendCourierT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendCourierIds = '{$join_ids}' AND
|
||||
Result_SendCourierT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendCourierType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendcourier (
|
||||
Log_ResultSendCourierDateTime,
|
||||
Log_ResultSendCourierJson,
|
||||
Log_ResultSendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
|
||||
//echo $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
// $result = array(
|
||||
// "total" => count($datarows) ,
|
||||
// "records" => $datarows,
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_doctor da on T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
JOIN helper_order ON Helper_OrderT_OrderHeaderID = T_OrderHeaderID
|
||||
AND Helper_OrderIsLAB = 'Y'
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderLabNumber like ?
|
||||
and
|
||||
( M_PatientName LIKE ?
|
||||
or ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL))
|
||||
or ((M_PatientDOB LIKE ? and M_PatientDOB IS NOT NULL))
|
||||
)
|
||||
order by T_OrderHeaderLabNumber DESC";
|
||||
$query = $this->db_smartone->query($sql, [$nolab, $search, $search, $search ]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderDate,
|
||||
M_PatientID, M_PatientNoReg, fn_global_patient_name(M_PatientID) M_PatientName,
|
||||
M_PatientDOB, T_OrderHeaderM_PatientAge, M_PatientHP, M_SexName,
|
||||
da.M_DoctorID doctor_pj_id, fn_global_doctor_name(da.M_DoctorID) doctor_pj_name,
|
||||
M_MouID, M_MouName, M_CompanyID, M_CompanyName,
|
||||
T_OrderHeaderFoNote, T_OrderHeaderSamplingNote, T_OrderHeaderResultNote, M_LangCode,
|
||||
T_OrderHeaderLangIsSI is_si
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_doctor da on T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
JOIN m_sex on M_PatientM_SexID = M_SexID
|
||||
JOIN helper_order ON Helper_OrderT_OrderHeaderID = T_OrderHeaderID
|
||||
AND Helper_OrderIsLAB = 'Y'
|
||||
JOIN m_lang ON T_OrderHeaderM_LangID = M_LangID
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderLabNumber like ?
|
||||
and
|
||||
( M_PatientName LIKE ?
|
||||
or ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL))
|
||||
or ((M_PatientDOB LIKE ? and M_PatientDOB IS NOT NULL))
|
||||
)
|
||||
order by T_OrderHeaderLabNumber DESC
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$nolab, $search, $search, $search ]);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$result = array("total" => $tot_count, "total_page" => ceil($tot_count/$max_rst), "cur_page" => $page, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
class Rv_px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Px API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->db_one = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 99;
|
||||
|
||||
$id = $prm["order_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
// $sql = "";
|
||||
// $query = $this->db_smartone->query($sql);
|
||||
|
||||
// if ($query) {
|
||||
// $tot_count = $query->result_array()[0]["total"];
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("re count", $this->db_smartone);
|
||||
// exit;
|
||||
// }
|
||||
$tot_count = 0;
|
||||
|
||||
$sql = "SELECT T_TestID
|
||||
FROM t_orderdetail JOIN t_test ON T_OrderDetailT_TEstID = T_TestID
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestParentT_TestID = 0";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
if ($query) {
|
||||
$rst = [];
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$sql = "WITH RECURSIVE ancestors AS
|
||||
(
|
||||
SELECT t_testid, t_testname,
|
||||
T_OrderDetailResult result, T_OrderDetailNote note, T_OrderDetailID id,
|
||||
T_OrderDetailT_TestIsResult is_result, 1 level,
|
||||
T_OrderDetailVerDeltaCheck delta_check,
|
||||
T_OrderDetailVerTrendAnalysis trend_analysis,
|
||||
T_OrderDetailVerification verification,
|
||||
T_OrderDetailVerification verification_old,
|
||||
T_OrderDetailReqStatus sample_handling_perfect
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
WHERE T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_OrderHeaderID = ?
|
||||
AND t_testid = ?
|
||||
|
||||
UNION
|
||||
|
||||
SELECT g.t_testid, g.t_testname,
|
||||
T_OrderDetailResult result, T_OrderDetailNote note, T_OrderDetailID id,
|
||||
T_OrderDetailT_TestIsResult is_result, level+1 level,
|
||||
T_OrderDetailVerDeltaCheck delta_check,
|
||||
T_OrderDetailVerTrendAnalysis trend_analysis,
|
||||
T_OrderDetailVerification verification,
|
||||
T_OrderDetailVerification verification_old,
|
||||
T_OrderDetailReqStatus sample_handling_perfect
|
||||
FROM ancestors a, t_orderdetail f
|
||||
JOIN t_test g ON f.T_OrderDetailT_TestID = g.T_TestID
|
||||
|
||||
WHERE T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_OrderHeaderID = ?
|
||||
AND g.t_testparentt_testid = a.t_testid and g.t_testisactive = 'Y' )
|
||||
SELECT * FROM ancestors;";
|
||||
$query = $this->db_smartone->query($sql, [$id, $v['T_TestID'], $id]);
|
||||
|
||||
$r = $query->result_array();
|
||||
foreach($r as $k => $v) {
|
||||
if ($v['delta_check'] == "X")
|
||||
{
|
||||
$tmp = $this->db_smartone->query("SELECT fn_process_re_deltacheck('{$v['id']}') x")
|
||||
->row();
|
||||
$v['delta_check'] = $tmp->x;
|
||||
}
|
||||
|
||||
if ($v['trend_analysis'] == "X")
|
||||
{
|
||||
$trend_sql = "SELECT fn_process_re_trendanalysis('{$v['id']}') x";
|
||||
$tmp = $this->db_smartone->query($trend_sql)
|
||||
->row();
|
||||
$j_trend_analysis= json_decode($tmp->x);
|
||||
$v['trend_analysis'] = $j_trend_analysis->status;
|
||||
}
|
||||
// Sample Handling & Verification Perfect
|
||||
// sipe always checked
|
||||
if (true || $v['sample_handling_perfect'] == 'X')
|
||||
{
|
||||
$y = $this->db_smartone->query("SELECT fn_process_sample_handling_perfect('{$id}', '{$v['t_testid']}') c")
|
||||
->row();
|
||||
$v['sample_handling_perfect'] = $y->c;
|
||||
}
|
||||
|
||||
// Override
|
||||
if ($y->c == "N")
|
||||
{
|
||||
$v['delta_check'] = "N";
|
||||
$v['trend_analysis'] = "N";
|
||||
}
|
||||
$rst[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rst, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RE Px rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["id"]);
|
||||
|
||||
if (sizeof($data) < 1)
|
||||
{
|
||||
$this->sys_error_db("RE Verification Confirmation", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailVerDeltaCheck', $v->delta)
|
||||
->set('T_OrderDetailVerTrendAnalysis', $v->trend)
|
||||
->set('T_OrderDetailVerification', $v->verification)
|
||||
->set('T_OrderDetailVerDate', date('Y-m-d H:i:s'))
|
||||
->set('T_OrderDetailVerUserID', $this->sys_user->M_UserID)
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_verification extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RV Px API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->db_one= $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function requirement($id) {
|
||||
$sql = "call sp_result_verify_requirement(?)";
|
||||
$query = $this->db_one->query($sql, array($id));
|
||||
$this->clean_mysqli_connection($this->db_one);
|
||||
$rows = $query->result_array() ;
|
||||
$result = array();
|
||||
foreach( $rows as $r ) {
|
||||
$jdata = json_decode( $r["jdata"] );
|
||||
$a_pos = array();
|
||||
foreach($jdata as $req ) {
|
||||
$xreq = json_decode($req,true);
|
||||
foreach($xreq as $position => $req) {
|
||||
$a_req = explode("^",$req);
|
||||
$a_pos[$position] = $a_req;
|
||||
}
|
||||
}
|
||||
$result = $a_pos;
|
||||
}
|
||||
return $this->req_html($result);
|
||||
}
|
||||
function req_html($result) {
|
||||
$a_pos = $result;
|
||||
if (count($a_pos) == 0 ) return "";
|
||||
$html = "<table >\n";
|
||||
$html .= "<tr><th style='text-align:left;padding:5px;'>Position</th>
|
||||
<th style='text-align:left;padding:5px;' >Requirements</th></tr>\n";
|
||||
foreach($a_pos as $pos => $reqs) {
|
||||
$html .= "<tr valign='top' >\n";
|
||||
$html .= "<td style='text-align:left;padding:5px;'>$pos</td>";
|
||||
$html .= "<td style='text-align:left;padding:5px;'>";
|
||||
foreach($reqs as $r) {
|
||||
$html .= "$r<br/>";
|
||||
}
|
||||
$html .= "</td>";
|
||||
$html .= "</tr>";
|
||||
}
|
||||
$html .= "</table>";
|
||||
return $html;
|
||||
}
|
||||
public function trend_analysis()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["order_id"];
|
||||
$image = "";
|
||||
$note = "";
|
||||
try {
|
||||
$sql = "select fn_process_re_trendanalysis(?) ta";
|
||||
$qry = $this->db_one->query($sql,array($id));
|
||||
if ($qry) {
|
||||
$row = $qry->row();
|
||||
$j_tmp = json_decode($row->ta);
|
||||
if ($j_tmp->image != "") {
|
||||
$image = $j_tmp->image . "&ts=" . date("Ymdhnis");
|
||||
}
|
||||
$note = $j_tmp->note;
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
$req_note =$this->requirement($id);
|
||||
if ($req_note != "" ) {
|
||||
$note = $req_note;
|
||||
$image = "";
|
||||
}
|
||||
$data = ["image"=>$image,
|
||||
"note"=> $note,
|
||||
"title"=>"Trend Analisis"];
|
||||
$this->sys_ok($data);
|
||||
}
|
||||
|
||||
public function delta_check()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["order_id"];
|
||||
|
||||
$data = ["image"=>"https://www.sec.gov/files/trendChart-2018.jpg",
|
||||
"note"=>$this->requirement($id),
|
||||
"title"=>"Delta Check"];
|
||||
$this->sys_ok($data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
|
||||
if (sizeof($data) < 1)
|
||||
{
|
||||
$this->sys_error_db("RE Verification Confirmation", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailVerDeltaCheck', $v->delta)
|
||||
->set('T_OrderDetailVerTrendAnalysis', $v->trend)
|
||||
->set('T_OrderDetailVerification', $v->verification)
|
||||
->set('T_OrderDetailVerDate', $v->verification == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailVerUserID', $this->sys_user['M_UserID'])
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Verification')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', json_encode($data))
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Company extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Company API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from corporate
|
||||
where CorporateName like ?
|
||||
and CorporateIsActive = 'Y'
|
||||
limit 0,30";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
$result = array("data" => $rows );
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Helper extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Helper API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function calc_age()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "call sp_recount_age(?)";
|
||||
$query = $this->db_smartone->query($sql, array($orderID));
|
||||
|
||||
if ($query) {
|
||||
$sql = "select T_OrderHeaderM_PatientAge, M_PatientDOB
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
and T_OrderHeaderID = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($orderID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$rst = $rows;
|
||||
if (count($rows) > 0)
|
||||
$rst = $rows[0];
|
||||
$this->sys_ok($rst);
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function check_status_print()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "SELECT GROUP_CONCAT(T_TestName SEPARATOR ',') as testname, concat( '[', group_concat( json_object('T_TestID', T_TestID, 'T_TestName',T_TestName) separator ',' ), ']' ) testall
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'
|
||||
AND (T_OrderDetailResult IS NULL OR T_OrderDetailResult = '')";
|
||||
$query = $this->db_smartone->query($sql, array($orderID));
|
||||
|
||||
if ($query) {
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['testall'] = json_decode($v['testall']);
|
||||
}
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
$rst = array("total" => $tot_count,
|
||||
"records" => $rows);
|
||||
if (count($rows) > 0)
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function insertlogprint()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$tests = json_encode($prm['tests']);
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "INSERT INTO log_printresultpartial(
|
||||
Log_PrintResultPartialT_OrderHeaderID,
|
||||
Log_PrintResultPartialTests,
|
||||
Log_PrintResultPartialUserID)
|
||||
VALUES ('{$prm['orderid']}','{$tests}','{$userid}')";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_printresultpartial end| " .
|
||||
$this->db_smartone->error()["message"], "debug" => $this->db_smartone->last_query()]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
$arr_code = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) {
|
||||
continue;
|
||||
}
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] ;
|
||||
if (is_numeric($result) ) {
|
||||
$dec = strlen(substr(strrchr($result, "."), 1));
|
||||
$result = number_format($result,$dec,".",",");
|
||||
}
|
||||
$result .= " ". $r["T_OrderDetailResultFlag"];
|
||||
|
||||
$px_code = $r["T_TestSasCode"];
|
||||
if(! isset($arr_code[$px_code]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_code[$px_code] = true;
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
$px_code = "";
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function old_search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
class Re_mbv extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo "Api: Training Playground";
|
||||
}
|
||||
function get_note()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT Other_MBVNoteName as name,
|
||||
Other_MBVNoteDescription as description
|
||||
FROM other_mbvnote";
|
||||
$qry = $this->db->query($sql, []);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$raw = $qry->result_array();
|
||||
$result = array("records" => $raw);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_doctors()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 7 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
} else {
|
||||
$this->sys_error_db("Rerun rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function get_result_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$sql = "SELECT Other_MBVT_OrderDetailID as detail_id,
|
||||
Other_MBVID as id,
|
||||
Other_MBVSkorNugent as skor_nugent,
|
||||
Other_MBVBahan as bahan,
|
||||
Other_MBVM_DoctorID as doctor_id,
|
||||
Other_MBVDetailsSumLp as sum_lp,
|
||||
Other_MBVDetailsSkor as skor
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN other_mbv
|
||||
ON T_OrderDetailID = Other_MBVT_OrderDetailID
|
||||
AND Other_MBVIsActive = 'Y'
|
||||
JOIN other_mbvdetails
|
||||
ON Other_MBVID = Other_MBVDetailsOther_MBVID
|
||||
AND Other_MBVDetailsIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
AND T_OrderHeaderIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [$id]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$result = $qry->result_array();
|
||||
$this->sys_ok(array("records" => $result));
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveresult_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// print_r(json_encode($prm['detail']));
|
||||
// exit;
|
||||
$doctor = 0;
|
||||
if (isset($prm['doctor'])) {
|
||||
$doctor = $prm['doctor'];
|
||||
}
|
||||
|
||||
$bahan = 0;
|
||||
if (isset($prm['bahan'])) {
|
||||
$bahan = $prm['bahan'];
|
||||
}
|
||||
|
||||
$data = 0;
|
||||
if (isset($prm['detail'])) {
|
||||
$data = $prm['detail'];
|
||||
}
|
||||
// print_r(json_encode($data));
|
||||
// exit;
|
||||
$skor_nugent = 0;
|
||||
if (isset($prm['skor_nugent'])) {
|
||||
$skor_nugent = $prm['skor_nugent'];
|
||||
}
|
||||
// print_r(json_encode(array("dktr" => $doctor, "dt" => $data, "bhn" => $bahan, "skr" => $skor_nugent,)));
|
||||
// exit;
|
||||
if ($data == 0 || $doctor == 0) {
|
||||
$this->sys_error("result, doctor & bahan are mandatory");
|
||||
// print_r(json_encode(array("dktr" => $doctor == 0, "dt" => $data == 0, "bhn" => $bahan == 0, "skr" => $skor_nugent == 0,)));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
for ($i = 0; $i < count($data); $i++) {
|
||||
if ($data[$i]["xid"] == "0" && $data[$i]["orderdetail_id"] != "0") {
|
||||
//insert other_fna
|
||||
$sql = "INSERT INTO other_mbv
|
||||
(Other_MBVT_OrderDetailID,
|
||||
Other_MBVSkorNugent,
|
||||
Other_MBVBahan,
|
||||
Other_MBVM_DoctorID,
|
||||
Other_MBVUserID,
|
||||
Other_MBVCreated)
|
||||
VALUES(?,?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["orderdetail_id"], $skor_nugent, $bahan,
|
||||
$doctor["id"], 3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$inserted_id = $this->db->insert_id();
|
||||
$sql = "INSERT INTO other_mbvdetails(
|
||||
Other_MBVDetailsOther_MBVID,
|
||||
Other_MBVDetailsSumLp,
|
||||
Other_MBVDetailsSkor,
|
||||
Other_MBVDetailsUserID,
|
||||
Other_MBVDetailsCreated)
|
||||
VALUES(?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$inserted_id,
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql = "UPDATE other_mbv SET Other_MBVSkorNugent =? ,
|
||||
Other_MBVBahan = ?,
|
||||
Other_MBVM_DoctorID = ?
|
||||
WHERE Other_MBVID = ? AND Other_MBVIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$skor_nugent,
|
||||
$bahan,
|
||||
intval($doctor["id"]),
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE other_mbvdetails SET Other_MBVDetailsSumLp = ?,
|
||||
Other_MBVDetailsSkor = ?
|
||||
WHERE Other_MBVDetailsOther_MBVID = ? AND Other_MBVDetailsIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("success");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class Re_normal extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$od_id = $prm["order_detail_id"];
|
||||
$sql = "call sp_re_update_normal(?)";
|
||||
$this->db_smartone->query($sql, array($od_id));
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNormalValueNote,
|
||||
Nat_MethodeName
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_methode on T_OrderDetailNat_MethodeID = Nat_MethodeID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
$qry = $this->db_smartone->query($sql_norm,array($od_id));
|
||||
if ( $qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) {
|
||||
$result = array("status"=>"OK","records" => $rows[0]);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
|
||||
// start fitri update unit
|
||||
$sql = "select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN nat_normalvalue ON Nat_NormalValueID = T_OrderDetailNat_NormalValueID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_NormalValueNat_UnitID
|
||||
where T_OrderDetailID = ?";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$unit_id = $rows[0]["Nat_UnitID"];
|
||||
$unit_name = $rows[0]["Nat_UnitName"];
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
|
||||
}else{
|
||||
$sqlunit = $this->db_smartone->query("select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN t_test ON T_TestID = T_OrderDetailT_TestID
|
||||
JOIN nat_test ON Nat_TestID = T_TestNat_TestID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_TestNat_UnitID
|
||||
where T_OrderDetailID = '{$prm["detail_id"]}'")->row();
|
||||
$unit_id = $sqlunit->Nat_UnitID;
|
||||
$unit_name = $sqlunit->Nat_UnitName;
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
}
|
||||
}
|
||||
// end fitri update unit
|
||||
|
||||
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,T_OrderDetailNat_UnitID,T_OrderDetailNat_UnitName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
$xdata["unit_id"] = $rows[0]["T_OrderDetailNat_UnitID"];
|
||||
$xdata["unit_name"] = $rows[0]["T_OrderDetailNat_UnitName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,563 @@
|
||||
<?php
|
||||
|
||||
class Re_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
var $url_download;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["start_date"] . '%';
|
||||
$edate = $prm["end_date"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id'])) $group_id = $prm['group_id'];
|
||||
|
||||
$company_id = 0;
|
||||
$q_company = "";
|
||||
if (isset($prm['company_id'])) {
|
||||
$company_id = $prm['company_id'];
|
||||
if ($company_id > 0 ) {
|
||||
$q_company = " and T_OrderHeaderCorporateID = $company_id ";
|
||||
}
|
||||
}
|
||||
$q_search = " and
|
||||
( M_PatientName LIKE ?
|
||||
or T_OrderHeaderLabNumber like ?
|
||||
)";
|
||||
if ($prm["search"] == "" ) $q_search = "";
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
$max_rst = 9999;
|
||||
$offset = 0;
|
||||
|
||||
$q_group = "";
|
||||
if ($group_id != 0 ) {
|
||||
$sql = "select T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = $group_id
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " and T_TestNat_TestID in ( $nat_test_ids ) ";
|
||||
}
|
||||
|
||||
//janji hasil hari ini T_OrderHeaderID
|
||||
/* $sql = "select T_OrderPromiseT_OrderHeaderID
|
||||
from t_orderpromise
|
||||
where T_OrderPromiseIsActive = 'Y' and date(T_OrderPromiseDateTime) = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate));
|
||||
$promise_ids = "0";
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderPromiseT_OrderHeaderID"];
|
||||
$promise_ids = join(",",$xids);
|
||||
}
|
||||
}
|
||||
*/
|
||||
$order_ids = 0;
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y' and date(T_OrderHeaderDate) BETWEEN ? AND ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate,$edate));
|
||||
$order_ids = $promise_ids;
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderHeaderID"];
|
||||
$order_ids = join(",",$xids);
|
||||
}else{
|
||||
$order_ids = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *,
|
||||
CONCAT('[', GROUP_CONCAT(DISTINCT CONCAT('\"', T_OrderHeaderDate, '\"') SEPARATOR ','), ']') order_promise
|
||||
FROM (
|
||||
select T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderDate,
|
||||
'' T_OrderHeaderLabNumberExt, T_OrderHeaderDiagnose,
|
||||
M_PatientID, M_PatientNoReg, fn_global_patient_name(M_PatientID) M_PatientName,
|
||||
M_PatientDOB, T_OrderHeaderM_PatientAge, M_PatientHP, M_PatientGender M_SexName, '' M_PatientNote,
|
||||
da.M_DoctorID doctor_pj_id, fn_get_doctor_fullname(da.M_DoctorID) doctor_pj_name,
|
||||
0 doctor_sender_id, '' doctor_sender_name,
|
||||
'' M_MouID, '' M_MouName, CorporateID, CorporateName,
|
||||
T_OrderHeaderFoNote, T_OrderHeaderSamplingNote, T_OrderHeaderResultNote,
|
||||
la.M_LangID M_LangID, la.M_LangCode M_LangCode, la.M_LangName M_LangName, '' T_OrderHeaderLangIsSI,
|
||||
la.M_LangID SecondM_LangID, la.M_LangCode SecondM_LangCode, la.M_LangName SecondM_LangName,
|
||||
'' T_OrderHeaderAddOnSecondLangIsSI,
|
||||
'N' T_OrderHeaderIsCito, '' as delivery,
|
||||
'' T_OrderPromiseDateTime, '' is_history,
|
||||
'N' T_OrderHeaderAddOnVerificationDone,
|
||||
'N' T_OrderHeaderAddOnValidationDone, '' T_OrderHeaderAddOnRequestChangeDOB
|
||||
from t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_orderheaderlang ON T_OrderHeaderLangT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
{$q_group}
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
left join m_doctor da on T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN corporate on T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN m_lang la ON T_OrderHeaderLangM_LangID = la.M_LangID
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
{$q_company}
|
||||
{$q_search}
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
) x
|
||||
GROUP BY T_OrderHeaderID
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
";
|
||||
if ($q_search == "" ) {
|
||||
$query = $this->db_smartone->query($sql);
|
||||
} else {
|
||||
$query = $this->db_smartone->query($sql, [ $search, $search]);
|
||||
}
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$tmp_ohnumber = [];
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$lang = [["id"=>0, "code"=>"ID", "is_si"=>"N"]];
|
||||
if ($v['M_LangCode'] != "ID")
|
||||
$lang[] = ["id"=>$v['M_LangID'], "code"=>$v['M_LangCode'], "is_si"=>$v['T_OrderHeaderLangIsSI']];
|
||||
$sqltotal = "SELECT COUNT(T_OrderDetailID) as cnt_rst_a,
|
||||
SUM(IF(T_OrderDetailResult <> '' AND T_OrderDetailResult IS NOT NULL, 1, 0)) as cnt_rst_b,
|
||||
SUM(IF(T_OrderDetailVerification = 'Y', 1, 0)) as cnt_ver_n,
|
||||
SUM(IF(T_OrderDetailValidation = 'Y', 1, 0)) as cnt_val_n
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = {$v['T_OrderHeaderID']}
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'";
|
||||
$sqltotal = $this->db_smartone->query($sqltotal)->row();
|
||||
|
||||
if($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b < $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'P';
|
||||
}elseif($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b == $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'Y';
|
||||
}
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$rows[$k]['lang'] = $lang;
|
||||
$rows[$k]['delivery'] = JSON_DECODE($v['delivery']);
|
||||
$rows[$k]['order_promise'] = JSON_DECODE($v['order_promise']);
|
||||
|
||||
foreach($rows[$k]['order_promise'] as $l => $w)
|
||||
$rows[$k]['order_promise'][$l] = date('d-m-Y H:i', strtotime($w));
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from t_orderheader
|
||||
JOIN corporate ON CorporateID = T_OrderHeaderCorporateID AND CorporateIsActive = 'Y'
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
GROUP BY CorporateID";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$crows = $query->result_array();
|
||||
$crows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count,
|
||||
"total_page" => ceil($tot_count/$max_rst),
|
||||
"cur_page" => $page,
|
||||
"records" => $rows,
|
||||
"total_display" => sizeof($rows),
|
||||
"q" => $this->db_smartone->last_query(),
|
||||
"companies"=>$crows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function history()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_history(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$history = json_decode($row->rst);
|
||||
|
||||
$this->sys_ok($history);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("RESULT HISTORY", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_note()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderheader SET T_OrderHeaderResultNote = ?, T_OrderHeaderResultNoteM_UserID = ?
|
||||
WHERE T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['note'], $this->sys_user['M_UserID'], $prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$this->sys_ok($prm['order_id']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT NOTE", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function info_req()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_reqs(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$s_data = $row->data;
|
||||
$s_data = str_replace("\n"," ",$s_data);
|
||||
$this->sys_ok(json_decode($s_data));
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT REQ", $this->db_smartone);
|
||||
}
|
||||
|
||||
function downloadLocal()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$nat_tests = [];
|
||||
$test_refers = [];
|
||||
|
||||
|
||||
$sql = "SELECT t_orderdetail.*, T_TestNat_TestID as Nat_TestID
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsPrice = 'Y'
|
||||
JOIN nat_testrefer ON Nat_TestReferNat_TestID = T_TestNat_TestID
|
||||
WHERE
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$test_parents = $query->result_array();
|
||||
if (count($test_parents) > 0)
|
||||
{
|
||||
foreach ($test_parents as $test_parent){
|
||||
$sql = "SELECT t_orderdetail.*, T_TestNat_TestID as Nat_TestID
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
T_OrderDetailT_TestSasCode LIKE CONCAT(?,'%')";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'],$test_parent['T_OrderDetailT_TestSasCode']]);
|
||||
if ($query)
|
||||
{
|
||||
$tests = $query->result_array();
|
||||
foreach ($tests as $test)
|
||||
{
|
||||
$nat_tests[] = $test['Nat_TestID'];
|
||||
$test_refers[] = $test;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT t_orderdetail.*, T_TestNat_TestID as Nat_TestID
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsPrice = 'N'
|
||||
JOIN nat_testrefer ON Nat_TestReferNat_TestID = T_TestNat_TestID
|
||||
WHERE
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
$test_single = $query->result_array();
|
||||
foreach ($test_single as $test)
|
||||
{
|
||||
$sql = "SELECT t_orderdetail.*, T_TestNat_TestID as Nat_TestID
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
T_OrderDetailT_TestSasCode LIKE CONCAT(?, '%')";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'],$test['T_OrderDetailT_TestSasCode']]);
|
||||
if ($query)
|
||||
{
|
||||
$test_childs = $query->result_array();
|
||||
foreach ($test_childs as $test_child)
|
||||
{
|
||||
if (!in_array($test_child['Nat_TestID'], $nat_tests)){
|
||||
$test_insert[] = $test_child;
|
||||
$nat_tests[] = $test_child['Nat_TestID'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderDiagnose,
|
||||
T_OrderHeaderFoNote,
|
||||
m_patient.*,
|
||||
corporate.*,
|
||||
Mgm_McuNumber,
|
||||
Mgm_McuLabel,
|
||||
M_BranchIP,
|
||||
M_BranchID
|
||||
FROM t_orderheader
|
||||
JOIN m_branch ON T_OrderHeaderM_BranchID = M_BranchID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
|
||||
WHERE T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
//echo $this->db_smartone->last_query();
|
||||
if(!$query)
|
||||
{
|
||||
$this->sys_error_db("GET ORDER", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$order = $query->row_array();
|
||||
|
||||
$samples = [];
|
||||
$nat_tests_str = implode(",", $nat_tests);
|
||||
$sql = " SELECT t_ordersample.*
|
||||
FROM t_ordersample
|
||||
JOIN t_orderdetail ON T_OrderSampleT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestNat_TestID IN ({$nat_tests_str})
|
||||
WHERE
|
||||
T_OrderSampleT_OrderHeaderID = ? AND
|
||||
T_OrderSampleIsActive = 'Y' AND
|
||||
T_OrderSampleReceive = 'Y'
|
||||
GROUP BY T_OrderSampleID";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
//echo $this->db_smartone->last_query();
|
||||
if ($query)
|
||||
{
|
||||
$samples = $query->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_orderpromises WHERE T_OrderPromisesT_OrderHeaderID = ? AND T_OrderPromisesIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$order['T_OrderHeaderID']]);
|
||||
if(!$query)
|
||||
{
|
||||
$this->sys_error_db("GET ORDER PROMISES", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$order_promises = $query->result_array();
|
||||
if(count($order_promises) == 0){
|
||||
$order_promises = [];
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_orderdetail_promise WHERE T_OrderDetailPromiseT_OrderHeaderID = ? AND T_OrderDetailPromiseIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$order['T_OrderHeaderID']]);
|
||||
if(!$query)
|
||||
{
|
||||
$this->sys_error_db("GET ORDER DETAIL PROMISES", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$order_detail_promises = $query->result_array();
|
||||
if(count($order_detail_promises) == 0){
|
||||
$order_detail_promises = [];
|
||||
}
|
||||
|
||||
$result = [
|
||||
"order" => $order,
|
||||
"tests" => $test_refers,
|
||||
"samples" => $samples,
|
||||
"order_promises" => $order_promises,
|
||||
"order_detail_promises" => $order_detail_promises
|
||||
];
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function sendToLocal()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$order = $prm['order'];
|
||||
$tests = $prm['tests'];
|
||||
$sql = "SELECT *
|
||||
FROM t_orderheader
|
||||
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$query = $this->db_smartone->query($sql, [$order['T_OrderHeaderID']]);
|
||||
$order_corporate = $query->row_array();
|
||||
$prm['order']['CorporateName'] = $order_corporate['CorporateName'];
|
||||
$prm['order']['CorporateCode'] = $order_corporate['CorporateCode'];
|
||||
$prm['order']['CorporateID'] = $order_corporate['CorporateID'];
|
||||
$user_id = $this->sys_user['M_UserID']?$this->sys_user['M_UserID']:0;
|
||||
$log_id = -1;
|
||||
if ($order['M_BranchIP'] != '' && $order['M_BranchIP'] != null && count($tests) > 0)
|
||||
{
|
||||
$ip = $order['M_BranchIP'];
|
||||
$url = "{$ip}/one-api-lab/tools/local/r_download_local";
|
||||
$sql = "INSERT INTO cpone_log.log_local(
|
||||
Log_LocalT_OrderHeaderID,
|
||||
Log_LocalM_BranchID,
|
||||
Log_LocalUrl,
|
||||
Log_LocalData,
|
||||
Log_LocalCreated,
|
||||
Log_LocalCreatedUserID
|
||||
) VALUES (
|
||||
?, ?, ?, ?, NOW(), ?
|
||||
)";
|
||||
$query = $this->db_smartone->query($sql, [
|
||||
$order['T_OrderHeaderID'],
|
||||
$order['M_BranchID'],
|
||||
$url,
|
||||
json_encode($prm),
|
||||
$user_id
|
||||
]);
|
||||
if (!$query)
|
||||
{
|
||||
$this->sys_error_db("INSERT LOG LOCAL", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$log_id = $this->db_smartone->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error("Pastikan pemeriksaan sudah disetting di pengerjaan lokal dan pastikan IP lokal sudah di setting");
|
||||
exit;
|
||||
}
|
||||
|
||||
$md5 = md5(json_encode($prm));
|
||||
$z_param = gzdeflate(
|
||||
json_encode([
|
||||
"md5" => $md5,
|
||||
"data" => $prm,
|
||||
]),
|
||||
9
|
||||
);
|
||||
|
||||
$sql = "UPDATE cpone_log.log_local SET Log_LocalStatus = 'P' WHERE Log_LocalID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$log_id]);
|
||||
if (!$query)
|
||||
{
|
||||
$this->sys_error_db("UPDATE LOG LOCAL", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$response = $this->post($url, $z_param);
|
||||
$j_response = json_decode($response, true);
|
||||
$status = 'D';
|
||||
$message = $response;
|
||||
if (!$j_response) {
|
||||
$message = "Error Json : $response";
|
||||
$status = 'E';
|
||||
}
|
||||
if ($j_response["status"] == "ERR") {
|
||||
$message = $j_response["message"];
|
||||
$status = 'E';
|
||||
}
|
||||
$sql = "UPDATE cpone_log.log_local SET Log_LocalStatus = ?, Log_LocalResponse = ? WHERE Log_LocalID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$status, $message, $log_id]);
|
||||
if (!$query)
|
||||
{
|
||||
$this->sys_error_db("UPDATE LOG LOCAL", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
if ($status == 'D')
|
||||
{
|
||||
$this->sys_ok($j_response["result"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error($message);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
function get($url, $timeout = 60, $c_timeout = 5)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($ch);
|
||||
$err_msg = curl_error($ch);
|
||||
if ($err_msg != "") {
|
||||
return json_encode(["status" => "ERR", "message" => $err_msg]);
|
||||
}
|
||||
return gzinflate($result);
|
||||
}
|
||||
|
||||
function post($url, $data, $timeout = 180, $c_timeout = 5)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
$err_msg = curl_error($ch);
|
||||
if ($err_msg != "") {
|
||||
return json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $err_msg,
|
||||
"url" => $url,
|
||||
"data" => json_decode($data, true),
|
||||
]);
|
||||
}
|
||||
return gzinflate($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,710 @@
|
||||
<?php
|
||||
|
||||
class Re_px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Px API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 99;
|
||||
|
||||
$id = $prm["order_id"];
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$tot_count = 0;
|
||||
$lq = "";
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id']))
|
||||
$group_id = $prm['group_id'];
|
||||
|
||||
if ($group_id != 0)
|
||||
{
|
||||
$sql = "select distinct T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = {$group_id}";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " ( $nat_test_ids ) ";
|
||||
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime, fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_test tcheck on tcheck.T_TestNat_TestID in {$q_group}
|
||||
and ( tx.T_TestID = tcheck.T_TestID or tx.T_TestSasCode like concat(tcheck.T_TestSasCode,'%'))
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime , fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
// file_put_contents("/xtmp/re-query.sql",$lq);
|
||||
|
||||
if ($query) {
|
||||
$rst = [];
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v)
|
||||
{
|
||||
|
||||
if ($v['is_result'] == "Y" && $v['is_quantitative'] == "N")
|
||||
{
|
||||
$v['template'] = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$v['t_testid']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$v['template'] = $x->result_array();
|
||||
}
|
||||
|
||||
// IF Rujukan, by pas Pre Analytik
|
||||
if ($v['ref'] == 'Y')
|
||||
$v['pre_analytic'] = 'Y';
|
||||
|
||||
$rst[] = $v;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rst, "total_display" => sizeof($rows), "q" => $lq);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RE Px rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
if ( $v->resultInstrumentID > 0 ) {
|
||||
$sql_i = "select T_ResultInstrumentNat_NormalValueID normalValueID
|
||||
from t_resultinstrument
|
||||
where T_ResultInstrumentID = ?";
|
||||
$qry_i = $this->db_smartone->query($sql_i, array($v->resultInstrumentID));
|
||||
if ($qry_i) {
|
||||
$rows_i = $qry_i->result_array();
|
||||
|
||||
if (count($rows_i) > 0 ) {
|
||||
$sql_iu = "update t_orderdetail, nat_normalvalue
|
||||
set T_OrderDetailMinValue = Nat_NormalValueMinValue,
|
||||
T_OrderDetailMinValueInclusive = Nat_NormalValueMinValueInclusive,
|
||||
T_OrderDetailMaxValue = Nat_NormalValueMaxValue ,
|
||||
T_OrderDetailMaxValueInclusive = Nat_NormalValueMaxValueInclusive,
|
||||
T_OrderDetailNormalValueNote = Nat_NormalValueNote,
|
||||
T_OrderDetailNormalValueDescription = Nat_NormalValueDescription,
|
||||
T_OrderDetailNat_NormalValueID = Nat_NormalValueID
|
||||
where T_OrderDetailID = ? and Nat_NormalValueID = ?
|
||||
";
|
||||
$this->db_smartone->query($sql_iu, array($v->id, $rows_i[0]["normalValueID"]));
|
||||
//file_put_contents("/xtmp/update-nilai-normal", $this->db_smartone->last_query() . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
$y = $this->db_smartone->query("SELECT fn_process_sample_handling_perfect('{$v->order_id}', '{$v->test_id}') c")
|
||||
->row();
|
||||
$req_status = $y->c;
|
||||
$qry_norm = $this->db_smartone->query($sql_norm,$v->id);
|
||||
$result_flag = "";
|
||||
if ($qry_norm) {
|
||||
$rows_norm = $qry_norm->result_array();
|
||||
if (count($rows_norm) > 0 ) {
|
||||
$r = $rows_norm[0];
|
||||
if (is_numeric($v->result)) {
|
||||
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "Y" && $v->result < $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "N" && $v->result <= $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "Y" && $v->result > $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "N" && $v->result >= $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($lang == $this->lang_default_code)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailResult', $v->result)
|
||||
->set('T_OrderDetailResultFlag', $result_flag)
|
||||
->set('T_OrderDetailNote', $v->note)
|
||||
->set('T_OrderDetailReqStatus', $req_status)
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailLangResult', $v->result)
|
||||
->set('T_OrderDetailLangNote', $v->note)
|
||||
->where('T_OrderDetailLangID', $v->id)
|
||||
->update('t_orderdetaillang');
|
||||
}
|
||||
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Entry')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', json_encode($data))
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
//auto calculation
|
||||
$this->load->library("Resultcalc");
|
||||
$rows = $this->resultcalc->auto($order->id);
|
||||
|
||||
try {
|
||||
foreach($ids as $id ) {
|
||||
$this->db_smartone->query("call sp_set_normal_value_flag($id)");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
|
||||
public function save_template()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$n = $this->db_smartone->select("COUNT(T_ResultTemplateID) n")
|
||||
->where("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->where("T_ResultTemplateIsActive", "Y")
|
||||
->where("T_ResultTemplateValue", $prm['value'])
|
||||
->get('t_resulttemplate')
|
||||
->row();
|
||||
if ($n->n > 0)
|
||||
{
|
||||
$this->sys_error_db("Insert Result Template", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$r = $this->db_smartone->set("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->set("T_ResultTemplateValue", $prm['value'])
|
||||
->insert('t_resulttemplate');
|
||||
if ($r)
|
||||
{
|
||||
$template = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$prm['test_id']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$template = $x->result_array();
|
||||
|
||||
$this->sys_ok($template);
|
||||
}
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_lang(?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'], $prm['lang_id'], $prm['is_si'], $this->sys_user['M_UserID']]);
|
||||
if ($query)
|
||||
{
|
||||
$r = $query->row();
|
||||
if ($r->status == "OK")
|
||||
{
|
||||
$this->sys_ok($r->data);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Message : " . $r->message, $this->db_smartone);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Lang Result", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_group()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 100;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_WorklistID group_id, T_WorklistName group_name
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$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("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_rerun()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["detail_id"];
|
||||
|
||||
$sql = "CALL sp_process_result_rerun(?)";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdoctorsfna()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getfnaresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_FNADetailsID as xid,
|
||||
Other_FNAT_OrderDetailID as orderdetail_id,
|
||||
Other_FNADetailsCode as code,
|
||||
Other_FNADetailsLabel as label,
|
||||
Other_FNADetailsResult as result,
|
||||
IFNULL(Other_FNAM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_FNAM_DoctorID) OR Other_FNAM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_fna
|
||||
JOIN other_fnadetails ON Other_FNADetailsOther_FNAID = Other_FNAID AND Other_FNADetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_FNAM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_FNAT_OrderDetailID = {$id} AND Other_FNAIsActive = 'Y'
|
||||
GROUP BY Other_FNADetailsID
|
||||
ORDER BY Other_FNADetailsCode ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getpapsmearresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_PapSmearDetailsID as xid,
|
||||
Other_PapSmearID as header_id,
|
||||
Other_PapSmearT_OrderDetailID as orderdetail_id,
|
||||
Other_PapSmearDetailsCode as code,
|
||||
Other_PapSmearDetailsLabel as label,
|
||||
Other_PapSmearDetailsResult as result,
|
||||
IFNULL(Other_PapSmearM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_PapSmearM_DoctorID) OR Other_PapSmearM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_papsmear
|
||||
JOIN other_papsmeardetails ON Other_PapSmearDetailsOther_PapSmearID = Other_PapSmearID AND Other_PapSmearDetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_PapSmearM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_PapSmearT_OrderDetailID = {$id} AND Other_PapSmearIsActive = 'Y'
|
||||
GROUP BY Other_PapSmearDetailsID
|
||||
ORDER BY Other_PapSmearDetailsCode ASC";
|
||||
//echo $sql;
|
||||
$rows = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$rows){
|
||||
$rows = array(
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'A',
|
||||
'label' => 'Makroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'B',
|
||||
'label' => 'Mikroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'C',
|
||||
'label' => 'Kesimpulan',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$header_id = $rows[0]['header_id'];
|
||||
$sql = "SELECT Other_PapSmearMaturasiID as xid,
|
||||
Other_PapSmearMaturasiValue as value
|
||||
FROM other_papsmearmaturasi
|
||||
WHERE
|
||||
Other_PapSmearMaturasiOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearMaturasiIsActive = 'Y'
|
||||
";
|
||||
$maturasi = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$maturasi){
|
||||
$maturasi = array('xid'=>'0','value'=>'//');
|
||||
}
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearBahanID,0) as xid,
|
||||
M_PapSmearBahanID as bahan_id,
|
||||
M_PapSmearBahanName as name
|
||||
FROM m_papsmearbahan
|
||||
LEFT JOIN other_papsmearbahan ON Other_PapSmearBahanM_PapSmearBahanID = M_PapSmearBahanID AND
|
||||
Other_PapSmearBahanOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearBahanIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearBahanIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$bahans = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapsmearCategoryID,0) as xid,
|
||||
M_PapSmearCategoryID as category_id,
|
||||
M_PapSmearCategoryName as name
|
||||
FROM m_papsmearcategory
|
||||
LEFT JOIN other_papsmearcategory ON Other_PapsmearCategoryM_PapSmearCategoryID = M_PapSmearCategoryID AND
|
||||
Other_PapsmearCategoryOther_PapSmearID = {$header_id} AND
|
||||
Other_PapsmearCategoryIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCategoryIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$categories = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearCheckID,0) as xid,
|
||||
M_PapSmearCheckID as check_id,
|
||||
M_PapSmearCheckLabel as name,
|
||||
Other_PapSmearCheckNote as note
|
||||
FROM m_papsmearcheck
|
||||
LEFT JOIN other_papsmearcheck ON Other_PapSmearCheckM_PapSmearCheckID = M_PapSmearCheckID AND
|
||||
Other_PapSmearCheckOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearCheckIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCheckIsActive = 'Y'
|
||||
";
|
||||
$checks = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'checks'=>$checks,'bahans'=>$bahans,'categories'=>$categories,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
|
||||
}
|
||||
|
||||
function saveresult_fna()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
$prm = $inp['results'];
|
||||
$doctor_id = $inp['doctor'];
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$header_id = 0;
|
||||
if($prm[0]['xid'] == '0'){
|
||||
$sql = "INSERT INTO other_fna(
|
||||
Other_FNAM_DoctorID,
|
||||
Other_FNAT_OrderDetailID,
|
||||
Other_FNAUserID,
|
||||
Other_FNACreated
|
||||
)
|
||||
VALUES(
|
||||
{$doctor_id},
|
||||
{$prm[0]['orderdetail_id']},
|
||||
{$userid},
|
||||
NOW()
|
||||
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_smartone->query($sql);
|
||||
$header_id = $this->db_smartone->insert_id();
|
||||
}
|
||||
foreach($prm as $k => $v){
|
||||
if($v['xid'] == '0'){
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "INSERT INTO other_fnadetails(
|
||||
Other_FNADetailsOther_FNAID ,
|
||||
Other_FNADetailsCode,
|
||||
Other_FNADetailsLabel,
|
||||
Other_FNADetailsResult,
|
||||
Other_FNADetailsCreated,
|
||||
Other_FNADetailsUserID
|
||||
)
|
||||
VALUES(
|
||||
{$header_id},
|
||||
'{$v['code']}',
|
||||
'{$v['label']}',
|
||||
'{$results}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
else{
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "UPDATE other_fnadetails SET
|
||||
Other_FNADetailsResult = '{$results}',
|
||||
Other_FNADetailsUserID = {$userid}
|
||||
WHERE
|
||||
Other_FNADetailsID = {$v['xid']}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => array(), "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,621 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_validation extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Result Validation API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function mr_state()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["order_id"];
|
||||
|
||||
$data = [
|
||||
"image" => "http://blog.aylien.com/wp-content/uploads/2016/07/Screen-Shot-2016-07-21-at-18.46.42.png",
|
||||
"note" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
"title" => "Multi Rule"
|
||||
];
|
||||
$this->sys_ok($data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
|
||||
if (sizeof($data) < 1) {
|
||||
$this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
exit;
|
||||
} else {
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v) {
|
||||
$mr_state = "X";
|
||||
if (isset($v->mr_state[0])) $mr_state = $v->mr_state[0];
|
||||
$qry = $this->db_smartone->set('T_OrderDetailValMRState', $mr_state)
|
||||
->set('T_OrderDetailValidation', $v->validation)
|
||||
->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation1', $v->validation)
|
||||
->set('T_OrderDetailValidation1Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation2', $v->validation)
|
||||
->set('T_OrderDetailValidation2Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
if (!$qry) {
|
||||
print_r($this->db_smartone->error());
|
||||
}
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$sql_order = "SELECT
|
||||
T_OrderDetailT_OrderHeaderID
|
||||
FROM t_orderdetail
|
||||
WHERE T_OrderDetailID = ? and T_OrderDetailIsActive = 'Y'";
|
||||
$qry_order = $this->db_smartone->query($sql_order, [$data[0]->id]);
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($qry_order) {
|
||||
$row = $qry_order->row_array();
|
||||
} else {
|
||||
$this->sys_error_db("select orderheader", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select
|
||||
T_OrderHeaderID,T_OrderHeaderLabNumber,
|
||||
T_TestName, T_OrderDetailID, T_OrderDetailResult, T_OrderDetailNat_MethodeID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,
|
||||
T_OrderDetailMinValue, T_OrderDetailMaxValue, T_OrderDetailMinValueInclusive,
|
||||
T_OrderDetailMaxValueInclusive,
|
||||
Mcu_SummaryLabID,
|
||||
Mcu_SummaryLabValue,
|
||||
Mcu_SummaryLabNat_MethodeID,
|
||||
Mcu_SummaryLabWithMethode,
|
||||
Mcu_SummaryLabType,
|
||||
Mcu_SummaryLabIsNormalValue,
|
||||
Mcu_KelainanID, Mcu_KelainanName, Mcu_KelainanClasification,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
mcu_kelainangroup.*
|
||||
from t_orderdetail
|
||||
join t_orderheader on T_OrderHeaderID = ?
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
join t_test
|
||||
on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
join mcu_summarylab on T_TestNat_TestID = Mcu_SummaryLabNat_TestID AND Mcu_SummaryLabIsActive = 'Y'
|
||||
join mcu_kelainan on Mcu_SummaryLabMcu_KelainanID = Mcu_KelainanID
|
||||
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID";
|
||||
$qry = $this->db_smartone->query($sql, array($row["T_OrderDetailT_OrderHeaderID"]));
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get order | " . $this->db_smartone->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
$results = [];
|
||||
|
||||
$sql_upd = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabIsActive = 'N',
|
||||
T_KelainanLabCreatedUserID = {$this->sys_user['M_UserID']}
|
||||
WHERE T_KelainanLabT_OrderHeaderID = {$rows[0]['T_OrderHeaderID']}";
|
||||
$qry_upd = $this->db_smartone->query($sql_upd);
|
||||
if (!$qry_upd) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$result_value = $r['T_OrderDetailResult'];
|
||||
|
||||
$value_comparison = 0;
|
||||
//echo $r['Mcu_SummaryLabIsNormalValue'];
|
||||
$kelainan = [];
|
||||
$notavailable = [];
|
||||
if (trim($result_value) == 'NA') {
|
||||
$notavailable = $r;
|
||||
} elseif ($r['Mcu_SummaryLabIsNormalValue'] == 'Y') {
|
||||
if ($r['Mcu_SummaryLabType'] == '<' || $r['Mcu_SummaryLabType'] == '<=') {
|
||||
$value_comparison = $r['T_OrderDetailMinValue'];
|
||||
}
|
||||
if ($r['Mcu_SummaryLabType'] == '>' || $r['Mcu_SummaryLabType'] == '>=') {
|
||||
$value_comparison = $r['T_OrderDetailMaxValue'];
|
||||
}
|
||||
//echo "Y";
|
||||
if ($r['Mcu_SummaryLabWithMethode'] == 'N' && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
$value_comparison = $r['Mcu_SummaryLabValue'];
|
||||
if ($r['Mcu_SummaryLabType'] == '!=' || $r['Mcu_SummaryLabType'] == '==') {
|
||||
if ($this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
if (is_numeric($result_value) && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($results) > 0) {
|
||||
|
||||
foreach ($results as $v_result) {
|
||||
$sql_kel_lab = "SELECT *
|
||||
FROM t_kelainan_lab
|
||||
WHERE T_KelainanLabIsActive = 'Y'
|
||||
AND T_KelainanLabT_OrderDetailID = ?";
|
||||
$qry_kel_lab = $this->db_smartone->query($sql_kel_lab, array($v_result['orderdetailID']));
|
||||
if ($qry_kel_lab) {
|
||||
$rows_kel = $qry_kel_lab->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select kelainan lab", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows_kel) > 0) {
|
||||
|
||||
// print_r($v_result['orderdetailID']);
|
||||
// exit;
|
||||
|
||||
$sql_update_kel = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabT_OrderDetailID = ?,
|
||||
T_KelainanLabT_OrderHeaderID = ?,
|
||||
T_KelainanLabNat_TestID = ?,
|
||||
T_KelainanLabMcu_SummaryLabID = ?,
|
||||
T_KelainanLabCreatedUserID = ?,
|
||||
T_KelainanLabCreated = NOW()
|
||||
WHERE T_KelainanLabID = ?";
|
||||
$qry_update_kel = $this->db_smartone->query($sql_update_kel, array(
|
||||
$v_result['orderdetailID'],
|
||||
$v_result['orderheaderID'],
|
||||
$v_result['nat_testID'],
|
||||
$v_result['mcu_summarylabID'],
|
||||
$this->sys_user['M_UserID'],
|
||||
$rows_kel[0]['T_KelainanLabID']
|
||||
));
|
||||
if (!$qry_update_kel) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// print_r('insert');
|
||||
// exit;
|
||||
$sql_insert_lab = "INSERT INTO t_kelainan_lab(
|
||||
T_KelainanLabT_OrderDetailID,
|
||||
T_KelainanLabT_OrderHeaderID,
|
||||
T_KelainanLabNat_TestID,
|
||||
T_KelainanLabMcu_SummaryLabID,
|
||||
T_KelainanLabCreatedUserID,
|
||||
T_KelainanLabCreated) VALUES(
|
||||
{$v_result['orderdetailID']},
|
||||
{$v_result['orderheaderID']},
|
||||
{$v_result['nat_testID']},
|
||||
{$v_result['mcu_summarylabID']},
|
||||
{$this->sys_user['M_UserID']},
|
||||
NOW())";
|
||||
$qry_insert_lab = $this->db_smartone->query($sql_insert_lab);
|
||||
|
||||
if (!$qry_insert_lab) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error insert kelainan lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// END OF Log Process
|
||||
//update validation multi
|
||||
//$this->load->library("Txbranchstatus");
|
||||
// $this->txbranchstatus->update_multi("VALIDATION",$ids,$this->sys_user['M_StaffName']);
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
}
|
||||
|
||||
function dynamic_comparison($varleft, $op, $varright)
|
||||
{
|
||||
|
||||
switch ($op) {
|
||||
case "=":
|
||||
return $varleft == $varright;
|
||||
case "!=":
|
||||
return $varleft != $varright;
|
||||
case ">=":
|
||||
return $varleft >= $varright;
|
||||
case "<=":
|
||||
return $varleft <= $varright;
|
||||
case ">":
|
||||
return $varleft > $varright;
|
||||
case "<":
|
||||
return $varleft < $varright;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// public function validate()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $data = json_decode($prm["data"]);
|
||||
|
||||
// if (sizeof($data) < 1)
|
||||
// {
|
||||
// $this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
// exit;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $ids = [];
|
||||
// foreach ($data as $k => $v)
|
||||
// {
|
||||
// $this->db_smartone->set('T_OrderDetailValMRState', $v->mr_state)
|
||||
// ->set('T_OrderDetailValidation', $v->validation)
|
||||
// ->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
// ->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
// ->where('T_OrderDetailID', $v->id)
|
||||
// ->update('t_orderdetail');
|
||||
// $ids[] = $v->id;
|
||||
// }
|
||||
|
||||
// // LOG Process
|
||||
// $order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
// ->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
// ->where('T_OrderDetailID', $data[0]->id)
|
||||
// ->get('t_orderdetail')
|
||||
// ->row();
|
||||
|
||||
// $dblog = $this->load->database("onelog", true);
|
||||
// $dblog->set('Log_ProcessCode', 'PROCESS.Result.Validation')
|
||||
// ->set('Log_ProcessOrderID', $order->id)
|
||||
// ->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
// ->set('Log_ProcessJson', json_encode($data))
|
||||
// ->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
// ->insert('log_process');
|
||||
// // END OF Log Process
|
||||
|
||||
// $this->sys_ok($ids);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
function print_count()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->firstprint();
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = T_OrderDetailPrintCount + 1
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailValidation = 'Y'
|
||||
AND T_OrderDetailIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query) {
|
||||
$this->sys_ok($this->db_smartone->last_query());
|
||||
} else
|
||||
$this->sys_error_db("Print Count", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function reject()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_validation_reject(?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['id'], $prm['action']]);
|
||||
|
||||
if ($query) {
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
} else {
|
||||
$this->sys_error_db("REJECT VALIDATION", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
|
||||
public function unvalidate()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm["order_id"];
|
||||
|
||||
$this->db_smartone->set('T_OrderDetailValidation', "N")
|
||||
->set('T_OrderDetailValDate', null)
|
||||
->set('T_OrderDetailValUserID', 0)
|
||||
->set('T_OrderDetailValidation1', "N")
|
||||
->set('T_OrderDetailValidation1Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->set('T_OrderDetailValidation2', "N")
|
||||
->set('T_OrderDetailValidation2Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->where('T_OrderDetailIsActive', 'Y')
|
||||
->where('T_OrderDetailValidation', 'Y')
|
||||
->update('t_orderdetail');
|
||||
|
||||
$q = $this->db_smartone->last_query();
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
/* $dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Unvalidation')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', '{}')
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
*/
|
||||
$this->sys_ok($q);
|
||||
}
|
||||
|
||||
// Copas Fajri
|
||||
function firstprint()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm['T_OrderHeaderID'] = $prm['order_id'];
|
||||
$datarows = [];
|
||||
$query = " SELECT T_OrderDetailID,T_TestName
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName = 'lab'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDetailValidation = 'Y' AND
|
||||
T_OrderDetailPrintCount = 0 AND
|
||||
T_OrderDetailT_OrderPromiseID <> 0 AND
|
||||
( T_OrderDetailResult <> '' OR T_OrderDetailResult IS NOT NULL ) AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_OrderDetailID";
|
||||
//echo $query;
|
||||
$datarows = $this->db_smartone->query($query)->result_array();
|
||||
$ids = array();
|
||||
$testname = array();
|
||||
if ($datarows) {
|
||||
foreach ($datarows as $k => $v) {
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = 1 WHERE T_OrderDetailID = {$v['T_OrderDetailID']}";
|
||||
$this->db_smartone->query($sql);
|
||||
array_push($ids, $v['T_OrderDetailID']);
|
||||
array_push($testname, $v['T_TestName']);
|
||||
}
|
||||
}
|
||||
$join_ids = "[" . join(",", $ids) . "]";
|
||||
$join_testname = "[" . join(",", $testname) . "]";
|
||||
|
||||
$sql = "SELECT t_orderdelivery.*, M_DeliveryTypeCode as code
|
||||
FROM t_orderdelivery
|
||||
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
";
|
||||
//echo $sql;
|
||||
$result_delivery = $this->db_smartone->query($sql)->result_array();
|
||||
$arr_deliveryid = array();
|
||||
foreach ($result_delivery as $i => $j) {
|
||||
array_push($arr_deliveryid, $j["T_OrderDeliveryM_DeliveryID"]);
|
||||
}
|
||||
|
||||
foreach ($result_delivery as $k => $v) {
|
||||
|
||||
if ($v['code'] == 'PICKUP') {
|
||||
$sql = "INSERT INTO result_frontoffice(
|
||||
Result_FrontOfficeT_OrderHeaderID,
|
||||
Result_FrontOfficeIds,
|
||||
Result_FrontOfficeStatus,
|
||||
Result_FrontOfficeType,
|
||||
Result_FrontOfficeTestName,
|
||||
Result_FrontOfficeCreated,
|
||||
Result_FrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_FrontOfficeStatus = 'P',
|
||||
Result_FrontOfficeUserID = {$userid}
|
||||
";
|
||||
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_frontoffice
|
||||
WHERE Result_FrontOfficeT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_FrontOfficeIds = '{$join_ids}' AND
|
||||
Result_FrontOfficeType = 'lab'";
|
||||
$rst_log = $this->db_smartone->query($sql)->result_array();
|
||||
$dt_log = json_encode($rst_log);
|
||||
$sql = "INSERT INTO one_log.log_result_front_office(
|
||||
Log_ResultFrontOfficeDateTime,
|
||||
Log_ResultFrontOfficeJson,
|
||||
Log_ResultFrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'EMAIL') {
|
||||
$type = "MANUAL";
|
||||
if (in_array(1, $arr_deliveryid) && (in_array(3, $arr_deliveryid) || in_array(5, $arr_deliveryid) || in_array(11, $arr_deliveryid))) {
|
||||
$type = "FO";
|
||||
}
|
||||
$sql = "INSERT INTO result_sendemail(
|
||||
Result_SendEmailT_OrderHeaderID,
|
||||
Result_SendEmailActionBy,
|
||||
Result_SendEmailIds,
|
||||
Result_SendEmailT_OrderDeliveryID,
|
||||
Result_SendEmailStatus,
|
||||
Result_SendEmailType,
|
||||
Result_SendEmailT_TestName,
|
||||
Result_SendEmailCreated,
|
||||
Result_SendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$type}',
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendEmailStatus = 'P',
|
||||
Result_SendEmailUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendemail
|
||||
WHERE
|
||||
Result_SendEmailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendEmailIds = '{$join_ids}' AND
|
||||
Result_SendEmailT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendEmailType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendemail (
|
||||
Log_ResultSendEmailDatetime,
|
||||
Log_ResultSendEmailJson,
|
||||
Log_ResultSendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'ADDRESS') {
|
||||
$sql = "INSERT INTO result_sendcourier(
|
||||
Result_SendCourierT_OrderHeaderID,
|
||||
Result_SendCourierIds,
|
||||
Result_SendCourierT_OrderDeliveryID,
|
||||
Result_SendCourierStatus,
|
||||
Result_SendCourierType,
|
||||
Result_SendCourierT_TestName,
|
||||
Result_SendCourierCreated,
|
||||
Result_SendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendCourierStatus = 'P',
|
||||
Result_SendCourierUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendcourier
|
||||
WHERE
|
||||
Result_SendCourierT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendCourierIds = '{$join_ids}' AND
|
||||
Result_SendCourierT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendCourierType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendcourier (
|
||||
Log_ResultSendCourierDateTime,
|
||||
Log_ResultSendCourierJson,
|
||||
Log_ResultSendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
|
||||
//echo $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
// $result = array(
|
||||
// "total" => count($datarows) ,
|
||||
// "records" => $datarows,
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Company extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Company API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from corporate
|
||||
where CorporateName like ?
|
||||
and CorporateIsActive = 'Y'
|
||||
limit 0,30";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
$result = array("data" => $rows );
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Helper extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Helper API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function calc_age()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "call sp_recount_age(?)";
|
||||
$query = $this->db_smartone->query($sql, array($orderID));
|
||||
|
||||
if ($query) {
|
||||
$sql = "select T_OrderHeaderM_PatientAge, M_PatientDOB
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
and T_OrderHeaderID = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($orderID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$rst = $rows;
|
||||
if (count($rows) > 0)
|
||||
$rst = $rows[0];
|
||||
$this->sys_ok($rst);
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function check_status_print()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "SELECT GROUP_CONCAT(T_TestName SEPARATOR ',') as testname, concat( '[', group_concat( json_object('T_TestID', T_TestID, 'T_TestName',T_TestName) separator ',' ), ']' ) testall
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'
|
||||
AND (T_OrderDetailResult IS NULL OR T_OrderDetailResult = '')";
|
||||
$query = $this->db_smartone->query($sql, array($orderID));
|
||||
|
||||
if ($query) {
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['testall'] = json_decode($v['testall']);
|
||||
}
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
$rst = array("total" => $tot_count,
|
||||
"records" => $rows);
|
||||
if (count($rows) > 0)
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function insertlogprint()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$tests = json_encode($prm['tests']);
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "INSERT INTO log_printresultpartial(
|
||||
Log_PrintResultPartialT_OrderHeaderID,
|
||||
Log_PrintResultPartialTests,
|
||||
Log_PrintResultPartialUserID)
|
||||
VALUES ('{$prm['orderid']}','{$tests}','{$userid}')";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_printresultpartial end| " .
|
||||
$this->db_smartone->error()["message"], "debug" => $this->db_smartone->last_query()]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
$arr_code = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) {
|
||||
continue;
|
||||
}
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] ;
|
||||
if (is_numeric($result) ) {
|
||||
$dec = strlen(substr(strrchr($result, "."), 1));
|
||||
$result = number_format($result,$dec,".",",");
|
||||
}
|
||||
$result .= " ". $r["T_OrderDetailResultFlag"];
|
||||
|
||||
$px_code = $r["T_TestSasCode"];
|
||||
if(! isset($arr_code[$px_code]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_code[$px_code] = true;
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
$px_code = "";
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function old_search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
class Re_mbv extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo "Api: Training Playground";
|
||||
}
|
||||
function get_note()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT Other_MBVNoteName as name,
|
||||
Other_MBVNoteDescription as description
|
||||
FROM other_mbvnote";
|
||||
$qry = $this->db->query($sql, []);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$raw = $qry->result_array();
|
||||
$result = array("records" => $raw);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_doctors()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 7 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
} else {
|
||||
$this->sys_error_db("Rerun rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function get_result_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$sql = "SELECT Other_MBVT_OrderDetailID as detail_id,
|
||||
Other_MBVID as id,
|
||||
Other_MBVSkorNugent as skor_nugent,
|
||||
Other_MBVBahan as bahan,
|
||||
Other_MBVM_DoctorID as doctor_id,
|
||||
Other_MBVDetailsSumLp as sum_lp,
|
||||
Other_MBVDetailsSkor as skor
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN other_mbv
|
||||
ON T_OrderDetailID = Other_MBVT_OrderDetailID
|
||||
AND Other_MBVIsActive = 'Y'
|
||||
JOIN other_mbvdetails
|
||||
ON Other_MBVID = Other_MBVDetailsOther_MBVID
|
||||
AND Other_MBVDetailsIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
AND T_OrderHeaderIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [$id]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$result = $qry->result_array();
|
||||
$this->sys_ok(array("records" => $result));
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveresult_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// print_r(json_encode($prm['detail']));
|
||||
// exit;
|
||||
$doctor = 0;
|
||||
if (isset($prm['doctor'])) {
|
||||
$doctor = $prm['doctor'];
|
||||
}
|
||||
|
||||
$bahan = 0;
|
||||
if (isset($prm['bahan'])) {
|
||||
$bahan = $prm['bahan'];
|
||||
}
|
||||
|
||||
$data = 0;
|
||||
if (isset($prm['detail'])) {
|
||||
$data = $prm['detail'];
|
||||
}
|
||||
// print_r(json_encode($data));
|
||||
// exit;
|
||||
$skor_nugent = 0;
|
||||
if (isset($prm['skor_nugent'])) {
|
||||
$skor_nugent = $prm['skor_nugent'];
|
||||
}
|
||||
// print_r(json_encode(array("dktr" => $doctor, "dt" => $data, "bhn" => $bahan, "skr" => $skor_nugent,)));
|
||||
// exit;
|
||||
if ($data == 0 || $doctor == 0) {
|
||||
$this->sys_error("result, doctor & bahan are mandatory");
|
||||
// print_r(json_encode(array("dktr" => $doctor == 0, "dt" => $data == 0, "bhn" => $bahan == 0, "skr" => $skor_nugent == 0,)));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
for ($i = 0; $i < count($data); $i++) {
|
||||
if ($data[$i]["xid"] == "0" && $data[$i]["orderdetail_id"] != "0") {
|
||||
//insert other_fna
|
||||
$sql = "INSERT INTO other_mbv
|
||||
(Other_MBVT_OrderDetailID,
|
||||
Other_MBVSkorNugent,
|
||||
Other_MBVBahan,
|
||||
Other_MBVM_DoctorID,
|
||||
Other_MBVUserID,
|
||||
Other_MBVCreated)
|
||||
VALUES(?,?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["orderdetail_id"], $skor_nugent, $bahan,
|
||||
$doctor["id"], 3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$inserted_id = $this->db->insert_id();
|
||||
$sql = "INSERT INTO other_mbvdetails(
|
||||
Other_MBVDetailsOther_MBVID,
|
||||
Other_MBVDetailsSumLp,
|
||||
Other_MBVDetailsSkor,
|
||||
Other_MBVDetailsUserID,
|
||||
Other_MBVDetailsCreated)
|
||||
VALUES(?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$inserted_id,
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql = "UPDATE other_mbv SET Other_MBVSkorNugent =? ,
|
||||
Other_MBVBahan = ?,
|
||||
Other_MBVM_DoctorID = ?
|
||||
WHERE Other_MBVID = ? AND Other_MBVIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$skor_nugent,
|
||||
$bahan,
|
||||
intval($doctor["id"]),
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE other_mbvdetails SET Other_MBVDetailsSumLp = ?,
|
||||
Other_MBVDetailsSkor = ?
|
||||
WHERE Other_MBVDetailsOther_MBVID = ? AND Other_MBVDetailsIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("success");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class Re_normal extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$od_id = $prm["order_detail_id"];
|
||||
$sql = "call sp_re_update_normal(?)";
|
||||
$this->db_smartone->query($sql, array($od_id));
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNormalValueNote,
|
||||
Nat_MethodeName
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_methode on T_OrderDetailNat_MethodeID = Nat_MethodeID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
$qry = $this->db_smartone->query($sql_norm,array($od_id));
|
||||
if ( $qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) {
|
||||
$result = array("status"=>"OK","records" => $rows[0]);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
|
||||
// start fitri update unit
|
||||
$sql = "select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN nat_normalvalue ON Nat_NormalValueID = T_OrderDetailNat_NormalValueID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_NormalValueNat_UnitID
|
||||
where T_OrderDetailID = ?";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$unit_id = $rows[0]["Nat_UnitID"];
|
||||
$unit_name = $rows[0]["Nat_UnitName"];
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
|
||||
}else{
|
||||
$sqlunit = $this->db_smartone->query("select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN t_test ON T_TestID = T_OrderDetailT_TestID
|
||||
JOIN nat_test ON Nat_TestID = T_TestNat_TestID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_TestNat_UnitID
|
||||
where T_OrderDetailID = '{$prm["detail_id"]}'")->row();
|
||||
$unit_id = $sqlunit->Nat_UnitID;
|
||||
$unit_name = $sqlunit->Nat_UnitName;
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
}
|
||||
}
|
||||
// end fitri update unit
|
||||
|
||||
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,T_OrderDetailNat_UnitID,T_OrderDetailNat_UnitName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
$xdata["unit_id"] = $rows[0]["T_OrderDetailNat_UnitID"];
|
||||
$xdata["unit_name"] = $rows[0]["T_OrderDetailNat_UnitName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,563 @@
|
||||
<?php
|
||||
|
||||
class Re_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
var $url_download;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["start_date"] . '%';
|
||||
$edate = $prm["end_date"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id'])) $group_id = $prm['group_id'];
|
||||
|
||||
$company_id = 0;
|
||||
$q_company = "";
|
||||
if (isset($prm['company_id'])) {
|
||||
$company_id = $prm['company_id'];
|
||||
if ($company_id > 0 ) {
|
||||
$q_company = " and T_OrderHeaderCorporateID = $company_id ";
|
||||
}
|
||||
}
|
||||
$q_search = " and
|
||||
( M_PatientName LIKE ?
|
||||
or T_OrderHeaderLabNumber like ?
|
||||
)";
|
||||
if ($prm["search"] == "" ) $q_search = "";
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
$max_rst = 9999;
|
||||
$offset = 0;
|
||||
|
||||
$q_group = "";
|
||||
if ($group_id != 0 ) {
|
||||
$sql = "select T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = $group_id
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " and T_TestNat_TestID in ( $nat_test_ids ) ";
|
||||
}
|
||||
|
||||
//janji hasil hari ini T_OrderHeaderID
|
||||
/* $sql = "select T_OrderPromiseT_OrderHeaderID
|
||||
from t_orderpromise
|
||||
where T_OrderPromiseIsActive = 'Y' and date(T_OrderPromiseDateTime) = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate));
|
||||
$promise_ids = "0";
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderPromiseT_OrderHeaderID"];
|
||||
$promise_ids = join(",",$xids);
|
||||
}
|
||||
}
|
||||
*/
|
||||
$order_ids = 0;
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y' and date(T_OrderHeaderDate) BETWEEN ? AND ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate,$edate));
|
||||
$order_ids = $promise_ids;
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderHeaderID"];
|
||||
$order_ids = join(",",$xids);
|
||||
}else{
|
||||
$order_ids = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *,
|
||||
CONCAT('[', GROUP_CONCAT(DISTINCT CONCAT('\"', T_OrderHeaderDate, '\"') SEPARATOR ','), ']') order_promise
|
||||
FROM (
|
||||
select T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderDate,
|
||||
'' T_OrderHeaderLabNumberExt, T_OrderHeaderDiagnose,
|
||||
M_PatientID, M_PatientNoReg, fn_global_patient_name(M_PatientID) M_PatientName,
|
||||
M_PatientDOB, T_OrderHeaderM_PatientAge, M_PatientHP, M_PatientGender M_SexName, '' M_PatientNote,
|
||||
da.M_DoctorID doctor_pj_id, fn_get_doctor_fullname(da.M_DoctorID) doctor_pj_name,
|
||||
0 doctor_sender_id, '' doctor_sender_name,
|
||||
'' M_MouID, '' M_MouName, CorporateID, CorporateName,
|
||||
T_OrderHeaderFoNote, T_OrderHeaderSamplingNote, T_OrderHeaderResultNote,
|
||||
la.M_LangID M_LangID, la.M_LangCode M_LangCode, la.M_LangName M_LangName, '' T_OrderHeaderLangIsSI,
|
||||
la.M_LangID SecondM_LangID, la.M_LangCode SecondM_LangCode, la.M_LangName SecondM_LangName,
|
||||
'' T_OrderHeaderAddOnSecondLangIsSI,
|
||||
'N' T_OrderHeaderIsCito, '' as delivery,
|
||||
'' T_OrderPromiseDateTime, '' is_history,
|
||||
'N' T_OrderHeaderAddOnVerificationDone,
|
||||
'N' T_OrderHeaderAddOnValidationDone, '' T_OrderHeaderAddOnRequestChangeDOB
|
||||
from t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_orderheaderlang ON T_OrderHeaderLangT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
{$q_group}
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
left join m_doctor da on T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN corporate on T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN m_lang la ON T_OrderHeaderLangM_LangID = la.M_LangID
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
{$q_company}
|
||||
{$q_search}
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
) x
|
||||
GROUP BY T_OrderHeaderID
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
";
|
||||
if ($q_search == "" ) {
|
||||
$query = $this->db_smartone->query($sql);
|
||||
} else {
|
||||
$query = $this->db_smartone->query($sql, [ $search, $search]);
|
||||
}
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$tmp_ohnumber = [];
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$lang = [["id"=>0, "code"=>"ID", "is_si"=>"N"]];
|
||||
if ($v['M_LangCode'] != "ID")
|
||||
$lang[] = ["id"=>$v['M_LangID'], "code"=>$v['M_LangCode'], "is_si"=>$v['T_OrderHeaderLangIsSI']];
|
||||
$sqltotal = "SELECT COUNT(T_OrderDetailID) as cnt_rst_a,
|
||||
SUM(IF(T_OrderDetailResult <> '' AND T_OrderDetailResult IS NOT NULL, 1, 0)) as cnt_rst_b,
|
||||
SUM(IF(T_OrderDetailVerification = 'Y', 1, 0)) as cnt_ver_n,
|
||||
SUM(IF(T_OrderDetailValidation = 'Y', 1, 0)) as cnt_val_n
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = {$v['T_OrderHeaderID']}
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'";
|
||||
$sqltotal = $this->db_smartone->query($sqltotal)->row();
|
||||
|
||||
if($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b < $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'P';
|
||||
}elseif($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b == $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'Y';
|
||||
}
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$rows[$k]['lang'] = $lang;
|
||||
$rows[$k]['delivery'] = JSON_DECODE($v['delivery']);
|
||||
$rows[$k]['order_promise'] = JSON_DECODE($v['order_promise']);
|
||||
|
||||
foreach($rows[$k]['order_promise'] as $l => $w)
|
||||
$rows[$k]['order_promise'][$l] = date('d-m-Y H:i', strtotime($w));
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from t_orderheader
|
||||
JOIN corporate ON CorporateID = T_OrderHeaderCorporateID AND CorporateIsActive = 'Y'
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
GROUP BY CorporateID";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$crows = $query->result_array();
|
||||
$crows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count,
|
||||
"total_page" => ceil($tot_count/$max_rst),
|
||||
"cur_page" => $page,
|
||||
"records" => $rows,
|
||||
"total_display" => sizeof($rows),
|
||||
"q" => $this->db_smartone->last_query(),
|
||||
"companies"=>$crows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function history()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_history(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$history = json_decode($row->rst);
|
||||
|
||||
$this->sys_ok($history);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("RESULT HISTORY", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_note()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderheader SET T_OrderHeaderResultNote = ?, T_OrderHeaderResultNoteM_UserID = ?
|
||||
WHERE T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['note'], $this->sys_user['M_UserID'], $prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$this->sys_ok($prm['order_id']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT NOTE", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function info_req()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_reqs(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$s_data = $row->data;
|
||||
$s_data = str_replace("\n"," ",$s_data);
|
||||
$this->sys_ok(json_decode($s_data));
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT REQ", $this->db_smartone);
|
||||
}
|
||||
|
||||
function downloadLocal()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$nat_tests = [];
|
||||
$test_refers = [];
|
||||
|
||||
|
||||
$sql = "SELECT t_orderdetail.*, T_TestNat_TestID as Nat_TestID
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsPrice = 'Y'
|
||||
JOIN nat_testrefer ON Nat_TestReferNat_TestID = T_TestNat_TestID
|
||||
WHERE
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$test_parents = $query->result_array();
|
||||
if (count($test_parents) > 0)
|
||||
{
|
||||
foreach ($test_parents as $test_parent){
|
||||
$sql = "SELECT t_orderdetail.*, T_TestNat_TestID as Nat_TestID
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
T_OrderDetailT_TestSasCode LIKE CONCAT(?,'%')";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'],$test_parent['T_OrderDetailT_TestSasCode']]);
|
||||
if ($query)
|
||||
{
|
||||
$tests = $query->result_array();
|
||||
foreach ($tests as $test)
|
||||
{
|
||||
$nat_tests[] = $test['Nat_TestID'];
|
||||
$test_refers[] = $test;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT t_orderdetail.*, T_TestNat_TestID as Nat_TestID
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsPrice = 'N'
|
||||
JOIN nat_testrefer ON Nat_TestReferNat_TestID = T_TestNat_TestID
|
||||
WHERE
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
$test_single = $query->result_array();
|
||||
foreach ($test_single as $test)
|
||||
{
|
||||
$sql = "SELECT t_orderdetail.*, T_TestNat_TestID as Nat_TestID
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
T_OrderDetailT_TestSasCode LIKE CONCAT(?, '%')";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'],$test['T_OrderDetailT_TestSasCode']]);
|
||||
if ($query)
|
||||
{
|
||||
$test_childs = $query->result_array();
|
||||
foreach ($test_childs as $test_child)
|
||||
{
|
||||
if (!in_array($test_child['Nat_TestID'], $nat_tests)){
|
||||
$test_insert[] = $test_child;
|
||||
$nat_tests[] = $test_child['Nat_TestID'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderDiagnose,
|
||||
T_OrderHeaderFoNote,
|
||||
m_patient.*,
|
||||
corporate.*,
|
||||
Mgm_McuNumber,
|
||||
Mgm_McuLabel,
|
||||
M_BranchIP,
|
||||
M_BranchID
|
||||
FROM t_orderheader
|
||||
JOIN m_branch ON T_OrderHeaderM_BranchID = M_BranchID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
|
||||
WHERE T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
//echo $this->db_smartone->last_query();
|
||||
if(!$query)
|
||||
{
|
||||
$this->sys_error_db("GET ORDER", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$order = $query->row_array();
|
||||
|
||||
$samples = [];
|
||||
$nat_tests_str = implode(",", $nat_tests);
|
||||
$sql = " SELECT t_ordersample.*
|
||||
FROM t_ordersample
|
||||
JOIN t_orderdetail ON T_OrderSampleT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestNat_TestID IN ({$nat_tests_str})
|
||||
WHERE
|
||||
T_OrderSampleT_OrderHeaderID = ? AND
|
||||
T_OrderSampleIsActive = 'Y' AND
|
||||
T_OrderSampleReceive = 'Y'
|
||||
GROUP BY T_OrderSampleID";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
//echo $this->db_smartone->last_query();
|
||||
if ($query)
|
||||
{
|
||||
$samples = $query->result_array();
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_orderpromises WHERE T_OrderPromisesT_OrderHeaderID = ? AND T_OrderPromisesIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$order['T_OrderHeaderID']]);
|
||||
if(!$query)
|
||||
{
|
||||
$this->sys_error_db("GET ORDER PROMISES", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$order_promises = $query->result_array();
|
||||
if(count($order_promises) == 0){
|
||||
$order_promises = [];
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_orderdetail_promise WHERE T_OrderDetailPromiseT_OrderHeaderID = ? AND T_OrderDetailPromiseIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$order['T_OrderHeaderID']]);
|
||||
if(!$query)
|
||||
{
|
||||
$this->sys_error_db("GET ORDER DETAIL PROMISES", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$order_detail_promises = $query->result_array();
|
||||
if(count($order_detail_promises) == 0){
|
||||
$order_detail_promises = [];
|
||||
}
|
||||
|
||||
$result = [
|
||||
"order" => $order,
|
||||
"tests" => $test_refers,
|
||||
"samples" => $samples,
|
||||
"order_promises" => $order_promises,
|
||||
"order_detail_promises" => $order_detail_promises
|
||||
];
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function sendToLocal()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$order = $prm['order'];
|
||||
$tests = $prm['tests'];
|
||||
$sql = "SELECT *
|
||||
FROM t_orderheader
|
||||
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID
|
||||
WHERE T_OrderHeaderID = ?
|
||||
LIMIT 1";
|
||||
$query = $this->db_smartone->query($sql, [$order['T_OrderHeaderID']]);
|
||||
$order_corporate = $query->row_array();
|
||||
$prm['order']['CorporateName'] = $order_corporate['CorporateName'];
|
||||
$prm['order']['CorporateCode'] = $order_corporate['CorporateCode'];
|
||||
$prm['order']['CorporateID'] = $order_corporate['CorporateID'];
|
||||
$user_id = $this->sys_user['M_UserID']?$this->sys_user['M_UserID']:0;
|
||||
$log_id = -1;
|
||||
if ($order['M_BranchIP'] != '' && $order['M_BranchIP'] != null && count($tests) > 0)
|
||||
{
|
||||
$ip = $order['M_BranchIP'];
|
||||
$url = "{$ip}/one-api-lab/tools/local/r_download_local";
|
||||
$sql = "INSERT INTO cpone_log.log_local(
|
||||
Log_LocalT_OrderHeaderID,
|
||||
Log_LocalM_BranchID,
|
||||
Log_LocalUrl,
|
||||
Log_LocalData,
|
||||
Log_LocalCreated,
|
||||
Log_LocalCreatedUserID
|
||||
) VALUES (
|
||||
?, ?, ?, ?, NOW(), ?
|
||||
)";
|
||||
$query = $this->db_smartone->query($sql, [
|
||||
$order['T_OrderHeaderID'],
|
||||
$order['M_BranchID'],
|
||||
$url,
|
||||
json_encode($prm),
|
||||
$user_id
|
||||
]);
|
||||
if (!$query)
|
||||
{
|
||||
$this->sys_error_db("INSERT LOG LOCAL", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$log_id = $this->db_smartone->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error("Pastikan pemeriksaan sudah disetting di pengerjaan lokal dan pastikan IP lokal sudah di setting");
|
||||
exit;
|
||||
}
|
||||
|
||||
$md5 = md5(json_encode($prm));
|
||||
$z_param = gzdeflate(
|
||||
json_encode([
|
||||
"md5" => $md5,
|
||||
"data" => $prm,
|
||||
]),
|
||||
9
|
||||
);
|
||||
|
||||
$sql = "UPDATE cpone_log.log_local SET Log_LocalStatus = 'P' WHERE Log_LocalID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$log_id]);
|
||||
if (!$query)
|
||||
{
|
||||
$this->sys_error_db("UPDATE LOG LOCAL", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$response = $this->post($url, $z_param);
|
||||
$j_response = json_decode($response, true);
|
||||
$status = 'D';
|
||||
$message = $response;
|
||||
if (!$j_response) {
|
||||
$message = "Error Json : $response";
|
||||
$status = 'E';
|
||||
}
|
||||
if ($j_response["status"] == "ERR") {
|
||||
$message = $j_response["message"];
|
||||
$status = 'E';
|
||||
}
|
||||
$sql = "UPDATE cpone_log.log_local SET Log_LocalStatus = ?, Log_LocalResponse = ? WHERE Log_LocalID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$status, $message, $log_id]);
|
||||
if (!$query)
|
||||
{
|
||||
$this->sys_error_db("UPDATE LOG LOCAL", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
if ($status == 'D')
|
||||
{
|
||||
$this->sys_ok($j_response["result"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error($message);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
function get($url, $timeout = 60, $c_timeout = 5)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($ch);
|
||||
$err_msg = curl_error($ch);
|
||||
if ($err_msg != "") {
|
||||
return json_encode(["status" => "ERR", "message" => $err_msg]);
|
||||
}
|
||||
return gzinflate($result);
|
||||
}
|
||||
|
||||
function post($url, $data, $timeout = 180, $c_timeout = 5)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
$err_msg = curl_error($ch);
|
||||
if ($err_msg != "") {
|
||||
return json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $err_msg,
|
||||
"url" => $url,
|
||||
"data" => json_decode($data, true),
|
||||
]);
|
||||
}
|
||||
return gzinflate($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,710 @@
|
||||
<?php
|
||||
|
||||
class Re_px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Px API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 99;
|
||||
|
||||
$id = $prm["order_id"];
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$tot_count = 0;
|
||||
$lq = "";
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id']))
|
||||
$group_id = $prm['group_id'];
|
||||
|
||||
if ($group_id != 0)
|
||||
{
|
||||
$sql = "select distinct T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = {$group_id}";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " ( $nat_test_ids ) ";
|
||||
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime, fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_test tcheck on tcheck.T_TestNat_TestID in {$q_group}
|
||||
and ( tx.T_TestID = tcheck.T_TestID or tx.T_TestSasCode like concat(tcheck.T_TestSasCode,'%'))
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime , fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
// file_put_contents("/xtmp/re-query.sql",$lq);
|
||||
|
||||
if ($query) {
|
||||
$rst = [];
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v)
|
||||
{
|
||||
|
||||
if ($v['is_result'] == "Y" && $v['is_quantitative'] == "N")
|
||||
{
|
||||
$v['template'] = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$v['t_testid']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$v['template'] = $x->result_array();
|
||||
}
|
||||
|
||||
// IF Rujukan, by pas Pre Analytik
|
||||
if ($v['ref'] == 'Y')
|
||||
$v['pre_analytic'] = 'Y';
|
||||
|
||||
$rst[] = $v;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rst, "total_display" => sizeof($rows), "q" => $lq);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RE Px rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
if ( $v->resultInstrumentID > 0 ) {
|
||||
$sql_i = "select T_ResultInstrumentNat_NormalValueID normalValueID
|
||||
from t_resultinstrument
|
||||
where T_ResultInstrumentID = ?";
|
||||
$qry_i = $this->db_smartone->query($sql_i, array($v->resultInstrumentID));
|
||||
if ($qry_i) {
|
||||
$rows_i = $qry_i->result_array();
|
||||
|
||||
if (count($rows_i) > 0 ) {
|
||||
$sql_iu = "update t_orderdetail, nat_normalvalue
|
||||
set T_OrderDetailMinValue = Nat_NormalValueMinValue,
|
||||
T_OrderDetailMinValueInclusive = Nat_NormalValueMinValueInclusive,
|
||||
T_OrderDetailMaxValue = Nat_NormalValueMaxValue ,
|
||||
T_OrderDetailMaxValueInclusive = Nat_NormalValueMaxValueInclusive,
|
||||
T_OrderDetailNormalValueNote = Nat_NormalValueNote,
|
||||
T_OrderDetailNormalValueDescription = Nat_NormalValueDescription,
|
||||
T_OrderDetailNat_NormalValueID = Nat_NormalValueID
|
||||
where T_OrderDetailID = ? and Nat_NormalValueID = ?
|
||||
";
|
||||
$this->db_smartone->query($sql_iu, array($v->id, $rows_i[0]["normalValueID"]));
|
||||
//file_put_contents("/xtmp/update-nilai-normal", $this->db_smartone->last_query() . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
$y = $this->db_smartone->query("SELECT fn_process_sample_handling_perfect('{$v->order_id}', '{$v->test_id}') c")
|
||||
->row();
|
||||
$req_status = $y->c;
|
||||
$qry_norm = $this->db_smartone->query($sql_norm,$v->id);
|
||||
$result_flag = "";
|
||||
if ($qry_norm) {
|
||||
$rows_norm = $qry_norm->result_array();
|
||||
if (count($rows_norm) > 0 ) {
|
||||
$r = $rows_norm[0];
|
||||
if (is_numeric($v->result)) {
|
||||
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "Y" && $v->result < $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "N" && $v->result <= $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "Y" && $v->result > $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "N" && $v->result >= $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($lang == $this->lang_default_code)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailResult', $v->result)
|
||||
->set('T_OrderDetailResultFlag', $result_flag)
|
||||
->set('T_OrderDetailNote', $v->note)
|
||||
->set('T_OrderDetailReqStatus', $req_status)
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailLangResult', $v->result)
|
||||
->set('T_OrderDetailLangNote', $v->note)
|
||||
->where('T_OrderDetailLangID', $v->id)
|
||||
->update('t_orderdetaillang');
|
||||
}
|
||||
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Entry')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', json_encode($data))
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
//auto calculation
|
||||
$this->load->library("Resultcalc");
|
||||
$rows = $this->resultcalc->auto($order->id);
|
||||
|
||||
try {
|
||||
foreach($ids as $id ) {
|
||||
$this->db_smartone->query("call sp_set_normal_value_flag($id)");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
|
||||
public function save_template()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$n = $this->db_smartone->select("COUNT(T_ResultTemplateID) n")
|
||||
->where("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->where("T_ResultTemplateIsActive", "Y")
|
||||
->where("T_ResultTemplateValue", $prm['value'])
|
||||
->get('t_resulttemplate')
|
||||
->row();
|
||||
if ($n->n > 0)
|
||||
{
|
||||
$this->sys_error_db("Insert Result Template", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$r = $this->db_smartone->set("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->set("T_ResultTemplateValue", $prm['value'])
|
||||
->insert('t_resulttemplate');
|
||||
if ($r)
|
||||
{
|
||||
$template = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$prm['test_id']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$template = $x->result_array();
|
||||
|
||||
$this->sys_ok($template);
|
||||
}
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_lang(?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'], $prm['lang_id'], $prm['is_si'], $this->sys_user['M_UserID']]);
|
||||
if ($query)
|
||||
{
|
||||
$r = $query->row();
|
||||
if ($r->status == "OK")
|
||||
{
|
||||
$this->sys_ok($r->data);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Message : " . $r->message, $this->db_smartone);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Lang Result", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_group()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 100;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_WorklistID group_id, T_WorklistName group_name
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$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("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_rerun()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["detail_id"];
|
||||
|
||||
$sql = "CALL sp_process_result_rerun(?)";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdoctorsfna()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getfnaresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_FNADetailsID as xid,
|
||||
Other_FNAT_OrderDetailID as orderdetail_id,
|
||||
Other_FNADetailsCode as code,
|
||||
Other_FNADetailsLabel as label,
|
||||
Other_FNADetailsResult as result,
|
||||
IFNULL(Other_FNAM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_FNAM_DoctorID) OR Other_FNAM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_fna
|
||||
JOIN other_fnadetails ON Other_FNADetailsOther_FNAID = Other_FNAID AND Other_FNADetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_FNAM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_FNAT_OrderDetailID = {$id} AND Other_FNAIsActive = 'Y'
|
||||
GROUP BY Other_FNADetailsID
|
||||
ORDER BY Other_FNADetailsCode ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getpapsmearresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_PapSmearDetailsID as xid,
|
||||
Other_PapSmearID as header_id,
|
||||
Other_PapSmearT_OrderDetailID as orderdetail_id,
|
||||
Other_PapSmearDetailsCode as code,
|
||||
Other_PapSmearDetailsLabel as label,
|
||||
Other_PapSmearDetailsResult as result,
|
||||
IFNULL(Other_PapSmearM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_PapSmearM_DoctorID) OR Other_PapSmearM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_papsmear
|
||||
JOIN other_papsmeardetails ON Other_PapSmearDetailsOther_PapSmearID = Other_PapSmearID AND Other_PapSmearDetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_PapSmearM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_PapSmearT_OrderDetailID = {$id} AND Other_PapSmearIsActive = 'Y'
|
||||
GROUP BY Other_PapSmearDetailsID
|
||||
ORDER BY Other_PapSmearDetailsCode ASC";
|
||||
//echo $sql;
|
||||
$rows = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$rows){
|
||||
$rows = array(
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'A',
|
||||
'label' => 'Makroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'B',
|
||||
'label' => 'Mikroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'C',
|
||||
'label' => 'Kesimpulan',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$header_id = $rows[0]['header_id'];
|
||||
$sql = "SELECT Other_PapSmearMaturasiID as xid,
|
||||
Other_PapSmearMaturasiValue as value
|
||||
FROM other_papsmearmaturasi
|
||||
WHERE
|
||||
Other_PapSmearMaturasiOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearMaturasiIsActive = 'Y'
|
||||
";
|
||||
$maturasi = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$maturasi){
|
||||
$maturasi = array('xid'=>'0','value'=>'//');
|
||||
}
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearBahanID,0) as xid,
|
||||
M_PapSmearBahanID as bahan_id,
|
||||
M_PapSmearBahanName as name
|
||||
FROM m_papsmearbahan
|
||||
LEFT JOIN other_papsmearbahan ON Other_PapSmearBahanM_PapSmearBahanID = M_PapSmearBahanID AND
|
||||
Other_PapSmearBahanOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearBahanIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearBahanIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$bahans = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapsmearCategoryID,0) as xid,
|
||||
M_PapSmearCategoryID as category_id,
|
||||
M_PapSmearCategoryName as name
|
||||
FROM m_papsmearcategory
|
||||
LEFT JOIN other_papsmearcategory ON Other_PapsmearCategoryM_PapSmearCategoryID = M_PapSmearCategoryID AND
|
||||
Other_PapsmearCategoryOther_PapSmearID = {$header_id} AND
|
||||
Other_PapsmearCategoryIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCategoryIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$categories = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearCheckID,0) as xid,
|
||||
M_PapSmearCheckID as check_id,
|
||||
M_PapSmearCheckLabel as name,
|
||||
Other_PapSmearCheckNote as note
|
||||
FROM m_papsmearcheck
|
||||
LEFT JOIN other_papsmearcheck ON Other_PapSmearCheckM_PapSmearCheckID = M_PapSmearCheckID AND
|
||||
Other_PapSmearCheckOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearCheckIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCheckIsActive = 'Y'
|
||||
";
|
||||
$checks = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'checks'=>$checks,'bahans'=>$bahans,'categories'=>$categories,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
|
||||
}
|
||||
|
||||
function saveresult_fna()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
$prm = $inp['results'];
|
||||
$doctor_id = $inp['doctor'];
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$header_id = 0;
|
||||
if($prm[0]['xid'] == '0'){
|
||||
$sql = "INSERT INTO other_fna(
|
||||
Other_FNAM_DoctorID,
|
||||
Other_FNAT_OrderDetailID,
|
||||
Other_FNAUserID,
|
||||
Other_FNACreated
|
||||
)
|
||||
VALUES(
|
||||
{$doctor_id},
|
||||
{$prm[0]['orderdetail_id']},
|
||||
{$userid},
|
||||
NOW()
|
||||
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_smartone->query($sql);
|
||||
$header_id = $this->db_smartone->insert_id();
|
||||
}
|
||||
foreach($prm as $k => $v){
|
||||
if($v['xid'] == '0'){
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "INSERT INTO other_fnadetails(
|
||||
Other_FNADetailsOther_FNAID ,
|
||||
Other_FNADetailsCode,
|
||||
Other_FNADetailsLabel,
|
||||
Other_FNADetailsResult,
|
||||
Other_FNADetailsCreated,
|
||||
Other_FNADetailsUserID
|
||||
)
|
||||
VALUES(
|
||||
{$header_id},
|
||||
'{$v['code']}',
|
||||
'{$v['label']}',
|
||||
'{$results}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
else{
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "UPDATE other_fnadetails SET
|
||||
Other_FNADetailsResult = '{$results}',
|
||||
Other_FNADetailsUserID = {$userid}
|
||||
WHERE
|
||||
Other_FNADetailsID = {$v['xid']}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => array(), "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,621 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_validation extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Result Validation API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function mr_state()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["order_id"];
|
||||
|
||||
$data = [
|
||||
"image" => "http://blog.aylien.com/wp-content/uploads/2016/07/Screen-Shot-2016-07-21-at-18.46.42.png",
|
||||
"note" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
"title" => "Multi Rule"
|
||||
];
|
||||
$this->sys_ok($data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
|
||||
if (sizeof($data) < 1) {
|
||||
$this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
exit;
|
||||
} else {
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v) {
|
||||
$mr_state = "X";
|
||||
if (isset($v->mr_state[0])) $mr_state = $v->mr_state[0];
|
||||
$qry = $this->db_smartone->set('T_OrderDetailValMRState', $mr_state)
|
||||
->set('T_OrderDetailValidation', $v->validation)
|
||||
->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation1', $v->validation)
|
||||
->set('T_OrderDetailValidation1Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation2', $v->validation)
|
||||
->set('T_OrderDetailValidation2Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
if (!$qry) {
|
||||
print_r($this->db_smartone->error());
|
||||
}
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$sql_order = "SELECT
|
||||
T_OrderDetailT_OrderHeaderID
|
||||
FROM t_orderdetail
|
||||
WHERE T_OrderDetailID = ? and T_OrderDetailIsActive = 'Y'";
|
||||
$qry_order = $this->db_smartone->query($sql_order, [$data[0]->id]);
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($qry_order) {
|
||||
$row = $qry_order->row_array();
|
||||
} else {
|
||||
$this->sys_error_db("select orderheader", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select
|
||||
T_OrderHeaderID,T_OrderHeaderLabNumber,
|
||||
T_TestName, T_OrderDetailID, T_OrderDetailResult, T_OrderDetailNat_MethodeID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,
|
||||
T_OrderDetailMinValue, T_OrderDetailMaxValue, T_OrderDetailMinValueInclusive,
|
||||
T_OrderDetailMaxValueInclusive,
|
||||
Mcu_SummaryLabID,
|
||||
Mcu_SummaryLabValue,
|
||||
Mcu_SummaryLabNat_MethodeID,
|
||||
Mcu_SummaryLabWithMethode,
|
||||
Mcu_SummaryLabType,
|
||||
Mcu_SummaryLabIsNormalValue,
|
||||
Mcu_KelainanID, Mcu_KelainanName, Mcu_KelainanClasification,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
mcu_kelainangroup.*
|
||||
from t_orderdetail
|
||||
join t_orderheader on T_OrderHeaderID = ?
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
join t_test
|
||||
on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
join mcu_summarylab on T_TestNat_TestID = Mcu_SummaryLabNat_TestID AND Mcu_SummaryLabIsActive = 'Y'
|
||||
join mcu_kelainan on Mcu_SummaryLabMcu_KelainanID = Mcu_KelainanID
|
||||
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID";
|
||||
$qry = $this->db_smartone->query($sql, array($row["T_OrderDetailT_OrderHeaderID"]));
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get order | " . $this->db_smartone->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
$results = [];
|
||||
|
||||
$sql_upd = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabIsActive = 'N',
|
||||
T_KelainanLabCreatedUserID = {$this->sys_user['M_UserID']}
|
||||
WHERE T_KelainanLabT_OrderHeaderID = {$rows[0]['T_OrderHeaderID']}";
|
||||
$qry_upd = $this->db_smartone->query($sql_upd);
|
||||
if (!$qry_upd) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$result_value = $r['T_OrderDetailResult'];
|
||||
|
||||
$value_comparison = 0;
|
||||
//echo $r['Mcu_SummaryLabIsNormalValue'];
|
||||
$kelainan = [];
|
||||
$notavailable = [];
|
||||
if (trim($result_value) == 'NA') {
|
||||
$notavailable = $r;
|
||||
} elseif ($r['Mcu_SummaryLabIsNormalValue'] == 'Y') {
|
||||
if ($r['Mcu_SummaryLabType'] == '<' || $r['Mcu_SummaryLabType'] == '<=') {
|
||||
$value_comparison = $r['T_OrderDetailMinValue'];
|
||||
}
|
||||
if ($r['Mcu_SummaryLabType'] == '>' || $r['Mcu_SummaryLabType'] == '>=') {
|
||||
$value_comparison = $r['T_OrderDetailMaxValue'];
|
||||
}
|
||||
//echo "Y";
|
||||
if ($r['Mcu_SummaryLabWithMethode'] == 'N' && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
$value_comparison = $r['Mcu_SummaryLabValue'];
|
||||
if ($r['Mcu_SummaryLabType'] == '!=' || $r['Mcu_SummaryLabType'] == '==') {
|
||||
if ($this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
if (is_numeric($result_value) && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($results) > 0) {
|
||||
|
||||
foreach ($results as $v_result) {
|
||||
$sql_kel_lab = "SELECT *
|
||||
FROM t_kelainan_lab
|
||||
WHERE T_KelainanLabIsActive = 'Y'
|
||||
AND T_KelainanLabT_OrderDetailID = ?";
|
||||
$qry_kel_lab = $this->db_smartone->query($sql_kel_lab, array($v_result['orderdetailID']));
|
||||
if ($qry_kel_lab) {
|
||||
$rows_kel = $qry_kel_lab->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select kelainan lab", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows_kel) > 0) {
|
||||
|
||||
// print_r($v_result['orderdetailID']);
|
||||
// exit;
|
||||
|
||||
$sql_update_kel = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabT_OrderDetailID = ?,
|
||||
T_KelainanLabT_OrderHeaderID = ?,
|
||||
T_KelainanLabNat_TestID = ?,
|
||||
T_KelainanLabMcu_SummaryLabID = ?,
|
||||
T_KelainanLabCreatedUserID = ?,
|
||||
T_KelainanLabCreated = NOW()
|
||||
WHERE T_KelainanLabID = ?";
|
||||
$qry_update_kel = $this->db_smartone->query($sql_update_kel, array(
|
||||
$v_result['orderdetailID'],
|
||||
$v_result['orderheaderID'],
|
||||
$v_result['nat_testID'],
|
||||
$v_result['mcu_summarylabID'],
|
||||
$this->sys_user['M_UserID'],
|
||||
$rows_kel[0]['T_KelainanLabID']
|
||||
));
|
||||
if (!$qry_update_kel) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// print_r('insert');
|
||||
// exit;
|
||||
$sql_insert_lab = "INSERT INTO t_kelainan_lab(
|
||||
T_KelainanLabT_OrderDetailID,
|
||||
T_KelainanLabT_OrderHeaderID,
|
||||
T_KelainanLabNat_TestID,
|
||||
T_KelainanLabMcu_SummaryLabID,
|
||||
T_KelainanLabCreatedUserID,
|
||||
T_KelainanLabCreated) VALUES(
|
||||
{$v_result['orderdetailID']},
|
||||
{$v_result['orderheaderID']},
|
||||
{$v_result['nat_testID']},
|
||||
{$v_result['mcu_summarylabID']},
|
||||
{$this->sys_user['M_UserID']},
|
||||
NOW())";
|
||||
$qry_insert_lab = $this->db_smartone->query($sql_insert_lab);
|
||||
|
||||
if (!$qry_insert_lab) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error insert kelainan lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// END OF Log Process
|
||||
//update validation multi
|
||||
//$this->load->library("Txbranchstatus");
|
||||
// $this->txbranchstatus->update_multi("VALIDATION",$ids,$this->sys_user['M_StaffName']);
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
}
|
||||
|
||||
function dynamic_comparison($varleft, $op, $varright)
|
||||
{
|
||||
|
||||
switch ($op) {
|
||||
case "=":
|
||||
return $varleft == $varright;
|
||||
case "!=":
|
||||
return $varleft != $varright;
|
||||
case ">=":
|
||||
return $varleft >= $varright;
|
||||
case "<=":
|
||||
return $varleft <= $varright;
|
||||
case ">":
|
||||
return $varleft > $varright;
|
||||
case "<":
|
||||
return $varleft < $varright;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// public function validate()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $data = json_decode($prm["data"]);
|
||||
|
||||
// if (sizeof($data) < 1)
|
||||
// {
|
||||
// $this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
// exit;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $ids = [];
|
||||
// foreach ($data as $k => $v)
|
||||
// {
|
||||
// $this->db_smartone->set('T_OrderDetailValMRState', $v->mr_state)
|
||||
// ->set('T_OrderDetailValidation', $v->validation)
|
||||
// ->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
// ->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
// ->where('T_OrderDetailID', $v->id)
|
||||
// ->update('t_orderdetail');
|
||||
// $ids[] = $v->id;
|
||||
// }
|
||||
|
||||
// // LOG Process
|
||||
// $order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
// ->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
// ->where('T_OrderDetailID', $data[0]->id)
|
||||
// ->get('t_orderdetail')
|
||||
// ->row();
|
||||
|
||||
// $dblog = $this->load->database("onelog", true);
|
||||
// $dblog->set('Log_ProcessCode', 'PROCESS.Result.Validation')
|
||||
// ->set('Log_ProcessOrderID', $order->id)
|
||||
// ->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
// ->set('Log_ProcessJson', json_encode($data))
|
||||
// ->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
// ->insert('log_process');
|
||||
// // END OF Log Process
|
||||
|
||||
// $this->sys_ok($ids);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
function print_count()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->firstprint();
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = T_OrderDetailPrintCount + 1
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailValidation = 'Y'
|
||||
AND T_OrderDetailIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query) {
|
||||
$this->sys_ok($this->db_smartone->last_query());
|
||||
} else
|
||||
$this->sys_error_db("Print Count", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function reject()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_validation_reject(?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['id'], $prm['action']]);
|
||||
|
||||
if ($query) {
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
} else {
|
||||
$this->sys_error_db("REJECT VALIDATION", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
|
||||
public function unvalidate()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm["order_id"];
|
||||
|
||||
$this->db_smartone->set('T_OrderDetailValidation', "N")
|
||||
->set('T_OrderDetailValDate', null)
|
||||
->set('T_OrderDetailValUserID', 0)
|
||||
->set('T_OrderDetailValidation1', "N")
|
||||
->set('T_OrderDetailValidation1Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->set('T_OrderDetailValidation2', "N")
|
||||
->set('T_OrderDetailValidation2Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->where('T_OrderDetailIsActive', 'Y')
|
||||
->where('T_OrderDetailValidation', 'Y')
|
||||
->update('t_orderdetail');
|
||||
|
||||
$q = $this->db_smartone->last_query();
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
/* $dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Unvalidation')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', '{}')
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
*/
|
||||
$this->sys_ok($q);
|
||||
}
|
||||
|
||||
// Copas Fajri
|
||||
function firstprint()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm['T_OrderHeaderID'] = $prm['order_id'];
|
||||
$datarows = [];
|
||||
$query = " SELECT T_OrderDetailID,T_TestName
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName = 'lab'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDetailValidation = 'Y' AND
|
||||
T_OrderDetailPrintCount = 0 AND
|
||||
T_OrderDetailT_OrderPromiseID <> 0 AND
|
||||
( T_OrderDetailResult <> '' OR T_OrderDetailResult IS NOT NULL ) AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_OrderDetailID";
|
||||
//echo $query;
|
||||
$datarows = $this->db_smartone->query($query)->result_array();
|
||||
$ids = array();
|
||||
$testname = array();
|
||||
if ($datarows) {
|
||||
foreach ($datarows as $k => $v) {
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = 1 WHERE T_OrderDetailID = {$v['T_OrderDetailID']}";
|
||||
$this->db_smartone->query($sql);
|
||||
array_push($ids, $v['T_OrderDetailID']);
|
||||
array_push($testname, $v['T_TestName']);
|
||||
}
|
||||
}
|
||||
$join_ids = "[" . join(",", $ids) . "]";
|
||||
$join_testname = "[" . join(",", $testname) . "]";
|
||||
|
||||
$sql = "SELECT t_orderdelivery.*, M_DeliveryTypeCode as code
|
||||
FROM t_orderdelivery
|
||||
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
";
|
||||
//echo $sql;
|
||||
$result_delivery = $this->db_smartone->query($sql)->result_array();
|
||||
$arr_deliveryid = array();
|
||||
foreach ($result_delivery as $i => $j) {
|
||||
array_push($arr_deliveryid, $j["T_OrderDeliveryM_DeliveryID"]);
|
||||
}
|
||||
|
||||
foreach ($result_delivery as $k => $v) {
|
||||
|
||||
if ($v['code'] == 'PICKUP') {
|
||||
$sql = "INSERT INTO result_frontoffice(
|
||||
Result_FrontOfficeT_OrderHeaderID,
|
||||
Result_FrontOfficeIds,
|
||||
Result_FrontOfficeStatus,
|
||||
Result_FrontOfficeType,
|
||||
Result_FrontOfficeTestName,
|
||||
Result_FrontOfficeCreated,
|
||||
Result_FrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_FrontOfficeStatus = 'P',
|
||||
Result_FrontOfficeUserID = {$userid}
|
||||
";
|
||||
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_frontoffice
|
||||
WHERE Result_FrontOfficeT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_FrontOfficeIds = '{$join_ids}' AND
|
||||
Result_FrontOfficeType = 'lab'";
|
||||
$rst_log = $this->db_smartone->query($sql)->result_array();
|
||||
$dt_log = json_encode($rst_log);
|
||||
$sql = "INSERT INTO one_log.log_result_front_office(
|
||||
Log_ResultFrontOfficeDateTime,
|
||||
Log_ResultFrontOfficeJson,
|
||||
Log_ResultFrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'EMAIL') {
|
||||
$type = "MANUAL";
|
||||
if (in_array(1, $arr_deliveryid) && (in_array(3, $arr_deliveryid) || in_array(5, $arr_deliveryid) || in_array(11, $arr_deliveryid))) {
|
||||
$type = "FO";
|
||||
}
|
||||
$sql = "INSERT INTO result_sendemail(
|
||||
Result_SendEmailT_OrderHeaderID,
|
||||
Result_SendEmailActionBy,
|
||||
Result_SendEmailIds,
|
||||
Result_SendEmailT_OrderDeliveryID,
|
||||
Result_SendEmailStatus,
|
||||
Result_SendEmailType,
|
||||
Result_SendEmailT_TestName,
|
||||
Result_SendEmailCreated,
|
||||
Result_SendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$type}',
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendEmailStatus = 'P',
|
||||
Result_SendEmailUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendemail
|
||||
WHERE
|
||||
Result_SendEmailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendEmailIds = '{$join_ids}' AND
|
||||
Result_SendEmailT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendEmailType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendemail (
|
||||
Log_ResultSendEmailDatetime,
|
||||
Log_ResultSendEmailJson,
|
||||
Log_ResultSendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'ADDRESS') {
|
||||
$sql = "INSERT INTO result_sendcourier(
|
||||
Result_SendCourierT_OrderHeaderID,
|
||||
Result_SendCourierIds,
|
||||
Result_SendCourierT_OrderDeliveryID,
|
||||
Result_SendCourierStatus,
|
||||
Result_SendCourierType,
|
||||
Result_SendCourierT_TestName,
|
||||
Result_SendCourierCreated,
|
||||
Result_SendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendCourierStatus = 'P',
|
||||
Result_SendCourierUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendcourier
|
||||
WHERE
|
||||
Result_SendCourierT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendCourierIds = '{$join_ids}' AND
|
||||
Result_SendCourierT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendCourierType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendcourier (
|
||||
Log_ResultSendCourierDateTime,
|
||||
Log_ResultSendCourierJson,
|
||||
Log_ResultSendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
|
||||
//echo $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
// $result = array(
|
||||
// "total" => count($datarows) ,
|
||||
// "records" => $datarows,
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Company extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Company API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from corporate
|
||||
where CorporateName like ?
|
||||
and CorporateIsActive = 'Y'
|
||||
limit 0,30";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
$result = array("data" => $rows );
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Helper extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Helper API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function calc_age()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "call sp_recount_age(?)";
|
||||
$query = $this->db_smartone->query($sql,array($orderID));
|
||||
|
||||
if ($query) {
|
||||
$sql = "select T_OrderHeaderM_PatientAge, M_PatientDOB
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
and T_OrderHeaderID = ?";
|
||||
$qry = $this->db_smartone->query($sql,array($orderID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$rst = $rows;
|
||||
if (count($rows) > 0 ) $rst = $rows[0];
|
||||
$this->sys_ok($rst);
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
$arr_code = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) {
|
||||
continue;
|
||||
}
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] ;
|
||||
if (is_numeric($result) ) {
|
||||
$dec = strlen(substr(strrchr($result, "."), 1));
|
||||
$result = number_format($result,$dec,".",",");
|
||||
}
|
||||
$result .= " ". $r["T_OrderDetailResultFlag"];
|
||||
|
||||
$px_code = $r["T_TestSasCode"];
|
||||
if(! isset($arr_code[$px_code]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_code[$px_code] = true;
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
$px_code = "";
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function old_search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
class Re_mbv extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo "Api: Training Playground";
|
||||
}
|
||||
function get_note()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT Other_MBVNoteName as name,
|
||||
Other_MBVNoteDescription as description
|
||||
FROM other_mbvnote";
|
||||
$qry = $this->db->query($sql, []);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$raw = $qry->result_array();
|
||||
$result = array("records" => $raw);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_doctors()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 7 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
} else {
|
||||
$this->sys_error_db("Rerun rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function get_result_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$sql = "SELECT Other_MBVT_OrderDetailID as detail_id,
|
||||
Other_MBVID as id,
|
||||
Other_MBVSkorNugent as skor_nugent,
|
||||
Other_MBVBahan as bahan,
|
||||
Other_MBVM_DoctorID as doctor_id,
|
||||
Other_MBVDetailsSumLp as sum_lp,
|
||||
Other_MBVDetailsSkor as skor
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN other_mbv
|
||||
ON T_OrderDetailID = Other_MBVT_OrderDetailID
|
||||
AND Other_MBVIsActive = 'Y'
|
||||
JOIN other_mbvdetails
|
||||
ON Other_MBVID = Other_MBVDetailsOther_MBVID
|
||||
AND Other_MBVDetailsIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
AND T_OrderHeaderIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [$id]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$result = $qry->result_array();
|
||||
$this->sys_ok(array("records" => $result));
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveresult_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// print_r(json_encode($prm['detail']));
|
||||
// exit;
|
||||
$doctor = 0;
|
||||
if (isset($prm['doctor'])) {
|
||||
$doctor = $prm['doctor'];
|
||||
}
|
||||
|
||||
$bahan = 0;
|
||||
if (isset($prm['bahan'])) {
|
||||
$bahan = $prm['bahan'];
|
||||
}
|
||||
|
||||
$data = 0;
|
||||
if (isset($prm['detail'])) {
|
||||
$data = $prm['detail'];
|
||||
}
|
||||
// print_r(json_encode($data));
|
||||
// exit;
|
||||
$skor_nugent = 0;
|
||||
if (isset($prm['skor_nugent'])) {
|
||||
$skor_nugent = $prm['skor_nugent'];
|
||||
}
|
||||
// print_r(json_encode(array("dktr" => $doctor, "dt" => $data, "bhn" => $bahan, "skr" => $skor_nugent,)));
|
||||
// exit;
|
||||
if ($data == 0 || $doctor == 0) {
|
||||
$this->sys_error("result, doctor & bahan are mandatory");
|
||||
// print_r(json_encode(array("dktr" => $doctor == 0, "dt" => $data == 0, "bhn" => $bahan == 0, "skr" => $skor_nugent == 0,)));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
for ($i = 0; $i < count($data); $i++) {
|
||||
if ($data[$i]["xid"] == "0" && $data[$i]["orderdetail_id"] != "0") {
|
||||
//insert other_fna
|
||||
$sql = "INSERT INTO other_mbv
|
||||
(Other_MBVT_OrderDetailID,
|
||||
Other_MBVSkorNugent,
|
||||
Other_MBVBahan,
|
||||
Other_MBVM_DoctorID,
|
||||
Other_MBVUserID,
|
||||
Other_MBVCreated)
|
||||
VALUES(?,?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["orderdetail_id"], $skor_nugent, $bahan,
|
||||
$doctor["id"], 3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$inserted_id = $this->db->insert_id();
|
||||
$sql = "INSERT INTO other_mbvdetails(
|
||||
Other_MBVDetailsOther_MBVID,
|
||||
Other_MBVDetailsSumLp,
|
||||
Other_MBVDetailsSkor,
|
||||
Other_MBVDetailsUserID,
|
||||
Other_MBVDetailsCreated)
|
||||
VALUES(?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$inserted_id,
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql = "UPDATE other_mbv SET Other_MBVSkorNugent =? ,
|
||||
Other_MBVBahan = ?,
|
||||
Other_MBVM_DoctorID = ?
|
||||
WHERE Other_MBVID = ? AND Other_MBVIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$skor_nugent,
|
||||
$bahan,
|
||||
intval($doctor["id"]),
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE other_mbvdetails SET Other_MBVDetailsSumLp = ?,
|
||||
Other_MBVDetailsSkor = ?
|
||||
WHERE Other_MBVDetailsOther_MBVID = ? AND Other_MBVDetailsIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("success");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class Re_normal extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$od_id = $prm["order_detail_id"];
|
||||
$sql = "call sp_re_update_normal(?)";
|
||||
$this->db_smartone->query($sql, array($od_id));
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNormalValueNote,
|
||||
Nat_MethodeName
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_methode on T_OrderDetailNat_MethodeID = Nat_MethodeID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
$qry = $this->db_smartone->query($sql_norm,array($od_id));
|
||||
if ( $qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) {
|
||||
$result = array("status"=>"OK","records" => $rows[0]);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
|
||||
// start fitri update unit
|
||||
$sql = "select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN nat_normalvalue ON Nat_NormalValueID = T_OrderDetailNat_NormalValueID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_NormalValueNat_UnitID
|
||||
where T_OrderDetailID = ?";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$unit_id = $rows[0]["Nat_UnitID"];
|
||||
$unit_name = $rows[0]["Nat_UnitName"];
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
|
||||
}else{
|
||||
$sqlunit = $this->db_smartone->query("select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN t_test ON T_TestID = T_OrderDetailT_TestID
|
||||
JOIN nat_test ON Nat_TestID = T_TestNat_TestID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_TestNat_UnitID
|
||||
where T_OrderDetailID = '{$prm["detail_id"]}'")->row();
|
||||
$unit_id = $sqlunit->Nat_UnitID;
|
||||
$unit_name = $sqlunit->Nat_UnitName;
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
}
|
||||
}
|
||||
// end fitri update unit
|
||||
|
||||
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,T_OrderDetailNat_UnitID,T_OrderDetailNat_UnitName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
$xdata["unit_id"] = $rows[0]["T_OrderDetailNat_UnitID"];
|
||||
$xdata["unit_name"] = $rows[0]["T_OrderDetailNat_UnitName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
class Re_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$filter_branch = '';
|
||||
$sql = "SELECT *
|
||||
FROM m_user
|
||||
WHERE
|
||||
M_UserID = {$userid}";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$data_user = $query->row_array();
|
||||
if(intval($data_user['M_UserLoginM_BranchID']) > 0){
|
||||
$filter_branch = " AND T_OrderHeaderM_BranchID = {$data_user['M_UserLoginM_BranchID']}";
|
||||
}
|
||||
|
||||
$sdate = $prm["start_date"] . '%';
|
||||
$edate = $prm["end_date"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id'])) $group_id = $prm['group_id'];
|
||||
|
||||
$company_id = 0;
|
||||
$q_company = "";
|
||||
if (isset($prm['company_id'])) {
|
||||
$company_id = $prm['company_id'];
|
||||
if ($company_id > 0 ) {
|
||||
$q_company = " and T_OrderHeaderCorporateID = $company_id ";
|
||||
}
|
||||
}
|
||||
$q_search = " and
|
||||
( M_PatientName LIKE ?
|
||||
or T_OrderHeaderLabNumber like ?
|
||||
)";
|
||||
if ($prm["search"] == "" ) $q_search = "";
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
$max_rst = 9999;
|
||||
$offset = 0;
|
||||
|
||||
$q_group = "";
|
||||
if ($group_id != 0 ) {
|
||||
$sql = "select T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = $group_id
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " and T_TestNat_TestID in ( $nat_test_ids ) ";
|
||||
}
|
||||
|
||||
//janji hasil hari ini T_OrderHeaderID
|
||||
/* $sql = "select T_OrderPromiseT_OrderHeaderID
|
||||
from t_orderpromise
|
||||
where T_OrderPromiseIsActive = 'Y' and date(T_OrderPromiseDateTime) = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate));
|
||||
$promise_ids = "0";
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderPromiseT_OrderHeaderID"];
|
||||
$promise_ids = join(",",$xids);
|
||||
}
|
||||
}
|
||||
*/
|
||||
$order_ids = 0;
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y' and date(T_OrderHeaderDate) BETWEEN ? AND ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate,$edate));
|
||||
$order_ids = $promise_ids;
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderHeaderID"];
|
||||
$order_ids = join(",",$xids);
|
||||
}else{
|
||||
$order_ids = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *,
|
||||
CONCAT('[', GROUP_CONCAT(DISTINCT CONCAT('\"', T_OrderHeaderDate, '\"') SEPARATOR ','), ']') order_promise
|
||||
FROM (
|
||||
select T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderDate,
|
||||
'' T_OrderHeaderLabNumberExt, T_OrderHeaderDiagnose,
|
||||
M_PatientID, M_PatientNoReg, fn_global_patient_name(M_PatientID) M_PatientName,
|
||||
M_PatientDOB, T_OrderHeaderM_PatientAge, M_PatientHP, M_PatientGender M_SexName, '' M_PatientNote,
|
||||
da.M_DoctorID doctor_pj_id, fn_get_doctor_fullname(da.M_DoctorID) doctor_pj_name,
|
||||
0 doctor_sender_id, '' doctor_sender_name,
|
||||
'' M_MouID, '' M_MouName, CorporateID, CorporateName,
|
||||
T_OrderHeaderFoNote, T_OrderHeaderSamplingNote, T_OrderHeaderResultNote,
|
||||
la.M_LangID M_LangID, la.M_LangCode M_LangCode, la.M_LangName M_LangName, '' T_OrderHeaderLangIsSI,
|
||||
la.M_LangID SecondM_LangID, la.M_LangCode SecondM_LangCode, la.M_LangName SecondM_LangName,
|
||||
'' T_OrderHeaderAddOnSecondLangIsSI,
|
||||
'N' T_OrderHeaderIsCito, '' as delivery,
|
||||
'' T_OrderPromiseDateTime, '' is_history,
|
||||
'N' T_OrderHeaderAddOnVerificationDone,
|
||||
'N' T_OrderHeaderAddOnValidationDone, '' T_OrderHeaderAddOnRequestChangeDOB
|
||||
from t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y' $filter_branch
|
||||
JOIN t_orderheaderlang ON T_OrderHeaderLangT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
{$q_group}
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
left join m_doctor da on T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN corporate on T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN m_lang la ON T_OrderHeaderLangM_LangID = la.M_LangID
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
{$q_company}
|
||||
{$q_search}
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
) x
|
||||
GROUP BY T_OrderHeaderID
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
";
|
||||
if ($q_search == "" ) {
|
||||
$query = $this->db_smartone->query($sql);
|
||||
} else {
|
||||
$query = $this->db_smartone->query($sql, [ $search, $search]);
|
||||
}
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$tmp_ohnumber = [];
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$lang = [["id"=>0, "code"=>"ID", "is_si"=>"N"]];
|
||||
if ($v['M_LangCode'] != "ID")
|
||||
$lang[] = ["id"=>$v['M_LangID'], "code"=>$v['M_LangCode'], "is_si"=>$v['T_OrderHeaderLangIsSI']];
|
||||
$sqltotal = "SELECT COUNT(T_OrderDetailID) as cnt_rst_a,
|
||||
SUM(IF(T_OrderDetailResult <> '' AND T_OrderDetailResult IS NOT NULL, 1, 0)) as cnt_rst_b,
|
||||
SUM(IF(T_OrderDetailVerification = 'Y', 1, 0)) as cnt_ver_n,
|
||||
SUM(IF(T_OrderDetailValidation = 'Y', 1, 0)) as cnt_val_n
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = {$v['T_OrderHeaderID']}
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'";
|
||||
$sqltotal = $this->db_smartone->query($sqltotal)->row();
|
||||
|
||||
if($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b < $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'P';
|
||||
}elseif($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b == $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'Y';
|
||||
}
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$rows[$k]['lang'] = $lang;
|
||||
$rows[$k]['delivery'] = JSON_DECODE($v['delivery']);
|
||||
$rows[$k]['order_promise'] = JSON_DECODE($v['order_promise']);
|
||||
|
||||
foreach($rows[$k]['order_promise'] as $l => $w)
|
||||
$rows[$k]['order_promise'][$l] = date('d-m-Y H:i', strtotime($w));
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from t_orderheader
|
||||
JOIN corporate ON CorporateID = T_OrderHeaderCorporateID AND CorporateIsActive = 'Y'
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
GROUP BY CorporateID";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$crows = $query->result_array();
|
||||
$crows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count,
|
||||
"total_page" => ceil($tot_count/$max_rst),
|
||||
"cur_page" => $page,
|
||||
"records" => $rows,
|
||||
"total_display" => sizeof($rows),
|
||||
"q" => $this->db_smartone->last_query(),
|
||||
"companies"=>$crows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function history()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_history(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$history = json_decode($row->rst);
|
||||
|
||||
$this->sys_ok($history);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("RESULT HISTORY", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_note()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderheader SET T_OrderHeaderResultNote = ?, T_OrderHeaderResultNoteM_UserID = ?
|
||||
WHERE T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['note'], $this->sys_user['M_UserID'], $prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$this->sys_ok($prm['order_id']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT NOTE", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function info_req()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_reqs(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$s_data = $row->data;
|
||||
$s_data = str_replace("\n"," ",$s_data);
|
||||
$this->sys_ok(json_decode($s_data));
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT REQ", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,710 @@
|
||||
<?php
|
||||
|
||||
class Re_px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Px API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 99;
|
||||
|
||||
$id = $prm["order_id"];
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$tot_count = 0;
|
||||
$lq = "";
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id']))
|
||||
$group_id = $prm['group_id'];
|
||||
|
||||
if ($group_id != 0)
|
||||
{
|
||||
$sql = "select distinct T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = {$group_id}";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " ( $nat_test_ids ) ";
|
||||
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime, fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_test tcheck on tcheck.T_TestNat_TestID in {$q_group}
|
||||
and ( tx.T_TestID = tcheck.T_TestID or tx.T_TestSasCode like concat(tcheck.T_TestSasCode,'%'))
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime , fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
// file_put_contents("/xtmp/re-query.sql",$lq);
|
||||
|
||||
if ($query) {
|
||||
$rst = [];
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v)
|
||||
{
|
||||
|
||||
if ($v['is_result'] == "Y" && $v['is_quantitative'] == "N")
|
||||
{
|
||||
$v['template'] = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$v['t_testid']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$v['template'] = $x->result_array();
|
||||
}
|
||||
|
||||
// IF Rujukan, by pas Pre Analytik
|
||||
if ($v['ref'] == 'Y')
|
||||
$v['pre_analytic'] = 'Y';
|
||||
|
||||
$rst[] = $v;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rst, "total_display" => sizeof($rows), "q" => $lq);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RE Px rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
if ( $v->resultInstrumentID > 0 ) {
|
||||
$sql_i = "select T_ResultInstrumentNat_NormalValueID normalValueID
|
||||
from t_resultinstrument
|
||||
where T_ResultInstrumentID = ?";
|
||||
$qry_i = $this->db_smartone->query($sql_i, array($v->resultInstrumentID));
|
||||
if ($qry_i) {
|
||||
$rows_i = $qry_i->result_array();
|
||||
|
||||
if (count($rows_i) > 0 ) {
|
||||
$sql_iu = "update t_orderdetail, nat_normalvalue
|
||||
set T_OrderDetailMinValue = Nat_NormalValueMinValue,
|
||||
T_OrderDetailMinValueInclusive = Nat_NormalValueMinValueInclusive,
|
||||
T_OrderDetailMaxValue = Nat_NormalValueMaxValue ,
|
||||
T_OrderDetailMaxValueInclusive = Nat_NormalValueMaxValueInclusive,
|
||||
T_OrderDetailNormalValueNote = Nat_NormalValueNote,
|
||||
T_OrderDetailNormalValueDescription = Nat_NormalValueDescription,
|
||||
T_OrderDetailNat_NormalValueID = Nat_NormalValueID
|
||||
where T_OrderDetailID = ? and Nat_NormalValueID = ?
|
||||
";
|
||||
$this->db_smartone->query($sql_iu, array($v->id, $rows_i[0]["normalValueID"]));
|
||||
//file_put_contents("/xtmp/update-nilai-normal", $this->db_smartone->last_query() . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
$y = $this->db_smartone->query("SELECT fn_process_sample_handling_perfect('{$v->order_id}', '{$v->test_id}') c")
|
||||
->row();
|
||||
$req_status = $y->c;
|
||||
$qry_norm = $this->db_smartone->query($sql_norm,$v->id);
|
||||
$result_flag = "";
|
||||
if ($qry_norm) {
|
||||
$rows_norm = $qry_norm->result_array();
|
||||
if (count($rows_norm) > 0 ) {
|
||||
$r = $rows_norm[0];
|
||||
if (is_numeric($v->result)) {
|
||||
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "Y" && $v->result < $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "N" && $v->result <= $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "Y" && $v->result > $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "N" && $v->result >= $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($lang == $this->lang_default_code)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailResult', $v->result)
|
||||
->set('T_OrderDetailResultFlag', $result_flag)
|
||||
->set('T_OrderDetailNote', $v->note)
|
||||
->set('T_OrderDetailReqStatus', $req_status)
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailLangResult', $v->result)
|
||||
->set('T_OrderDetailLangNote', $v->note)
|
||||
->where('T_OrderDetailLangID', $v->id)
|
||||
->update('t_orderdetaillang');
|
||||
}
|
||||
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Entry')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', json_encode($data))
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
//auto calculation
|
||||
$this->load->library("Resultcalc");
|
||||
$rows = $this->resultcalc->auto($order->id);
|
||||
|
||||
try {
|
||||
foreach($ids as $id ) {
|
||||
$this->db_smartone->query("call sp_set_normal_value_flag($id)");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
|
||||
public function save_template()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$n = $this->db_smartone->select("COUNT(T_ResultTemplateID) n")
|
||||
->where("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->where("T_ResultTemplateIsActive", "Y")
|
||||
->where("T_ResultTemplateValue", $prm['value'])
|
||||
->get('t_resulttemplate')
|
||||
->row();
|
||||
if ($n->n > 0)
|
||||
{
|
||||
$this->sys_error_db("Insert Result Template", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$r = $this->db_smartone->set("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->set("T_ResultTemplateValue", $prm['value'])
|
||||
->insert('t_resulttemplate');
|
||||
if ($r)
|
||||
{
|
||||
$template = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$prm['test_id']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$template = $x->result_array();
|
||||
|
||||
$this->sys_ok($template);
|
||||
}
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_lang(?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'], $prm['lang_id'], $prm['is_si'], $this->sys_user['M_UserID']]);
|
||||
if ($query)
|
||||
{
|
||||
$r = $query->row();
|
||||
if ($r->status == "OK")
|
||||
{
|
||||
$this->sys_ok($r->data);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Message : " . $r->message, $this->db_smartone);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Lang Result", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_group()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 100;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_WorklistID group_id, T_WorklistName group_name
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$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("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_rerun()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["detail_id"];
|
||||
|
||||
$sql = "CALL sp_process_result_rerun(?)";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdoctorsfna()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getfnaresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_FNADetailsID as xid,
|
||||
Other_FNAT_OrderDetailID as orderdetail_id,
|
||||
Other_FNADetailsCode as code,
|
||||
Other_FNADetailsLabel as label,
|
||||
Other_FNADetailsResult as result,
|
||||
IFNULL(Other_FNAM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_FNAM_DoctorID) OR Other_FNAM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_fna
|
||||
JOIN other_fnadetails ON Other_FNADetailsOther_FNAID = Other_FNAID AND Other_FNADetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_FNAM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_FNAT_OrderDetailID = {$id} AND Other_FNAIsActive = 'Y'
|
||||
GROUP BY Other_FNADetailsID
|
||||
ORDER BY Other_FNADetailsCode ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getpapsmearresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_PapSmearDetailsID as xid,
|
||||
Other_PapSmearID as header_id,
|
||||
Other_PapSmearT_OrderDetailID as orderdetail_id,
|
||||
Other_PapSmearDetailsCode as code,
|
||||
Other_PapSmearDetailsLabel as label,
|
||||
Other_PapSmearDetailsResult as result,
|
||||
IFNULL(Other_PapSmearM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_PapSmearM_DoctorID) OR Other_PapSmearM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_papsmear
|
||||
JOIN other_papsmeardetails ON Other_PapSmearDetailsOther_PapSmearID = Other_PapSmearID AND Other_PapSmearDetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_PapSmearM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_PapSmearT_OrderDetailID = {$id} AND Other_PapSmearIsActive = 'Y'
|
||||
GROUP BY Other_PapSmearDetailsID
|
||||
ORDER BY Other_PapSmearDetailsCode ASC";
|
||||
//echo $sql;
|
||||
$rows = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$rows){
|
||||
$rows = array(
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'A',
|
||||
'label' => 'Makroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'B',
|
||||
'label' => 'Mikroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'C',
|
||||
'label' => 'Kesimpulan',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$header_id = $rows[0]['header_id'];
|
||||
$sql = "SELECT Other_PapSmearMaturasiID as xid,
|
||||
Other_PapSmearMaturasiValue as value
|
||||
FROM other_papsmearmaturasi
|
||||
WHERE
|
||||
Other_PapSmearMaturasiOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearMaturasiIsActive = 'Y'
|
||||
";
|
||||
$maturasi = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$maturasi){
|
||||
$maturasi = array('xid'=>'0','value'=>'//');
|
||||
}
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearBahanID,0) as xid,
|
||||
M_PapSmearBahanID as bahan_id,
|
||||
M_PapSmearBahanName as name
|
||||
FROM m_papsmearbahan
|
||||
LEFT JOIN other_papsmearbahan ON Other_PapSmearBahanM_PapSmearBahanID = M_PapSmearBahanID AND
|
||||
Other_PapSmearBahanOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearBahanIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearBahanIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$bahans = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapsmearCategoryID,0) as xid,
|
||||
M_PapSmearCategoryID as category_id,
|
||||
M_PapSmearCategoryName as name
|
||||
FROM m_papsmearcategory
|
||||
LEFT JOIN other_papsmearcategory ON Other_PapsmearCategoryM_PapSmearCategoryID = M_PapSmearCategoryID AND
|
||||
Other_PapsmearCategoryOther_PapSmearID = {$header_id} AND
|
||||
Other_PapsmearCategoryIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCategoryIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$categories = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearCheckID,0) as xid,
|
||||
M_PapSmearCheckID as check_id,
|
||||
M_PapSmearCheckLabel as name,
|
||||
Other_PapSmearCheckNote as note
|
||||
FROM m_papsmearcheck
|
||||
LEFT JOIN other_papsmearcheck ON Other_PapSmearCheckM_PapSmearCheckID = M_PapSmearCheckID AND
|
||||
Other_PapSmearCheckOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearCheckIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCheckIsActive = 'Y'
|
||||
";
|
||||
$checks = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'checks'=>$checks,'bahans'=>$bahans,'categories'=>$categories,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
|
||||
}
|
||||
|
||||
function saveresult_fna()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
$prm = $inp['results'];
|
||||
$doctor_id = $inp['doctor'];
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$header_id = 0;
|
||||
if($prm[0]['xid'] == '0'){
|
||||
$sql = "INSERT INTO other_fna(
|
||||
Other_FNAM_DoctorID,
|
||||
Other_FNAT_OrderDetailID,
|
||||
Other_FNAUserID,
|
||||
Other_FNACreated
|
||||
)
|
||||
VALUES(
|
||||
{$doctor_id},
|
||||
{$prm[0]['orderdetail_id']},
|
||||
{$userid},
|
||||
NOW()
|
||||
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_smartone->query($sql);
|
||||
$header_id = $this->db_smartone->insert_id();
|
||||
}
|
||||
foreach($prm as $k => $v){
|
||||
if($v['xid'] == '0'){
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "INSERT INTO other_fnadetails(
|
||||
Other_FNADetailsOther_FNAID ,
|
||||
Other_FNADetailsCode,
|
||||
Other_FNADetailsLabel,
|
||||
Other_FNADetailsResult,
|
||||
Other_FNADetailsCreated,
|
||||
Other_FNADetailsUserID
|
||||
)
|
||||
VALUES(
|
||||
{$header_id},
|
||||
'{$v['code']}',
|
||||
'{$v['label']}',
|
||||
'{$results}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
else{
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "UPDATE other_fnadetails SET
|
||||
Other_FNADetailsResult = '{$results}',
|
||||
Other_FNADetailsUserID = {$userid}
|
||||
WHERE
|
||||
Other_FNADetailsID = {$v['xid']}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => array(), "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,621 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_validation extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Result Validation API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function mr_state()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["order_id"];
|
||||
|
||||
$data = [
|
||||
"image" => "http://blog.aylien.com/wp-content/uploads/2016/07/Screen-Shot-2016-07-21-at-18.46.42.png",
|
||||
"note" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
"title" => "Multi Rule"
|
||||
];
|
||||
$this->sys_ok($data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
|
||||
if (sizeof($data) < 1) {
|
||||
$this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
exit;
|
||||
} else {
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v) {
|
||||
$mr_state = "X";
|
||||
if (isset($v->mr_state[0])) $mr_state = $v->mr_state[0];
|
||||
$qry = $this->db_smartone->set('T_OrderDetailValMRState', $mr_state)
|
||||
->set('T_OrderDetailValidation', $v->validation)
|
||||
->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation1', $v->validation)
|
||||
->set('T_OrderDetailValidation1Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation2', $v->validation)
|
||||
->set('T_OrderDetailValidation2Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
if (!$qry) {
|
||||
print_r($this->db_smartone->error());
|
||||
}
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$sql_order = "SELECT
|
||||
T_OrderDetailT_OrderHeaderID
|
||||
FROM t_orderdetail
|
||||
WHERE T_OrderDetailID = ? and T_OrderDetailIsActive = 'Y'";
|
||||
$qry_order = $this->db_smartone->query($sql_order, [$data[0]->id]);
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($qry_order) {
|
||||
$row = $qry_order->row_array();
|
||||
} else {
|
||||
$this->sys_error_db("select orderheader", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select
|
||||
T_OrderHeaderID,T_OrderHeaderLabNumber,
|
||||
T_TestName, T_OrderDetailID, T_OrderDetailResult, T_OrderDetailNat_MethodeID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,
|
||||
T_OrderDetailMinValue, T_OrderDetailMaxValue, T_OrderDetailMinValueInclusive,
|
||||
T_OrderDetailMaxValueInclusive,
|
||||
Mcu_SummaryLabID,
|
||||
Mcu_SummaryLabValue,
|
||||
Mcu_SummaryLabNat_MethodeID,
|
||||
Mcu_SummaryLabWithMethode,
|
||||
Mcu_SummaryLabType,
|
||||
Mcu_SummaryLabIsNormalValue,
|
||||
Mcu_KelainanID, Mcu_KelainanName, Mcu_KelainanClasification,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
mcu_kelainangroup.*
|
||||
from t_orderdetail
|
||||
join t_orderheader on T_OrderHeaderID = ?
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
join t_test
|
||||
on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
join mcu_summarylab on T_TestNat_TestID = Mcu_SummaryLabNat_TestID AND Mcu_SummaryLabIsActive = 'Y'
|
||||
join mcu_kelainan on Mcu_SummaryLabMcu_KelainanID = Mcu_KelainanID
|
||||
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID";
|
||||
$qry = $this->db_smartone->query($sql, array($row["T_OrderDetailT_OrderHeaderID"]));
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get order | " . $this->db_smartone->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
$results = [];
|
||||
|
||||
$sql_upd = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabIsActive = 'N',
|
||||
T_KelainanLabCreatedUserID = {$this->sys_user['M_UserID']}
|
||||
WHERE T_KelainanLabT_OrderHeaderID = {$rows[0]['T_OrderHeaderID']}";
|
||||
$qry_upd = $this->db_smartone->query($sql_upd);
|
||||
if (!$qry_upd) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$result_value = $r['T_OrderDetailResult'];
|
||||
|
||||
$value_comparison = 0;
|
||||
//echo $r['Mcu_SummaryLabIsNormalValue'];
|
||||
$kelainan = [];
|
||||
$notavailable = [];
|
||||
if (trim($result_value) == 'NA') {
|
||||
$notavailable = $r;
|
||||
} elseif ($r['Mcu_SummaryLabIsNormalValue'] == 'Y') {
|
||||
if ($r['Mcu_SummaryLabType'] == '<' || $r['Mcu_SummaryLabType'] == '<=') {
|
||||
$value_comparison = $r['T_OrderDetailMinValue'];
|
||||
}
|
||||
if ($r['Mcu_SummaryLabType'] == '>' || $r['Mcu_SummaryLabType'] == '>=') {
|
||||
$value_comparison = $r['T_OrderDetailMaxValue'];
|
||||
}
|
||||
//echo "Y";
|
||||
if ($r['Mcu_SummaryLabWithMethode'] == 'N' && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
$value_comparison = $r['Mcu_SummaryLabValue'];
|
||||
if ($r['Mcu_SummaryLabType'] == '!=' || $r['Mcu_SummaryLabType'] == '==') {
|
||||
if ($this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
if (is_numeric($result_value) && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($results) > 0) {
|
||||
|
||||
foreach ($results as $v_result) {
|
||||
$sql_kel_lab = "SELECT *
|
||||
FROM t_kelainan_lab
|
||||
WHERE T_KelainanLabIsActive = 'Y'
|
||||
AND T_KelainanLabT_OrderDetailID = ?";
|
||||
$qry_kel_lab = $this->db_smartone->query($sql_kel_lab, array($v_result['orderdetailID']));
|
||||
if ($qry_kel_lab) {
|
||||
$rows_kel = $qry_kel_lab->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select kelainan lab", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows_kel) > 0) {
|
||||
|
||||
// print_r($v_result['orderdetailID']);
|
||||
// exit;
|
||||
|
||||
$sql_update_kel = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabT_OrderDetailID = ?,
|
||||
T_KelainanLabT_OrderHeaderID = ?,
|
||||
T_KelainanLabNat_TestID = ?,
|
||||
T_KelainanLabMcu_SummaryLabID = ?,
|
||||
T_KelainanLabCreatedUserID = ?,
|
||||
T_KelainanLabCreated = NOW()
|
||||
WHERE T_KelainanLabID = ?";
|
||||
$qry_update_kel = $this->db_smartone->query($sql_update_kel, array(
|
||||
$v_result['orderdetailID'],
|
||||
$v_result['orderheaderID'],
|
||||
$v_result['nat_testID'],
|
||||
$v_result['mcu_summarylabID'],
|
||||
$this->sys_user['M_UserID'],
|
||||
$rows_kel[0]['T_KelainanLabID']
|
||||
));
|
||||
if (!$qry_update_kel) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// print_r('insert');
|
||||
// exit;
|
||||
$sql_insert_lab = "INSERT INTO t_kelainan_lab(
|
||||
T_KelainanLabT_OrderDetailID,
|
||||
T_KelainanLabT_OrderHeaderID,
|
||||
T_KelainanLabNat_TestID,
|
||||
T_KelainanLabMcu_SummaryLabID,
|
||||
T_KelainanLabCreatedUserID,
|
||||
T_KelainanLabCreated) VALUES(
|
||||
{$v_result['orderdetailID']},
|
||||
{$v_result['orderheaderID']},
|
||||
{$v_result['nat_testID']},
|
||||
{$v_result['mcu_summarylabID']},
|
||||
{$this->sys_user['M_UserID']},
|
||||
NOW())";
|
||||
$qry_insert_lab = $this->db_smartone->query($sql_insert_lab);
|
||||
|
||||
if (!$qry_insert_lab) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error insert kelainan lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// END OF Log Process
|
||||
//update validation multi
|
||||
//$this->load->library("Txbranchstatus");
|
||||
// $this->txbranchstatus->update_multi("VALIDATION",$ids,$this->sys_user['M_StaffName']);
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
}
|
||||
|
||||
function dynamic_comparison($varleft, $op, $varright)
|
||||
{
|
||||
|
||||
switch ($op) {
|
||||
case "=":
|
||||
return $varleft == $varright;
|
||||
case "!=":
|
||||
return $varleft != $varright;
|
||||
case ">=":
|
||||
return $varleft >= $varright;
|
||||
case "<=":
|
||||
return $varleft <= $varright;
|
||||
case ">":
|
||||
return $varleft > $varright;
|
||||
case "<":
|
||||
return $varleft < $varright;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// public function validate()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $data = json_decode($prm["data"]);
|
||||
|
||||
// if (sizeof($data) < 1)
|
||||
// {
|
||||
// $this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
// exit;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $ids = [];
|
||||
// foreach ($data as $k => $v)
|
||||
// {
|
||||
// $this->db_smartone->set('T_OrderDetailValMRState', $v->mr_state)
|
||||
// ->set('T_OrderDetailValidation', $v->validation)
|
||||
// ->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
// ->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
// ->where('T_OrderDetailID', $v->id)
|
||||
// ->update('t_orderdetail');
|
||||
// $ids[] = $v->id;
|
||||
// }
|
||||
|
||||
// // LOG Process
|
||||
// $order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
// ->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
// ->where('T_OrderDetailID', $data[0]->id)
|
||||
// ->get('t_orderdetail')
|
||||
// ->row();
|
||||
|
||||
// $dblog = $this->load->database("onelog", true);
|
||||
// $dblog->set('Log_ProcessCode', 'PROCESS.Result.Validation')
|
||||
// ->set('Log_ProcessOrderID', $order->id)
|
||||
// ->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
// ->set('Log_ProcessJson', json_encode($data))
|
||||
// ->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
// ->insert('log_process');
|
||||
// // END OF Log Process
|
||||
|
||||
// $this->sys_ok($ids);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
function print_count()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->firstprint();
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = T_OrderDetailPrintCount + 1
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailValidation = 'Y'
|
||||
AND T_OrderDetailIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query) {
|
||||
$this->sys_ok($this->db_smartone->last_query());
|
||||
} else
|
||||
$this->sys_error_db("Print Count", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function reject()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_validation_reject(?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['id'], $prm['action']]);
|
||||
|
||||
if ($query) {
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
} else {
|
||||
$this->sys_error_db("REJECT VALIDATION", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
|
||||
public function unvalidate()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm["order_id"];
|
||||
|
||||
$this->db_smartone->set('T_OrderDetailValidation', "N")
|
||||
->set('T_OrderDetailValDate', null)
|
||||
->set('T_OrderDetailValUserID', 0)
|
||||
->set('T_OrderDetailValidation1', "N")
|
||||
->set('T_OrderDetailValidation1Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->set('T_OrderDetailValidation2', "N")
|
||||
->set('T_OrderDetailValidation2Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->where('T_OrderDetailIsActive', 'Y')
|
||||
->where('T_OrderDetailValidation', 'Y')
|
||||
->update('t_orderdetail');
|
||||
|
||||
$q = $this->db_smartone->last_query();
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
/* $dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Unvalidation')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', '{}')
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
*/
|
||||
$this->sys_ok($q);
|
||||
}
|
||||
|
||||
// Copas Fajri
|
||||
function firstprint()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm['T_OrderHeaderID'] = $prm['order_id'];
|
||||
$datarows = [];
|
||||
$query = " SELECT T_OrderDetailID,T_TestName
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName = 'lab'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDetailValidation = 'Y' AND
|
||||
T_OrderDetailPrintCount = 0 AND
|
||||
T_OrderDetailT_OrderPromiseID <> 0 AND
|
||||
( T_OrderDetailResult <> '' OR T_OrderDetailResult IS NOT NULL ) AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_OrderDetailID";
|
||||
//echo $query;
|
||||
$datarows = $this->db_smartone->query($query)->result_array();
|
||||
$ids = array();
|
||||
$testname = array();
|
||||
if ($datarows) {
|
||||
foreach ($datarows as $k => $v) {
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = 1 WHERE T_OrderDetailID = {$v['T_OrderDetailID']}";
|
||||
$this->db_smartone->query($sql);
|
||||
array_push($ids, $v['T_OrderDetailID']);
|
||||
array_push($testname, $v['T_TestName']);
|
||||
}
|
||||
}
|
||||
$join_ids = "[" . join(",", $ids) . "]";
|
||||
$join_testname = "[" . join(",", $testname) . "]";
|
||||
|
||||
$sql = "SELECT t_orderdelivery.*, M_DeliveryTypeCode as code
|
||||
FROM t_orderdelivery
|
||||
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
";
|
||||
//echo $sql;
|
||||
$result_delivery = $this->db_smartone->query($sql)->result_array();
|
||||
$arr_deliveryid = array();
|
||||
foreach ($result_delivery as $i => $j) {
|
||||
array_push($arr_deliveryid, $j["T_OrderDeliveryM_DeliveryID"]);
|
||||
}
|
||||
|
||||
foreach ($result_delivery as $k => $v) {
|
||||
|
||||
if ($v['code'] == 'PICKUP') {
|
||||
$sql = "INSERT INTO result_frontoffice(
|
||||
Result_FrontOfficeT_OrderHeaderID,
|
||||
Result_FrontOfficeIds,
|
||||
Result_FrontOfficeStatus,
|
||||
Result_FrontOfficeType,
|
||||
Result_FrontOfficeTestName,
|
||||
Result_FrontOfficeCreated,
|
||||
Result_FrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_FrontOfficeStatus = 'P',
|
||||
Result_FrontOfficeUserID = {$userid}
|
||||
";
|
||||
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_frontoffice
|
||||
WHERE Result_FrontOfficeT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_FrontOfficeIds = '{$join_ids}' AND
|
||||
Result_FrontOfficeType = 'lab'";
|
||||
$rst_log = $this->db_smartone->query($sql)->result_array();
|
||||
$dt_log = json_encode($rst_log);
|
||||
$sql = "INSERT INTO one_log.log_result_front_office(
|
||||
Log_ResultFrontOfficeDateTime,
|
||||
Log_ResultFrontOfficeJson,
|
||||
Log_ResultFrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'EMAIL') {
|
||||
$type = "MANUAL";
|
||||
if (in_array(1, $arr_deliveryid) && (in_array(3, $arr_deliveryid) || in_array(5, $arr_deliveryid) || in_array(11, $arr_deliveryid))) {
|
||||
$type = "FO";
|
||||
}
|
||||
$sql = "INSERT INTO result_sendemail(
|
||||
Result_SendEmailT_OrderHeaderID,
|
||||
Result_SendEmailActionBy,
|
||||
Result_SendEmailIds,
|
||||
Result_SendEmailT_OrderDeliveryID,
|
||||
Result_SendEmailStatus,
|
||||
Result_SendEmailType,
|
||||
Result_SendEmailT_TestName,
|
||||
Result_SendEmailCreated,
|
||||
Result_SendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$type}',
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendEmailStatus = 'P',
|
||||
Result_SendEmailUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendemail
|
||||
WHERE
|
||||
Result_SendEmailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendEmailIds = '{$join_ids}' AND
|
||||
Result_SendEmailT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendEmailType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendemail (
|
||||
Log_ResultSendEmailDatetime,
|
||||
Log_ResultSendEmailJson,
|
||||
Log_ResultSendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'ADDRESS') {
|
||||
$sql = "INSERT INTO result_sendcourier(
|
||||
Result_SendCourierT_OrderHeaderID,
|
||||
Result_SendCourierIds,
|
||||
Result_SendCourierT_OrderDeliveryID,
|
||||
Result_SendCourierStatus,
|
||||
Result_SendCourierType,
|
||||
Result_SendCourierT_TestName,
|
||||
Result_SendCourierCreated,
|
||||
Result_SendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendCourierStatus = 'P',
|
||||
Result_SendCourierUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendcourier
|
||||
WHERE
|
||||
Result_SendCourierT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendCourierIds = '{$join_ids}' AND
|
||||
Result_SendCourierT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendCourierType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendcourier (
|
||||
Log_ResultSendCourierDateTime,
|
||||
Log_ResultSendCourierJson,
|
||||
Log_ResultSendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
|
||||
//echo $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
// $result = array(
|
||||
// "total" => count($datarows) ,
|
||||
// "records" => $datarows,
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Company extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Company API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from corporate
|
||||
where CorporateName like ?
|
||||
and CorporateIsActive = 'Y'
|
||||
limit 0,30";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
$result = array("data" => $rows );
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Helper extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Helper API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function calc_age()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "call sp_recount_age(?)";
|
||||
$query = $this->db_smartone->query($sql, array($orderID));
|
||||
|
||||
if ($query) {
|
||||
$sql = "select T_OrderHeaderM_PatientAge, M_PatientDOB
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
and T_OrderHeaderID = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($orderID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$rst = $rows;
|
||||
if (count($rows) > 0)
|
||||
$rst = $rows[0];
|
||||
$this->sys_ok($rst);
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function check_status_print()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "SELECT GROUP_CONCAT(T_TestName SEPARATOR ',') as testname, concat( '[', group_concat( json_object('T_TestID', T_TestID, 'T_TestName',T_TestName) separator ',' ), ']' ) testall
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'
|
||||
AND (T_OrderDetailResult IS NULL OR T_OrderDetailResult = '')";
|
||||
$query = $this->db_smartone->query($sql, array($orderID));
|
||||
|
||||
if ($query) {
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['testall'] = json_decode($v['testall']);
|
||||
}
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
$rst = array("total" => $tot_count,
|
||||
"records" => $rows);
|
||||
if (count($rows) > 0)
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function insertlogprint()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$tests = json_encode($prm['tests']);
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "INSERT INTO log_printresultpartial(
|
||||
Log_PrintResultPartialT_OrderHeaderID,
|
||||
Log_PrintResultPartialTests,
|
||||
Log_PrintResultPartialUserID)
|
||||
VALUES ('{$prm['orderid']}','{$tests}','{$userid}')";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_printresultpartial end| " .
|
||||
$this->db_smartone->error()["message"], "debug" => $this->db_smartone->last_query()]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
$arr_code = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) {
|
||||
continue;
|
||||
}
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] ;
|
||||
if (is_numeric($result) ) {
|
||||
$dec = strlen(substr(strrchr($result, "."), 1));
|
||||
$result = number_format($result,$dec,".",",");
|
||||
}
|
||||
$result .= " ". $r["T_OrderDetailResultFlag"];
|
||||
|
||||
$px_code = $r["T_TestSasCode"];
|
||||
if(! isset($arr_code[$px_code]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_code[$px_code] = true;
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
$px_code = "";
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function old_search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
class Re_mbv extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo "Api: Training Playground";
|
||||
}
|
||||
function get_note()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT Other_MBVNoteName as name,
|
||||
Other_MBVNoteDescription as description
|
||||
FROM other_mbvnote";
|
||||
$qry = $this->db->query($sql, []);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$raw = $qry->result_array();
|
||||
$result = array("records" => $raw);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_doctors()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 7 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
} else {
|
||||
$this->sys_error_db("Rerun rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function get_result_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$sql = "SELECT Other_MBVT_OrderDetailID as detail_id,
|
||||
Other_MBVID as id,
|
||||
Other_MBVSkorNugent as skor_nugent,
|
||||
Other_MBVBahan as bahan,
|
||||
Other_MBVM_DoctorID as doctor_id,
|
||||
Other_MBVDetailsSumLp as sum_lp,
|
||||
Other_MBVDetailsSkor as skor
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN other_mbv
|
||||
ON T_OrderDetailID = Other_MBVT_OrderDetailID
|
||||
AND Other_MBVIsActive = 'Y'
|
||||
JOIN other_mbvdetails
|
||||
ON Other_MBVID = Other_MBVDetailsOther_MBVID
|
||||
AND Other_MBVDetailsIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
AND T_OrderHeaderIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [$id]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$result = $qry->result_array();
|
||||
$this->sys_ok(array("records" => $result));
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveresult_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// print_r(json_encode($prm['detail']));
|
||||
// exit;
|
||||
$doctor = 0;
|
||||
if (isset($prm['doctor'])) {
|
||||
$doctor = $prm['doctor'];
|
||||
}
|
||||
|
||||
$bahan = 0;
|
||||
if (isset($prm['bahan'])) {
|
||||
$bahan = $prm['bahan'];
|
||||
}
|
||||
|
||||
$data = 0;
|
||||
if (isset($prm['detail'])) {
|
||||
$data = $prm['detail'];
|
||||
}
|
||||
// print_r(json_encode($data));
|
||||
// exit;
|
||||
$skor_nugent = 0;
|
||||
if (isset($prm['skor_nugent'])) {
|
||||
$skor_nugent = $prm['skor_nugent'];
|
||||
}
|
||||
// print_r(json_encode(array("dktr" => $doctor, "dt" => $data, "bhn" => $bahan, "skr" => $skor_nugent,)));
|
||||
// exit;
|
||||
if ($data == 0 || $doctor == 0) {
|
||||
$this->sys_error("result, doctor & bahan are mandatory");
|
||||
// print_r(json_encode(array("dktr" => $doctor == 0, "dt" => $data == 0, "bhn" => $bahan == 0, "skr" => $skor_nugent == 0,)));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
for ($i = 0; $i < count($data); $i++) {
|
||||
if ($data[$i]["xid"] == "0" && $data[$i]["orderdetail_id"] != "0") {
|
||||
//insert other_fna
|
||||
$sql = "INSERT INTO other_mbv
|
||||
(Other_MBVT_OrderDetailID,
|
||||
Other_MBVSkorNugent,
|
||||
Other_MBVBahan,
|
||||
Other_MBVM_DoctorID,
|
||||
Other_MBVUserID,
|
||||
Other_MBVCreated)
|
||||
VALUES(?,?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["orderdetail_id"], $skor_nugent, $bahan,
|
||||
$doctor["id"], 3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$inserted_id = $this->db->insert_id();
|
||||
$sql = "INSERT INTO other_mbvdetails(
|
||||
Other_MBVDetailsOther_MBVID,
|
||||
Other_MBVDetailsSumLp,
|
||||
Other_MBVDetailsSkor,
|
||||
Other_MBVDetailsUserID,
|
||||
Other_MBVDetailsCreated)
|
||||
VALUES(?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$inserted_id,
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql = "UPDATE other_mbv SET Other_MBVSkorNugent =? ,
|
||||
Other_MBVBahan = ?,
|
||||
Other_MBVM_DoctorID = ?
|
||||
WHERE Other_MBVID = ? AND Other_MBVIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$skor_nugent,
|
||||
$bahan,
|
||||
intval($doctor["id"]),
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE other_mbvdetails SET Other_MBVDetailsSumLp = ?,
|
||||
Other_MBVDetailsSkor = ?
|
||||
WHERE Other_MBVDetailsOther_MBVID = ? AND Other_MBVDetailsIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("success");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class Re_normal extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$od_id = $prm["order_detail_id"];
|
||||
$sql = "call sp_re_update_normal(?)";
|
||||
$this->db_smartone->query($sql, array($od_id));
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNormalValueNote,
|
||||
Nat_MethodeName
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_methode on T_OrderDetailNat_MethodeID = Nat_MethodeID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
$qry = $this->db_smartone->query($sql_norm,array($od_id));
|
||||
if ( $qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) {
|
||||
$result = array("status"=>"OK","records" => $rows[0]);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
|
||||
// start fitri update unit
|
||||
$sql = "select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN nat_normalvalue ON Nat_NormalValueID = T_OrderDetailNat_NormalValueID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_NormalValueNat_UnitID
|
||||
where T_OrderDetailID = ?";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$unit_id = $rows[0]["Nat_UnitID"];
|
||||
$unit_name = $rows[0]["Nat_UnitName"];
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
|
||||
}else{
|
||||
$sqlunit = $this->db_smartone->query("select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN t_test ON T_TestID = T_OrderDetailT_TestID
|
||||
JOIN nat_test ON Nat_TestID = T_TestNat_TestID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_TestNat_UnitID
|
||||
where T_OrderDetailID = '{$prm["detail_id"]}'")->row();
|
||||
$unit_id = $sqlunit->Nat_UnitID;
|
||||
$unit_name = $sqlunit->Nat_UnitName;
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
}
|
||||
}
|
||||
// end fitri update unit
|
||||
|
||||
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,T_OrderDetailNat_UnitID,T_OrderDetailNat_UnitName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
$xdata["unit_id"] = $rows[0]["T_OrderDetailNat_UnitID"];
|
||||
$xdata["unit_name"] = $rows[0]["T_OrderDetailNat_UnitName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,263 @@
|
||||
<?php
|
||||
|
||||
class Re_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["start_date"] . '%';
|
||||
$edate = $prm["end_date"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id'])) $group_id = $prm['group_id'];
|
||||
|
||||
$company_id = 0;
|
||||
$q_company = "";
|
||||
if (isset($prm['company_id'])) {
|
||||
$company_id = $prm['company_id'];
|
||||
if ($company_id > 0 ) {
|
||||
$q_company = " and T_OrderHeaderCorporateID = $company_id ";
|
||||
}
|
||||
}
|
||||
$q_search = " and
|
||||
( M_PatientName LIKE ?
|
||||
or T_OrderHeaderLabNumber like ?
|
||||
)";
|
||||
if ($prm["search"] == "" ) $q_search = "";
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
$max_rst = 9999;
|
||||
$offset = 0;
|
||||
|
||||
$q_group = "";
|
||||
if ($group_id != 0 ) {
|
||||
$sql = "select T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = $group_id
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " and T_TestNat_TestID in ( $nat_test_ids ) ";
|
||||
}
|
||||
|
||||
//janji hasil hari ini T_OrderHeaderID
|
||||
/* $sql = "select T_OrderPromiseT_OrderHeaderID
|
||||
from t_orderpromise
|
||||
where T_OrderPromiseIsActive = 'Y' and date(T_OrderPromiseDateTime) = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate));
|
||||
$promise_ids = "0";
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderPromiseT_OrderHeaderID"];
|
||||
$promise_ids = join(",",$xids);
|
||||
}
|
||||
}
|
||||
*/
|
||||
$order_ids = 0;
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y' and date(T_OrderHeaderDate) BETWEEN ? AND ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate,$edate));
|
||||
$order_ids = $promise_ids;
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderHeaderID"];
|
||||
$order_ids = join(",",$xids);
|
||||
}else{
|
||||
$order_ids = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *,
|
||||
CONCAT('[', GROUP_CONCAT(DISTINCT CONCAT('\"', T_OrderHeaderDate, '\"') SEPARATOR ','), ']') order_promise
|
||||
FROM (
|
||||
select T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderDate,
|
||||
'' T_OrderHeaderLabNumberExt, T_OrderHeaderDiagnose,
|
||||
M_PatientID, M_PatientNoReg, fn_global_patient_name(M_PatientID) M_PatientName,
|
||||
M_PatientDOB, T_OrderHeaderM_PatientAge, M_PatientHP, M_PatientGender M_SexName, '' M_PatientNote,
|
||||
da.M_DoctorID doctor_pj_id, fn_get_doctor_fullname(da.M_DoctorID) doctor_pj_name,
|
||||
0 doctor_sender_id, '' doctor_sender_name,
|
||||
'' M_MouID, '' M_MouName, CorporateID, CorporateName,
|
||||
T_OrderHeaderFoNote, T_OrderHeaderSamplingNote, T_OrderHeaderResultNote,
|
||||
la.M_LangID M_LangID, la.M_LangCode M_LangCode, la.M_LangName M_LangName, '' T_OrderHeaderLangIsSI,
|
||||
la.M_LangID SecondM_LangID, la.M_LangCode SecondM_LangCode, la.M_LangName SecondM_LangName,
|
||||
'' T_OrderHeaderAddOnSecondLangIsSI,
|
||||
'N' T_OrderHeaderIsCito, '' as delivery,
|
||||
'' T_OrderPromiseDateTime, '' is_history,
|
||||
'N' T_OrderHeaderAddOnVerificationDone,
|
||||
'N' T_OrderHeaderAddOnValidationDone, '' T_OrderHeaderAddOnRequestChangeDOB
|
||||
from t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_orderheaderlang ON T_OrderHeaderLangT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
{$q_group}
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
left join m_doctor da on T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN corporate on T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN m_lang la ON T_OrderHeaderLangM_LangID = la.M_LangID
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
{$q_company}
|
||||
{$q_search}
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
) x
|
||||
GROUP BY T_OrderHeaderID
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
";
|
||||
if ($q_search == "" ) {
|
||||
$query = $this->db_smartone->query($sql);
|
||||
} else {
|
||||
$query = $this->db_smartone->query($sql, [ $search, $search]);
|
||||
}
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$tmp_ohnumber = [];
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$lang = [["id"=>0, "code"=>"ID", "is_si"=>"N"]];
|
||||
if ($v['M_LangCode'] != "ID")
|
||||
$lang[] = ["id"=>$v['M_LangID'], "code"=>$v['M_LangCode'], "is_si"=>$v['T_OrderHeaderLangIsSI']];
|
||||
$sqltotal = "SELECT COUNT(T_OrderDetailID) as cnt_rst_a,
|
||||
SUM(IF(T_OrderDetailResult <> '' AND T_OrderDetailResult IS NOT NULL, 1, 0)) as cnt_rst_b,
|
||||
SUM(IF(T_OrderDetailVerification = 'Y', 1, 0)) as cnt_ver_n,
|
||||
SUM(IF(T_OrderDetailValidation = 'Y', 1, 0)) as cnt_val_n
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = {$v['T_OrderHeaderID']}
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'";
|
||||
$sqltotal = $this->db_smartone->query($sqltotal)->row();
|
||||
|
||||
if($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b < $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'P';
|
||||
}elseif($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b == $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'Y';
|
||||
}
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$rows[$k]['lang'] = $lang;
|
||||
$rows[$k]['delivery'] = JSON_DECODE($v['delivery']);
|
||||
$rows[$k]['order_promise'] = JSON_DECODE($v['order_promise']);
|
||||
|
||||
foreach($rows[$k]['order_promise'] as $l => $w)
|
||||
$rows[$k]['order_promise'][$l] = date('d-m-Y H:i', strtotime($w));
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from t_orderheader
|
||||
JOIN corporate ON CorporateID = T_OrderHeaderCorporateID AND CorporateIsActive = 'Y'
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
GROUP BY CorporateID";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$crows = $query->result_array();
|
||||
$crows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count,
|
||||
"total_page" => ceil($tot_count/$max_rst),
|
||||
"cur_page" => $page,
|
||||
"records" => $rows,
|
||||
"total_display" => sizeof($rows),
|
||||
"q" => $this->db_smartone->last_query(),
|
||||
"companies"=>$crows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function history()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_history(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$history = json_decode($row->rst);
|
||||
|
||||
$this->sys_ok($history);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("RESULT HISTORY", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_note()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderheader SET T_OrderHeaderResultNote = ?, T_OrderHeaderResultNoteM_UserID = ?
|
||||
WHERE T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['note'], $this->sys_user['M_UserID'], $prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$this->sys_ok($prm['order_id']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT NOTE", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function info_req()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_reqs(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$s_data = $row->data;
|
||||
$s_data = str_replace("\n"," ",$s_data);
|
||||
$this->sys_ok(json_decode($s_data));
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT REQ", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,710 @@
|
||||
<?php
|
||||
|
||||
class Re_px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Px API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 99;
|
||||
|
||||
$id = $prm["order_id"];
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$tot_count = 0;
|
||||
$lq = "";
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id']))
|
||||
$group_id = $prm['group_id'];
|
||||
|
||||
if ($group_id != 0)
|
||||
{
|
||||
$sql = "select distinct T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = {$group_id}";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " ( $nat_test_ids ) ";
|
||||
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime, fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_test tcheck on tcheck.T_TestNat_TestID in {$q_group}
|
||||
and ( tx.T_TestID = tcheck.T_TestID or tx.T_TestSasCode like concat(tcheck.T_TestSasCode,'%'))
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime , fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
// file_put_contents("/xtmp/re-query.sql",$lq);
|
||||
|
||||
if ($query) {
|
||||
$rst = [];
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v)
|
||||
{
|
||||
|
||||
if ($v['is_result'] == "Y" && $v['is_quantitative'] == "N")
|
||||
{
|
||||
$v['template'] = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$v['t_testid']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$v['template'] = $x->result_array();
|
||||
}
|
||||
|
||||
// IF Rujukan, by pas Pre Analytik
|
||||
if ($v['ref'] == 'Y')
|
||||
$v['pre_analytic'] = 'Y';
|
||||
|
||||
$rst[] = $v;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rst, "total_display" => sizeof($rows), "q" => $lq);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RE Px rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
if ( $v->resultInstrumentID > 0 ) {
|
||||
$sql_i = "select T_ResultInstrumentNat_NormalValueID normalValueID
|
||||
from t_resultinstrument
|
||||
where T_ResultInstrumentID = ?";
|
||||
$qry_i = $this->db_smartone->query($sql_i, array($v->resultInstrumentID));
|
||||
if ($qry_i) {
|
||||
$rows_i = $qry_i->result_array();
|
||||
|
||||
if (count($rows_i) > 0 ) {
|
||||
$sql_iu = "update t_orderdetail, nat_normalvalue
|
||||
set T_OrderDetailMinValue = Nat_NormalValueMinValue,
|
||||
T_OrderDetailMinValueInclusive = Nat_NormalValueMinValueInclusive,
|
||||
T_OrderDetailMaxValue = Nat_NormalValueMaxValue ,
|
||||
T_OrderDetailMaxValueInclusive = Nat_NormalValueMaxValueInclusive,
|
||||
T_OrderDetailNormalValueNote = Nat_NormalValueNote,
|
||||
T_OrderDetailNormalValueDescription = Nat_NormalValueDescription,
|
||||
T_OrderDetailNat_NormalValueID = Nat_NormalValueID
|
||||
where T_OrderDetailID = ? and Nat_NormalValueID = ?
|
||||
";
|
||||
$this->db_smartone->query($sql_iu, array($v->id, $rows_i[0]["normalValueID"]));
|
||||
//file_put_contents("/xtmp/update-nilai-normal", $this->db_smartone->last_query() . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
$y = $this->db_smartone->query("SELECT fn_process_sample_handling_perfect('{$v->order_id}', '{$v->test_id}') c")
|
||||
->row();
|
||||
$req_status = $y->c;
|
||||
$qry_norm = $this->db_smartone->query($sql_norm,$v->id);
|
||||
$result_flag = "";
|
||||
if ($qry_norm) {
|
||||
$rows_norm = $qry_norm->result_array();
|
||||
if (count($rows_norm) > 0 ) {
|
||||
$r = $rows_norm[0];
|
||||
if (is_numeric($v->result)) {
|
||||
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "Y" && $v->result < $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "N" && $v->result <= $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "Y" && $v->result > $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "N" && $v->result >= $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($lang == $this->lang_default_code)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailResult', $v->result)
|
||||
->set('T_OrderDetailResultFlag', $result_flag)
|
||||
->set('T_OrderDetailNote', $v->note)
|
||||
->set('T_OrderDetailReqStatus', $req_status)
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailLangResult', $v->result)
|
||||
->set('T_OrderDetailLangNote', $v->note)
|
||||
->where('T_OrderDetailLangID', $v->id)
|
||||
->update('t_orderdetaillang');
|
||||
}
|
||||
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Entry')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', json_encode($data))
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
//auto calculation
|
||||
$this->load->library("Resultcalc");
|
||||
$rows = $this->resultcalc->auto($order->id);
|
||||
|
||||
try {
|
||||
foreach($ids as $id ) {
|
||||
$this->db_smartone->query("call sp_set_normal_value_flag($id)");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
|
||||
public function save_template()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$n = $this->db_smartone->select("COUNT(T_ResultTemplateID) n")
|
||||
->where("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->where("T_ResultTemplateIsActive", "Y")
|
||||
->where("T_ResultTemplateValue", $prm['value'])
|
||||
->get('t_resulttemplate')
|
||||
->row();
|
||||
if ($n->n > 0)
|
||||
{
|
||||
$this->sys_error_db("Insert Result Template", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$r = $this->db_smartone->set("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->set("T_ResultTemplateValue", $prm['value'])
|
||||
->insert('t_resulttemplate');
|
||||
if ($r)
|
||||
{
|
||||
$template = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$prm['test_id']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$template = $x->result_array();
|
||||
|
||||
$this->sys_ok($template);
|
||||
}
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_lang(?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'], $prm['lang_id'], $prm['is_si'], $this->sys_user['M_UserID']]);
|
||||
if ($query)
|
||||
{
|
||||
$r = $query->row();
|
||||
if ($r->status == "OK")
|
||||
{
|
||||
$this->sys_ok($r->data);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Message : " . $r->message, $this->db_smartone);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Lang Result", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_group()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 100;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_WorklistID group_id, T_WorklistName group_name
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$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("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_rerun()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["detail_id"];
|
||||
|
||||
$sql = "CALL sp_process_result_rerun(?)";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdoctorsfna()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getfnaresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_FNADetailsID as xid,
|
||||
Other_FNAT_OrderDetailID as orderdetail_id,
|
||||
Other_FNADetailsCode as code,
|
||||
Other_FNADetailsLabel as label,
|
||||
Other_FNADetailsResult as result,
|
||||
IFNULL(Other_FNAM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_FNAM_DoctorID) OR Other_FNAM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_fna
|
||||
JOIN other_fnadetails ON Other_FNADetailsOther_FNAID = Other_FNAID AND Other_FNADetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_FNAM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_FNAT_OrderDetailID = {$id} AND Other_FNAIsActive = 'Y'
|
||||
GROUP BY Other_FNADetailsID
|
||||
ORDER BY Other_FNADetailsCode ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getpapsmearresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_PapSmearDetailsID as xid,
|
||||
Other_PapSmearID as header_id,
|
||||
Other_PapSmearT_OrderDetailID as orderdetail_id,
|
||||
Other_PapSmearDetailsCode as code,
|
||||
Other_PapSmearDetailsLabel as label,
|
||||
Other_PapSmearDetailsResult as result,
|
||||
IFNULL(Other_PapSmearM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_PapSmearM_DoctorID) OR Other_PapSmearM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_papsmear
|
||||
JOIN other_papsmeardetails ON Other_PapSmearDetailsOther_PapSmearID = Other_PapSmearID AND Other_PapSmearDetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_PapSmearM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_PapSmearT_OrderDetailID = {$id} AND Other_PapSmearIsActive = 'Y'
|
||||
GROUP BY Other_PapSmearDetailsID
|
||||
ORDER BY Other_PapSmearDetailsCode ASC";
|
||||
//echo $sql;
|
||||
$rows = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$rows){
|
||||
$rows = array(
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'A',
|
||||
'label' => 'Makroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'B',
|
||||
'label' => 'Mikroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'C',
|
||||
'label' => 'Kesimpulan',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$header_id = $rows[0]['header_id'];
|
||||
$sql = "SELECT Other_PapSmearMaturasiID as xid,
|
||||
Other_PapSmearMaturasiValue as value
|
||||
FROM other_papsmearmaturasi
|
||||
WHERE
|
||||
Other_PapSmearMaturasiOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearMaturasiIsActive = 'Y'
|
||||
";
|
||||
$maturasi = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$maturasi){
|
||||
$maturasi = array('xid'=>'0','value'=>'//');
|
||||
}
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearBahanID,0) as xid,
|
||||
M_PapSmearBahanID as bahan_id,
|
||||
M_PapSmearBahanName as name
|
||||
FROM m_papsmearbahan
|
||||
LEFT JOIN other_papsmearbahan ON Other_PapSmearBahanM_PapSmearBahanID = M_PapSmearBahanID AND
|
||||
Other_PapSmearBahanOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearBahanIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearBahanIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$bahans = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapsmearCategoryID,0) as xid,
|
||||
M_PapSmearCategoryID as category_id,
|
||||
M_PapSmearCategoryName as name
|
||||
FROM m_papsmearcategory
|
||||
LEFT JOIN other_papsmearcategory ON Other_PapsmearCategoryM_PapSmearCategoryID = M_PapSmearCategoryID AND
|
||||
Other_PapsmearCategoryOther_PapSmearID = {$header_id} AND
|
||||
Other_PapsmearCategoryIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCategoryIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$categories = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearCheckID,0) as xid,
|
||||
M_PapSmearCheckID as check_id,
|
||||
M_PapSmearCheckLabel as name,
|
||||
Other_PapSmearCheckNote as note
|
||||
FROM m_papsmearcheck
|
||||
LEFT JOIN other_papsmearcheck ON Other_PapSmearCheckM_PapSmearCheckID = M_PapSmearCheckID AND
|
||||
Other_PapSmearCheckOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearCheckIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCheckIsActive = 'Y'
|
||||
";
|
||||
$checks = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'checks'=>$checks,'bahans'=>$bahans,'categories'=>$categories,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
|
||||
}
|
||||
|
||||
function saveresult_fna()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
$prm = $inp['results'];
|
||||
$doctor_id = $inp['doctor'];
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$header_id = 0;
|
||||
if($prm[0]['xid'] == '0'){
|
||||
$sql = "INSERT INTO other_fna(
|
||||
Other_FNAM_DoctorID,
|
||||
Other_FNAT_OrderDetailID,
|
||||
Other_FNAUserID,
|
||||
Other_FNACreated
|
||||
)
|
||||
VALUES(
|
||||
{$doctor_id},
|
||||
{$prm[0]['orderdetail_id']},
|
||||
{$userid},
|
||||
NOW()
|
||||
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_smartone->query($sql);
|
||||
$header_id = $this->db_smartone->insert_id();
|
||||
}
|
||||
foreach($prm as $k => $v){
|
||||
if($v['xid'] == '0'){
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "INSERT INTO other_fnadetails(
|
||||
Other_FNADetailsOther_FNAID ,
|
||||
Other_FNADetailsCode,
|
||||
Other_FNADetailsLabel,
|
||||
Other_FNADetailsResult,
|
||||
Other_FNADetailsCreated,
|
||||
Other_FNADetailsUserID
|
||||
)
|
||||
VALUES(
|
||||
{$header_id},
|
||||
'{$v['code']}',
|
||||
'{$v['label']}',
|
||||
'{$results}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
else{
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "UPDATE other_fnadetails SET
|
||||
Other_FNADetailsResult = '{$results}',
|
||||
Other_FNADetailsUserID = {$userid}
|
||||
WHERE
|
||||
Other_FNADetailsID = {$v['xid']}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => array(), "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,621 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_validation extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Result Validation API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function mr_state()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["order_id"];
|
||||
|
||||
$data = [
|
||||
"image" => "http://blog.aylien.com/wp-content/uploads/2016/07/Screen-Shot-2016-07-21-at-18.46.42.png",
|
||||
"note" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
"title" => "Multi Rule"
|
||||
];
|
||||
$this->sys_ok($data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
|
||||
if (sizeof($data) < 1) {
|
||||
$this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
exit;
|
||||
} else {
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v) {
|
||||
$mr_state = "X";
|
||||
if (isset($v->mr_state[0])) $mr_state = $v->mr_state[0];
|
||||
$qry = $this->db_smartone->set('T_OrderDetailValMRState', $mr_state)
|
||||
->set('T_OrderDetailValidation', $v->validation)
|
||||
->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation1', $v->validation)
|
||||
->set('T_OrderDetailValidation1Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation2', $v->validation)
|
||||
->set('T_OrderDetailValidation2Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
if (!$qry) {
|
||||
print_r($this->db_smartone->error());
|
||||
}
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$sql_order = "SELECT
|
||||
T_OrderDetailT_OrderHeaderID
|
||||
FROM t_orderdetail
|
||||
WHERE T_OrderDetailID = ? and T_OrderDetailIsActive = 'Y'";
|
||||
$qry_order = $this->db_smartone->query($sql_order, [$data[0]->id]);
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($qry_order) {
|
||||
$row = $qry_order->row_array();
|
||||
} else {
|
||||
$this->sys_error_db("select orderheader", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select
|
||||
T_OrderHeaderID,T_OrderHeaderLabNumber,
|
||||
T_TestName, T_OrderDetailID, T_OrderDetailResult, T_OrderDetailNat_MethodeID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,
|
||||
T_OrderDetailMinValue, T_OrderDetailMaxValue, T_OrderDetailMinValueInclusive,
|
||||
T_OrderDetailMaxValueInclusive,
|
||||
Mcu_SummaryLabID,
|
||||
Mcu_SummaryLabValue,
|
||||
Mcu_SummaryLabNat_MethodeID,
|
||||
Mcu_SummaryLabWithMethode,
|
||||
Mcu_SummaryLabType,
|
||||
Mcu_SummaryLabIsNormalValue,
|
||||
Mcu_KelainanID, Mcu_KelainanName, Mcu_KelainanClasification,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
mcu_kelainangroup.*
|
||||
from t_orderdetail
|
||||
join t_orderheader on T_OrderHeaderID = ?
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
join t_test
|
||||
on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
join mcu_summarylab on T_TestNat_TestID = Mcu_SummaryLabNat_TestID AND Mcu_SummaryLabIsActive = 'Y'
|
||||
join mcu_kelainan on Mcu_SummaryLabMcu_KelainanID = Mcu_KelainanID
|
||||
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID";
|
||||
$qry = $this->db_smartone->query($sql, array($row["T_OrderDetailT_OrderHeaderID"]));
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get order | " . $this->db_smartone->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
$results = [];
|
||||
|
||||
$sql_upd = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabIsActive = 'N',
|
||||
T_KelainanLabCreatedUserID = {$this->sys_user['M_UserID']}
|
||||
WHERE T_KelainanLabT_OrderHeaderID = {$rows[0]['T_OrderHeaderID']}";
|
||||
$qry_upd = $this->db_smartone->query($sql_upd);
|
||||
if (!$qry_upd) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$result_value = $r['T_OrderDetailResult'];
|
||||
|
||||
$value_comparison = 0;
|
||||
//echo $r['Mcu_SummaryLabIsNormalValue'];
|
||||
$kelainan = [];
|
||||
$notavailable = [];
|
||||
if (trim($result_value) == 'NA') {
|
||||
$notavailable = $r;
|
||||
} elseif ($r['Mcu_SummaryLabIsNormalValue'] == 'Y') {
|
||||
if ($r['Mcu_SummaryLabType'] == '<' || $r['Mcu_SummaryLabType'] == '<=') {
|
||||
$value_comparison = $r['T_OrderDetailMinValue'];
|
||||
}
|
||||
if ($r['Mcu_SummaryLabType'] == '>' || $r['Mcu_SummaryLabType'] == '>=') {
|
||||
$value_comparison = $r['T_OrderDetailMaxValue'];
|
||||
}
|
||||
//echo "Y";
|
||||
if ($r['Mcu_SummaryLabWithMethode'] == 'N' && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
$value_comparison = $r['Mcu_SummaryLabValue'];
|
||||
if ($r['Mcu_SummaryLabType'] == '!=' || $r['Mcu_SummaryLabType'] == '==') {
|
||||
if ($this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
if (is_numeric($result_value) && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($results) > 0) {
|
||||
|
||||
foreach ($results as $v_result) {
|
||||
$sql_kel_lab = "SELECT *
|
||||
FROM t_kelainan_lab
|
||||
WHERE T_KelainanLabIsActive = 'Y'
|
||||
AND T_KelainanLabT_OrderDetailID = ?";
|
||||
$qry_kel_lab = $this->db_smartone->query($sql_kel_lab, array($v_result['orderdetailID']));
|
||||
if ($qry_kel_lab) {
|
||||
$rows_kel = $qry_kel_lab->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select kelainan lab", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows_kel) > 0) {
|
||||
|
||||
// print_r($v_result['orderdetailID']);
|
||||
// exit;
|
||||
|
||||
$sql_update_kel = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabT_OrderDetailID = ?,
|
||||
T_KelainanLabT_OrderHeaderID = ?,
|
||||
T_KelainanLabNat_TestID = ?,
|
||||
T_KelainanLabMcu_SummaryLabID = ?,
|
||||
T_KelainanLabCreatedUserID = ?,
|
||||
T_KelainanLabCreated = NOW()
|
||||
WHERE T_KelainanLabID = ?";
|
||||
$qry_update_kel = $this->db_smartone->query($sql_update_kel, array(
|
||||
$v_result['orderdetailID'],
|
||||
$v_result['orderheaderID'],
|
||||
$v_result['nat_testID'],
|
||||
$v_result['mcu_summarylabID'],
|
||||
$this->sys_user['M_UserID'],
|
||||
$rows_kel[0]['T_KelainanLabID']
|
||||
));
|
||||
if (!$qry_update_kel) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// print_r('insert');
|
||||
// exit;
|
||||
$sql_insert_lab = "INSERT INTO t_kelainan_lab(
|
||||
T_KelainanLabT_OrderDetailID,
|
||||
T_KelainanLabT_OrderHeaderID,
|
||||
T_KelainanLabNat_TestID,
|
||||
T_KelainanLabMcu_SummaryLabID,
|
||||
T_KelainanLabCreatedUserID,
|
||||
T_KelainanLabCreated) VALUES(
|
||||
{$v_result['orderdetailID']},
|
||||
{$v_result['orderheaderID']},
|
||||
{$v_result['nat_testID']},
|
||||
{$v_result['mcu_summarylabID']},
|
||||
{$this->sys_user['M_UserID']},
|
||||
NOW())";
|
||||
$qry_insert_lab = $this->db_smartone->query($sql_insert_lab);
|
||||
|
||||
if (!$qry_insert_lab) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error insert kelainan lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// END OF Log Process
|
||||
//update validation multi
|
||||
//$this->load->library("Txbranchstatus");
|
||||
// $this->txbranchstatus->update_multi("VALIDATION",$ids,$this->sys_user['M_StaffName']);
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
}
|
||||
|
||||
function dynamic_comparison($varleft, $op, $varright)
|
||||
{
|
||||
|
||||
switch ($op) {
|
||||
case "=":
|
||||
return $varleft == $varright;
|
||||
case "!=":
|
||||
return $varleft != $varright;
|
||||
case ">=":
|
||||
return $varleft >= $varright;
|
||||
case "<=":
|
||||
return $varleft <= $varright;
|
||||
case ">":
|
||||
return $varleft > $varright;
|
||||
case "<":
|
||||
return $varleft < $varright;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// public function validate()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $data = json_decode($prm["data"]);
|
||||
|
||||
// if (sizeof($data) < 1)
|
||||
// {
|
||||
// $this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
// exit;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $ids = [];
|
||||
// foreach ($data as $k => $v)
|
||||
// {
|
||||
// $this->db_smartone->set('T_OrderDetailValMRState', $v->mr_state)
|
||||
// ->set('T_OrderDetailValidation', $v->validation)
|
||||
// ->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
// ->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
// ->where('T_OrderDetailID', $v->id)
|
||||
// ->update('t_orderdetail');
|
||||
// $ids[] = $v->id;
|
||||
// }
|
||||
|
||||
// // LOG Process
|
||||
// $order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
// ->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
// ->where('T_OrderDetailID', $data[0]->id)
|
||||
// ->get('t_orderdetail')
|
||||
// ->row();
|
||||
|
||||
// $dblog = $this->load->database("onelog", true);
|
||||
// $dblog->set('Log_ProcessCode', 'PROCESS.Result.Validation')
|
||||
// ->set('Log_ProcessOrderID', $order->id)
|
||||
// ->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
// ->set('Log_ProcessJson', json_encode($data))
|
||||
// ->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
// ->insert('log_process');
|
||||
// // END OF Log Process
|
||||
|
||||
// $this->sys_ok($ids);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
function print_count()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->firstprint();
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = T_OrderDetailPrintCount + 1
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailValidation = 'Y'
|
||||
AND T_OrderDetailIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query) {
|
||||
$this->sys_ok($this->db_smartone->last_query());
|
||||
} else
|
||||
$this->sys_error_db("Print Count", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function reject()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_validation_reject(?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['id'], $prm['action']]);
|
||||
|
||||
if ($query) {
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
} else {
|
||||
$this->sys_error_db("REJECT VALIDATION", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
|
||||
public function unvalidate()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm["order_id"];
|
||||
|
||||
$this->db_smartone->set('T_OrderDetailValidation', "N")
|
||||
->set('T_OrderDetailValDate', null)
|
||||
->set('T_OrderDetailValUserID', 0)
|
||||
->set('T_OrderDetailValidation1', "N")
|
||||
->set('T_OrderDetailValidation1Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->set('T_OrderDetailValidation2', "N")
|
||||
->set('T_OrderDetailValidation2Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->where('T_OrderDetailIsActive', 'Y')
|
||||
->where('T_OrderDetailValidation', 'Y')
|
||||
->update('t_orderdetail');
|
||||
|
||||
$q = $this->db_smartone->last_query();
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
/* $dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Unvalidation')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', '{}')
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
*/
|
||||
$this->sys_ok($q);
|
||||
}
|
||||
|
||||
// Copas Fajri
|
||||
function firstprint()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm['T_OrderHeaderID'] = $prm['order_id'];
|
||||
$datarows = [];
|
||||
$query = " SELECT T_OrderDetailID,T_TestName
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName = 'lab'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDetailValidation = 'Y' AND
|
||||
T_OrderDetailPrintCount = 0 AND
|
||||
T_OrderDetailT_OrderPromiseID <> 0 AND
|
||||
( T_OrderDetailResult <> '' OR T_OrderDetailResult IS NOT NULL ) AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_OrderDetailID";
|
||||
//echo $query;
|
||||
$datarows = $this->db_smartone->query($query)->result_array();
|
||||
$ids = array();
|
||||
$testname = array();
|
||||
if ($datarows) {
|
||||
foreach ($datarows as $k => $v) {
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = 1 WHERE T_OrderDetailID = {$v['T_OrderDetailID']}";
|
||||
$this->db_smartone->query($sql);
|
||||
array_push($ids, $v['T_OrderDetailID']);
|
||||
array_push($testname, $v['T_TestName']);
|
||||
}
|
||||
}
|
||||
$join_ids = "[" . join(",", $ids) . "]";
|
||||
$join_testname = "[" . join(",", $testname) . "]";
|
||||
|
||||
$sql = "SELECT t_orderdelivery.*, M_DeliveryTypeCode as code
|
||||
FROM t_orderdelivery
|
||||
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
";
|
||||
//echo $sql;
|
||||
$result_delivery = $this->db_smartone->query($sql)->result_array();
|
||||
$arr_deliveryid = array();
|
||||
foreach ($result_delivery as $i => $j) {
|
||||
array_push($arr_deliveryid, $j["T_OrderDeliveryM_DeliveryID"]);
|
||||
}
|
||||
|
||||
foreach ($result_delivery as $k => $v) {
|
||||
|
||||
if ($v['code'] == 'PICKUP') {
|
||||
$sql = "INSERT INTO result_frontoffice(
|
||||
Result_FrontOfficeT_OrderHeaderID,
|
||||
Result_FrontOfficeIds,
|
||||
Result_FrontOfficeStatus,
|
||||
Result_FrontOfficeType,
|
||||
Result_FrontOfficeTestName,
|
||||
Result_FrontOfficeCreated,
|
||||
Result_FrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_FrontOfficeStatus = 'P',
|
||||
Result_FrontOfficeUserID = {$userid}
|
||||
";
|
||||
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_frontoffice
|
||||
WHERE Result_FrontOfficeT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_FrontOfficeIds = '{$join_ids}' AND
|
||||
Result_FrontOfficeType = 'lab'";
|
||||
$rst_log = $this->db_smartone->query($sql)->result_array();
|
||||
$dt_log = json_encode($rst_log);
|
||||
$sql = "INSERT INTO one_log.log_result_front_office(
|
||||
Log_ResultFrontOfficeDateTime,
|
||||
Log_ResultFrontOfficeJson,
|
||||
Log_ResultFrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'EMAIL') {
|
||||
$type = "MANUAL";
|
||||
if (in_array(1, $arr_deliveryid) && (in_array(3, $arr_deliveryid) || in_array(5, $arr_deliveryid) || in_array(11, $arr_deliveryid))) {
|
||||
$type = "FO";
|
||||
}
|
||||
$sql = "INSERT INTO result_sendemail(
|
||||
Result_SendEmailT_OrderHeaderID,
|
||||
Result_SendEmailActionBy,
|
||||
Result_SendEmailIds,
|
||||
Result_SendEmailT_OrderDeliveryID,
|
||||
Result_SendEmailStatus,
|
||||
Result_SendEmailType,
|
||||
Result_SendEmailT_TestName,
|
||||
Result_SendEmailCreated,
|
||||
Result_SendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$type}',
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendEmailStatus = 'P',
|
||||
Result_SendEmailUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendemail
|
||||
WHERE
|
||||
Result_SendEmailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendEmailIds = '{$join_ids}' AND
|
||||
Result_SendEmailT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendEmailType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendemail (
|
||||
Log_ResultSendEmailDatetime,
|
||||
Log_ResultSendEmailJson,
|
||||
Log_ResultSendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'ADDRESS') {
|
||||
$sql = "INSERT INTO result_sendcourier(
|
||||
Result_SendCourierT_OrderHeaderID,
|
||||
Result_SendCourierIds,
|
||||
Result_SendCourierT_OrderDeliveryID,
|
||||
Result_SendCourierStatus,
|
||||
Result_SendCourierType,
|
||||
Result_SendCourierT_TestName,
|
||||
Result_SendCourierCreated,
|
||||
Result_SendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendCourierStatus = 'P',
|
||||
Result_SendCourierUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendcourier
|
||||
WHERE
|
||||
Result_SendCourierT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendCourierIds = '{$join_ids}' AND
|
||||
Result_SendCourierT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendCourierType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendcourier (
|
||||
Log_ResultSendCourierDateTime,
|
||||
Log_ResultSendCourierJson,
|
||||
Log_ResultSendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
|
||||
//echo $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
// $result = array(
|
||||
// "total" => count($datarows) ,
|
||||
// "records" => $datarows,
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Company extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Company API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from corporate
|
||||
where CorporateName like ?
|
||||
and CorporateIsActive = 'Y'
|
||||
limit 0,30";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
$result = array("data" => $rows );
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Helper extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Helper API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function calc_age()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "call sp_recount_age(?)";
|
||||
$query = $this->db_smartone->query($sql, array($orderID));
|
||||
|
||||
if ($query) {
|
||||
$sql = "select T_OrderHeaderM_PatientAge, M_PatientDOB
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
and T_OrderHeaderID = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($orderID));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$rst = $rows;
|
||||
if (count($rows) > 0)
|
||||
$rst = $rows[0];
|
||||
$this->sys_ok($rst);
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function check_status_print()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
|
||||
$sql = "SELECT GROUP_CONCAT(T_TestName SEPARATOR ',') as testname, concat( '[', group_concat( json_object('T_TestID', T_TestID, 'T_TestName',T_TestName) separator ',' ), ']' ) testall
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'
|
||||
AND (T_OrderDetailResult IS NULL OR T_OrderDetailResult = '')";
|
||||
$query = $this->db_smartone->query($sql, array($orderID));
|
||||
|
||||
if ($query) {
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['testall'] = json_decode($v['testall']);
|
||||
}
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
$rst = array("total" => $tot_count,
|
||||
"records" => $rows);
|
||||
if (count($rows) > 0)
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function insertlogprint()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$tests = json_encode($prm['tests']);
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "INSERT INTO log_printresultpartial(
|
||||
Log_PrintResultPartialT_OrderHeaderID,
|
||||
Log_PrintResultPartialTests,
|
||||
Log_PrintResultPartialUserID)
|
||||
VALUES ('{$prm['orderid']}','{$tests}','{$userid}')";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_printresultpartial end| " .
|
||||
$this->db_smartone->error()["message"], "debug" => $this->db_smartone->last_query()]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
$arr_code = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) {
|
||||
continue;
|
||||
}
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] ;
|
||||
if (is_numeric($result) ) {
|
||||
$dec = strlen(substr(strrchr($result, "."), 1));
|
||||
$result = number_format($result,$dec,".",",");
|
||||
}
|
||||
$result .= " ". $r["T_OrderDetailResultFlag"];
|
||||
|
||||
$px_code = $r["T_TestSasCode"];
|
||||
if(! isset($arr_code[$px_code]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_code[$px_code] = true;
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
$px_code = "";
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function old_search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
|
||||
$maxOrder = 5;
|
||||
$sql = "select min(T_OrderHeaderID) minID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0, $maxOrder";
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$minOrderID = $rows[0]["minID"];
|
||||
|
||||
$sql = "select date(T_OrderHeaderDate) T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level, T_TestSasCode, Nat_UnitName
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderID >= ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_unit on T_OrderDetailNat_UnitID = Nat_UnitID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID, $minOrderID ) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$prev_id = 0;
|
||||
$arr_px = array();
|
||||
|
||||
$arr_date = array();
|
||||
$index_px = 0;
|
||||
$arr_test = array();
|
||||
|
||||
foreach($rows as $r) {
|
||||
$is_result = $r["T_TestIsResult"];
|
||||
if ($is_result == "N" ) continue;
|
||||
$order_id = $r["T_OrderHeaderID"];
|
||||
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
$px_name = $r["T_TestShortName"] ;
|
||||
$result = $r["T_OrderDetailResult"] . $r["T_OrderDetailResultFlag"];
|
||||
|
||||
if(! isset($arr_px[$px_name]) ) {
|
||||
$arr_result[] = array(
|
||||
"px_name" => $px_name,
|
||||
"code" => $r["T_TestSasCode"],
|
||||
"unit" => $r["Nat_UnitName"],
|
||||
"result" => array()
|
||||
);
|
||||
$arr_px[$px_name] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$arr_test[] = array("code" => $r["T_TestSasCode"], "name" => $px_name);
|
||||
$index_px = count($arr_result) - 1;
|
||||
}
|
||||
if (! in_array($date, $arr_date) ) $arr_date[] = $date;
|
||||
$arr_result[$index_px]["result"][$date] = $result;
|
||||
$prev_id = $order_id;
|
||||
}
|
||||
foreach($arr_result as $idx => $v ) {
|
||||
foreach($arr_date as $date) {
|
||||
if (! isset($v["result"][$date] ) ) {
|
||||
$arr_result[$idx]["result"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array("pxs" => $arr_test, "result" => $arr_result, "dates" => $arr_date);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["order_id"];
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$query = $this->db_smartone->query($sql, array($orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$this->sys_error_db("No Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber,T_OrderHeaderID,
|
||||
T_TestShortName , T_OrderDetailResult, T_TestIsResult, T_OrderDetailResultFlag,
|
||||
(length(T_TestSasCode) - 6 ) / 2 Level
|
||||
from t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderHeaderID < ?
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join group_resultdetail on T_TestID = Group_ResultDetailT_TestID
|
||||
and Group_ResultDetailGroup_ResultID = 1
|
||||
order by T_OrderHeaderID, T_TestSasCode";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($patientID, $orderID) );
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : History ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$result = array();
|
||||
$prev_date = "";
|
||||
$cur_idx = 0;
|
||||
$max_hist = 4;
|
||||
foreach($rows as $r) {
|
||||
$date = $r["T_OrderHeaderDate"];
|
||||
if ($prev_date != $date ) {
|
||||
if ($cur_idx == $max_hist ) break;
|
||||
$result[]["date"] = $date;
|
||||
$cur_idx = count($result) - 1;
|
||||
$result[$cur_idx]["data"] = array();
|
||||
$result[$cur_idx]["id"] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
$result[$cur_idx]["data"][] = array(
|
||||
"px_name" => $r["T_TestShortName"],
|
||||
"is_result" => $r["T_TestIsResult"],
|
||||
"result" => $r["T_OrderDetailResult"],
|
||||
"flag" => $r["T_OrderDetailResultFlag"],
|
||||
"level" => $r["Level"]
|
||||
);
|
||||
$prev_date = $date ;
|
||||
}
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
class Re_mbv extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo "Api: Training Playground";
|
||||
}
|
||||
function get_note()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT Other_MBVNoteName as name,
|
||||
Other_MBVNoteDescription as description
|
||||
FROM other_mbvnote";
|
||||
$qry = $this->db->query($sql, []);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$raw = $qry->result_array();
|
||||
$result = array("records" => $raw);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function get_doctors()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 7 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
} else {
|
||||
$this->sys_error_db("Rerun rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function get_result_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$sql = "SELECT Other_MBVT_OrderDetailID as detail_id,
|
||||
Other_MBVID as id,
|
||||
Other_MBVSkorNugent as skor_nugent,
|
||||
Other_MBVBahan as bahan,
|
||||
Other_MBVM_DoctorID as doctor_id,
|
||||
Other_MBVDetailsSumLp as sum_lp,
|
||||
Other_MBVDetailsSkor as skor
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN other_mbv
|
||||
ON T_OrderDetailID = Other_MBVT_OrderDetailID
|
||||
AND Other_MBVIsActive = 'Y'
|
||||
JOIN other_mbvdetails
|
||||
ON Other_MBVID = Other_MBVDetailsOther_MBVID
|
||||
AND Other_MBVDetailsIsActive = 'Y'
|
||||
WHERE T_OrderHeaderID = ?
|
||||
AND T_OrderHeaderIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [$id]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$result = $qry->result_array();
|
||||
$this->sys_ok(array("records" => $result));
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveresult_mbv()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// print_r(json_encode($prm['detail']));
|
||||
// exit;
|
||||
$doctor = 0;
|
||||
if (isset($prm['doctor'])) {
|
||||
$doctor = $prm['doctor'];
|
||||
}
|
||||
|
||||
$bahan = 0;
|
||||
if (isset($prm['bahan'])) {
|
||||
$bahan = $prm['bahan'];
|
||||
}
|
||||
|
||||
$data = 0;
|
||||
if (isset($prm['detail'])) {
|
||||
$data = $prm['detail'];
|
||||
}
|
||||
// print_r(json_encode($data));
|
||||
// exit;
|
||||
$skor_nugent = 0;
|
||||
if (isset($prm['skor_nugent'])) {
|
||||
$skor_nugent = $prm['skor_nugent'];
|
||||
}
|
||||
// print_r(json_encode(array("dktr" => $doctor, "dt" => $data, "bhn" => $bahan, "skr" => $skor_nugent,)));
|
||||
// exit;
|
||||
if ($data == 0 || $doctor == 0) {
|
||||
$this->sys_error("result, doctor & bahan are mandatory");
|
||||
// print_r(json_encode(array("dktr" => $doctor == 0, "dt" => $data == 0, "bhn" => $bahan == 0, "skr" => $skor_nugent == 0,)));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
for ($i = 0; $i < count($data); $i++) {
|
||||
if ($data[$i]["xid"] == "0" && $data[$i]["orderdetail_id"] != "0") {
|
||||
//insert other_fna
|
||||
$sql = "INSERT INTO other_mbv
|
||||
(Other_MBVT_OrderDetailID,
|
||||
Other_MBVSkorNugent,
|
||||
Other_MBVBahan,
|
||||
Other_MBVM_DoctorID,
|
||||
Other_MBVUserID,
|
||||
Other_MBVCreated)
|
||||
VALUES(?,?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["orderdetail_id"], $skor_nugent, $bahan,
|
||||
$doctor["id"], 3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
$inserted_id = $this->db->insert_id();
|
||||
$sql = "INSERT INTO other_mbvdetails(
|
||||
Other_MBVDetailsOther_MBVID,
|
||||
Other_MBVDetailsSumLp,
|
||||
Other_MBVDetailsSkor,
|
||||
Other_MBVDetailsUserID,
|
||||
Other_MBVDetailsCreated)
|
||||
VALUES(?,?,?,?, NOW())";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$inserted_id,
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
3
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql = "UPDATE other_mbv SET Other_MBVSkorNugent =? ,
|
||||
Other_MBVBahan = ?,
|
||||
Other_MBVM_DoctorID = ?
|
||||
WHERE Other_MBVID = ? AND Other_MBVIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$skor_nugent,
|
||||
$bahan,
|
||||
intval($doctor["id"]),
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE other_mbvdetails SET Other_MBVDetailsSumLp = ?,
|
||||
Other_MBVDetailsSkor = ?
|
||||
WHERE Other_MBVDetailsOther_MBVID = ? AND Other_MBVDetailsIsActive = 'Y'";
|
||||
$qry =
|
||||
$this->db->query($sql, [
|
||||
$data[$i]["sum_lp"],
|
||||
$data[$i]["skor"],
|
||||
intval($data[$i]["xid"]),
|
||||
]);
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"etc" => $this->db
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("success");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class Re_normal extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$od_id = $prm["order_detail_id"];
|
||||
$sql = "call sp_re_update_normal(?)";
|
||||
$this->db_smartone->query($sql, array($od_id));
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh,
|
||||
T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNormalValueNote,
|
||||
Nat_MethodeName
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_methode on T_OrderDetailNat_MethodeID = Nat_MethodeID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
$qry = $this->db_smartone->query($sql_norm,array($od_id));
|
||||
if ( $qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) {
|
||||
$result = array("status"=>"OK","records" => $rows[0]);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
class Re_normal_method extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Normal Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_normalvalue
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
WHERE Nat_NormalValueIsActive = 'Y' and Nat_MethodeIsActive = 'Y'
|
||||
AND Nat_NormalValueNat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeName";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$prm['nattest_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records" => $rows]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function save_method()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_method_change(?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['detail_id'], $prm['method_id'], $this->sys_user['M_UserID']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$xdata = json_decode($rows[0]["data"],true);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
|
||||
// start fitri update unit
|
||||
$sql = "select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN nat_normalvalue ON Nat_NormalValueID = T_OrderDetailNat_NormalValueID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_NormalValueNat_UnitID
|
||||
where T_OrderDetailID = ?";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$unit_id = $rows[0]["Nat_UnitID"];
|
||||
$unit_name = $rows[0]["Nat_UnitName"];
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
|
||||
}else{
|
||||
$sqlunit = $this->db_smartone->query("select Nat_UnitID,
|
||||
Nat_UnitName
|
||||
from t_orderdetail
|
||||
JOIN t_test ON T_TestID = T_OrderDetailT_TestID
|
||||
JOIN nat_test ON Nat_TestID = T_TestNat_TestID
|
||||
JOIN nat_unit ON Nat_UnitID = Nat_TestNat_UnitID
|
||||
where T_OrderDetailID = '{$prm["detail_id"]}'")->row();
|
||||
$unit_id = $sqlunit->Nat_UnitID;
|
||||
$unit_name = $sqlunit->Nat_UnitName;
|
||||
$query ="UPDATE t_orderdetail SET
|
||||
T_OrderDetailNat_UnitID = '{$unit_id}',
|
||||
T_OrderDetailNat_UnitName = '{$unit_name}'
|
||||
WHERE
|
||||
T_OrderDetailID = '{$prm["detail_id"]}'
|
||||
";
|
||||
$rows = $this->db_smartone->query($query);
|
||||
}
|
||||
}
|
||||
// end fitri update unit
|
||||
|
||||
|
||||
$sql = "select T_OrderDetailNormalValueNote, T_OrderDetailNormalValueDescription,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,T_OrderDetailNat_UnitID,T_OrderDetailNat_UnitName
|
||||
from t_orderdetail where T_OrderDetailID = ? ";
|
||||
$qry2 = $this->db_smartone->query($sql,array($prm["detail_id"]));
|
||||
if ($qry2) {
|
||||
$rows = $qry2->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$xdata["normal_note"] = $rows[0]["T_OrderDetailNormalValueNote"];
|
||||
$xdata["normal_desc"] = $rows[0]["T_OrderDetailNormalValueDescription"];
|
||||
$xdata["method_id"] = $rows[0]["T_OrderDetailNat_MethodeID"];
|
||||
$xdata["method_name"] = $rows[0]["T_OrderDetailNat_MethodeName"];
|
||||
$xdata["unit_id"] = $rows[0]["T_OrderDetailNat_UnitID"];
|
||||
$xdata["unit_name"] = $rows[0]["T_OrderDetailNat_UnitName"];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(['data'=>$xdata, 'query'=>$this->db_smartone->last_query()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Change Methode", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,263 @@
|
||||
<?php
|
||||
|
||||
class Re_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["start_date"] . '%';
|
||||
$edate = $prm["end_date"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id'])) $group_id = $prm['group_id'];
|
||||
|
||||
$company_id = 0;
|
||||
$q_company = "";
|
||||
if (isset($prm['company_id'])) {
|
||||
$company_id = $prm['company_id'];
|
||||
if ($company_id > 0 ) {
|
||||
$q_company = " and T_OrderHeaderCorporateID = $company_id ";
|
||||
}
|
||||
}
|
||||
$q_search = " and
|
||||
( M_PatientName LIKE ?
|
||||
or T_OrderHeaderLabNumber like ?
|
||||
)";
|
||||
if ($prm["search"] == "" ) $q_search = "";
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
$max_rst = 9999;
|
||||
$offset = 0;
|
||||
|
||||
$q_group = "";
|
||||
if ($group_id != 0 ) {
|
||||
$sql = "select T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = $group_id
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " and T_TestNat_TestID in ( $nat_test_ids ) ";
|
||||
}
|
||||
|
||||
//janji hasil hari ini T_OrderHeaderID
|
||||
/* $sql = "select T_OrderPromiseT_OrderHeaderID
|
||||
from t_orderpromise
|
||||
where T_OrderPromiseIsActive = 'Y' and date(T_OrderPromiseDateTime) = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate));
|
||||
$promise_ids = "0";
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderPromiseT_OrderHeaderID"];
|
||||
$promise_ids = join(",",$xids);
|
||||
}
|
||||
}
|
||||
*/
|
||||
$order_ids = 0;
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y' and date(T_OrderHeaderDate) BETWEEN ? AND ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate,$edate));
|
||||
$order_ids = $promise_ids;
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if ( count($xrows) > 0 ) {
|
||||
$xids = array();
|
||||
foreach($xrows as $r) $xids[] = $r["T_OrderHeaderID"];
|
||||
$order_ids = join(",",$xids);
|
||||
}else{
|
||||
$order_ids = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT *,
|
||||
CONCAT('[', GROUP_CONCAT(DISTINCT CONCAT('\"', T_OrderHeaderDate, '\"') SEPARATOR ','), ']') order_promise
|
||||
FROM (
|
||||
select T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderDate,
|
||||
'' T_OrderHeaderLabNumberExt, T_OrderHeaderDiagnose,
|
||||
M_PatientID, M_PatientNoReg, fn_global_patient_name(M_PatientID) M_PatientName,
|
||||
M_PatientDOB, T_OrderHeaderM_PatientAge, M_PatientHP, M_PatientGender M_SexName, '' M_PatientNote,
|
||||
da.M_DoctorID doctor_pj_id, fn_get_doctor_fullname(da.M_DoctorID) doctor_pj_name,
|
||||
0 doctor_sender_id, '' doctor_sender_name,
|
||||
'' M_MouID, '' M_MouName, CorporateID, CorporateName,
|
||||
T_OrderHeaderFoNote, T_OrderHeaderSamplingNote, T_OrderHeaderResultNote,
|
||||
la.M_LangID M_LangID, la.M_LangCode M_LangCode, la.M_LangName M_LangName, '' T_OrderHeaderLangIsSI,
|
||||
la.M_LangID SecondM_LangID, la.M_LangCode SecondM_LangCode, la.M_LangName SecondM_LangName,
|
||||
'' T_OrderHeaderAddOnSecondLangIsSI,
|
||||
'N' T_OrderHeaderIsCito, '' as delivery,
|
||||
'' T_OrderPromiseDateTime, '' is_history,
|
||||
'N' T_OrderHeaderAddOnVerificationDone,
|
||||
'N' T_OrderHeaderAddOnValidationDone, '' T_OrderHeaderAddOnRequestChangeDOB
|
||||
from t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_orderheaderlang ON T_OrderHeaderLangT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
{$q_group}
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
left join m_doctor da on T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN corporate on T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN m_lang la ON T_OrderHeaderLangM_LangID = la.M_LangID
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
{$q_company}
|
||||
{$q_search}
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
) x
|
||||
GROUP BY T_OrderHeaderID
|
||||
order by FIELD(T_OrderHeaderIsCito, 'Y', 'N') ASC, T_OrderHeaderLabNumber
|
||||
";
|
||||
if ($q_search == "" ) {
|
||||
$query = $this->db_smartone->query($sql);
|
||||
} else {
|
||||
$query = $this->db_smartone->query($sql, [ $search, $search]);
|
||||
}
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$tmp_ohnumber = [];
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$lang = [["id"=>0, "code"=>"ID", "is_si"=>"N"]];
|
||||
if ($v['M_LangCode'] != "ID")
|
||||
$lang[] = ["id"=>$v['M_LangID'], "code"=>$v['M_LangCode'], "is_si"=>$v['T_OrderHeaderLangIsSI']];
|
||||
$sqltotal = "SELECT COUNT(T_OrderDetailID) as cnt_rst_a,
|
||||
SUM(IF(T_OrderDetailResult <> '' AND T_OrderDetailResult IS NOT NULL, 1, 0)) as cnt_rst_b,
|
||||
SUM(IF(T_OrderDetailVerification = 'Y', 1, 0)) as cnt_ver_n,
|
||||
SUM(IF(T_OrderDetailValidation = 'Y', 1, 0)) as cnt_val_n
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = {$v['T_OrderHeaderID']}
|
||||
AND T_OrderDetailT_TestIsResult = 'Y'";
|
||||
$sqltotal = $this->db_smartone->query($sqltotal)->row();
|
||||
|
||||
if($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b < $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'P';
|
||||
}elseif($sqltotal->cnt_rst_b > 0 && $sqltotal->cnt_rst_b == $sqltotal->cnt_rst_a){
|
||||
$rows[$k]['T_OrderHeaderAddOnValidationDone'] = 'Y';
|
||||
}
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$rows[$k]['lang'] = $lang;
|
||||
$rows[$k]['delivery'] = JSON_DECODE($v['delivery']);
|
||||
$rows[$k]['order_promise'] = JSON_DECODE($v['order_promise']);
|
||||
|
||||
foreach($rows[$k]['order_promise'] as $l => $w)
|
||||
$rows[$k]['order_promise'][$l] = date('d-m-Y H:i', strtotime($w));
|
||||
}
|
||||
$tot_count = count( $rows );
|
||||
|
||||
$sql = "Select CorporateID, CorporateName
|
||||
from t_orderheader
|
||||
JOIN corporate ON CorporateID = T_OrderHeaderCorporateID AND CorporateIsActive = 'Y'
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ( $order_ids )
|
||||
GROUP BY CorporateID";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$crows = $query->result_array();
|
||||
$crows[] = array("CorporateID" => 0, "CorporateName" => "Semua");
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count,
|
||||
"total_page" => ceil($tot_count/$max_rst),
|
||||
"cur_page" => $page,
|
||||
"records" => $rows,
|
||||
"total_display" => sizeof($rows),
|
||||
"q" => $this->db_smartone->last_query(),
|
||||
"companies"=>$crows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function history()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_history(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$history = json_decode($row->rst);
|
||||
|
||||
$this->sys_ok($history);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("RESULT HISTORY", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_note()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderheader SET T_OrderHeaderResultNote = ?, T_OrderHeaderResultNoteM_UserID = ?
|
||||
WHERE T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$prm['note'], $this->sys_user['M_UserID'], $prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$this->sys_ok($prm['order_id']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT NOTE", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function info_req()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_reqs(?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$s_data = $row->data;
|
||||
$s_data = str_replace("\n"," ",$s_data);
|
||||
$this->sys_ok(json_decode($s_data));
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_error_db("RESULT REQ", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,710 @@
|
||||
<?php
|
||||
|
||||
class Re_px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Px API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 99;
|
||||
|
||||
$id = $prm["order_id"];
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$tot_count = 0;
|
||||
$lq = "";
|
||||
$group_id = 0;
|
||||
if (isset($prm['group_id']))
|
||||
$group_id = $prm['group_id'];
|
||||
|
||||
if ($group_id != 0)
|
||||
{
|
||||
$sql = "select distinct T_WorklistDetailNat_TestID Nat_TestID
|
||||
from t_worklistdetailv2
|
||||
where T_WorklistDetailT_WorklistID = {$group_id}";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
$nat_test_ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$nat_test_ids .= ", " . $r["Nat_TestID"];
|
||||
}
|
||||
$q_group = " ( $nat_test_ids ) ";
|
||||
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime, fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_test tcheck on tcheck.T_TestNat_TestID in {$q_group}
|
||||
and ( tx.T_TestID = tcheck.T_TestID or tx.T_TestSasCode like concat(tcheck.T_TestSasCode,'%'))
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "
|
||||
SELECT a1.*, cOUNT(a2.T_OrderDetailID) level
|
||||
FROM (
|
||||
SELECT IFNULL(y.T_OrderDetailT_TestID, x.T_OrderDetailT_TestID) t_testid,
|
||||
IFNULL(y.T_OrderDetailT_TestName, y.T_OrderDetailT_TestName) t_testname,
|
||||
y.T_OrderDetailResult result, y.T_OrderDetailResult result_old, y.T_OrderDetailNote note, y.T_OrderDetailNote note_old,
|
||||
y.T_OrderDetailID id,
|
||||
y.T_OrderDetailT_TestIsResult is_result, a.T_TestIsQuantitative is_quantitative,
|
||||
y.T_OrderDetailResultFlag result_flag,
|
||||
y.T_OrderDetailNat_NormalValueID normal_id,
|
||||
y.T_OrderDetailNormalValueNote normal_note, y.T_OrderDetailNat_UnitName unit_name,
|
||||
y.T_OrderdetailNat_MethodeID methode_id, y.T_OrderdetailNat_MethodeName methode_name,
|
||||
a.T_TestNat_TestID nattest_id, a.T_TestID tx_id, count(T_ResultInstrumentID) as result_instrument_n,
|
||||
y.T_OrderDetailVerification, T_OrderSampleReceive sample_receive,
|
||||
T_OrderSampleProcessing sample_processing, T_OrderSampleWorklistReceive sample_worklist_receive,
|
||||
IF(T_OrderDetailAddOnPreAnalytic = 'Y', T_OrderDetailAddOnPreAnalytic, PreAnalyticIsOk) pre_analytic,
|
||||
T_OrderDetailAddOnPreAnalytic,
|
||||
T_OrderHeaderID order_id, y.T_OrderDetailT_TestSasCode test_sas_code,
|
||||
tx.T_TestSasCode,
|
||||
T_OrderDetailAddOnResample `resample`, T_OrderDetailAddOnResampleStatus resample_status,
|
||||
T_OrderDetailAddOnRef ref, y.T_OrderDetailVerification verification, y.T_OrderDetailValidation validation,
|
||||
T_OrderPromiseDateTime , fn_process_group_result(x.T_OrderDetailT_TestID) ResultGroupName
|
||||
FROM t_orderdetail x
|
||||
left join t_orderpromise on x.T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test tx ON x.T_OrderDetailT_TestID = T_TestID
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = tx.T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
AND DocumentationGroupName = 'lab'
|
||||
LEFT JOIN t_orderdetail y ON x.T_OrderDetailT_TestSasCode LIKE CONCAT(y.T_OrderDetailT_TestSasCode, '%')
|
||||
AND x.T_OrderDetailT_OrderHeaderID = y.T_OrderDetailT_OrderHeaderID
|
||||
AND y.T_OrderDetailIsActive = 'Y'
|
||||
|
||||
LEFT JOIN t_orderdetailaddon ON x.T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
|
||||
JOIN t_orderheader ON y.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_test a ON y.T_OrderDetailT_TestID = a.T_TestID
|
||||
AND a.T_TestIsNonLab = ''
|
||||
LEFT JOIN (SELECT T_OrderSampleT_SampleTypeID, T_OrderSampleReceive, T_OrderSampleProcessing, T_OrderSampleWorklistReceive
|
||||
FROM t_ordersample WHERE T_OrderSampleT_OrderHeaderID = ?
|
||||
AND T_OrderSampleIsactive = 'Y'
|
||||
GROUP BY T_OrderSampleT_SampleTypeID) os ON a.T_TestT_SampleTypeID = os.T_OrderSampleT_SampleTypeID
|
||||
|
||||
LEFT JOIN t_resultinstrument ON T_ResultInstrumentT_OrderDetailID = x.T_OrderDetailID
|
||||
LEFT JOIN pre_analytic ON PreAnalyticNat_TestID = a.T_TestNat_TestID AND PreAnalyticDate = date(now()) and PreAnalyticIsActive = 'Y'
|
||||
WHERE x.T_OrderDetailT_OrderHeaderID = ?
|
||||
AND x.T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY y.T_OrderDetailT_TestID
|
||||
ORDER BY y.T_OrderDetailT_TestSasCode ASC
|
||||
) a1
|
||||
|
||||
LEFT JOIN t_orderdetail a2 ON a2.T_OrderDetailT_OrderHeaderID = a1.order_id
|
||||
AND a2.T_OrderDetailIsActive = 'Y'
|
||||
AND a1.test_sas_code LIKE CONCAT(a2.T_OrderDetailT_testSasCode, '%')
|
||||
GROUP BY a1.t_testid
|
||||
order by a1.T_TestSasCode
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, [$id, $id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
}
|
||||
// file_put_contents("/xtmp/re-query.sql",$lq);
|
||||
|
||||
if ($query) {
|
||||
$rst = [];
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v)
|
||||
{
|
||||
|
||||
if ($v['is_result'] == "Y" && $v['is_quantitative'] == "N")
|
||||
{
|
||||
$v['template'] = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$v['t_testid']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$v['template'] = $x->result_array();
|
||||
}
|
||||
|
||||
// IF Rujukan, by pas Pre Analytik
|
||||
if ($v['ref'] == 'Y')
|
||||
$v['pre_analytic'] = 'Y';
|
||||
|
||||
$rst[] = $v;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rst, "total_display" => sizeof($rows), "q" => $lq);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RE Px rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
$lang = $this->lang_default_code;
|
||||
$lang_id = isset($prm['lang_id']) ? $prm['lang_id'] : '0';
|
||||
|
||||
if ($lang_id != 0)
|
||||
{
|
||||
$l = $this->db_smartone->where("Nat_LangID", $lang_id)->get("nat_lang")->row();
|
||||
$lang = $l->Nat_LangCode;
|
||||
}
|
||||
|
||||
$sql_norm = "select T_OrderDetailMinValue, T_OrderDetailMaxValue,
|
||||
T_OrderDetailMinValueInclusive, T_OrderDetailMaxValueInclusive,
|
||||
Nat_TestFlagLow, Nat_TestFlagHigh
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestIsActive = 'Y'
|
||||
where T_OrderDetailID = ? ";
|
||||
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
if ( $v->resultInstrumentID > 0 ) {
|
||||
$sql_i = "select T_ResultInstrumentNat_NormalValueID normalValueID
|
||||
from t_resultinstrument
|
||||
where T_ResultInstrumentID = ?";
|
||||
$qry_i = $this->db_smartone->query($sql_i, array($v->resultInstrumentID));
|
||||
if ($qry_i) {
|
||||
$rows_i = $qry_i->result_array();
|
||||
|
||||
if (count($rows_i) > 0 ) {
|
||||
$sql_iu = "update t_orderdetail, nat_normalvalue
|
||||
set T_OrderDetailMinValue = Nat_NormalValueMinValue,
|
||||
T_OrderDetailMinValueInclusive = Nat_NormalValueMinValueInclusive,
|
||||
T_OrderDetailMaxValue = Nat_NormalValueMaxValue ,
|
||||
T_OrderDetailMaxValueInclusive = Nat_NormalValueMaxValueInclusive,
|
||||
T_OrderDetailNormalValueNote = Nat_NormalValueNote,
|
||||
T_OrderDetailNormalValueDescription = Nat_NormalValueDescription,
|
||||
T_OrderDetailNat_NormalValueID = Nat_NormalValueID
|
||||
where T_OrderDetailID = ? and Nat_NormalValueID = ?
|
||||
";
|
||||
$this->db_smartone->query($sql_iu, array($v->id, $rows_i[0]["normalValueID"]));
|
||||
//file_put_contents("/xtmp/update-nilai-normal", $this->db_smartone->last_query() . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
$y = $this->db_smartone->query("SELECT fn_process_sample_handling_perfect('{$v->order_id}', '{$v->test_id}') c")
|
||||
->row();
|
||||
$req_status = $y->c;
|
||||
$qry_norm = $this->db_smartone->query($sql_norm,$v->id);
|
||||
$result_flag = "";
|
||||
if ($qry_norm) {
|
||||
$rows_norm = $qry_norm->result_array();
|
||||
if (count($rows_norm) > 0 ) {
|
||||
$r = $rows_norm[0];
|
||||
if (is_numeric($v->result)) {
|
||||
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "Y" && $v->result < $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMinValueInclusive"] == "N" && $v->result <= $r["T_OrderDetailMinValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagLow"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "Y" && $v->result > $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
if ( $r["T_OrderDetailMaxValueInclusive"] == "N" && $v->result >= $r["T_OrderDetailMaxValue"] ) {
|
||||
$result_flag = $r["Nat_TestFlagHigh"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($lang == $this->lang_default_code)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailResult', $v->result)
|
||||
->set('T_OrderDetailResultFlag', $result_flag)
|
||||
->set('T_OrderDetailNote', $v->note)
|
||||
->set('T_OrderDetailReqStatus', $req_status)
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailLangResult', $v->result)
|
||||
->set('T_OrderDetailLangNote', $v->note)
|
||||
->where('T_OrderDetailLangID', $v->id)
|
||||
->update('t_orderdetaillang');
|
||||
}
|
||||
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Entry')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', json_encode($data))
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
//auto calculation
|
||||
$this->load->library("Resultcalc");
|
||||
$rows = $this->resultcalc->auto($order->id);
|
||||
|
||||
try {
|
||||
foreach($ids as $id ) {
|
||||
$this->db_smartone->query("call sp_set_normal_value_flag($id)");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
|
||||
public function save_template()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$n = $this->db_smartone->select("COUNT(T_ResultTemplateID) n")
|
||||
->where("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->where("T_ResultTemplateIsActive", "Y")
|
||||
->where("T_ResultTemplateValue", $prm['value'])
|
||||
->get('t_resulttemplate')
|
||||
->row();
|
||||
if ($n->n > 0)
|
||||
{
|
||||
$this->sys_error_db("Insert Result Template", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$r = $this->db_smartone->set("T_ResultTemplateT_TestID", $prm['test_id'])
|
||||
->set("T_ResultTemplateValue", $prm['value'])
|
||||
->insert('t_resulttemplate');
|
||||
if ($r)
|
||||
{
|
||||
$template = [];
|
||||
$x = $this->db_smartone->query("CALL sp_master_resulttemplate_get('{$prm['test_id']}')");
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
if ($x)
|
||||
$template = $x->result_array();
|
||||
|
||||
$this->sys_ok($template);
|
||||
}
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_process_result_lang(?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id'], $prm['lang_id'], $prm['is_si'], $this->sys_user['M_UserID']]);
|
||||
if ($query)
|
||||
{
|
||||
$r = $query->row();
|
||||
if ($r->status == "OK")
|
||||
{
|
||||
$this->sys_ok($r->data);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("Message : " . $r->message, $this->db_smartone);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Lang Result", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_group()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 100;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_WorklistID group_id, T_WorklistName group_name
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$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("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_rerun()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["detail_id"];
|
||||
|
||||
$sql = "CALL sp_process_result_rerun(?)";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdoctorsfna()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
// $id = $prm["id"];
|
||||
|
||||
$sql = " SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getfnaresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_FNADetailsID as xid,
|
||||
Other_FNAT_OrderDetailID as orderdetail_id,
|
||||
Other_FNADetailsCode as code,
|
||||
Other_FNADetailsLabel as label,
|
||||
Other_FNADetailsResult as result,
|
||||
IFNULL(Other_FNAM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_FNAM_DoctorID) OR Other_FNAM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_fna
|
||||
JOIN other_fnadetails ON Other_FNADetailsOther_FNAID = Other_FNAID AND Other_FNADetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_FNAM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_FNAT_OrderDetailID = {$id} AND Other_FNAIsActive = 'Y'
|
||||
GROUP BY Other_FNADetailsID
|
||||
ORDER BY Other_FNADetailsCode ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Rerun rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getpapsmearresult()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = " SELECT Other_PapSmearDetailsID as xid,
|
||||
Other_PapSmearID as header_id,
|
||||
Other_PapSmearT_OrderDetailID as orderdetail_id,
|
||||
Other_PapSmearDetailsCode as code,
|
||||
Other_PapSmearDetailsLabel as label,
|
||||
Other_PapSmearDetailsResult as result,
|
||||
IFNULL(Other_PapSmearM_DoctorID,0) as doctor_id,
|
||||
IF(ISNULL(Other_PapSmearM_DoctorID) OR Other_PapSmearM_DoctorID = 0 ,'0', CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3)) as doctor_name
|
||||
FROM other_papsmear
|
||||
JOIN other_papsmeardetails ON Other_PapSmearDetailsOther_PapSmearID = Other_PapSmearID AND Other_PapSmearDetailsIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON Other_PapSmearM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
Other_PapSmearT_OrderDetailID = {$id} AND Other_PapSmearIsActive = 'Y'
|
||||
GROUP BY Other_PapSmearDetailsID
|
||||
ORDER BY Other_PapSmearDetailsCode ASC";
|
||||
//echo $sql;
|
||||
$rows = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$rows){
|
||||
$rows = array(
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'A',
|
||||
'label' => 'Makroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'B',
|
||||
'label' => 'Mikroskopik',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
),
|
||||
array(
|
||||
'xid' => '0',
|
||||
'header_id' => '0',
|
||||
'orderdetail_id' => $id,
|
||||
'code' => 'C',
|
||||
'label' => 'Kesimpulan',
|
||||
'result' => '',
|
||||
'doctor_id' => '0',
|
||||
'doctor_name' => ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$header_id = $rows[0]['header_id'];
|
||||
$sql = "SELECT Other_PapSmearMaturasiID as xid,
|
||||
Other_PapSmearMaturasiValue as value
|
||||
FROM other_papsmearmaturasi
|
||||
WHERE
|
||||
Other_PapSmearMaturasiOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearMaturasiIsActive = 'Y'
|
||||
";
|
||||
$maturasi = $this->db_smartone->query($sql)->result_array();
|
||||
if(!$maturasi){
|
||||
$maturasi = array('xid'=>'0','value'=>'//');
|
||||
}
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearBahanID,0) as xid,
|
||||
M_PapSmearBahanID as bahan_id,
|
||||
M_PapSmearBahanName as name
|
||||
FROM m_papsmearbahan
|
||||
LEFT JOIN other_papsmearbahan ON Other_PapSmearBahanM_PapSmearBahanID = M_PapSmearBahanID AND
|
||||
Other_PapSmearBahanOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearBahanIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearBahanIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$bahans = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapsmearCategoryID,0) as xid,
|
||||
M_PapSmearCategoryID as category_id,
|
||||
M_PapSmearCategoryName as name
|
||||
FROM m_papsmearcategory
|
||||
LEFT JOIN other_papsmearcategory ON Other_PapsmearCategoryM_PapSmearCategoryID = M_PapSmearCategoryID AND
|
||||
Other_PapsmearCategoryOther_PapSmearID = {$header_id} AND
|
||||
Other_PapsmearCategoryIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCategoryIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$categories = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT IFNULL(Other_PapSmearCheckID,0) as xid,
|
||||
M_PapSmearCheckID as check_id,
|
||||
M_PapSmearCheckLabel as name,
|
||||
Other_PapSmearCheckNote as note
|
||||
FROM m_papsmearcheck
|
||||
LEFT JOIN other_papsmearcheck ON Other_PapSmearCheckM_PapSmearCheckID = M_PapSmearCheckID AND
|
||||
Other_PapSmearCheckOther_PapSmearID = {$header_id} AND
|
||||
Other_PapSmearCheckIsActive = 'Y'
|
||||
WHERE
|
||||
M_PapSmearCheckIsActive = 'Y'
|
||||
";
|
||||
$checks = $this->db_smartone->query($sql)->result_array();
|
||||
|
||||
$sql = "
|
||||
SELECT '0' as id, 'Belum memilih dokter' as name
|
||||
UNION
|
||||
SELECT M_DoctorID as id, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name
|
||||
FROM m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID AND
|
||||
M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorSONat_SubGroupID = 9 AND
|
||||
M_DoctorSOIsActive = 'Y'
|
||||
ORDER BY name ASC";
|
||||
//echo $sql;
|
||||
$doctors = $this->db_smartone->query($sql)->result_array();
|
||||
$rst = array('doctors'=>$doctors,'checks'=>$checks,'bahans'=>$bahans,'categories'=>$categories,'results'=>$rows);
|
||||
$this->sys_ok(["records"=>$rst]);
|
||||
|
||||
}
|
||||
|
||||
function saveresult_fna()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
$prm = $inp['results'];
|
||||
$doctor_id = $inp['doctor'];
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$header_id = 0;
|
||||
if($prm[0]['xid'] == '0'){
|
||||
$sql = "INSERT INTO other_fna(
|
||||
Other_FNAM_DoctorID,
|
||||
Other_FNAT_OrderDetailID,
|
||||
Other_FNAUserID,
|
||||
Other_FNACreated
|
||||
)
|
||||
VALUES(
|
||||
{$doctor_id},
|
||||
{$prm[0]['orderdetail_id']},
|
||||
{$userid},
|
||||
NOW()
|
||||
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_smartone->query($sql);
|
||||
$header_id = $this->db_smartone->insert_id();
|
||||
}
|
||||
foreach($prm as $k => $v){
|
||||
if($v['xid'] == '0'){
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "INSERT INTO other_fnadetails(
|
||||
Other_FNADetailsOther_FNAID ,
|
||||
Other_FNADetailsCode,
|
||||
Other_FNADetailsLabel,
|
||||
Other_FNADetailsResult,
|
||||
Other_FNADetailsCreated,
|
||||
Other_FNADetailsUserID
|
||||
)
|
||||
VALUES(
|
||||
{$header_id},
|
||||
'{$v['code']}',
|
||||
'{$v['label']}',
|
||||
'{$results}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
else{
|
||||
$results = str_replace("'", "\\'", $v['result']);
|
||||
$sql = "UPDATE other_fnadetails SET
|
||||
Other_FNADetailsResult = '{$results}',
|
||||
Other_FNADetailsUserID = {$userid}
|
||||
WHERE
|
||||
Other_FNADetailsID = {$v['xid']}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => array(), "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,621 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_validation extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Result Validation API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function mr_state()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["order_id"];
|
||||
|
||||
$data = [
|
||||
"image" => "http://blog.aylien.com/wp-content/uploads/2016/07/Screen-Shot-2016-07-21-at-18.46.42.png",
|
||||
"note" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
"title" => "Multi Rule"
|
||||
];
|
||||
$this->sys_ok($data);
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
|
||||
if (sizeof($data) < 1) {
|
||||
$this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
exit;
|
||||
} else {
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v) {
|
||||
$mr_state = "X";
|
||||
if (isset($v->mr_state[0])) $mr_state = $v->mr_state[0];
|
||||
$qry = $this->db_smartone->set('T_OrderDetailValMRState', $mr_state)
|
||||
->set('T_OrderDetailValidation', $v->validation)
|
||||
->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation1', $v->validation)
|
||||
->set('T_OrderDetailValidation1Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->set('T_OrderDetailValidation2', $v->validation)
|
||||
->set('T_OrderDetailValidation2Time', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
->set('T_OrderDetailValidation1UserID', $this->sys_user['M_UserID'])
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
if (!$qry) {
|
||||
print_r($this->db_smartone->error());
|
||||
}
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$sql_order = "SELECT
|
||||
T_OrderDetailT_OrderHeaderID
|
||||
FROM t_orderdetail
|
||||
WHERE T_OrderDetailID = ? and T_OrderDetailIsActive = 'Y'";
|
||||
$qry_order = $this->db_smartone->query($sql_order, [$data[0]->id]);
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($qry_order) {
|
||||
$row = $qry_order->row_array();
|
||||
} else {
|
||||
$this->sys_error_db("select orderheader", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select
|
||||
T_OrderHeaderID,T_OrderHeaderLabNumber,
|
||||
T_TestName, T_OrderDetailID, T_OrderDetailResult, T_OrderDetailNat_MethodeID,
|
||||
T_OrderDetailNat_MethodeID, T_OrderDetailNat_MethodeName,
|
||||
T_OrderDetailMinValue, T_OrderDetailMaxValue, T_OrderDetailMinValueInclusive,
|
||||
T_OrderDetailMaxValueInclusive,
|
||||
Mcu_SummaryLabID,
|
||||
Mcu_SummaryLabValue,
|
||||
Mcu_SummaryLabNat_MethodeID,
|
||||
Mcu_SummaryLabWithMethode,
|
||||
Mcu_SummaryLabType,
|
||||
Mcu_SummaryLabIsNormalValue,
|
||||
Mcu_KelainanID, Mcu_KelainanName, Mcu_KelainanClasification,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
mcu_kelainangroup.*
|
||||
from t_orderdetail
|
||||
join t_orderheader on T_OrderHeaderID = ?
|
||||
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
join t_test
|
||||
on T_OrderDetailT_TestID = T_TestID
|
||||
join nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
join mcu_summarylab on T_TestNat_TestID = Mcu_SummaryLabNat_TestID AND Mcu_SummaryLabIsActive = 'Y'
|
||||
join mcu_kelainan on Mcu_SummaryLabMcu_KelainanID = Mcu_KelainanID
|
||||
join mcu_kelainangroup on Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID";
|
||||
$qry = $this->db_smartone->query($sql, array($row["T_OrderDetailT_OrderHeaderID"]));
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error get order | " . $this->db_smartone->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
$results = [];
|
||||
|
||||
$sql_upd = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabIsActive = 'N',
|
||||
T_KelainanLabCreatedUserID = {$this->sys_user['M_UserID']}
|
||||
WHERE T_KelainanLabT_OrderHeaderID = {$rows[0]['T_OrderHeaderID']}";
|
||||
$qry_upd = $this->db_smartone->query($sql_upd);
|
||||
if (!$qry_upd) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$result_value = $r['T_OrderDetailResult'];
|
||||
|
||||
$value_comparison = 0;
|
||||
//echo $r['Mcu_SummaryLabIsNormalValue'];
|
||||
$kelainan = [];
|
||||
$notavailable = [];
|
||||
if (trim($result_value) == 'NA') {
|
||||
$notavailable = $r;
|
||||
} elseif ($r['Mcu_SummaryLabIsNormalValue'] == 'Y') {
|
||||
if ($r['Mcu_SummaryLabType'] == '<' || $r['Mcu_SummaryLabType'] == '<=') {
|
||||
$value_comparison = $r['T_OrderDetailMinValue'];
|
||||
}
|
||||
if ($r['Mcu_SummaryLabType'] == '>' || $r['Mcu_SummaryLabType'] == '>=') {
|
||||
$value_comparison = $r['T_OrderDetailMaxValue'];
|
||||
}
|
||||
//echo "Y";
|
||||
if ($r['Mcu_SummaryLabWithMethode'] == 'N' && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
$value_comparison = $r['Mcu_SummaryLabValue'];
|
||||
if ($r['Mcu_SummaryLabType'] == '!=' || $r['Mcu_SummaryLabType'] == '==') {
|
||||
if ($this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
} else {
|
||||
if (is_numeric($result_value) && $this->dynamic_comparison($result_value, $r['Mcu_SummaryLabType'], $value_comparison)) {
|
||||
//echo $r['T_TestName']." : ".$r['Mcu_KelainanName'].", ";
|
||||
$kelainan = $r;
|
||||
$results[] = array('test' => $r['T_TestName'], 'nat_test' => $r['Nat_TestCode'], 'kelainan' => $r['Mcu_KelainanName'], 'orderdetailID' => $r['T_OrderDetailID'], 'orderheaderID' => $r['T_OrderHeaderID'], 'nat_testID' => $r['Nat_TestID'], 'mcu_summarylabID' => $r['Mcu_SummaryLabID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($results) > 0) {
|
||||
|
||||
foreach ($results as $v_result) {
|
||||
$sql_kel_lab = "SELECT *
|
||||
FROM t_kelainan_lab
|
||||
WHERE T_KelainanLabIsActive = 'Y'
|
||||
AND T_KelainanLabT_OrderDetailID = ?";
|
||||
$qry_kel_lab = $this->db_smartone->query($sql_kel_lab, array($v_result['orderdetailID']));
|
||||
if ($qry_kel_lab) {
|
||||
$rows_kel = $qry_kel_lab->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select kelainan lab", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows_kel) > 0) {
|
||||
|
||||
// print_r($v_result['orderdetailID']);
|
||||
// exit;
|
||||
|
||||
$sql_update_kel = "UPDATE t_kelainan_lab
|
||||
SET T_KelainanLabT_OrderDetailID = ?,
|
||||
T_KelainanLabT_OrderHeaderID = ?,
|
||||
T_KelainanLabNat_TestID = ?,
|
||||
T_KelainanLabMcu_SummaryLabID = ?,
|
||||
T_KelainanLabCreatedUserID = ?,
|
||||
T_KelainanLabCreated = NOW()
|
||||
WHERE T_KelainanLabID = ?";
|
||||
$qry_update_kel = $this->db_smartone->query($sql_update_kel, array(
|
||||
$v_result['orderdetailID'],
|
||||
$v_result['orderheaderID'],
|
||||
$v_result['nat_testID'],
|
||||
$v_result['mcu_summarylabID'],
|
||||
$this->sys_user['M_UserID'],
|
||||
$rows_kel[0]['T_KelainanLabID']
|
||||
));
|
||||
if (!$qry_update_kel) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error update lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// print_r('insert');
|
||||
// exit;
|
||||
$sql_insert_lab = "INSERT INTO t_kelainan_lab(
|
||||
T_KelainanLabT_OrderDetailID,
|
||||
T_KelainanLabT_OrderHeaderID,
|
||||
T_KelainanLabNat_TestID,
|
||||
T_KelainanLabMcu_SummaryLabID,
|
||||
T_KelainanLabCreatedUserID,
|
||||
T_KelainanLabCreated) VALUES(
|
||||
{$v_result['orderdetailID']},
|
||||
{$v_result['orderheaderID']},
|
||||
{$v_result['nat_testID']},
|
||||
{$v_result['mcu_summarylabID']},
|
||||
{$this->sys_user['M_UserID']},
|
||||
NOW())";
|
||||
$qry_insert_lab = $this->db_smartone->query($sql_insert_lab);
|
||||
|
||||
if (!$qry_insert_lab) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db('error', 'Error insert kelainan lab: ' . $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// END OF Log Process
|
||||
//update validation multi
|
||||
//$this->load->library("Txbranchstatus");
|
||||
// $this->txbranchstatus->update_multi("VALIDATION",$ids,$this->sys_user['M_StaffName']);
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
}
|
||||
|
||||
function dynamic_comparison($varleft, $op, $varright)
|
||||
{
|
||||
|
||||
switch ($op) {
|
||||
case "=":
|
||||
return $varleft == $varright;
|
||||
case "!=":
|
||||
return $varleft != $varright;
|
||||
case ">=":
|
||||
return $varleft >= $varright;
|
||||
case "<=":
|
||||
return $varleft <= $varright;
|
||||
case ">":
|
||||
return $varleft > $varright;
|
||||
case "<":
|
||||
return $varleft < $varright;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// public function validate()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $data = json_decode($prm["data"]);
|
||||
|
||||
// if (sizeof($data) < 1)
|
||||
// {
|
||||
// $this->sys_error_db("RE Validation Confirmation", $this->db_smartone);
|
||||
// exit;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $ids = [];
|
||||
// foreach ($data as $k => $v)
|
||||
// {
|
||||
// $this->db_smartone->set('T_OrderDetailValMRState', $v->mr_state)
|
||||
// ->set('T_OrderDetailValidation', $v->validation)
|
||||
// ->set('T_OrderDetailValDate', $v->validation == "Y" ? date('Y-m-d H:i:s') : null)
|
||||
// ->set('T_OrderDetailValUserID', $this->sys_user['M_UserID'])
|
||||
// ->where('T_OrderDetailID', $v->id)
|
||||
// ->update('t_orderdetail');
|
||||
// $ids[] = $v->id;
|
||||
// }
|
||||
|
||||
// // LOG Process
|
||||
// $order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
// ->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
// ->where('T_OrderDetailID', $data[0]->id)
|
||||
// ->get('t_orderdetail')
|
||||
// ->row();
|
||||
|
||||
// $dblog = $this->load->database("onelog", true);
|
||||
// $dblog->set('Log_ProcessCode', 'PROCESS.Result.Validation')
|
||||
// ->set('Log_ProcessOrderID', $order->id)
|
||||
// ->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
// ->set('Log_ProcessJson', json_encode($data))
|
||||
// ->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
// ->insert('log_process');
|
||||
// // END OF Log Process
|
||||
|
||||
// $this->sys_ok($ids);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
function print_count()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->firstprint();
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = T_OrderDetailPrintCount + 1
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailValidation = 'Y'
|
||||
AND T_OrderDetailIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$prm['order_id']]);
|
||||
if ($query) {
|
||||
$this->sys_ok($this->db_smartone->last_query());
|
||||
} else
|
||||
$this->sys_error_db("Print Count", $this->db_smartone);
|
||||
}
|
||||
|
||||
public function reject()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "CALL sp_process_result_validation_reject(?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$prm['id'], $prm['action']]);
|
||||
|
||||
if ($query) {
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
} else {
|
||||
$this->sys_error_db("REJECT VALIDATION", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
|
||||
public function unvalidate()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm["order_id"];
|
||||
|
||||
$this->db_smartone->set('T_OrderDetailValidation', "N")
|
||||
->set('T_OrderDetailValDate', null)
|
||||
->set('T_OrderDetailValUserID', 0)
|
||||
->set('T_OrderDetailValidation1', "N")
|
||||
->set('T_OrderDetailValidation1Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->set('T_OrderDetailValidation2', "N")
|
||||
->set('T_OrderDetailValidation2Time', null)
|
||||
->set('T_OrderDetailValidation1UserID', 0)
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->where('T_OrderDetailIsActive', 'Y')
|
||||
->where('T_OrderDetailValidation', 'Y')
|
||||
->update('t_orderdetail');
|
||||
|
||||
$q = $this->db_smartone->last_query();
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailT_OrderHeaderID', $prm['order_id'])
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
/* $dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Unvalidation')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', '{}')
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
*/
|
||||
$this->sys_ok($q);
|
||||
}
|
||||
|
||||
// Copas Fajri
|
||||
function firstprint()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm['T_OrderHeaderID'] = $prm['order_id'];
|
||||
$datarows = [];
|
||||
$query = " SELECT T_OrderDetailID,T_TestName
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName = 'lab'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDetailValidation = 'Y' AND
|
||||
T_OrderDetailPrintCount = 0 AND
|
||||
T_OrderDetailT_OrderPromiseID <> 0 AND
|
||||
( T_OrderDetailResult <> '' OR T_OrderDetailResult IS NOT NULL ) AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_OrderDetailID";
|
||||
//echo $query;
|
||||
$datarows = $this->db_smartone->query($query)->result_array();
|
||||
$ids = array();
|
||||
$testname = array();
|
||||
if ($datarows) {
|
||||
foreach ($datarows as $k => $v) {
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailPrintCount = 1 WHERE T_OrderDetailID = {$v['T_OrderDetailID']}";
|
||||
$this->db_smartone->query($sql);
|
||||
array_push($ids, $v['T_OrderDetailID']);
|
||||
array_push($testname, $v['T_TestName']);
|
||||
}
|
||||
}
|
||||
$join_ids = "[" . join(",", $ids) . "]";
|
||||
$join_testname = "[" . join(",", $testname) . "]";
|
||||
|
||||
$sql = "SELECT t_orderdelivery.*, M_DeliveryTypeCode as code
|
||||
FROM t_orderdelivery
|
||||
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
";
|
||||
//echo $sql;
|
||||
$result_delivery = $this->db_smartone->query($sql)->result_array();
|
||||
$arr_deliveryid = array();
|
||||
foreach ($result_delivery as $i => $j) {
|
||||
array_push($arr_deliveryid, $j["T_OrderDeliveryM_DeliveryID"]);
|
||||
}
|
||||
|
||||
foreach ($result_delivery as $k => $v) {
|
||||
|
||||
if ($v['code'] == 'PICKUP') {
|
||||
$sql = "INSERT INTO result_frontoffice(
|
||||
Result_FrontOfficeT_OrderHeaderID,
|
||||
Result_FrontOfficeIds,
|
||||
Result_FrontOfficeStatus,
|
||||
Result_FrontOfficeType,
|
||||
Result_FrontOfficeTestName,
|
||||
Result_FrontOfficeCreated,
|
||||
Result_FrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_FrontOfficeStatus = 'P',
|
||||
Result_FrontOfficeUserID = {$userid}
|
||||
";
|
||||
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_frontoffice
|
||||
WHERE Result_FrontOfficeT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_FrontOfficeIds = '{$join_ids}' AND
|
||||
Result_FrontOfficeType = 'lab'";
|
||||
$rst_log = $this->db_smartone->query($sql)->result_array();
|
||||
$dt_log = json_encode($rst_log);
|
||||
$sql = "INSERT INTO one_log.log_result_front_office(
|
||||
Log_ResultFrontOfficeDateTime,
|
||||
Log_ResultFrontOfficeJson,
|
||||
Log_ResultFrontOfficeUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'EMAIL') {
|
||||
$type = "MANUAL";
|
||||
if (in_array(1, $arr_deliveryid) && (in_array(3, $arr_deliveryid) || in_array(5, $arr_deliveryid) || in_array(11, $arr_deliveryid))) {
|
||||
$type = "FO";
|
||||
}
|
||||
$sql = "INSERT INTO result_sendemail(
|
||||
Result_SendEmailT_OrderHeaderID,
|
||||
Result_SendEmailActionBy,
|
||||
Result_SendEmailIds,
|
||||
Result_SendEmailT_OrderDeliveryID,
|
||||
Result_SendEmailStatus,
|
||||
Result_SendEmailType,
|
||||
Result_SendEmailT_TestName,
|
||||
Result_SendEmailCreated,
|
||||
Result_SendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$type}',
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendEmailStatus = 'P',
|
||||
Result_SendEmailUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendemail
|
||||
WHERE
|
||||
Result_SendEmailT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendEmailIds = '{$join_ids}' AND
|
||||
Result_SendEmailT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendEmailType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendemail (
|
||||
Log_ResultSendEmailDatetime,
|
||||
Log_ResultSendEmailJson,
|
||||
Log_ResultSendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
if ($v['code'] == 'ADDRESS') {
|
||||
$sql = "INSERT INTO result_sendcourier(
|
||||
Result_SendCourierT_OrderHeaderID,
|
||||
Result_SendCourierIds,
|
||||
Result_SendCourierT_OrderDeliveryID,
|
||||
Result_SendCourierStatus,
|
||||
Result_SendCourierType,
|
||||
Result_SendCourierT_TestName,
|
||||
Result_SendCourierCreated,
|
||||
Result_SendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
'{$join_ids}',
|
||||
{$v['T_OrderDeliveryID']},
|
||||
'P',
|
||||
'lab',
|
||||
'Pemeriksaan Laboratorium',
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Result_SendCourierStatus = 'P',
|
||||
Result_SendCourierUserID = {$userid}
|
||||
";
|
||||
$this->db_smartone->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM result_sendcourier
|
||||
WHERE
|
||||
Result_SendCourierT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND
|
||||
Result_SendCourierIds = '{$join_ids}' AND
|
||||
Result_SendCourierT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_SendCourierType = 'lab' LIMIT 1";
|
||||
$dt_log = json_encode($this->db_smartone->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendcourier (
|
||||
Log_ResultSendCourierDateTime,
|
||||
Log_ResultSendCourierJson,
|
||||
Log_ResultSendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_smartone->query($sql);
|
||||
}
|
||||
|
||||
|
||||
//echo $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
// $result = array(
|
||||
// "total" => count($datarows) ,
|
||||
// "records" => $datarows,
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
const URL = "/one-api/mockup/process/cpone-process-resultentry-v21/";
|
||||
|
||||
export async function search(token, qry, c_token) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'company/search', {
|
||||
token: token,
|
||||
qry: qry
|
||||
},{ cancelToken : c_token });
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data.data;
|
||||
return {
|
||||
status: "OK",
|
||||
data : data
|
||||
};
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
const URL = "/one-api/mockup/process/cpone-process-resultentry-v21/";
|
||||
|
||||
export async function calc_age(prm ) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'helper/calc_age', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: "OK",
|
||||
data : resp.data.data
|
||||
};
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function check_status_print(prm ) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'helper/check_status_print', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: "OK",
|
||||
data : resp.data.data
|
||||
};
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function insertlogprint(prm ) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'helper/insertlogprint', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: "OK",
|
||||
data : resp.data.data
|
||||
};
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
const URL = "/one-api/mockup/process/cpone-process-resultentry-v21/";
|
||||
|
||||
export async function history(token, order_id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'history/search_v2', {
|
||||
token: token,
|
||||
order_id: order_id
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
const URL = "/one-api/mockup/process/cpone-process-resultentry-v21/";
|
||||
|
||||
export async function update(token, order_detail_id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_normal/update', {
|
||||
token: token,
|
||||
order_detail_id
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
const URL = "/one-api/mockup/process/cpone-process-resultentry-v21/";
|
||||
|
||||
export async function search_method(token, nattest_id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_normal_method/search_method', {
|
||||
token: token,
|
||||
nattest_id: nattest_id
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function save_method(token, detail_id, method_id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_normal_method/save_method', {
|
||||
token: token,
|
||||
detail_id: detail_id,
|
||||
method_id: method_id
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
const URL = "/one-api/mockup/process/cpone-process-resultentry-v21/";
|
||||
|
||||
export async function search(token, sdate, edate, search, group_id, page, company_id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_patient/search', {
|
||||
token: token,
|
||||
start_date: sdate,
|
||||
end_date: edate,
|
||||
search: search,
|
||||
group_id: group_id,
|
||||
page: page,
|
||||
company_id : company_id
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function save_note(token, order_id, note) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_patient/save_note', {
|
||||
token: token,
|
||||
order_id: order_id,
|
||||
note: note
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function info_req(token, order_id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_patient/info_req', {
|
||||
token: token,
|
||||
order_id: order_id
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,574 @@
|
||||
const URL = "/one-api/mockup/process/cpone-process-resultentry-v21/";
|
||||
|
||||
export async function search(token, order_id, lang_id, lang_si, group_id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/search', {
|
||||
token: token,
|
||||
order_id: order_id,
|
||||
lang_id: lang_id,
|
||||
lang_si: lang_si,
|
||||
group_id: group_id
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function save(token, lang_id, is_si, datax) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/save', {
|
||||
token: token,
|
||||
lang_id: lang_id,
|
||||
is_si: is_si,
|
||||
data: datax
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function confirm(token, datax) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'rv_validation/confirm', {
|
||||
token: token,
|
||||
data: datax
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function unvalidate(token, id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 'rv_validation/unvalidate', {
|
||||
token: token,
|
||||
order_id: id
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function uploadimage(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/uploadimage',prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function save_template(token, test_id, value) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/save_template', {
|
||||
token: token,
|
||||
test_id: test_id,
|
||||
value: value
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
export async function savererun(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/savererun', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function lang_export(token, order_id, lang_id, is_si) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/export', {
|
||||
token: token,
|
||||
order_id: order_id,
|
||||
lang_id: lang_id,
|
||||
is_si: is_si
|
||||
});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function search_group() {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/search_group', {});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function search_rerun(detail_id) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/search_rerun', {detail_id: detail_id});
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function getmikroresult(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/getmikroresult', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function getpapsmearresult(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/getpapsmearresult', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getantibiotics(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/getantibiotics', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getlcprepresult(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/getlcprepresult', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getfnaresult(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/getfnaresult', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getcytologiresult(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/getcytologiresult', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function saveresult_mikro(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/saveresult_mikro', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveresult_papsmear(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/saveresult_papsmear', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function saveresult_lcprep(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/saveresult_lcprep', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function get_doctors(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/getdoctorsfna', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function saveresult_fna(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/saveresult_fna', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function saveresult_cytologi(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/saveresult_cytologi', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function uploadimage_preparasi_sperma(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/uploadimage_preparasi_sperma', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function getpreparasispermaresult(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/getpreparasispermaresult', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function saveresult_preparasi_sperma(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/saveresult_preparasi_sperma', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function get_doctors_preparasi_sperma(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/get_doctors_preparasi_sperma', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function getdnafragmentasiresult(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/getdnafragmentasiresult', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function saveresult_dnafragmentasi(prm) {
|
||||
try {
|
||||
var resp = await axios.post(URL + 're_px/saveresult_dnafragmentasi', prm);
|
||||
if (resp.status != 200) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: resp.statusText
|
||||
};
|
||||
}
|
||||
let data = resp.data;
|
||||
return data;
|
||||
} catch(e) {
|
||||
return {
|
||||
status: "ERR",
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<v-menu
|
||||
v-model="menu2"
|
||||
:close-on-content-click="false"
|
||||
:nudge-right="40"
|
||||
lazy
|
||||
transition="scale-transition"
|
||||
offset-y
|
||||
full-width
|
||||
max-width="290px"
|
||||
min-width="290px"
|
||||
>
|
||||
<v-text-field
|
||||
slot="activator"
|
||||
v-model="computedDateFormatted"
|
||||
:label=init_label
|
||||
hint="DD-MM-YYYY format"
|
||||
persistent-hint
|
||||
readonly
|
||||
solo
|
||||
hide-details
|
||||
class="ma-1"
|
||||
></v-text-field>
|
||||
<v-date-picker v-model="init_date" no-title @input="menu2 = false"></v-date-picker>
|
||||
</v-menu>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
props : ['label', 'date', 'data'],
|
||||
|
||||
data () {
|
||||
return {
|
||||
init_date: this.date ? this.date : new Date().toISOString().substr(0, 10),
|
||||
dateFormatted: this.formatDate(new Date().toISOString().substr(0, 10)),
|
||||
menu1: false,
|
||||
menu2: false,
|
||||
|
||||
init_label: this.label ? this.label : 'Date',
|
||||
init_data: this.data ? this.data : ''
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
computedDateFormatted () {
|
||||
return this.formatDate(this.init_date)
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
init_date (n, o) {
|
||||
this.dateFormatted = this.formatDate(this.init_date)
|
||||
|
||||
this.$emit('change', {"old_date":o, "new_date":n, "data":this.init_data});
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
formatDate (date) {
|
||||
if (!date) return null
|
||||
|
||||
const [year, month, day] = date.split('-')
|
||||
return `${day}-${month}-${year}`
|
||||
},
|
||||
parseDate (date) {
|
||||
if (!date) return null
|
||||
|
||||
const [month, day, year] = date.split('/')
|
||||
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`
|
||||
},
|
||||
|
||||
emitChange (n, o) {
|
||||
console.log("old:"+o)
|
||||
console.log("new:"+n)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<v-menu
|
||||
v-model="menu2"
|
||||
:close-on-content-click="false"
|
||||
:nudge-right="40"
|
||||
lazy
|
||||
transition="scale-transition"
|
||||
offset-y
|
||||
full-width
|
||||
max-width="290px"
|
||||
min-width="290px"
|
||||
>
|
||||
<v-text-field
|
||||
slot="activator"
|
||||
v-model="computedDateFormatted"
|
||||
:label=init_label
|
||||
hint="DD-MM-YYYY format"
|
||||
persistent-hint
|
||||
readonly
|
||||
solo
|
||||
hide-details
|
||||
class="ma-1"
|
||||
></v-text-field>
|
||||
<v-date-picker v-model="init_date" no-title @input="menu2 = false"></v-date-picker>
|
||||
</v-menu>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
props : ['label', 'date', 'data'],
|
||||
|
||||
data () {
|
||||
return {
|
||||
init_date: this.date ? this.date : new Date().toISOString().substr(0, 10),
|
||||
dateFormatted: this.formatDate(new Date().toISOString().substr(0, 10)),
|
||||
menu1: false,
|
||||
menu2: false,
|
||||
|
||||
init_label: this.label ? this.label : 'Date',
|
||||
init_data: this.data ? this.data : ''
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
computedDateFormatted () {
|
||||
return this.formatDate(this.init_date)
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
init_date (n, o) {
|
||||
this.dateFormatted = this.formatDate(this.init_date)
|
||||
|
||||
this.$emit('change', {"old_date":o, "new_date":n, "data":this.init_data});
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
formatDate (date) {
|
||||
if (!date) return null
|
||||
|
||||
const [year, month, day] = date.split('-')
|
||||
return `${day}-${month}-${year}`
|
||||
},
|
||||
parseDate (date) {
|
||||
if (!date) return null
|
||||
|
||||
const [month, day, year] = date.split('/')
|
||||
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`
|
||||
},
|
||||
|
||||
emitChange (n, o) {
|
||||
console.log("old:"+o)
|
||||
console.log("new:"+n)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<div style="height:30px;
|
||||
position:fixed;bottom:0px;
|
||||
left:50%;
|
||||
color:white;
|
||||
font-size:16px;
|
||||
padding-bottom:5px;
|
||||
font-weight:bold;
|
||||
z-index:999;
|
||||
margin-left:-150px;width:300px;">
|
||||
Pasien hari ini : {{ hari_ini }} , menyusul {{ total - hari_ini}}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
computed: {
|
||||
total() {
|
||||
try {
|
||||
let pxs = this.$store.state.re_patient.patients
|
||||
return pxs.length
|
||||
} catch(e) {
|
||||
return 0
|
||||
}
|
||||
},
|
||||
hari_ini() {
|
||||
try {
|
||||
let pxs = this.$store.state.re_patient.patients
|
||||
let curdate = moment().format('DD.MM.YYYY')
|
||||
let xtot = _.filter(pxs,function(p) {
|
||||
let xdate = moment(p.T_OrderHeaderDate).format('DD.MM.YYYY')
|
||||
return curdate == xdate
|
||||
});
|
||||
return xtot.length
|
||||
} catch(e) {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
max-width="500px"
|
||||
>
|
||||
<v-card>
|
||||
<v-card-text>
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12>
|
||||
<v-text-field
|
||||
label="Pemeriksaan"
|
||||
v-model="selected_px.t_testname"
|
||||
readonly
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12>
|
||||
<v-text-field
|
||||
label="Metode sekarang"
|
||||
v-model="selected_px.methode_name"
|
||||
readonly
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12>
|
||||
<v-select
|
||||
:items="methods"
|
||||
item-text="Nat_MethodeName"
|
||||
item-value="Nat_MethodeID"
|
||||
return-object
|
||||
v-model="selected_method"
|
||||
label="Pilih Metode baru"
|
||||
></v-select>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn color="primary" flat @click="dialog=!dialog">Tutup</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="primary" dark @click="save">Simpan</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data () {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
computed : {
|
||||
dialog : {
|
||||
get () { return this.$store.state.normal_method.dialog_method },
|
||||
set (v) { this.$store.commit('normal_method/update_dialog_method', v) }
|
||||
},
|
||||
|
||||
methods () {
|
||||
return this.$store.state.normal_method.methods
|
||||
},
|
||||
|
||||
selected_method : {
|
||||
get () { return this.$store.state.normal_method.selected_method },
|
||||
set (v) { this.$store.commit('normal_method/update_selected_method', v) }
|
||||
},
|
||||
|
||||
selected_px () {
|
||||
return this.$store.state.re_px.selected_px
|
||||
}
|
||||
},
|
||||
|
||||
methods : {
|
||||
save () {
|
||||
this.$store.dispatch('normal_method/save_method')
|
||||
}
|
||||
},
|
||||
|
||||
watch : {
|
||||
dialog(val, old) {
|
||||
if (val && !old) {
|
||||
this.$store.dispatch('normal_method/search_method')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
max-width="500px"
|
||||
persistent
|
||||
>
|
||||
<v-card>
|
||||
<v-card-text>
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12>
|
||||
<v-textarea
|
||||
rows="5"
|
||||
outline
|
||||
label="Catatan Proses"
|
||||
hide-details
|
||||
v-model="result_note"
|
||||
></v-textarea>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-actions>
|
||||
<v-btn color="primary" flat @click="dialog=!dialog">Tutup</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="primary" @click="save">Simpan</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
/* .v-overlay--active {
|
||||
z-index: 1005 !important;
|
||||
}
|
||||
|
||||
.v-dialog__content--active {
|
||||
z-index: 1006 !important;
|
||||
} */
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data () {
|
||||
return {}
|
||||
},
|
||||
|
||||
computed : {
|
||||
dialog : {
|
||||
get () { return this.$store.state.re_patient.dialog_note },
|
||||
set (v) { this.$store.commit('re_patient/update_dialog_note', v) }
|
||||
},
|
||||
|
||||
result_note : {
|
||||
get () { return this.$store.state.re_patient.result_note },
|
||||
set (v) { this.$store.commit('re_patient/update_result_note', v) }
|
||||
}
|
||||
},
|
||||
|
||||
methods : {
|
||||
save () {
|
||||
this.$store.dispatch('re_patient/save_note')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
max-width="500px"
|
||||
persistent
|
||||
>
|
||||
<v-card>
|
||||
<v-card-text>
|
||||
<v-layout row wrap mb-2 v-show="info_req.note_fo != ''">
|
||||
<v-flex xs12>
|
||||
<h5 class="caption">Catatan FO</h5>
|
||||
<h3 class="title font-weight-regular">{{info_req.note_fo}}</h3>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout row wrap mb-2 v-show="info_req.note_fo_ver != ''">
|
||||
<v-flex xs12>
|
||||
<h5 class="caption">Catatan Screening</h5>
|
||||
<h3 class="title font-weight-regular">{{info_req.note_fo_ver}}</h3>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout row wrap mb-2 v-show="info_req.note_sampling != ''">
|
||||
<v-flex xs12>
|
||||
<h5 class="caption">Catatan Specimen</h5>
|
||||
<h3 class="title font-weight-regular">{{info_req.note_sampling}}</h3>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row wrap mb-2 v-show="info_req.req_fo.length > 0">
|
||||
<v-flex xs12>
|
||||
<h5 class="caption">Requirement FO</h5>
|
||||
<h3 class="title font-weight-regular">{{info_req.req_fo.join(', ')}}</h3>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row wrap mb-2 v-show="info_req.req_spec_col.length > 0">
|
||||
<v-flex xs12>
|
||||
<h5 class="caption">Requirement Specimen Collection</h5>
|
||||
<h3 class="title font-weight-regular">{{info_req.req_spec_col.join(', ')}}</h3>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row wrap mb-2 v-show="info_req.req_spec_ver.length > 0">
|
||||
<v-flex xs12>
|
||||
<h5 class="caption">Requirement Specimen Verification</h5>
|
||||
<h3 class="title font-weight-regular">{{info_req.req_spec_ver.join(', ')}}</h3>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row wrap mb-2 v-show="info_req.req_samp_ver.length > 0">
|
||||
<v-flex xs12>
|
||||
<h5 class="caption">Requirement Sample Verification</h5>
|
||||
<h3 class="title font-weight-regular">{{info_req.req_samp_ver.join(', ')}}</h3>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row wrap mb-2 v-show="info_req.req_pre_an.length > 0">
|
||||
<v-flex xs12>
|
||||
<h5 class="caption">Requirement Pre Analitik</h5>
|
||||
<h3 class="title font-weight-regular">{{info_req.req_pre_an.join(', ')}}</h3>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="primary" flat @click="dialog=!dialog">Tutup</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
/* .v-overlay--active {
|
||||
z-index: 1005 !important;
|
||||
}
|
||||
|
||||
.v-dialog__content--active {
|
||||
z-index: 1006 !important;
|
||||
} */
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data () {
|
||||
return {}
|
||||
},
|
||||
|
||||
computed : {
|
||||
dialog : {
|
||||
get () { return this.$store.state.re_patient.dialog_req },
|
||||
set (v) { this.$store.commit('re_patient/update_dialog_req', v) }
|
||||
},
|
||||
|
||||
info_req () {
|
||||
return this.$store.state.re_patient.info_req
|
||||
}
|
||||
},
|
||||
|
||||
methods : {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
max-width="400px"
|
||||
>
|
||||
<v-card>
|
||||
<v-card-title primary-title class="grey darken-3 white--text">
|
||||
<h3 class="headliine">Tambah Template Hasil</h3>
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text>
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12>
|
||||
<v-text-field
|
||||
label="Pemeriksaan"
|
||||
readonly
|
||||
v-model="curr_px"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12>
|
||||
<v-text-field
|
||||
label="Keterangan Hasil"
|
||||
v-model="template_new_value"
|
||||
:error="error || dup_error"
|
||||
:error-messages="error_msg"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-actions>
|
||||
<v-btn color="primary" flat @click="dialog=false">Tutup</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="primary" dark @click="save">Simpan</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
error_messages: ''
|
||||
}
|
||||
},
|
||||
|
||||
computed : {
|
||||
dialog : {
|
||||
get() {
|
||||
return this.$store.state.re_px.dialog_template_new
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('re_px/update_dialog_template_new', v)
|
||||
}
|
||||
},
|
||||
|
||||
template_new_value : {
|
||||
get() {
|
||||
return this.$store.state.re_px.template_new_value
|
||||
},
|
||||
set (v) {
|
||||
this.$store.commit('re_px/update_template_new_value', v)
|
||||
}
|
||||
},
|
||||
|
||||
curr_px () {
|
||||
return this.$store.state.re_px.selected_px.t_testname
|
||||
},
|
||||
|
||||
error () {
|
||||
|
||||
if (this.template_new_value.length < 1) {
|
||||
this.error_messages = "Keterangan Isi Hasil tidak boleh kosong !"
|
||||
return true
|
||||
}
|
||||
|
||||
this.error_messages = ""
|
||||
return false
|
||||
},
|
||||
|
||||
error_msg () {
|
||||
if (this.error_messages != '')
|
||||
return this.error_messages
|
||||
|
||||
return this.dup_error_messages
|
||||
},
|
||||
|
||||
dup_error : {
|
||||
get() { return this.$store.state.re_px.dup_template_error.status },
|
||||
set (v) {
|
||||
let x = this.$store.state.re_px.dup_template_error
|
||||
x.status = v
|
||||
this.$store.commit('re_px/update_dup_template_error', x)
|
||||
}
|
||||
},
|
||||
|
||||
dup_error_messages : {
|
||||
get() { return this.$store.state.re_px.dup_template_error.messages },
|
||||
set (v) {
|
||||
let x = this.$store.state.re_px.dup_template_error
|
||||
x.messages = v
|
||||
this.$store.commit('re_px/update_dup_template_error', x)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods : {
|
||||
save () {
|
||||
if (this.error) {
|
||||
return
|
||||
} else {
|
||||
this.$store.dispatch('re_px/save_template')
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
watch : {
|
||||
template_new_value (v, o) {
|
||||
|
||||
if (this.dup_error) {
|
||||
if (v != o)
|
||||
this.$store.commit('re_px/update_dup_template_error', {
|
||||
status: false,
|
||||
messages: ''
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
dialog (v, o) {
|
||||
if (v && !o)
|
||||
this.template_new_value = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
persistent
|
||||
max-width="500px"
|
||||
transition="dialog-transition"
|
||||
>
|
||||
|
||||
<v-layout class="fill-height" column>
|
||||
<v-card class="grow" color="blue-grey lighten-2">
|
||||
<v-card-title primary-title class="title white--text pb-2">
|
||||
HISTORI PEMERIKSAAN
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-2 pb-2">
|
||||
|
||||
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="white" flat @click="dialog = false">Tutup</v-btn>
|
||||
</v-card-actions>
|
||||
|
||||
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
query: "",
|
||||
items: [],
|
||||
headers: [
|
||||
{
|
||||
text: "PEMERIKSAAN",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
width: "45%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "HASIL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "35%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "FLAG",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
isLoading: false
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
methods : {
|
||||
|
||||
},
|
||||
|
||||
computed : {
|
||||
dialog : {
|
||||
get () { return this.$store.state.re_history.dialog_history },
|
||||
set (v) { this.$store.commit('re_history/update_dialog_history', v) }
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,209 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
persistent
|
||||
max-width="1000px"
|
||||
min-height="600px"
|
||||
transition="dialog-transition"
|
||||
>
|
||||
|
||||
<v-layout class="fill-height" column>
|
||||
<v-card class="grow" color="blue-grey lighten-2">
|
||||
<v-card-title primary-title class="title white--text pb-2">
|
||||
HISTORI PEMERIKSAAN
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="white" flat @click="filter_test()">{{text_filter_test}}</v-btn>
|
||||
<v-btn color="white" flat @click="uncheck_all()">Clear Test</v-btn>
|
||||
<v-btn color="white" flat @click="dialog = false">Tutup</v-btn>
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text class="pt-2 pb-2">
|
||||
|
||||
<v-layout v-if="show_filter_test" xs12 row wrap style="background-color:white;padding-top:10px;border-radius:10px 10px 0px 0px;padding-left:10px;">
|
||||
<v-flex xs3 v-for="(p, i) in pxs" v-bind:key="p.code" class="pr-2 pb-1">
|
||||
<v-layout row>
|
||||
<v-flex class="boxoutline" class="text-left" style="padding-top:10px" pl-2 pr-2 xs2>
|
||||
<v-layout row align-left justify-space-between>
|
||||
<v-icon v-if="! px_selected(p.code)" @click="selectPx(p.code)" style="color:red">clear</v-icon>
|
||||
<v-icon v-if="px_selected(p.code)" @click="unSelectPx(p.code)" style="color:green">check</v-icon>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex class="boxoutline " style="text-overflow:ellipsis;overflow:hidden;padding-top:10px;" xs11>
|
||||
<span >{{p.name}}</span>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12 >
|
||||
<v-card>
|
||||
<v-card-text class="pt-1 pb-1 pl-1 pr-1">
|
||||
<v-data-table
|
||||
:headers="new_headers" :items="result"
|
||||
:loading="isLoading"
|
||||
hide-actions class="elevation-1 table-history"
|
||||
>
|
||||
<template slot="items" slot-scope="props">
|
||||
<td class="text-xs-left pl-2 pr-2 pa-1 green--text" >
|
||||
{{ props.item.px_name }}
|
||||
</td>
|
||||
<td class="text-xs-left pl-2 pr-2 pa-1" >
|
||||
{{ props.item.unit}}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pl-2 pr-2 pa-1" v-for="xdate in dates" >
|
||||
{{ props.item.result[xdate] }}
|
||||
</td>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="white" flat @click="dialog = false">Tutup</v-btn>
|
||||
</v-card-actions>
|
||||
|
||||
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
|
||||
.table-history table td {
|
||||
height: 40px !important
|
||||
}
|
||||
|
||||
.boxoutline {
|
||||
color: #000099;
|
||||
border: 1px solid #e6f7ff;
|
||||
justify-content: center;
|
||||
height: 55px;
|
||||
line-height: 25px;
|
||||
padding-left: 5px;
|
||||
background: #b3e7ff;
|
||||
font-size: 14px;
|
||||
border-radius: 1px;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
.boxoutline:hover {
|
||||
background: #e6f7ff!important;
|
||||
font-size: 14px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
query: "",
|
||||
items: [],
|
||||
|
||||
isLoading: false,
|
||||
show_filter_test: false
|
||||
};
|
||||
},
|
||||
|
||||
methods : {
|
||||
filter_test() {
|
||||
this.show_filter_test = !this.show_filter_test
|
||||
},
|
||||
oneMoment : function(d) {
|
||||
return window.oneMoment(d)
|
||||
},
|
||||
uncheck_all() {
|
||||
this.$store.commit('re_history/update_selected_px',[])
|
||||
},
|
||||
selectPx(code) {
|
||||
console.log('Select ' + code )
|
||||
let pxs = this.$store.state.re_history.pxs
|
||||
let obj = _.filter(pxs,function(o){ return o.code == code})
|
||||
let spx = this.$store.state.re_history.selected_px
|
||||
let n_spx = _.concat(spx,obj)
|
||||
this.$store.commit('re_history/update_selected_px',n_spx)
|
||||
},
|
||||
unSelectPx(code) {
|
||||
let spx = this.$store.state.re_history.selected_px
|
||||
let new_spx = _.filter(spx,function(o){ return o.code != code })
|
||||
this.$store.commit('re_history/update_selected_px',new_spx)
|
||||
},
|
||||
px_selected(code) {
|
||||
let spx = this.$store.state.re_history.selected_px
|
||||
let rst = _.findIndex(spx,{'code':code})
|
||||
if (rst == -1 ) return false
|
||||
return true
|
||||
},
|
||||
},
|
||||
|
||||
computed : {
|
||||
dates() {
|
||||
return this.$store.state.re_history.dates
|
||||
},
|
||||
text_filter_test() {
|
||||
if (this.show_filter_test) return "Hide Test"
|
||||
return "Show Test"
|
||||
},
|
||||
new_headers() {
|
||||
let headers = [
|
||||
{
|
||||
text: "PEMERIKSAAN",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
width: "45%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "Unit",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "16%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
} ]
|
||||
|
||||
for(let i =0; i< this.dates.length ; i++ ) {
|
||||
headers.push({
|
||||
text: this.dates[i],
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "15%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
})
|
||||
}
|
||||
|
||||
return headers
|
||||
},
|
||||
result () {
|
||||
let spx = this.$store.state.re_history.selected_px
|
||||
let rst = this.$store.state.re_history.result
|
||||
let new_rst = _.filter(rst, function(r) {
|
||||
return _.findIndex(spx,{'code':r.code}) > -1
|
||||
})
|
||||
return new_rst
|
||||
},
|
||||
pxs () {
|
||||
return this.$store.state.re_history.pxs
|
||||
},
|
||||
dialog : {
|
||||
get () { return this.$store.state.re_history.dialog_history },
|
||||
set (v) { this.$store.commit('re_history/update_dialog_history', v) }
|
||||
},
|
||||
selected_px: {
|
||||
get () { return this.$store.state.re_history.selected_px }
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
persistent
|
||||
max-width="500px"
|
||||
transition="dialog-transition"
|
||||
>
|
||||
|
||||
<v-layout class="fill-height" column>
|
||||
<v-card class="grow" color="blue-grey lighten-2">
|
||||
<v-card-title primary-title class="title white--text pb-2">
|
||||
HISTORI PEMERIKSAAN
|
||||
</v-card-title>
|
||||
<v-card-text class="pt-2 pb-2">
|
||||
|
||||
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="white" flat @click="dialog = false">Tutup</v-btn>
|
||||
</v-card-actions>
|
||||
|
||||
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.v-card__actions { display:none }
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
query: "",
|
||||
items: [],
|
||||
headers: [
|
||||
{
|
||||
text: "PEMERIKSAAN",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
width: "45%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "HASIL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "35%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "FLAG",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
isLoading: false
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
methods : {
|
||||
|
||||
},
|
||||
|
||||
computed : {
|
||||
dialog : {
|
||||
get () { return this.$store.state.re_history.dialog_history },
|
||||
set (v) { this.$store.commit('re_history/update_dialog_history', v) }
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,236 @@
|
||||
<template>
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12>
|
||||
<v-card class="pa-2" v-show="!detail">
|
||||
<v-layout row wrap>
|
||||
<v-flex xs3>
|
||||
<div class="caption font-weight-light">No Reg / Tanggal</div>
|
||||
<div class="subheading">{{ selected_patient.T_OrderHeaderLabNumber }} / {{ order_date }}</div>
|
||||
</v-flex>
|
||||
<v-flex xs3>
|
||||
<div class="caption font-weight-light">Nama / Jenis Kelamin</div>
|
||||
<div class="subheading">{{ selected_patient.M_PatientName }} / {{ selected_patient.M_SexName }}
|
||||
</div>
|
||||
</v-flex>
|
||||
<v-flex xs3>
|
||||
<div class="caption font-weight-light">DOB / Umur</div>
|
||||
<div class="subheading">{{ dob_date }} / {{ age }}</div>
|
||||
</v-flex>
|
||||
<!-- <v-flex xs3>
|
||||
<div class="caption font-weight-light">Pengirim</div>
|
||||
<div class="subheading">{{ selected_patient.doctor_sender_name }} </div>
|
||||
</v-flex>
|
||||
-->
|
||||
</v-layout>
|
||||
<v-btn absolute dark top right color="black" flat depressed @click="detail = !detail" class="btn-detail">
|
||||
<v-icon>keyboard_arrow_up</v-icon>
|
||||
</v-btn>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
<v-flex xs12 v-show="detail">
|
||||
<v-card class="pa-2">
|
||||
<v-layout row wrap>
|
||||
<v-flex xs6>
|
||||
<div class="caption font-weight-light">No Reg / Tanggal</div>
|
||||
<div class="subheading">{{ selected_patient.T_OrderHeaderLabNumber }} / {{ order_date }}</div>
|
||||
|
||||
<div class="caption font-weight-light mt-2">Nama / Jenis Kelamin</div>
|
||||
<div class="subheading">{{ selected_patient.M_PatientName }} / {{ selected_patient.M_SexName }}
|
||||
</div>
|
||||
|
||||
<div class="caption font-weight-light mt-2">DOB / Umur</div>
|
||||
<div class="subheading">{{ dob_date }} / {{ age }}</div>
|
||||
|
||||
<div class="caption font-weight-light mt-2">Phone</div>
|
||||
<div class="subheading">{{ selected_patient.M_PatientHP }}
|
||||
</div>
|
||||
<div class="caption font-weight-light mt-2">Diagnose</div>
|
||||
<div class="subheading">{{ selected_patient.T_OrderHeaderDiagnose }}</div>
|
||||
</v-flex>
|
||||
<v-flex xs6>
|
||||
<div class="caption font-weight-light">Corporate</div>
|
||||
<div class="subheading">{{ selected_patient.CorporateName }} </div>
|
||||
|
||||
<!-- <div class="caption font-weight-light mt-2">Pengirim</div>
|
||||
<div class="subheading">{{ selected_patient.doctor_sender_name }} </div>
|
||||
|
||||
<div class="caption font-weight-light mt-2">Pengiriman Hasil</div>
|
||||
<div class="subheading">{{ selected_patient.delivery ? selected_patient.delivery.join(",
|
||||
"):''}} </div>
|
||||
-->
|
||||
|
||||
<div class="caption font-weight-light mt-2">Format Hasil</div>
|
||||
<div class="subheading">{{ langs }} </div>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row v-show="false">
|
||||
<v-flex xs3>
|
||||
<v-layout row wrap pr-2>
|
||||
<v-flex xs7 pr-2>
|
||||
|
||||
<v-text-field label="Nomor Lab" v-model="selected_patient.T_OrderHeaderLabNumber"
|
||||
readonly></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs5>
|
||||
<v-text-field label="Tanggal" v-model="order_date" readonly></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12>
|
||||
<v-text-field label="Nama" v-model="selected_patient.M_PatientName"
|
||||
readonly></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs3>
|
||||
<v-layout row wrap pl-2>
|
||||
<v-flex xs5 pr-2>
|
||||
<v-text-field label="DOB" v-model="dob_date" readonly></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs7 pl-2>
|
||||
<v-text-field label="Umur" v-model="age" readonly></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12>
|
||||
<v-text-field label="Jenis Kelamin" v-model="selected_patient.M_SexName"
|
||||
readonly></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs3>
|
||||
<v-layout row wrap pl-2>
|
||||
<v-flex xs12>
|
||||
<v-text-field label="Dokter" v-model="selected_patient.doctor_pj_name"
|
||||
readonly></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12>
|
||||
<v-text-field label="Corporate" v-model="selected_patient.CorporateName"
|
||||
readonly></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs3>
|
||||
<v-layout row wrap pl-2>
|
||||
<v-flex xs12 mb-3>
|
||||
<v-text-field label="No HP" v-model="selected_patient.M_PatientHP" readonly
|
||||
hide-details></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12>
|
||||
<v-text-field label="Catatan Pasien" outline readonly hide-details
|
||||
v-model="selected_patient.M_PatientNote"></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-layout row wrap v-show="false">
|
||||
<v-flex xs4 pr-2>
|
||||
<v-text-field label="Catatan FO" outline readonly hide-details
|
||||
v-model="selected_patient.T_OrderHeaderFoNote"></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs4 pr-2>
|
||||
<v-text-field label="Catatan Sampling" outline readonly hide-details
|
||||
v-model="selected_patient.T_OrderHeaderSamplingNote"></v-text-field>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs4>
|
||||
<v-text-field label="Catatan Sample Handling" outline readonly hide-details
|
||||
v-model="selected_patient.T_OrderHeaderResultNote"></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<v-btn absolute dark top right color="black" flat depressed @click="detail=!detail" class="btn-detail">
|
||||
<v-icon>keyboard_arrow_down</v-icon>
|
||||
</v-btn>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.btn-detail {
|
||||
min-width: 0px !important;
|
||||
height: auto;
|
||||
padding: 0px;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
detail: false
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
selected_patient() {
|
||||
let x = this.$store.state.re_patient.selected_patient
|
||||
if (x)
|
||||
return x
|
||||
return {}
|
||||
},
|
||||
|
||||
order_date() {
|
||||
let d = this.selected_patient.T_OrderHeaderDate
|
||||
let e = ''
|
||||
try {
|
||||
e = d.substr(0, 10).split('-').reverse().join('-')
|
||||
} catch (e) { /*console.log(e.message)*/ }
|
||||
|
||||
return e
|
||||
},
|
||||
|
||||
dob_date() {
|
||||
let d = this.selected_patient.M_PatientDOB
|
||||
let e = ''
|
||||
try {
|
||||
e = d.substr(0, 10).split('-').reverse().join('-')
|
||||
} catch (e) { /*console.log(e.message)*/ }
|
||||
|
||||
return e
|
||||
},
|
||||
|
||||
age() {
|
||||
let d = this.selected_patient.T_OrderHeaderM_PatientAge
|
||||
return d
|
||||
let e = ''
|
||||
try {
|
||||
e = d.replace(/tahun/, 'th').replace(/bulan/, 'bl').replace(/hari/, 'hr')
|
||||
} catch (e) { /*console.log(e.message)*/ }
|
||||
|
||||
return e
|
||||
},
|
||||
|
||||
langs() {
|
||||
let x = this.selected_patient
|
||||
if (!x) return ''
|
||||
|
||||
let si_01 = x.T_OrderHeaderLangIsSI == 'Y' ? ' (SI)' : ''
|
||||
let si_02 = x.T_OrderHeaderAddOnSecondLangIsSI == 'Y' ? ' (SI)' : ''
|
||||
|
||||
if (!x.SecondM_LangID) return x.M_LangName + si_01
|
||||
|
||||
return x.M_LangName + si_01 + ', ' + x.SecondM_LangName + si_02
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,222 @@
|
||||
<template>
|
||||
<v-layout class="fill-height" column>
|
||||
<v-card class="grow">
|
||||
<hr style="border-top:0px solid #c8c8c8;" />
|
||||
<div class="one-critical-value-header"
|
||||
:data-header-id="selected_patient.T_OrderHeaderID" ></div>
|
||||
<v-data-table
|
||||
:headers="headers" :items="patients"
|
||||
:loading="isLoading"
|
||||
hide-actions class="xelevation-1">
|
||||
<template slot="items" slot-scope="props">
|
||||
<tr :class="{
|
||||
'susulan' : is_susulan(props.item),
|
||||
'valid_done': is_valid_done(props.item), 'valid_partial':is_valid_partial(props.item) }"
|
||||
>
|
||||
<td
|
||||
class="text-xs-left pa-2 green--text" v-bind:class="[ is_cito(props.item)]"
|
||||
@click="select(props.item)">
|
||||
<span style="color:black">{{ props.item.T_OrderHeaderLabNumber }}</span><br/>
|
||||
<span style="color:#660000">{{props.item.T_OrderHeaderLabNumberExt}}</span>
|
||||
</td>
|
||||
<td
|
||||
class="text-xs-left pa-2" v-bind:class="[ is_cito(props.item)]"
|
||||
@click="select(props.item)">
|
||||
{{ props.item.M_PatientName }} <br/>
|
||||
<span style="color:#660000">{{format_date(props.item.T_OrderHeaderDate)}}</span>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<v-icon v-if="is_selected(props.item)" >pan_tool</v-icon>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
</v-data-table>
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
div.v-table__overflow {
|
||||
height:680px!important;
|
||||
overflow-y:scroll;
|
||||
}
|
||||
tr.susulan {
|
||||
background-image: linear-gradient(to right, white 5%);
|
||||
}
|
||||
tr.susulan.verif_partial{
|
||||
background-image: linear-gradient(to right, rgba(255, 0, 0,0.9) 5%, white 5%, white 40%,yellow 70%);
|
||||
}
|
||||
tr.susulan.verif_done {
|
||||
background-image: linear-gradient(to right, rgba(255, 0, 0,0.9) 5%, yellow 5%);
|
||||
}
|
||||
tr.susulan.verif_partial.valid_partial {
|
||||
background-image: linear-gradient(to right, #99e699 5%,#99e699 5%, #99e699 40%, #ef9f13 60%);
|
||||
}
|
||||
tr.susulan.valid_partial {
|
||||
background-image: linear-gradient(to right, #ef9f13,#ef9f13, #ef9f13, #ef9f13);
|
||||
}
|
||||
tr.susulan.valid_done{
|
||||
background-image: linear-gradient(to right, #c16eb0,#c16eb0, #c16eb0, #c16eb0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
tr.verif_partial{
|
||||
background-image: linear-gradient(to right, white 40%,yellow 70%);
|
||||
}
|
||||
tr.verif_done {
|
||||
background-image: linear-gradient(to right, yellow,yellow, yellow, yellow);
|
||||
}
|
||||
tr.verif_partial.valid_partial {
|
||||
background-image: linear-gradient(to right, #ef9f13,#ef9f13 #ef9f13, #ef9f13);
|
||||
}
|
||||
tr.valid_partial {
|
||||
background-image: linear-gradient(to right, #ef9f13,#ef9f13, #ef9f13, #ef9f13);
|
||||
}
|
||||
tr.valid_done{
|
||||
background-image: linear-gradient(to right, #c16eb0,#c16eb0, #c16eb0, #c16eb0);
|
||||
}
|
||||
|
||||
.searchbox .v-input.v-text-field .v-input__slot{
|
||||
min-height:60px;
|
||||
}
|
||||
.searchbox .v-btn {
|
||||
min-height:60px;
|
||||
}
|
||||
table.v-table tbody td,table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
query: "",
|
||||
items: [],
|
||||
headers: [
|
||||
{
|
||||
text: "NO REG",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "30%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "NAMA",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "60%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "",
|
||||
align: "center",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "10%",
|
||||
class: "pa-2 text-xs-right blue lighten-3 white--text"
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
isLoading: false
|
||||
};
|
||||
},
|
||||
|
||||
methods : {
|
||||
is_valid_partial(i) {
|
||||
return i.T_OrderHeaderAddOnValidationDone == 'P'
|
||||
},
|
||||
is_susulan(i) {
|
||||
let cur_date = moment().format('DD.MM.YYYY')
|
||||
let o_date = moment(i.T_OrderHeaderDate).format('DD.MM.YYYY')
|
||||
|
||||
return cur_date != o_date
|
||||
},
|
||||
is_valid_done(i) {
|
||||
return i.T_OrderHeaderAddOnValidationDone == 'Y'
|
||||
},
|
||||
is_verif_partial(i) {
|
||||
return i.T_OrderHeaderAddOnVerificationDone == 'P'
|
||||
},
|
||||
is_verif_done(i) {
|
||||
return i.T_OrderHeaderAddOnVerificationDone == 'Y'
|
||||
},
|
||||
oneMoment : function(d) {
|
||||
return window.oneMoment(d)
|
||||
},
|
||||
format_date(p) {
|
||||
return moment(p).format("DD.MM.YYYY HH:mm")
|
||||
},
|
||||
select (item) {
|
||||
this.$store.commit('re_patient/update_selected_patient', item)
|
||||
this.$store.commit('re_px/update_id', item.T_OrderHeaderID)
|
||||
this.$store.dispatch('re_px/search')
|
||||
this.$store.dispatch('re_patient/info_req')
|
||||
},
|
||||
|
||||
is_selected (item) {
|
||||
let x = this.$store.state.re_patient.selected_patient
|
||||
if (!x)
|
||||
return ''
|
||||
|
||||
if (x.T_OrderHeaderID == item.T_OrderHeaderID)
|
||||
return 'green lighten-4'
|
||||
|
||||
return ''
|
||||
},
|
||||
|
||||
is_cito (item) {
|
||||
let x = this.$store.state.re_patient.selected_patient
|
||||
if (!x)
|
||||
return ''
|
||||
|
||||
if (item.T_OrderHeaderIsCito == "Y")
|
||||
return 'amber'
|
||||
|
||||
return ''
|
||||
},
|
||||
|
||||
change_page(x) {
|
||||
this.curr_patient_page = x
|
||||
this.$store.dispatch('re_patient/search')
|
||||
}
|
||||
},
|
||||
|
||||
computed : {
|
||||
patients () {
|
||||
return this.$store.state.re_patient.patients
|
||||
},
|
||||
|
||||
total_patient () {
|
||||
return this.$store.state.re_patient.total_patient
|
||||
},
|
||||
|
||||
total_patient_page () {
|
||||
return this.$store.state.re_patient.total_patient_page
|
||||
},
|
||||
|
||||
curr_patient_page : {
|
||||
get () { return this.$store.state.re_patient.curr_patient_page },
|
||||
set (v) { this.$store.commit('re_patient/update_curr_patient_page', v) }
|
||||
},
|
||||
selected_patient() {
|
||||
return this.$store.state.re_patient.selected_patient;
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
this.$store.dispatch('re_patient/search')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,475 @@
|
||||
<template>
|
||||
<v-layout class="fill-height flex-card" column>
|
||||
<v-card class="fill-height">
|
||||
<!-- <v-subheader>
|
||||
<h3 class="title">DAFTAR PASIEN</h3>
|
||||
</v-subheader> -->
|
||||
<hr style="border-top:0px solid #c8c8c8;" />
|
||||
<!--
|
||||
<v-progress-linear :indeterminate="true" class="mt-1 mb-1" v-if="search_status == 1"
|
||||
height="10" striped></v-progress-linear>
|
||||
-->
|
||||
<v-data-table
|
||||
:headers="headers" :items="pxs"
|
||||
:loading="search_status == 1"
|
||||
hide-actions class="xelevation-1">
|
||||
|
||||
<template slot="items" slot-scope="props">
|
||||
<tr :class="{'red lighten-4': props.item.verification == 'Y',
|
||||
'green lighten-4': props.item.validation== 'Y' }">
|
||||
<td class="text-xs-left pt-2 pb-2 pr-2 green--text" v-bind:class="margin_left(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'N'" colspan="7">
|
||||
{{ props.item.t_testname }}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pt-2 pb-2 pr-2 green--text" v-bind:class="margin_left(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
{{ props.item.t_testname }}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'" style="position: relative">
|
||||
|
||||
<v-textarea
|
||||
v-if="props.item.ResultGroupName === 'FNA'"
|
||||
:value="props.item.result === null || props.item.result === ''?'Belum diisi':'Terlampir'"
|
||||
append-icon="description"
|
||||
solo
|
||||
readonly
|
||||
single-line
|
||||
rows=1
|
||||
auto-grow
|
||||
hide-details
|
||||
label=""
|
||||
type="text"
|
||||
@click:append="openDialogFNA(props.item)"
|
||||
></v-textarea>
|
||||
|
||||
<v-textarea
|
||||
v-if="props.item.ResultGroupName === 'Papsmear'"
|
||||
:value="props.item.result === null || props.item.result === ''?'Belum diisi':'Terlampir'"
|
||||
append-icon="description"
|
||||
solo
|
||||
readonly
|
||||
single-line
|
||||
rows=1
|
||||
auto-grow
|
||||
hide-details
|
||||
label=""
|
||||
type="text"
|
||||
@click:append="openDialogPapsmear(props.item)"
|
||||
></v-textarea>
|
||||
|
||||
|
||||
<v-textarea
|
||||
label=""
|
||||
solo
|
||||
rows=1
|
||||
hide-details
|
||||
v-on:keyup="update_result(props.index, $event.target.value)"
|
||||
:value="props.item.result"
|
||||
v-if="props.item.is_quantitative == 'Y' && props.item.ResultGroupName === 'LAB'"
|
||||
auto-grow
|
||||
:readonly="props.item.T_OrderDetailVerification == 'Y'"
|
||||
:flat="props.item.T_OrderDetailVerification == 'Y'"
|
||||
v-show="(props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.resample == 'Y' && props.item.resample_status == 'W')"
|
||||
></v-textarea>
|
||||
|
||||
<v-select
|
||||
:items="props.item.template"
|
||||
|
||||
label=""
|
||||
item-value="T_ResultTemplateValue"
|
||||
item-text="T_ResultTemplateValue"
|
||||
v-if="props.item.is_quantitative == 'N' && props.item.ResultGroupName === 'LAB'"
|
||||
solo
|
||||
hide-details
|
||||
:value="props.item.result"
|
||||
@change="update_result(props.index, $event)"
|
||||
:disabled="props.item.T_OrderDetailVerification == 'Y'"
|
||||
v-show="(props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.resample == 'Y' && props.item.resample_status == 'W')"
|
||||
>
|
||||
<template style="margin-top: 3px;" v-slot:append-outer>
|
||||
<v-btn icon dark color="blue" small class="btn-outer ma-0" @click="template_new(props.item)"><v-icon>add_circle</v-icon></v-btn>
|
||||
</template>
|
||||
</v-select>
|
||||
|
||||
<span class="body-1" v-show="props.item.sample_worklist_receive != 'Y' || !props.item.pre_analytic || (props.item.resample == 'Y' && props.item.resample_status != 'W')">{{init_result(props.item)}}</span>
|
||||
|
||||
<!-- <v-textarea
|
||||
solo
|
||||
hide-details
|
||||
rows="2"
|
||||
:value="props.item.result"
|
||||
@change="update_result(props.index, $event)"
|
||||
>
|
||||
</v-textarea> -->
|
||||
|
||||
<v-btn style="width: 28px;padding-bottom: 10px;" v-if="props.item.is_quantitative == 'Y' && props.item.result_instrument_n > 0 " color="blue lighten-2" class="btn_rerun" icon flat small @click="rerun_me(props.index, props.item)">
|
||||
<v-img :src="icon_info" aspect-ratio="1" height="15" contain></v-img>
|
||||
</v-btn>
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
{{ !init_blank(props.item) ? props.item.result_flag : '' }}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
{{ !init_blank(props.item) ? props.item.normal_note : '' }}
|
||||
<a href="javascript:;" v-show="props.item.normal_note != '' && props.item.normal_note != null && props.item.sample_processing == 'Y' && !init_blank(props.item)" @click="normalChange(props)"><v-icon small color="blue">create</v-icon></a>
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
{{ !init_blank(props.item) ? props.item.unit_name : '' }}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
{{ !init_blank(props.item) ? props.item.methode_name : '' }}
|
||||
<a href="javascript:;" v-show="props.item.methode_name != '' && props.item.methode_name != null && props.item.sample_processing == 'Y' && !init_blank(props.item)" @click="methodeChange(props)"><v-icon small color="blue">create</v-icon></a>
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
<v-textarea
|
||||
label=""
|
||||
solo
|
||||
rows=1
|
||||
hide-details
|
||||
v-on:keyup="update_note(props.index, $event.target.value)"
|
||||
:value="props.item.note"
|
||||
auto-grow
|
||||
:readonly="props.item.T_OrderDetailVerification == 'Y'"
|
||||
:flat="props.item.T_OrderDetailVerification == 'Y'"
|
||||
v-show="props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && !init_blank(props.item)"
|
||||
></v-textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
</v-data-table>
|
||||
|
||||
|
||||
</v-card>
|
||||
|
||||
<one-process-re-rerun-result></one-process-re-rerun-result>
|
||||
<one-process-re-history></one-process-re-history>
|
||||
<one-process-re-fna></one-process-re-fna>
|
||||
<one-process-re-papsmear></one-process-re-papsmear>
|
||||
<v-snackbar
|
||||
v-model="snackbar"
|
||||
:timeout="5000"
|
||||
bottom right
|
||||
>
|
||||
{{ save_text }}
|
||||
<v-btn
|
||||
color="pink"
|
||||
flat
|
||||
@click="snackbar = false"
|
||||
>
|
||||
Close
|
||||
</v-btn>
|
||||
</v-snackbar>
|
||||
|
||||
<one-dialog-template>
|
||||
</one-dialog-template>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
div.v-table__overflow {
|
||||
height:640px!important;
|
||||
overflow-y:scroll;
|
||||
}
|
||||
.searchbox .v-input.v-text-field .v-input__slot{
|
||||
min-height:60px;
|
||||
}
|
||||
.searchbox .v-btn {
|
||||
min-height:60px;
|
||||
}
|
||||
table.v-table tbody td,table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.btn_rerun {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 2px
|
||||
}
|
||||
|
||||
.flex-card {
|
||||
min-height: -webkit-min-content;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.v-text-field.v-text-field--solo .v-input__control {
|
||||
min-height: 32px;
|
||||
box-shadow:none;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
.v-textarea.v-text-field--box.v-text-field--single-line .v-text-field__prefix, .v-textarea.v-text-field--box.v-text-field--single-line textarea, .v-textarea.v-text-field--enclosed.v-text-field--single-line .v-text-field__prefix, .v-textarea.v-text-field--enclosed.v-text-field--single-line textarea {
|
||||
margin-top: 2px;
|
||||
|
||||
}
|
||||
.v-textarea.v-text-field--solo .v-input__append-inner, .v-textarea.v-text-field--solo .v-input__append-outer, .v-textarea.v-text-field--solo .v-input__prepend-inner, .v-textarea.v-text-field--solo .v-input__prepend-outer {
|
||||
align-self: flex-start;
|
||||
margin-top: 3px;
|
||||
}
|
||||
.v-textarea.v-text-field--solo .v-input__append-inner .v-input__icon {
|
||||
align-items: center;
|
||||
display: inline-flex;
|
||||
height: 24px;
|
||||
flex: 1 0 auto;
|
||||
justify-content: center;
|
||||
min-width: 24px;
|
||||
width: 24px;
|
||||
padding-bottom: 6px;
|
||||
padding-left: 18px;
|
||||
}
|
||||
.v-text-field.v-text-field--solo .v-input__append-outer, .v-text-field.v-text-field--solo .v-input__prepend-outer {
|
||||
margin-top: 3px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
let ts = '?ts=' + moment().format('YYMMDDhhmmss')
|
||||
module.exports = {
|
||||
components : {
|
||||
'one-process-re-rerun-result': httpVueLoader('./oneProcessReRerunResult.vue' + ts ),
|
||||
'one-process-re-history': httpVueLoader('./oneProcessReHistory.vue' + ts ),
|
||||
'one-process-re-fna': httpVueLoader('./oneResultFNA.vue' + ts ),
|
||||
'one-process-re-papsmear': httpVueLoader('./oneResultPapsmear.vue' + ts ),
|
||||
'one-dialog-template': httpVueLoader('./oneProcessReDialogResultTemplateNew.vue' + ts )
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
query: "",
|
||||
save_text: "Data telah tersimpan.",
|
||||
items: [],
|
||||
headers: [
|
||||
{
|
||||
text: "NAMA PEMERIKSAAN",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "15%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "HASIL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "15%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "FLAG",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "10%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "NILAI NORMAL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "15%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "UNIT",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "10%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "METODE",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "15%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "CATATAN",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
}
|
||||
],
|
||||
|
||||
isLoading: false
|
||||
};
|
||||
},
|
||||
|
||||
computed : {
|
||||
pxs () {
|
||||
return this.$store.state.re_px.pxs
|
||||
},
|
||||
|
||||
icon_info () {
|
||||
return window.BASE_URL + '/one-ui/apps/image/info.png'
|
||||
},
|
||||
|
||||
snackbar : {
|
||||
get () { return this.$store.state.re_px.snackbar },
|
||||
set (v) { this.$store.commit('re_px/update_snackbar', v) }
|
||||
},
|
||||
|
||||
search_status () {
|
||||
return this.$store.state.re_px.search_status
|
||||
},
|
||||
|
||||
selected_px () {
|
||||
return this.$store.state.re_px.selected_px
|
||||
}
|
||||
},
|
||||
|
||||
methods : {
|
||||
openDialogFNA(value){
|
||||
if(value.result === null || value.result === ''){
|
||||
var results = []
|
||||
results.push({xid:'0',orderdetail_id:value.id,code:'A',label:'Diagnosis Klinis',result:''})
|
||||
results.push({xid:'0',orderdetail_id:value.id,code:'B',label:'Makroskopis/Tindakan',result:''})
|
||||
results.push({xid:'0',orderdetail_id:value.id,code:'C',label:'Mikroskopis',result:''})
|
||||
results.push({xid:'0',orderdetail_id:value.id,code:'D',label:'Kesimpulan/Diagnosa',result:''})
|
||||
results.push({xid:'0',orderdetail_id:value.id,code:'E',label:'Saran',result:''})
|
||||
this.$store.commit("re_fna/update_results",results)
|
||||
this.$store.dispatch("re_fna/get_doctors",{token:''})
|
||||
}
|
||||
else
|
||||
this.$store.dispatch("re_fna/get_fnaresult",value)
|
||||
},
|
||||
openDialogPapsmear(value){
|
||||
this.$store.dispatch("re_papsmear/get_papsmearresult",value)
|
||||
},
|
||||
oneMoment : function(d) {
|
||||
return window.oneMoment(d)
|
||||
},
|
||||
|
||||
select (idx, item) {
|
||||
this.$store.commit('re_px/update_selected_px', item)
|
||||
this.$store.commit('re_px/update_selected_px_idx', idx)
|
||||
},
|
||||
|
||||
is_selected (item) {
|
||||
|
||||
return ''
|
||||
},
|
||||
|
||||
margin_left (item) {
|
||||
if (item.level == 2)
|
||||
return 'pl-4'
|
||||
|
||||
if (item.level == 3)
|
||||
return 'pl-5'
|
||||
|
||||
return 'pl-2'
|
||||
},
|
||||
|
||||
rerun_me (idx, item) {
|
||||
if(item.verification == 'Y' ) return
|
||||
this.select(idx, item)
|
||||
this.$store.commit('re_px/update_dialog_rerun', true)
|
||||
},
|
||||
|
||||
update_result(idx, result) {
|
||||
let x = this.$store.state.re_px.pxs
|
||||
x[idx]['result'] = result
|
||||
|
||||
this.$store.commit('re_px/update_pxs', {records:x})
|
||||
},
|
||||
|
||||
update_note(idx, note) {
|
||||
|
||||
let x = this.$store.state.re_px.pxs
|
||||
x[idx]['note'] = note
|
||||
|
||||
this.$store.commit('re_px/update_pxs', {records:x})
|
||||
},
|
||||
|
||||
template_new(item) {
|
||||
this.$store.commit('re_px/update_selected_px', item)
|
||||
this.$store.commit('re_px/update_dialog_template_new', true)
|
||||
},
|
||||
|
||||
methodeChange(d) {
|
||||
if (d.item.verification == 'Y') return
|
||||
this.select(d.index, d.item)
|
||||
this.$store.commit('normal_method/update_nattest_id', d.item.nattest_id)
|
||||
this.$store.commit('normal_method/update_id', d.item.id)
|
||||
this.$store.commit('normal_method/update_dialog_method', true)
|
||||
},
|
||||
|
||||
normalChange(d) {
|
||||
return
|
||||
},
|
||||
|
||||
init_result(x) {
|
||||
if (x.verification == "Y" || x.validation == "Y")
|
||||
return x.result
|
||||
|
||||
let susul_date = moment(x.T_OrderPromiseDateTime).format('DD.MM.YYYY HH:mm')
|
||||
// Override
|
||||
if (x.resample == "Y") {
|
||||
if (x.resample_status == "N")
|
||||
return "Bahan belum"
|
||||
if (x.resample_status == "R")
|
||||
return "Hasil Menyusul : " + susul_date
|
||||
if (x.resample_status == "W")
|
||||
return x.result
|
||||
}
|
||||
|
||||
if (x.sample_receive != 'Y')
|
||||
return "Bahan belum"
|
||||
if (x.sample_receive == 'Y' && !x.pre_analytic)
|
||||
return "Belum Pre Analitik"
|
||||
if (x.sample_receive == 'Y' && x.pre_analytic)
|
||||
{
|
||||
if (x.sample_worklist_receive == "Y")
|
||||
return x.result
|
||||
else
|
||||
return "Hasil Menyusul : " + susul_date
|
||||
}
|
||||
},
|
||||
|
||||
init_blank(x) {
|
||||
if (x.verification == "Y" || x.validation == "Y")
|
||||
return false
|
||||
|
||||
// Override
|
||||
if (x.resample == "Y") {
|
||||
if (x.resample_status == "N" || x.resample_status == "R")
|
||||
return true
|
||||
}
|
||||
|
||||
if (x.sample_receive != 'Y' || !x.pre_analytic || x.sample_worklist_receive != "Y")
|
||||
return true
|
||||
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
// this.$store.dispatch('re_patient/search')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,604 @@
|
||||
<template>
|
||||
<v-layout class="fill-height flex-card" column>
|
||||
<v-card class="fill-height">
|
||||
<!-- <v-subheader>
|
||||
<h3 class="title">DAFTAR PASIEN</h3>
|
||||
</v-subheader> -->
|
||||
<hr style="border-top:0px solid #c8c8c8;" />
|
||||
<!--
|
||||
<v-progress-linear :indeterminate="true" class="mt-1 mb-1" v-if="search_status == 1"
|
||||
height="10" striped></v-progress-linear>
|
||||
-->
|
||||
<v-data-table :headers="headers" :items="pxs" :loading="search_status == 1" hide-actions class="xelevation-1">
|
||||
|
||||
<template slot="items" slot-scope="props">
|
||||
<tr :class="{
|
||||
'red lighten-4': props.item.verification == 'Y',
|
||||
'green lighten-4': props.item.validation == 'Y'
|
||||
}">
|
||||
<td class="text-xs-left pt-2 pb-2 pr-2 green--text" v-bind:class="margin_left(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'N'" colspan="7">
|
||||
{{ props.item.t_testname }}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pt-2 pb-2 pr-2 green--text" v-bind:class="margin_left(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
{{ props.item.t_testname }}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'"
|
||||
style="position: relative">
|
||||
<v-textarea label="" disabled solo rows=1 hide-details
|
||||
v-on:keyup="update_result(props.index, $event.target.value)" :value="props.item.result"
|
||||
@keydown.ctrl.a="keyDownResult(props.index, props.item)" auto-grow
|
||||
:readonly="props.item.T_OrderDetailVerification == 'Y'"
|
||||
:flat="props.item.T_OrderDetailVerification == 'Y'" v-show="(props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.resample == 'Y' && props.item.resample_status == 'W')"></v-textarea>
|
||||
|
||||
<!-- <v-textarea
|
||||
:value="props.item.result === null || props.item.result === '' ? 'Belum diisi' : 'Terlampir'"
|
||||
append-icon="description"
|
||||
v-if="(props.item.ResultGroupName === 'DFI' && props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.ResultGroupName === 'DFI' && props.item.resample == 'Y' && props.item.resample_status == 'W')" solo
|
||||
readonly single-line rows=1 auto-grow hide-details label="" type="text"
|
||||
@click:append="openDialogDNAFRagmentasi(props.item)"></v-textarea>
|
||||
|
||||
|
||||
<v-textarea
|
||||
:value="props.item.result === null || props.item.result === '' ? 'Belum diisi' : 'Terlampir'"
|
||||
append-icon="description"
|
||||
v-if="(props.item.ResultGroupName === 'Preparasi Sperma' && props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.ResultGroupName === 'Preparasi Sperma' && props.item.resample == 'Y' && props.item.resample_status == 'W')"
|
||||
solo readonly single-line rows=1 auto-grow hide-details label="" type="text"
|
||||
@click:append="openDialogPreparasiSperma(props.item)"></v-textarea>
|
||||
|
||||
|
||||
<v-textarea
|
||||
:value="props.item.result === null || props.item.result === '' ? 'Belum diisi' : 'Terlampir'"
|
||||
append-icon="description"
|
||||
v-if="(props.item.ResultGroupName === 'FNA' && props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.ResultGroupName === 'FNA' && props.item.resample == 'Y' && props.item.resample_status == 'W')" solo
|
||||
readonly single-line rows=1 auto-grow hide-details label="" type="text"
|
||||
@click:append="openDialogFNA(props.item)"></v-textarea>
|
||||
|
||||
<v-textarea
|
||||
:value="props.item.result === null || props.item.result === '' ? 'Belum diisi' : 'Terlampir'"
|
||||
append-icon="description"
|
||||
v-if="(props.item.ResultGroupName === 'Cytologi' && props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.ResultGroupName === 'Cytologi' && props.item.resample == 'Y' && props.item.resample_status == 'W')" solo
|
||||
readonly single-line rows=1 auto-grow hide-details label="" type="text"
|
||||
@click:append="openDialogCytologi(props.item)"></v-textarea>
|
||||
|
||||
<v-textarea
|
||||
:value="props.item.result === null || props.item.result === '' ? 'Belum diisi' : 'Terlampir'"
|
||||
append-icon="description"
|
||||
v-if="(props.item.ResultGroupName === 'Papsmear' && props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.ResultGroupName === 'Papsmear' && props.item.resample == 'Y' && props.item.resample_status == 'W')"
|
||||
solo readonly single-line rows=1 auto-grow hide-details label="" type="text"
|
||||
@click:append="openDialogPapsmear(props.item)"></v-textarea>
|
||||
|
||||
<v-textarea
|
||||
:value="props.item.result === null || props.item.result === '' ? 'Belum diisi' : 'Terlampir'"
|
||||
append-icon="description"
|
||||
v-if="(props.item.ResultGroupName === 'Pap Smear (Liquid C Prep)' && props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.ResultGroupName === 'Pap Smear (Liquid C Prep)' && props.item.resample == 'Y' && props.item.resample_status == 'W')"
|
||||
solo readonly single-line rows=1 auto-grow hide-details label="" type="text"
|
||||
@click:append="openDialogLcprep(props.item)"></v-textarea>
|
||||
|
||||
<v-textarea
|
||||
:value="props.item.result === null || props.item.result === '' ? 'Belum diisi' : props.item.result"
|
||||
append-icon="description"
|
||||
v-if="(props.item.ResultGroupName === 'Mikro' && props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic === 'Y' && props.item.resample == 'N') ||
|
||||
(props.item.ResultGroupName === 'Mikro' && props.item.resample == 'Y' && props.item.resample_status == 'W')" solo
|
||||
readonly single-line rows=1 auto-grow hide-details label="" type="text"
|
||||
@click:append="openDialogMikro(props.item)"></v-textarea>
|
||||
|
||||
|
||||
<v-textarea label="" solo rows=1 hide-details
|
||||
v-on:keyup="update_result(props.index, $event.target.value)" :value="props.item.result"
|
||||
v-if="props.item.is_quantitative == 'Y' && props.item.ResultGroupName === 'LAB'"
|
||||
@keydown.ctrl.a="keyDownResult(props.index, props.item)" auto-grow
|
||||
:readonly="props.item.T_OrderDetailVerification == 'Y'"
|
||||
:flat="props.item.T_OrderDetailVerification == 'Y'" v-show="(props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.resample == 'Y' && props.item.resample_status == 'W')"></v-textarea>
|
||||
|
||||
<v-select :items="props.item.template" label="" item-value="T_ResultTemplateValue"
|
||||
item-text="T_ResultTemplateValue"
|
||||
v-if="props.item.is_quantitative == 'N' && props.item.ResultGroupName === 'LAB'" solo
|
||||
hide-details :value="props.item.result" @change="update_result(props.index, $event)"
|
||||
:disabled="props.item.T_OrderDetailVerification == 'Y'" v-show="(props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && props.item.resample == 'N') ||
|
||||
(props.item.resample == 'Y' && props.item.resample_status == 'W')">
|
||||
<template style="margin-top: 3px;" v-slot:append-outer>
|
||||
<v-btn icon dark color="blue" small class="btn-outer ma-0"
|
||||
@click="template_new(props.item)"><v-icon>add_circle</v-icon></v-btn>
|
||||
</template>
|
||||
</v-select>
|
||||
-->
|
||||
<span class="body-1"
|
||||
v-show="props.item.sample_worklist_receive != 'Y' || !props.item.pre_analytic || (props.item.resample == 'Y' && props.item.resample_status != 'W')">{{ init_result(props.item) }}</span>
|
||||
|
||||
<!-- <v-textarea
|
||||
solo
|
||||
hide-details
|
||||
rows="2"
|
||||
:value="props.item.result"
|
||||
@change="update_result(props.index, $event)"
|
||||
>
|
||||
</v-textarea>
|
||||
|
||||
<v-btn style="width: 28px;padding-bottom: 10px;"
|
||||
v-if="props.item.is_quantitative == 'Y' && props.item.result_instrument_n > 0"
|
||||
color="blue lighten-2" class="btn_rerun" icon flat small
|
||||
@click="rerun_me(props.index, props.item)">
|
||||
<v-img :src="icon_info" aspect-ratio="1" height="15" contain></v-img>
|
||||
</v-btn> -->
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
<span v-if="props.item.is_result = 'Y'" class="one-critical-value" :data-detail-id="props.item.id"
|
||||
style="margin-right:20px"></span>
|
||||
{{props.item.result_flag}}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
{{ props.item.normal_note}}
|
||||
<a href="javascript:;"
|
||||
v-show="props.item.normal_note != '' && props.item.normal_note != null && props.item.sample_processing == 'Y' && !init_blank_normal(props.item) && false"
|
||||
@click="normalChange(props)"><v-icon small color="blue">create</v-icon></a>
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
{{props.item.unit_name}}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
{{props.item.methode_name}}
|
||||
<a href="javascript:;"
|
||||
v-show="props.item.methode_name != '' && props.item.methode_name != null && props.item.sample_processing == 'Y' && !init_blank_normal(props.item)"
|
||||
@click="methodeChange(props)"><v-icon small color="blue">create</v-icon></a>
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
|
||||
@click="select(props.index, props.item)" v-if="props.item.is_result == 'Y'">
|
||||
<v-textarea label="" solo rows=1 hide-details
|
||||
v-on:keyup="update_note(props.index, $event.target.value)" :value="props.item.note" auto-grow
|
||||
@keydown.ctrl.a="keyDownResult(props.index, props.item)"
|
||||
:readonly="props.item.T_OrderDetailVerification == 'Y'"
|
||||
:flat="props.item.T_OrderDetailVerification == 'Y'"
|
||||
v-show="props.item.sample_worklist_receive == 'Y' && props.item.pre_analytic && !init_blank(props.item)"></v-textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
</v-data-table>
|
||||
|
||||
|
||||
</v-card>
|
||||
|
||||
<one-process-re-rerun-result></one-process-re-rerun-result>
|
||||
<one-process-re-history></one-process-re-history>
|
||||
<one-process-re-fna></one-process-re-fna>
|
||||
<one-process-re-cytologi></one-process-re-cytologi>
|
||||
<one-process-re-papsmear></one-process-re-papsmear>
|
||||
<one-process-re-lcprep></one-process-re-lcprep>
|
||||
<one-process-re-mikro></one-process-re-mikro>
|
||||
<one-process-re-preparasisperma></one-process-re-preparasisperma>
|
||||
<one-process-re-dnafragmentasi></one-process-re-dnafragmentasi>
|
||||
<v-snackbar v-model="snackbar" :timeout="5000" bottom right>
|
||||
{{ save_text }}
|
||||
<v-btn color="pink" flat @click="snackbar = false">
|
||||
Close
|
||||
</v-btn>
|
||||
</v-snackbar>
|
||||
|
||||
<one-dialog-template>
|
||||
</one-dialog-template>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
div.v-table__overflow {
|
||||
height: 640px !important;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.searchbox .v-input.v-text-field .v-input__slot {
|
||||
min-height: 60px;
|
||||
}
|
||||
|
||||
.searchbox .v-btn {
|
||||
min-height: 60px;
|
||||
}
|
||||
|
||||
table.v-table tbody td,
|
||||
table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.btn_rerun {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 2px
|
||||
}
|
||||
|
||||
.flex-card {
|
||||
min-height: -webkit-min-content;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.v-text-field.v-text-field--solo .v-input__control {
|
||||
min-height: 32px;
|
||||
box-shadow: none;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
.v-textarea.v-text-field--box.v-text-field--single-line .v-text-field__prefix,
|
||||
.v-textarea.v-text-field--box.v-text-field--single-line textarea,
|
||||
.v-textarea.v-text-field--enclosed.v-text-field--single-line .v-text-field__prefix,
|
||||
.v-textarea.v-text-field--enclosed.v-text-field--single-line textarea {
|
||||
margin-top: 2px;
|
||||
|
||||
}
|
||||
|
||||
.v-textarea.v-text-field--solo .v-input__append-inner,
|
||||
.v-textarea.v-text-field--solo .v-input__append-outer,
|
||||
.v-textarea.v-text-field--solo .v-input__prepend-inner,
|
||||
.v-textarea.v-text-field--solo .v-input__prepend-outer {
|
||||
align-self: flex-start;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.v-textarea.v-text-field--solo .v-input__append-inner .v-input__icon {
|
||||
align-items: center;
|
||||
display: inline-flex;
|
||||
height: 24px;
|
||||
flex: 1 0 auto;
|
||||
justify-content: center;
|
||||
min-width: 24px;
|
||||
width: 24px;
|
||||
padding-bottom: 6px;
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
.v-text-field.v-text-field--solo .v-input__append-outer,
|
||||
.v-text-field.v-text-field--solo .v-input__prepend-outer {
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
table.table_antibiotics {
|
||||
font-family: arial, sans-serif;
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.table_antibiotics tbody td,
|
||||
table.table_antibiotics tbody th {
|
||||
border: 1px solid #dddddd;
|
||||
text-align: left;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.table_antibiotics tbody tr:nth-child(even) {
|
||||
background-color: #dddddd;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
let ts = '?ts=' + moment().format('YYMMDDhhmmss')
|
||||
module.exports = {
|
||||
components: {
|
||||
'one-process-re-rerun-result': httpVueLoader('./oneProcessReRerunResult.vue' + ts),
|
||||
'one-process-re-history': httpVueLoader('./oneProcessReHistory.vue' + ts),
|
||||
'one-process-re-fna': httpVueLoader('./oneResultFNA.vue' + ts),
|
||||
'one-process-re-cytologi': httpVueLoader('./oneResultCytologi.vue' + ts),
|
||||
'one-process-re-papsmear': httpVueLoader('./oneResultPapsmear.vue' + ts),
|
||||
'one-process-re-lcprep': httpVueLoader('./oneResultLcprep.vue' + ts),
|
||||
'one-process-re-mikro': httpVueLoader('./oneResultMikro.vue' + ts),
|
||||
'one-dialog-template': httpVueLoader('./oneProcessReDialogResultTemplateNew.vue' + ts),
|
||||
'one-process-re-preparasisperma': httpVueLoader('./oneResultPreparasiSperma.vue' + ts),
|
||||
'one-process-re-dnafragmentasi': httpVueLoader('./oneResultDNAFragmentasi.vue' + ts),
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
query: "",
|
||||
save_text: "Data telah tersimpan.",
|
||||
items: [],
|
||||
headers: [
|
||||
{
|
||||
text: "NAMA PEMERIKSAAN",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "15%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "HASIL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "15%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "FLAG",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "10%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "NILAI NORMAL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "15%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "UNIT",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "10%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "METODE",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "15%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "CATATAN",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
}
|
||||
],
|
||||
|
||||
isLoading: false
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
pxs() {
|
||||
return this.$store.state.re_px.pxs
|
||||
},
|
||||
|
||||
icon_info() {
|
||||
return window.BASE_URL + '/one-ui/apps/image/info.png'
|
||||
},
|
||||
|
||||
snackbar: {
|
||||
get() { return this.$store.state.re_px.snackbar },
|
||||
set(v) { this.$store.commit('re_px/update_snackbar', v) }
|
||||
},
|
||||
|
||||
search_status() {
|
||||
return this.$store.state.re_px.search_status
|
||||
},
|
||||
selected_px() {
|
||||
return this.$store.state.re_px.selected_px
|
||||
},
|
||||
selected_patient() {
|
||||
return this.$store.state.re_patient.selected_patient;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async keyDownResult(idx, item) {
|
||||
await this.$store.dispatch('re_normal/update', item.id)
|
||||
if (this.$store.state.re_normal.error == "") {
|
||||
let result = this.$store.state.re_normal.result
|
||||
let pxs = this.$store.state.re_px.pxs
|
||||
pxs[idx]["normal_id"] = result.T_OrderDetailNat_NormalValueID
|
||||
pxs[idx]["normal_note"] = result.T_OrderDetailNormalValueNote
|
||||
pxs[idx]["methode_id"] = result.T_OrderDetailNat_MethodeID
|
||||
pxs[idx]["methode_name"] = result.Nat_MethodeName
|
||||
let data = { records: pxs }
|
||||
this.$store.commit("re_px/update_pxs", data)
|
||||
}
|
||||
},
|
||||
openDialogFNA(value) {
|
||||
if (value.result === null || value.result === '') {
|
||||
var results = []
|
||||
results.push({ xid: '0', orderdetail_id: value.id, code: 'A', label: 'Diagnosis Klinis', result: '' })
|
||||
results.push({ xid: '0', orderdetail_id: value.id, code: 'B', label: 'Makroskopis/Tindakan', result: '' })
|
||||
results.push({ xid: '0', orderdetail_id: value.id, code: 'C', label: 'Mikroskopis', result: '' })
|
||||
results.push({ xid: '0', orderdetail_id: value.id, code: 'D', label: 'Kesimpulan/Diagnosa', result: '' })
|
||||
results.push({ xid: '0', orderdetail_id: value.id, code: 'E', label: 'Saran', result: '' })
|
||||
this.$store.commit("re_fna/update_results", results)
|
||||
this.$store.dispatch("re_fna/get_doctors", { token: '' })
|
||||
}
|
||||
else
|
||||
this.$store.dispatch("re_fna/get_fnaresult", value)
|
||||
},
|
||||
openDialogCytologi(value) {
|
||||
//console.log(value.result)
|
||||
if (value.result === null || value.result === '') {
|
||||
console.log("ane-01")
|
||||
var results = []
|
||||
results.push({ xid: '0', orderdetail_id: value.id, code: 'A', label: 'Makroskopis', result: '' })
|
||||
results.push({ xid: '0', orderdetail_id: value.id, code: 'B', label: 'Mikroskopis', result: '' })
|
||||
results.push({ xid: '0', orderdetail_id: value.id, code: 'C', label: 'Kesimpulan', result: '' })
|
||||
this.$store.commit("re_cytologi/update_results", results)
|
||||
this.$store.dispatch("re_cytologi/get_doctors", { token: '' })
|
||||
}
|
||||
else {
|
||||
console.log("ane-09")
|
||||
this.$store.dispatch("re_cytologi/get_cytologiresult", value)
|
||||
}
|
||||
|
||||
},
|
||||
openDialogPapsmear(value) {
|
||||
this.$store.commit("re_papsmear/update_selected_papsmear", value)
|
||||
this.$store.dispatch("re_papsmear/get_papsmearresult", value)
|
||||
},
|
||||
openDialogLcprep(value) {
|
||||
console.log(value)
|
||||
this.$store.commit("re_lcprep/update_selected_lcprep", value)
|
||||
this.$store.dispatch("re_lcprep/get_lcprepresult", value)
|
||||
},
|
||||
openDialogMikro(value) {
|
||||
this.$store.commit("re_mikro/update_selected_mikro", value)
|
||||
this.$store.dispatch("re_mikro/get_mikroresult", value)
|
||||
},
|
||||
openDialogPreparasiSperma(value) {
|
||||
console.log(value)
|
||||
this.$store.commit("re_preparasisperma/update_selected_preparasisperma", value)
|
||||
if (value.result === null || value.result === '') {
|
||||
var results = { xid: '0' }
|
||||
console.log('result null')
|
||||
this.$store.commit("re_preparasisperma/update_results", results)
|
||||
this.$store.dispatch("re_preparasisperma/get_doctors_preparasi_sperma", { token: '' })
|
||||
}
|
||||
else
|
||||
this.$store.dispatch("re_preparasisperma/get_preparasispermaresult", value)
|
||||
},
|
||||
openDialogDNAFRagmentasi(value) {
|
||||
this.$store.commit("re_dnafragmentasi/update_selected_dnafragmentasi", value)
|
||||
this.$store.dispatch("re_dnafragmentasi/get_dnafragmentasiresult", value)
|
||||
},
|
||||
oneMoment: function (d) {
|
||||
return window.oneMoment(d)
|
||||
},
|
||||
|
||||
select(idx, item) {
|
||||
this.$store.commit('re_px/update_selected_px', item)
|
||||
this.$store.commit('re_px/update_selected_px_idx', idx)
|
||||
},
|
||||
|
||||
is_selected(item) {
|
||||
|
||||
return ''
|
||||
},
|
||||
|
||||
margin_left(item) {
|
||||
if (item.level == 2)
|
||||
return 'pl-4'
|
||||
|
||||
if (item.level == 3)
|
||||
return 'pl-5'
|
||||
|
||||
return 'pl-2'
|
||||
},
|
||||
|
||||
rerun_me(idx, item) {
|
||||
if (item.verification == 'Y') return
|
||||
this.select(idx, item)
|
||||
this.$store.commit('re_px/update_dialog_rerun', true)
|
||||
},
|
||||
|
||||
update_result(idx, result) {
|
||||
let x = this.$store.state.re_px.pxs
|
||||
x[idx]['result'] = result
|
||||
|
||||
this.$store.commit('re_px/update_pxs', { records: x })
|
||||
},
|
||||
|
||||
update_note(idx, note) {
|
||||
|
||||
let x = this.$store.state.re_px.pxs
|
||||
x[idx]['note'] = note
|
||||
|
||||
this.$store.commit('re_px/update_pxs', { records: x })
|
||||
},
|
||||
|
||||
template_new(item) {
|
||||
this.$store.commit('re_px/update_selected_px', item)
|
||||
this.$store.commit('re_px/update_dialog_template_new', true)
|
||||
},
|
||||
|
||||
methodeChange(d) {
|
||||
if (d.item.verification == 'Y') return
|
||||
this.select(d.index, d.item)
|
||||
this.$store.commit('normal_method/update_nattest_id', d.item.nattest_id)
|
||||
this.$store.commit('normal_method/update_id', d.item.id)
|
||||
this.$store.commit('normal_method/update_dialog_method', true)
|
||||
},
|
||||
|
||||
normalChange(d) {
|
||||
return
|
||||
},
|
||||
|
||||
init_result(x) {
|
||||
if (x.verification == "Y" || x.validation == "Y")
|
||||
return x.result
|
||||
|
||||
let susul_date = moment(x.T_OrderPromiseDateTime).format('DD.MM.YYYY HH:mm')
|
||||
// Override
|
||||
if (x.resample == "Y") {
|
||||
if (x.resample_status == "N")
|
||||
return "Bahan belum"
|
||||
if (x.resample_status == "R")
|
||||
return "Hasil Menyusul : " + susul_date
|
||||
if (x.resample_status == "W")
|
||||
return x.result
|
||||
}
|
||||
|
||||
if (x.sample_receive != 'Y')
|
||||
return "Bahan belum"
|
||||
if (x.sample_receive == 'Y' && !x.pre_analytic)
|
||||
return "Belum Pre Analitik"
|
||||
if (x.sample_receive == 'Y' && x.pre_analytic) {
|
||||
if (x.sample_worklist_receive == "Y")
|
||||
return x.result
|
||||
else
|
||||
return "Hasil Menyusul : " + susul_date
|
||||
}
|
||||
},
|
||||
|
||||
init_blank_normal(x) {
|
||||
if (x.verification == "Y" || x.validation == "Y")
|
||||
return false
|
||||
|
||||
if (x.sample_receive != "Y")
|
||||
return true
|
||||
|
||||
return false
|
||||
},
|
||||
init_blank(x) {
|
||||
if (x.verification == "Y" || x.validation == "Y")
|
||||
return false
|
||||
|
||||
// Override
|
||||
if (x.resample == "Y") {
|
||||
if (x.resample_status == "N" || x.resample_status == "R")
|
||||
return true
|
||||
}
|
||||
|
||||
if (x.sample_receive != 'Y' || !x.pre_analytic || x.sample_worklist_receive != "Y")
|
||||
return true
|
||||
|
||||
return false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
selected_patient(n, o) {
|
||||
setTimeout(() => {
|
||||
window.render_one_critical_value();
|
||||
window.render_one_critical_value_header();
|
||||
}, 1500);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('dna fragmentasi')
|
||||
// this.$store.dispatch('re_patient/search')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,174 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
persistent
|
||||
max-width="500px"
|
||||
transition="dialog-transition"
|
||||
>
|
||||
|
||||
|
||||
<v-layout class="fill-height" column>
|
||||
<v-card class="grow">
|
||||
<v-card-text>
|
||||
<v-data-table
|
||||
:headers="headers" :items="reruns"
|
||||
:loading="isLoading"
|
||||
hide-actions class="elevation-1">
|
||||
<template slot="items" slot-scope="props">
|
||||
<td class="text-xs-left pa-2 green--text" v-bind:class="is_selected(props.item)">
|
||||
{{get_instrument_date(props.item)}}
|
||||
</td>
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)">
|
||||
{{ props.item.branch_name }}
|
||||
</td>
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)">
|
||||
{{ props.item.result }}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)">
|
||||
<v-btn flat icon color="green" @click="select(props.item)">
|
||||
<v-icon>get_app</v-icon>
|
||||
</v-btn>
|
||||
</td>
|
||||
</template>
|
||||
|
||||
</v-data-table>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="blue darken-1" flat @click="dialog = false">Tutup</v-btn>
|
||||
<!-- <v-btn color="blue darken-1" :dark="btn_save_enabled" @click="save" :disabled="!btn_save_enabled">Simpan</v-btn> -->
|
||||
</v-card-actions>
|
||||
|
||||
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.searchbox .v-input.v-text-field .v-input__slot{
|
||||
min-height:60px;
|
||||
}
|
||||
.searchbox .v-btn {
|
||||
min-height:60px;
|
||||
}
|
||||
table.v-table tbody td,table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
query: "",
|
||||
items: [],
|
||||
headers: [
|
||||
{
|
||||
text: "TANGGAL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "40%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "CABANG",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "35%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "HASIL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "5%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
isLoading: false
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
methods : {
|
||||
oneMoment : function(d) {
|
||||
return window.oneMoment(d)
|
||||
},
|
||||
get_instrument_date(i) {
|
||||
// debugger
|
||||
let rst = ''
|
||||
try {
|
||||
rst = moment(i.instrument_date).format('DD.MM.YYYY HH:mm')
|
||||
} catch(e) {}
|
||||
return rst
|
||||
},
|
||||
select (item) {
|
||||
this.$store.commit('re_px/update_selected_rerun', item)
|
||||
// this.$store.commit('re_px/update_dialog_rerun', false)
|
||||
|
||||
/* let x = this.$store.state.re_px.pxs
|
||||
x[this.$store.state.re_px.selected_px_idx]['result'] = item.result
|
||||
x[this.$store.state.re_px.selected_px_idx]['result_id'] = item.result_id
|
||||
console.log(x)
|
||||
this.$store.commit('re_px/update_pxs', {records:x})
|
||||
*/
|
||||
this.$store.dispatch("re_px/savererun", item)
|
||||
console.log(item)
|
||||
},
|
||||
|
||||
is_selected (item) {
|
||||
// let x = this.$store.state.re_patient.selected_patient
|
||||
// if (!x)
|
||||
// return ''
|
||||
|
||||
// if (x.T_OrderHeaderID == item.T_OrderHeaderID)
|
||||
// return 'green lighten-4'
|
||||
|
||||
return ''
|
||||
}
|
||||
},
|
||||
|
||||
computed : {
|
||||
reruns () {
|
||||
return this.$store.state.re_px.reruns
|
||||
},
|
||||
|
||||
dialog : {
|
||||
get () { return this.$store.state.re_px.dialog_rerun },
|
||||
set (v) { this.$store.commit('re_px/update_dialog_rerun', v) }
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
// this.$store.dispatch('re_px/search_rerun')
|
||||
},
|
||||
|
||||
watch : {
|
||||
dialog(n, o) {
|
||||
if (n && !o) {
|
||||
this.$store.dispatch('re_px/search_rerun')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,489 @@
|
||||
<template>
|
||||
<v-card class="mb-1 pa-1">
|
||||
<v-layout row>
|
||||
<v-flex xs8>
|
||||
<v-layout>
|
||||
<one-date-picker label="Tgl. Awal" :date="sdate" class="mydate" data="0"
|
||||
@change="changeDate"></one-date-picker>
|
||||
<one-edate-picker label="Tgl. Akhir" :date="edate" class="mydate" data="0"
|
||||
@change="echangeDate"></one-edate-picker>
|
||||
<v-text-field class="flex ma-1" label="" placeholder="No Reg / Nama" single-line solo hide-details
|
||||
v-model="search" @keyup.native="keySearch"></v-text-field>
|
||||
<v-select :items="companies" class="ma-1" v-model="company" item-text="CorporateName"
|
||||
item-value="CorporateID" label="Kelompok Pelanggan" return-object solo hide-details
|
||||
clearable></v-select>
|
||||
<!-- <v-autocomplete v-model="company" :items="companies" :loading="loading_company"
|
||||
:search-input.sync="search_company" class="ma-1 ml-1 mr-1" hide-no-data filled
|
||||
item-text="CorporateName" item-value="CorporateID" label=""
|
||||
placeholder="Cari Kelompok Pelanggan" return-object solo hide-details></v-autocomplete>
|
||||
|
||||
<v-select :items="groups" class="ma-1" v-model="selected_group" item-text="group_name"
|
||||
item-value="group_id" label="Grup Pemeriksaan" return-object solo hide-details
|
||||
clearable></v-select> -->
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
<v-flex xs2>
|
||||
<v-layout>
|
||||
<v-btn class="btn-search one-btn-icon ma-1" color="success" @click="searchs">
|
||||
<span class="icon-search"><span>
|
||||
</v-btn>
|
||||
</v-layout>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs6 class="text-xs-right">
|
||||
<!-- <img :src="'../../../libs/image/' + img_lang" height="36" style="float:left" alt="" /> -->
|
||||
|
||||
<v-btn v-show="false" v-for="(lang, n) in langs" v-bind:key="n" color="grey lighten-1"
|
||||
class="one-btn-icon pl-2 pr-2 ml-0 mr-1" depressed :outline="!lang_selected(lang)"
|
||||
@click="lang_change(lang)">
|
||||
<img :src="'../../../libs/image/' + img_lang_2(lang.code, lang.is_si)" height="40" alt="" />
|
||||
</v-btn>
|
||||
|
||||
<v-btn v-if="show_re_age" class="btn-search one-btn-icon ma-1" color="brown" @click="re_calc_age" dark>
|
||||
Re. Age
|
||||
</v-btn>
|
||||
|
||||
<!-- <v-btn v-show="!info_req_perfect" class="btn-search one-btn-icon ma-1" color="red" @click="info" dark>
|
||||
<v-icon>info</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<v-btn class="btn-search one-btn-icon ma-1" color="red" @click="note" dark>
|
||||
<v-icon>library_books</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<v-btn color="blue-grey" class="white--text ma-1" @click="histories" v-show="btn_history_show">
|
||||
Histori
|
||||
</v-btn> -->
|
||||
|
||||
<v-btn @click="doPrintKultur()" class="white--text ma-1" color="red darken-2" dark v-show="btn_print_kultur_show">Print out kultur <v-icon right
|
||||
dark>print</v-icon></v-btn>
|
||||
<v-btn @click="doPrintPapsmear()" class="white--text ma-1" color="brown" dark v-show="btn_print_papsmear_show">Print out papsmear <v-icon right
|
||||
dark>print</v-icon></v-btn>
|
||||
<v-btn @click="doPrintPatient()" class="white--text ma-1" color="purple darken-2" dark>Cetak History <v-icon right
|
||||
dark>print</v-icon></v-btn>
|
||||
<v-btn @click="doPrint()" class="white--text ma-1" color="orange" dark>Cetak <v-icon right
|
||||
dark>print</v-icon></v-btn>
|
||||
|
||||
<v-btn color="blue" class="white--text ma-1" @click="save_result">
|
||||
Simpan
|
||||
<v-icon right dark>save_alt</v-icon>
|
||||
</v-btn>
|
||||
<!-- <v-btn color="green" class="white--text ma-1" @click="save_validate" :disabled="!btn_validation_enable"
|
||||
:dark="btn_validation_enable">
|
||||
Validasi
|
||||
<v-icon right dark>save_alt</v-icon>
|
||||
</v-btn>
|
||||
<v-btn color="red" class="white--text ma-1" @click="unvalidate" dark>
|
||||
UnValidasi
|
||||
<v-icon right dark>save_alt</v-icon>
|
||||
</v-btn> -->
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
||||
<one-dialog-print :title="printtitle" :width="printwidth" :height="700" :status="openprint" :urlprint="urlprint"
|
||||
@close-dialog-print="openprint = false"></one-dialog-print>
|
||||
|
||||
<v-dialog v-model="dialog_print_new"
|
||||
max-width="1000px"
|
||||
persistent>
|
||||
<v-card>
|
||||
<v-card-text>
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12>
|
||||
<object style="overflow: hidden;" width="100%" :height="700" :data="urlprint"></object>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="primary" @click="closePrint">Tutup</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<v-dialog v-model="dialog_status"
|
||||
max-width="500px"
|
||||
persistent>
|
||||
<v-card>
|
||||
<v-card-text>
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12>{{status_print}}}
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-actions>
|
||||
<v-btn color="primary" flat @click="dialog_status=!dialog_status">Abaikan</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="primary" @click="add_log_print">Ya, mengerti</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.mydate {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
button {
|
||||
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
.btn-search {
|
||||
font-size: 1.5em
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
components: {
|
||||
'one-date-picker': httpVueLoader('./oneDatePicker.vue'),
|
||||
'one-edate-picker': httpVueLoader('./oneEndDatePicker.vue'),
|
||||
'one-dialog-print': httpVueLoader('../../common/oneDialogPrintX.vue')
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
search_company: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
search_company(n, o) {
|
||||
this.$store.dispatch('company/search', n)
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
test_not_yet: {
|
||||
get() { return this.$store.state.helper.test_not_yet },
|
||||
set(v) { this.$store.commit('helper/update_test_not_yet', v) }
|
||||
},
|
||||
urlprint: {
|
||||
get() { return this.$store.state.helper.urlprint },
|
||||
set(v) { this.$store.commit('helper/update_urlprint', v) }
|
||||
},
|
||||
printtitle: {
|
||||
get() { return this.$store.state.helper.printtitle },
|
||||
set(v) { this.$store.commit('helper/update_printtitle', v) }
|
||||
},
|
||||
printwidth: {
|
||||
get() { return this.$store.state.helper.printwidth },
|
||||
set(v) { this.$store.commit('helper/update_printwidth', v) }
|
||||
},
|
||||
show_re_age() {
|
||||
return this.$store.state.re_patient.selected_patient.T_OrderHeaderAddOnRequestChangeDOB == 'Y'
|
||||
},
|
||||
company: {
|
||||
get() { return this.$store.state.company.company },
|
||||
set(v) { this.$store.commit('company/update_company', v) }
|
||||
},
|
||||
companies() {
|
||||
return this.$store.state.company.companies
|
||||
},
|
||||
loading_company() {
|
||||
return this.$store.state.company.loading
|
||||
},
|
||||
nolab: {
|
||||
get() { return this.$store.state.re_patient.nolab },
|
||||
set(v) { this.$store.commit('re_patient/update_nolab', v) }
|
||||
},
|
||||
search: {
|
||||
get() { return this.$store.state.re_patient.search },
|
||||
set(v) { this.$store.commit('re_patient/update_search', v) }
|
||||
},
|
||||
status_print: {
|
||||
get() { return this.$store.state.helper.status_print },
|
||||
set(v) { this.$store.commit('helper/update_status_print', v) }
|
||||
},
|
||||
dialog_status : {
|
||||
get () { return this.$store.state.helper.dialog_status },
|
||||
set (v) { this.$store.commit('helper/update_dialog_status', v) }
|
||||
},
|
||||
groups() {
|
||||
return this.$store.state.re_px.groups
|
||||
},
|
||||
selected_group: {
|
||||
get() { return this.$store.state.re_px.selected_group },
|
||||
set(v) {
|
||||
this.$store.commit('re_px/update_selected_group', v)
|
||||
this.$store.dispatch('re_patient/search')
|
||||
}
|
||||
},
|
||||
btn_validation_enable() {
|
||||
return true
|
||||
let x = this.$store.state.re_px.pxs
|
||||
// console.log(x)
|
||||
let y = 0, n = 0
|
||||
for (let i in x) {
|
||||
// console.log(i+' : '+x[i].t_testname+' : '+x[i].is_result+' : '+x[i].validation+' : '+x[i].verification)
|
||||
if (x[i].is_result == 'Y') {
|
||||
n++
|
||||
if (x[i].validation == 'Y') { y++; }
|
||||
}
|
||||
}
|
||||
// console.log("n:"+n+" y:"+y)
|
||||
if (y < 1) return false
|
||||
return true
|
||||
},
|
||||
|
||||
btn_validation_show() {
|
||||
let x = this.$store.state.re_px.pxs
|
||||
let z = 0, n = 0
|
||||
for (let i in x) {
|
||||
if (x[i].is_result == 'Y') {
|
||||
n++
|
||||
if (x[i].validation_old == 'Y')
|
||||
z++
|
||||
}
|
||||
}
|
||||
|
||||
if (z == n) return false
|
||||
return true
|
||||
},
|
||||
btn_print_papsmear_show() {
|
||||
let x = this.$store.state.re_px.pxs
|
||||
for (let i in x) {
|
||||
|
||||
if (x[i].t_testid == '1611') {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// return true
|
||||
},
|
||||
btn_print_kultur_show() {
|
||||
let x = this.$store.state.re_px.pxs
|
||||
for (let i in x) {
|
||||
|
||||
if (x[i].ResultGroupName == 'Mikro') {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// return true
|
||||
},
|
||||
lang() {
|
||||
return this.$store.state.re_patient.selected_patient.M_LangCode
|
||||
},
|
||||
|
||||
img_lang() {
|
||||
if (this.lang == "ID")
|
||||
return "inako.png"
|
||||
// return "flag-ina_48.png"
|
||||
else if (this.lang == "EN")
|
||||
return "engko.png"
|
||||
// return "flag-us_48.png"
|
||||
},
|
||||
|
||||
langs() {
|
||||
return this.$store.state.re_patient.langs
|
||||
},
|
||||
|
||||
sdate: {
|
||||
get() { return this.$store.state.re_patient.s_date },
|
||||
set(v) { this.$store.commit('re_patient/update_sdate', v) }
|
||||
},
|
||||
edate: {
|
||||
get() { return this.$store.state.re_patient.e_date },
|
||||
set(v) { this.$store.commit('re_patient/update_edate', v) }
|
||||
},
|
||||
|
||||
selected_patient() {
|
||||
return this.$store.state.re_patient.selected_patient
|
||||
},
|
||||
|
||||
btn_history_show() {
|
||||
if (!this.selected_patient) return false
|
||||
if (!this.selected_patient.is_history) return false
|
||||
if (this.selected_patient.is_history == "N") return false
|
||||
|
||||
return true
|
||||
},
|
||||
|
||||
info_req_perfect() {
|
||||
let x = false
|
||||
try {
|
||||
x = this.$store.state.re_patient.info_req.is_perfect == 'Y';
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
return x
|
||||
},
|
||||
|
||||
openprint: {
|
||||
get() {
|
||||
return this.$store.state.helper.open_print
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("helper/update_open_print", false)
|
||||
}
|
||||
},
|
||||
dialog_print_new: {
|
||||
get() {
|
||||
return this.$store.state.helper.dialog_print_new
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit("helper/update_dialog_print_new", false)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
searchs() {
|
||||
this.$store.dispatch('re_patient/search')
|
||||
},
|
||||
async re_calc_age() {
|
||||
|
||||
let orderID = this.$store.state.re_patient.selected_patient.T_OrderHeaderID
|
||||
await this.$store.dispatch('helper/calc_age', orderID)
|
||||
},
|
||||
add_log_print() {
|
||||
id = this.$store.state.re_patient.selected_patient.T_OrderHeaderID
|
||||
let tests = this.$store.state.helper.test_not_yet
|
||||
this.$store.dispatch('helper/insertlogprint', {orderid : id, tests: tests})
|
||||
|
||||
/*
|
||||
tm = Date.now()
|
||||
let user = one_user()
|
||||
this.printwidth = 1700
|
||||
this.printtitle = ""
|
||||
let rpt = 'rpt_test'
|
||||
this.urlprint = "/birt/run?__report=report/one/lab/" + rpt + ".rptdesign&__format=pdf&PID=" + id + "&username=" + user.M_StaffName + "&tm=" + tm
|
||||
this.$store.commit("helper/update_open_print", true)
|
||||
*/
|
||||
},
|
||||
closePrint() {
|
||||
id = this.$store.state.re_patient.selected_patient.T_OrderHeaderID
|
||||
this.$store.dispatch('helper/check_status_print', id)
|
||||
},
|
||||
doPrint() {
|
||||
id = this.$store.state.re_patient.selected_patient.T_OrderHeaderID
|
||||
tm = Date.now()
|
||||
let user = one_user()
|
||||
this.printwidth = 1700
|
||||
this.printtitle = ""
|
||||
let rpt = 'rpt_test'
|
||||
// https://devcpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&PID=1&username=adhi&tm=1717726294764
|
||||
this.urlprint = "/birt/run?__report=report/one/lab/" + rpt + ".rptdesign&__format=pdf&PID=" + id + "&username=" + user.M_StaffName + "&tm=" + tm
|
||||
this.$store.commit("helper/update_dialog_print_new", true)
|
||||
|
||||
},
|
||||
doPrintPatient() {
|
||||
id = this.$store.state.re_patient.selected_patient.T_OrderHeaderID
|
||||
tm = Date.now()
|
||||
let user = one_user()
|
||||
this.printwidth = 1700
|
||||
this.printtitle = ""
|
||||
let rpt = 'rpt_test_history'
|
||||
// https://cpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_history.rptdesign&__format=pdf&PID=7931&username=adhi&tm=1717726294764
|
||||
this.urlprint = "/birt/run?__report=report/one/lab/" + rpt + ".rptdesign&__format=pdf&PID=" + id + "&username=" + user.M_StaffName + "&tm=" + tm
|
||||
this.$store.commit("helper/update_open_print", true)
|
||||
},
|
||||
doPrintPapsmear() {
|
||||
id = this.$store.state.re_patient.selected_patient.T_OrderHeaderID
|
||||
tm = Date.now()
|
||||
let user = one_user()
|
||||
this.printwidth = 1700
|
||||
this.printtitle = ""
|
||||
let rpt = 'rpt_test_papsmear'
|
||||
// https://cpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_papsmear.rptdesign&__format=pdf&PID=323&username=PETUGAS%20SAMPLE%20LAB&tm=1721461717824
|
||||
this.urlprint = "/birt/run?__report=report/one/lab/" + rpt + ".rptdesign&__format=pdf&PID=" + id + "&username=" + user.M_StaffName + "&tm=" + tm
|
||||
this.$store.commit("helper/update_open_print", true)
|
||||
},
|
||||
doPrintKultur() {
|
||||
id = this.$store.state.re_patient.selected_patient.T_OrderHeaderID
|
||||
tm = Date.now()
|
||||
let user = one_user()
|
||||
this.printwidth = 1700
|
||||
this.printtitle = ""
|
||||
let rpt = 'rpt_test_mikro'
|
||||
// https://cpone.aplikasi.web.id/birt/run?__report=report/one/lab/rpt_test_mikro.rptdesign&__format=pdf&PID=2088&username=PETUGAS%20SAMPLE%20LAB&tm=1721461717824
|
||||
this.urlprint = "/birt/run?__report=report/one/lab/" + rpt + ".rptdesign&__format=pdf&PID=" + id + "&username=" + user.M_StaffName + "&tm=" + tm
|
||||
this.$store.commit("helper/update_open_print", true)
|
||||
},
|
||||
keySearch(e) {
|
||||
if (e.which == 13) {
|
||||
this.searchs()
|
||||
}
|
||||
},
|
||||
|
||||
search_px() {
|
||||
this.$store.dispatch('re_px/search')
|
||||
},
|
||||
|
||||
save_result() {
|
||||
this.$store.dispatch('re_px/save')
|
||||
},
|
||||
save_validate() {
|
||||
this.$store.dispatch('re_px/confirm')
|
||||
let patient = this.$store.state.re_patient.selected_patient
|
||||
if (patient.T_OrderHeaderAddOnValidationDone == 'N') {
|
||||
patient.T_OrderHeaderAddOnValidationDone = 'P'
|
||||
}
|
||||
let patients = this.$store.state.re_patient.patients;
|
||||
|
||||
for (let i = 0; i < patients.length; i++) {
|
||||
if (patients[i].M_PatientID == patient.M_PatientID) {
|
||||
patients[i] = patient
|
||||
}
|
||||
}
|
||||
let dt = { records: patients, total_page: 1, total: patients.length }
|
||||
this.$store.commit("re_patient/update_patients", dt)
|
||||
console.log('pat', patients)
|
||||
},
|
||||
unvalidate() {
|
||||
this.$store.dispatch('re_px/unvalidate')
|
||||
},
|
||||
histories() {
|
||||
this.$store.dispatch('re_history/history')
|
||||
this.$store.commit('re_history/update_dialog_history', true)
|
||||
},
|
||||
|
||||
img_lang_2(lang, si) {
|
||||
|
||||
if (lang == "ID" && si == "N")
|
||||
return "inako.png"
|
||||
if (lang == "ID" && si == "Y")
|
||||
return "inasi.png"
|
||||
if (lang == "EN" && si == "N")
|
||||
return "engko.png"
|
||||
if (lang == "EN" && si == "Y")
|
||||
return "engsi.png"
|
||||
},
|
||||
|
||||
lang_change(lang) {
|
||||
this.$store.commit('re_patient/update_lang', lang)
|
||||
this.$store.dispatch('re_px/lang_export')
|
||||
},
|
||||
|
||||
lang_selected(lang) {
|
||||
if (lang.code == this.$store.state.re_patient.lang_code)
|
||||
return true
|
||||
return false
|
||||
},
|
||||
|
||||
changeDate(x) {
|
||||
this.sdate = x.new_date
|
||||
this.searchs()
|
||||
},
|
||||
echangeDate(x) {
|
||||
this.edate = x.new_date
|
||||
this.searchs()
|
||||
},
|
||||
note() {
|
||||
this.$store.commit('re_patient/update_dialog_note', true)
|
||||
},
|
||||
|
||||
info() {
|
||||
this.$store.commit('re_patient/update_dialog_req', true)
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
//this.$store.dispatch('company/search', {search_company: ''})
|
||||
this.$store.dispatch('re_px/search_group')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,171 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
persistent
|
||||
max-width="500px"
|
||||
transition="dialog-transition"
|
||||
>
|
||||
|
||||
|
||||
<v-layout class="fill-height" column>
|
||||
<v-card class="grow">
|
||||
<v-card-text>
|
||||
<v-data-table
|
||||
:headers="headers" :items="reruns"
|
||||
:loading="isLoading"
|
||||
hide-actions class="elevation-1">
|
||||
<template slot="items" slot-scope="props">
|
||||
<td class="text-xs-left pa-2 green--text" v-bind:class="is_selected(props.item)">
|
||||
{{get_instrument_date(props.item)}}
|
||||
</td>
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)">
|
||||
{{ props.item.instrument_name }}
|
||||
</td>
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)">
|
||||
{{ props.item.result }}
|
||||
</td>
|
||||
|
||||
<td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)">
|
||||
<v-btn flat icon color="green" @click="select(props.item)">
|
||||
<v-icon>get_app</v-icon>
|
||||
</v-btn>
|
||||
</td>
|
||||
</template>
|
||||
|
||||
</v-data-table>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="blue darken-1" flat @click="dialog = false">Tutup</v-btn>
|
||||
<!-- <v-btn color="blue darken-1" :dark="btn_save_enabled" @click="save" :disabled="!btn_save_enabled">Simpan</v-btn> -->
|
||||
</v-card-actions>
|
||||
|
||||
|
||||
</v-card>
|
||||
</v-layout>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.searchbox .v-input.v-text-field .v-input__slot{
|
||||
min-height:60px;
|
||||
}
|
||||
.searchbox .v-btn {
|
||||
min-height:60px;
|
||||
}
|
||||
table.v-table tbody td,table.v-table tbody th {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
table.v-table thead tr {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script>
|
||||
module.exports = {
|
||||
data() {
|
||||
return {
|
||||
query: "",
|
||||
items: [],
|
||||
headers: [
|
||||
{
|
||||
text: "TANGGAL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "40%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "ALAT",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "35%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "HASIL",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "20%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
},
|
||||
{
|
||||
text: "",
|
||||
align: "left",
|
||||
sortable: false,
|
||||
value: "mr",
|
||||
width: "5%",
|
||||
class: "pa-2 blue lighten-3 white--text"
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
isLoading: false
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
methods : {
|
||||
oneMoment : function(d) {
|
||||
return window.oneMoment(d)
|
||||
},
|
||||
get_instrument_date(i) {
|
||||
// debugger
|
||||
let rst = ''
|
||||
try {
|
||||
rst = moment(i.instrument_date).format('DD.MM.YYYY HH:mm')
|
||||
} catch(e) {}
|
||||
return rst
|
||||
},
|
||||
select (item) {
|
||||
this.$store.commit('re_px/update_selected_rerun', item)
|
||||
this.$store.commit('re_px/update_dialog_rerun', false)
|
||||
|
||||
let x = this.$store.state.re_px.pxs
|
||||
x[this.$store.state.re_px.selected_px_idx]['result'] = item.result
|
||||
x[this.$store.state.re_px.selected_px_idx]['resultInstrumentID'] = item.resultInstrumentID
|
||||
console.log(x)
|
||||
this.$store.commit('re_px/update_pxs', {records:x})
|
||||
},
|
||||
|
||||
is_selected (item) {
|
||||
// let x = this.$store.state.re_patient.selected_patient
|
||||
// if (!x)
|
||||
// return ''
|
||||
|
||||
// if (x.T_OrderHeaderID == item.T_OrderHeaderID)
|
||||
// return 'green lighten-4'
|
||||
|
||||
return ''
|
||||
}
|
||||
},
|
||||
|
||||
computed : {
|
||||
reruns () {
|
||||
return this.$store.state.re_px.reruns
|
||||
},
|
||||
|
||||
dialog : {
|
||||
get () { return this.$store.state.re_px.dialog_rerun },
|
||||
set (v) { this.$store.commit('re_px/update_dialog_rerun', v) }
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
// this.$store.dispatch('re_px/search_rerun')
|
||||
},
|
||||
|
||||
watch : {
|
||||
dialog(n, o) {
|
||||
if (n && !o) {
|
||||
this.$store.dispatch('re_px/search_rerun')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user