step 3 download api 10.9.9.8 result entry v105
This commit is contained in:
42
api/10.9.9.8/resultentry-v105/Company.php
Normal file
42
api/10.9.9.8/resultentry-v105/Company.php
Normal file
@@ -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 M_CompanyID, M_CompanyName
|
||||
from m_company
|
||||
where M_CompanyName like ?
|
||||
and M_CompanyIsActive = 'Y'
|
||||
limit 0,30";
|
||||
$query = $this->db_smartone->query($sql, array($qry) );
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
$result = array("data" => $rows );
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
47
api/10.9.9.8/resultentry-v105/Helper.php
Normal file
47
api/10.9.9.8/resultentry-v105/Helper.php
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
182
api/10.9.9.8/resultentry-v105/History-bkp.php
Normal file
182
api/10.9.9.8/resultentry-v105/History-bkp.php
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
350
api/10.9.9.8/resultentry-v105/History.php
Normal file
350
api/10.9.9.8/resultentry-v105/History.php
Normal file
@@ -0,0 +1,350 @@
|
||||
<?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"];
|
||||
|
||||
// patient note
|
||||
$patient_note = "";
|
||||
$sql_patient_note = "select M_PatientNote
|
||||
from m_patient
|
||||
where M_PatientID = ?
|
||||
AND M_PatientIsActive = 'Y'";
|
||||
|
||||
$query_patient_note = $this->db_smartone->query($sql_patient_note, [$patientID]);
|
||||
if (!$query_patient_note) {
|
||||
$this->sys_error_db("Err : Patient Note", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows_patient_note = $query_patient_note->result_array();
|
||||
$patient_note = $rows_patient_note[0]['M_PatientNote'];
|
||||
|
||||
$maxOrder = 10;
|
||||
|
||||
$sql_min_id = "select min(T_OrderHeaderID) as minID
|
||||
from (
|
||||
select (T_OrderHeaderID)
|
||||
from t_orderheader
|
||||
where T_OrderHeaderM_PatientID = ?
|
||||
and T_OrderHeaderID < ?
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate < NOW()
|
||||
group by DATE(T_OrderHeaderDate)
|
||||
order by T_OrderHeaderDate desc
|
||||
limit 0, $maxOrder
|
||||
) as minX";
|
||||
|
||||
$query = $this->db_smartone->query($sql_min_id, array($patientID, $orderID));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Err : Patient", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$rowsXX = $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,
|
||||
IFNULL(T_OrderDetailInternalNote,'') as T_OrderDetailInternalNote
|
||||
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"];
|
||||
$result_T_OrderDetailInternalNote = $r['T_OrderDetailInternalNote'];
|
||||
|
||||
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(),
|
||||
// T_OrderDetailInternalNote
|
||||
"notes" => []
|
||||
);
|
||||
$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;
|
||||
$arr_result[$index_px]["notes"][$date] = $result_T_OrderDetailInternalNote;
|
||||
$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] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // T_OrderDetailInternalNote
|
||||
foreach ($arr_result as $idx => $v) {
|
||||
foreach ($arr_date as $date) {
|
||||
if (!isset($v["notes"][$date])) {
|
||||
$arr_result[$idx]["notes"][$date] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($arr_date);
|
||||
|
||||
$result = array(
|
||||
// "lastData" => $lastData,
|
||||
// "x" => $lastData['minID'],
|
||||
// "rowsXX"=> $rowsXX,
|
||||
// "countrowsXX" => count($rowsXX),
|
||||
"sql_min_id" => $sql_min_id,
|
||||
"sql_last"=> $this->db_smartone->last_query(),
|
||||
"patient_note" => $patient_note,
|
||||
"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);
|
||||
}
|
||||
}
|
||||
49
api/10.9.9.8/resultentry-v105/Re_normal.php
Normal file
49
api/10.9.9.8/resultentry-v105/Re_normal.php
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
75
api/10.9.9.8/resultentry-v105/Re_normal_method-pe.php
Normal file
75
api/10.9.9.8/resultentry-v105/Re_normal_method-pe.php
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
75
api/10.9.9.8/resultentry-v105/Re_normal_method.php
Normal file
75
api/10.9.9.8/resultentry-v105/Re_normal_method.php
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
359
api/10.9.9.8/resultentry-v105/Re_patient.php
Normal file
359
api/10.9.9.8/resultentry-v105/Re_patient.php
Normal file
@@ -0,0 +1,359 @@
|
||||
<?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"] . '%';
|
||||
$sdate = $prm["start_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_OrderHeaderM_CompanyID = $company_id ";
|
||||
}
|
||||
}
|
||||
$q_search = " and
|
||||
( M_PatientName LIKE ?
|
||||
or T_OrderHeaderLabNumber like ?
|
||||
or T_OrderHeaderAddOnLabNumberOrigin like ?
|
||||
or T_OrderHeaderLabNumberExt 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);
|
||||
}
|
||||
}
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y' and date(T_OrderHeaderDate) = ?";
|
||||
$qry = $this->db_smartone->query($sql, array($sdate));
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
// t_order_attachment
|
||||
$sql_attachment = "select T_OrderAttachmentName, T_OrderAttachmentType, T_OrderAttachmentUrl
|
||||
from t_order_attachment
|
||||
join t_orderheader
|
||||
ON T_OrderAttachmentT_OrderHeaderID = T_OrderHeaderID
|
||||
AND T_OrderAttachmentIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderAttachmentT_OrderHeaderID in ( $order_ids )";
|
||||
|
||||
$qry_attachment = $this->db_smartone->query($sql_attachment);
|
||||
if (!$qry_attachment) {
|
||||
$this->db_smartone->trans_rollback();
|
||||
$this->sys_error_db("select t_order_attachment ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$extension_lab = "-";
|
||||
$extension_non_lab = "-";
|
||||
$lab_name = "-";
|
||||
$non_lab_name = "-";
|
||||
$lab_type = "-";
|
||||
$non_lab_type = "-";
|
||||
$lab_url = "-";
|
||||
$non_lab_url = "-";
|
||||
|
||||
$row_attachment = $qry_attachment->result_array();
|
||||
if (count($row_attachment) > 0) {
|
||||
foreach ($row_attachment as $key => $value) {
|
||||
if ($value['T_OrderAttachmentType'] == "NonLab") {
|
||||
$non_lab_type = $value['T_OrderAttachmentType'];
|
||||
$non_lab_url = $value['T_OrderAttachmentUrl'];
|
||||
$non_lab_name = $value['T_OrderAttachmentName'];
|
||||
$extension = pathinfo(strtolower($non_lab_name), PATHINFO_EXTENSION);
|
||||
if ($extension === "pdf") {
|
||||
$extension_non_lab = "pdf";
|
||||
} else {
|
||||
if ($extension === "png" || $extension === "jpg" || $extension === "jpeg") {
|
||||
$extension_non_lab = "image";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($value['T_OrderAttachmentType'] == "Lab") {
|
||||
$lab_type = $value['T_OrderAttachmentType'];
|
||||
$lab_url = $value['T_OrderAttachmentUrl'];
|
||||
$lab_name = $value['T_OrderAttachmentName'];
|
||||
$extension = pathinfo(strtolower($lab_name), PATHINFO_EXTENSION);
|
||||
if ($extension === "pdf") {
|
||||
$extension_lab = "pdf";
|
||||
} else {
|
||||
if ($extension === "png" || $extension === "jpg" || $extension === "jpeg") {
|
||||
$extension_lab = "image";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$extension_lab = "-";
|
||||
$extension_non_lab = "-";
|
||||
$lab_name = "-";
|
||||
$non_lab_name = "-";
|
||||
$lab_type = "-";
|
||||
$non_lab_type = "-";
|
||||
$lab_url = "-";
|
||||
$non_lab_url = "-";
|
||||
}
|
||||
|
||||
$sql = "SELECT *,
|
||||
CONCAT('[', GROUP_CONCAT(DISTINCT CONCAT('\"', T_OrderPromiseDateTime, '\"') SEPARATOR ','), ']') order_promise
|
||||
FROM (
|
||||
select
|
||||
BrnListBarcode,
|
||||
T_OrderHeaderAddOnBNR,
|
||||
T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderDate,
|
||||
if(T_OrderHeaderAddOnLabNumberOrigin is null, T_OrderHeaderLabNumberExt, T_OrderHeaderAddOnLabNumberOrigin)
|
||||
T_OrderHeaderLabNumberExt, T_OrderHeaderDiagnose,
|
||||
M_PatientID, M_PatientNoReg, fn_global_patient_name(M_PatientID) M_PatientName,
|
||||
M_PatientDOB, T_OrderHeaderM_PatientAge, M_PatientHP, M_SexName, M_PatientNote,
|
||||
da.M_DoctorID doctor_pj_id, fn_global_doctor_name(da.M_DoctorID) doctor_pj_name,
|
||||
db.M_DoctorID doctor_sender_id, fn_global_doctor_name(db.M_DoctorID) doctor_sender_name,
|
||||
M_MouID, M_MouName, M_CompanyID, M_CompanyName,
|
||||
T_OrderHeaderFoNote, T_OrderHeaderSamplingNote, T_OrderHeaderResultNote,
|
||||
la.Nat_LangID M_LangID, la.Nat_LangCode M_LangCode, la.Nat_LangName M_LangName, T_OrderHeaderLangIsSI,
|
||||
lb.Nat_LangID SecondM_LangID, lb.Nat_LangCode SecondM_LangCode, lb.Nat_LangName SecondM_LangName,
|
||||
T_OrderHeaderAddOnSecondLangIsSI,
|
||||
T_OrderHeaderIsCito, fn_global_delivery_items(T_OrderHeaderID) as delivery,
|
||||
T_OrderPromiseDateTime, fn_process_history(T_OrderHeaderID) is_history,
|
||||
T_OrderHeaderAddOnVerificationDone,
|
||||
T_OrderHeaderAddOnValidationDone, T_OrderHeaderAddOnRequestChangeDOB,
|
||||
IFNULL(userfo.M_UserUsername,'') as username_fo,
|
||||
IFNULL(usersample.M_UserUsername,'') as username_sample
|
||||
from t_orderheader
|
||||
JOIN t_orderheaderaddon ON T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
AND T_OrderHeaderAddOnVerificationDone <> 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderID in ( $order_ids )
|
||||
{$q_company}
|
||||
AND T_OrderHeaderAddOnFOVerification = 'Y'
|
||||
JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeadeRID and T_OrderPromiseIsActive = 'Y'
|
||||
JOIN t_orderdetail ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
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 {$q_search}
|
||||
LEFT JOIN m_doctor da ON T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN m_doctor db ON T_OrderHeaderSenderM_DoctorID = db.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 nat_lang la ON T_OrderHeaderM_LangID = la.Nat_LangID
|
||||
LEFT JOIN brn_list ON T_OrderHeaderAddOnBNR = BrnListBarcode
|
||||
LEFT JOIN nat_lang lb ON T_OrderHeaderAddOnSecondM_LangID = lb.Nat_LangID
|
||||
LEFT JOIN m_user userfo ON T_OrderHeaderFoNoteM_UserID = userfo.M_UserID
|
||||
LEFT JOIN m_user usersample ON T_OrderHeaderSamplingNoteM_UserID = usersample.M_UserID
|
||||
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, $search, $search]);
|
||||
}
|
||||
// echo $this->db_smartone->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$tmp_ohnumber = [];
|
||||
$arr_brn_have_lab = [];
|
||||
|
||||
foreach ($rows as $k => $v) {
|
||||
if ($v['T_OrderHeaderAddOnBNR'] != "") {
|
||||
$arr_brn_have_lab[] = "'" . $v['T_OrderHeaderAddOnBNR'] . "'";
|
||||
}
|
||||
$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']];
|
||||
|
||||
$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));
|
||||
}
|
||||
|
||||
$arr_itf = [];
|
||||
|
||||
if (count($arr_brn_have_lab) > 0) {
|
||||
$str_no_reg = implode(",", $arr_brn_have_lab);
|
||||
|
||||
$sql_itf = "select Itf_ResultNoreg,
|
||||
group_concat(Itf_ResultKode) as result
|
||||
from itf_result
|
||||
WHERE Itf_ResultNoReg IN ($str_no_reg)
|
||||
GROUP BY Itf_ResultNoReg
|
||||
";
|
||||
|
||||
$query_itf = $this->db_onedev->query($sql_itf);
|
||||
if (!$query_itf) {
|
||||
$this->sys_error_db(
|
||||
"Error Get Result "
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows_itf = $query_itf->result_array();
|
||||
// print_r($rows_itf);
|
||||
// exit;
|
||||
|
||||
foreach ($rows_itf as $key => $value) {
|
||||
$arr_itf[$value['Itf_ResultNoreg']] = $value['result'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$brn = $value['T_OrderHeaderAddOnBNR'];
|
||||
|
||||
if (isset($arr_itf[$brn])) {
|
||||
$rows[$key]['Itf'] = $arr_itf[$brn];
|
||||
} else {
|
||||
$rows[$key]['Itf'] = "";
|
||||
}
|
||||
}
|
||||
|
||||
$tot_count = count($rows);
|
||||
$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(),
|
||||
"attachment" => [
|
||||
"extension_lab" => $extension_lab,
|
||||
"extension_non_lab" => $extension_non_lab,
|
||||
"lab_name" => $lab_name,
|
||||
"non_lab_name" => $non_lab_name,
|
||||
"lab_type" => $lab_type,
|
||||
"non_lab_type" => $non_lab_type,
|
||||
"lab_url" => $lab_url,
|
||||
"non_lab_url" => $non_lab_url,
|
||||
]
|
||||
);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
710
api/10.9.9.8/resultentry-v105/Re_px-pe.php
Normal file
710
api/10.9.9.8/resultentry-v105/Re_px-pe.php
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
2939
api/10.9.9.8/resultentry-v105/Re_px.php
Normal file
2939
api/10.9.9.8/resultentry-v105/Re_px.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user