Initial import
This commit is contained in:
136
one-api/application/controllers/mockup/printresult/Done.php
Normal file
136
one-api/application/controllers/mockup/printresult/Done.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
class Done extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nolab = $prm["nolab"];
|
||||
$nama = $prm["name"];
|
||||
//$startdate = $prm["startdate"];
|
||||
//$enddate = $prm["enddate"];
|
||||
$groupid = 3;
|
||||
$subgroupid = $prm["subgroupid"];
|
||||
$join_group = '';
|
||||
if($groupid != 0){
|
||||
$join_group = "JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID AND Nat_GroupID = {$groupid}";
|
||||
}
|
||||
$join_subgroup = '';
|
||||
if($subgroupid != 0){
|
||||
$join_group = "JOIN nat_subgroup ON T_TestNat_SubgroupID = Nat_SubgroupID AND Nat_SubgroupID = {$subgroupid}";
|
||||
}
|
||||
|
||||
if(!isset($prm['current_page']))
|
||||
$prm['current_page'] = 1;
|
||||
|
||||
$sql_where = "WHERE Result_FrontOfficeStatus = 'P' ";
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
//$sql_param = array();
|
||||
if ($nolab != "" ) {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_OrderHeaderLabNumber like '%$nolab%' ";
|
||||
}
|
||||
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientName like '%$nama%' ";
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT Result_FrontOfficeID as xid,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderLabNumber as ordernumber,
|
||||
UPPER(CONCAT(M_TitleName,' ',M_PatientName)) as patient_fullname,
|
||||
Result_FrontOfficeTestName as test_name,
|
||||
'N' as chex
|
||||
FROM result_frontoffice
|
||||
join t_orderheader ON Result_FrontOfficeT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdelivery ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID AND T_OrderDeliveryM_DeliveryID = 1
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND JSON_CONTAINS(Result_FrontOfficeIds, T_OrderDetailID)
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND
|
||||
(DocumentationGroupName = 'lab')
|
||||
$sql_where
|
||||
GROUP BY Result_FrontOfficeID
|
||||
|
||||
";
|
||||
// echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
|
||||
$result = array("total" => count($rst), "records" => $rows, "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function dosend(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$selected = $prm['selected'];
|
||||
foreach($selected as $k => $v){
|
||||
$sql = "UPDATE result_frontoffice SET Result_FrontOfficeStatus = 'S' WHERE Result_FrontOfficeID = {$v['xid']}";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $sql;
|
||||
$sql = "SELECT * FROM result_frontoffice
|
||||
WHERE Result_FrontOfficeID = {$v['xid']}";
|
||||
$rst_log = $this->db_onedev->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}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
class Printresult extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Print Result API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$startdate = $prm['startdate'] . " 00:00:01";
|
||||
$enddate = $prm['enddate'] . " 23:59:59";
|
||||
$search = $prm["search"];
|
||||
$status = $prm["status"];
|
||||
$sql_where = '';
|
||||
$having = "HAVING already_validated > 0 AND ready_print > 0";
|
||||
if($status == 'Y'){
|
||||
$having = "HAVING already_validated > 0 AND ready_print = 0";
|
||||
}
|
||||
$prm['current_page'] = isset($prm['current_page'])?$prm['current_page']:1;
|
||||
|
||||
//$sql_where = "WHERE T_OrderHeaderIsActive = 'Y' AND ( T_OrderHeaderDate BETWEEN '{$startdate}' AND '{$enddate}' )";
|
||||
if ($search != "") {
|
||||
|
||||
$sql_where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' ) ";
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM
|
||||
(
|
||||
SELECT fn_result_print_already_validated(T_OrderHeaderID) as already_validated,
|
||||
fn_result_print_check_ready_print(T_OrderHeaderID) as ready_print
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName = 'lab'
|
||||
WHERE
|
||||
T_OrderHeaderIsActive = 'Y' $sql_where
|
||||
GROUP BY T_OrderHeaderID
|
||||
$having
|
||||
|
||||
) b
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = " SELECT T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber,
|
||||
DATE_FORMAT(T_OrderHeaderDate, '%d-%m-%Y %H:%i') as order_date,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
fn_result_print_already_validated(T_OrderHeaderID) as already_validated,
|
||||
fn_result_print_check_ready_print(T_OrderHeaderID) as ready_print
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID AND DocumentationGroupName = 'lab'
|
||||
WHERE
|
||||
T_OrderHeaderIsActive = 'Y' $sql_where
|
||||
GROUP BY T_OrderHeaderID
|
||||
$having
|
||||
|
||||
LIMIT $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function firstprint(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$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_onedev->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_onedev->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_onedev->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_onedev->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_onedev->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_onedev->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_onedev->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_onedev->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendemail (
|
||||
Log_ResultSendEmailDatetime,
|
||||
Log_ResultSendEmailJson,
|
||||
Log_ResultSendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_onedev->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_onedev->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_onedev->query($sql)->row_array());
|
||||
$sql = "INSERT INTO one_log.log_resultsendcourier (
|
||||
Log_ResultSendCourierDateTime,
|
||||
Log_ResultSendCourierJson,
|
||||
Log_ResultSendCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//echo $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user