Initial import
This commit is contained in:
416
application/controllers/his/Trx_order.php
Normal file
416
application/controllers/his/Trx_order.php
Normal file
@@ -0,0 +1,416 @@
|
||||
<?php
|
||||
|
||||
class Trx_order extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->helper(array('form', 'url'));
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->db_oneklinik = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function get_order() {
|
||||
$baseurl = 'https://yankes.itb.ac.id/data-services';
|
||||
$url = $baseurl.'/api/pemeriksan_mcu';
|
||||
$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wveWFua2VzLml0Yi5hYy5pZFwvZGV2LXNlcnZpY2VzXC9hcGlcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNzI3MDg0NTcyLCJleHAiOjE3NTg2MjA1NzIsIm5iZiI6MTcyNzA4NDU3MiwianRpIjoiOWpGc3A0TmFIbnZWQkdrVyIsInN1YiI6NzcsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.eduGs9bz64uD8paGYxJ1zxJ0du6lQ9yTFT7BzYTFg4A';
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Authorization: Bearer ' . $token,
|
||||
'Content-Type: application/json'
|
||||
));
|
||||
|
||||
// Eksekusi request cURL
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Debug: Cek error cURL
|
||||
if (curl_errno($ch)) {
|
||||
echo 'cURL Error: ' . curl_error($ch);
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
// Kembalikan hasil response (jika perlu, decode JSON)
|
||||
//echo $response;
|
||||
|
||||
|
||||
/*$sql = "INSERT INTO itb_yankes.tmp_response(
|
||||
response
|
||||
)
|
||||
VALUES(?)";
|
||||
$qry = $this->db_onedev->query($sql,array($response));
|
||||
if(!$qry){
|
||||
$this->sys_error_db("save response", $this->db_onedev);
|
||||
exit;
|
||||
}*/
|
||||
$rspn = json_decode($response, true);
|
||||
if($rspn['success'] == 1){
|
||||
$datas = $rspn['response_1'];
|
||||
|
||||
if(count($datas) > 0){
|
||||
//print_r($datas);
|
||||
foreach ($datas as $key => $value) {
|
||||
if($value['nik']){
|
||||
$sql = "SELECT * FROM itb_yankes.download_order WHERE DownloadOrderNumber = ?";
|
||||
$qry = $this->db_onedev->query($sql,array($value['no_order']));
|
||||
if(!$qry){
|
||||
$this->sys_error_db("select order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
//echo $this->db_onedev->last_query();
|
||||
$exist_dt = $qry->result_array();
|
||||
if(count($exist_dt) == 0){
|
||||
$sql = "INSERT INTO itb_yankes.download_order (
|
||||
DownloadOrderNumber,
|
||||
DownloadOrderDate,
|
||||
DownloadOrderNIK,
|
||||
DownloadOrderName,
|
||||
DownloadOrderGender,
|
||||
DownloadOrderDOB,
|
||||
DownloadOrderJSON,
|
||||
DownloadOrderCreated
|
||||
) VALUES(?,?,?,?,?,?,?,NOW()) ";
|
||||
$qry = $this->db_onedev->query($sql,array(
|
||||
$value['no_order'],
|
||||
$value['tanggal_pemeriksaan'],
|
||||
$value['nik'],
|
||||
$value['nama_lengkap'],
|
||||
$value['jenis_kelamin'],
|
||||
$value['tanggal_lahir'],
|
||||
json_encode($rspn)
|
||||
));
|
||||
if(!$qry){
|
||||
$this->sys_error_db("select order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
//echo $this->db_onedev->last_query();
|
||||
$lastID = $this->db_onedev->insert_id();
|
||||
}else{
|
||||
$lastID = $exist_dt[0]['DownloadOrderID'];
|
||||
$sql = "UPDATE itb_yankes.download_order SET
|
||||
DownloadOrderNIK = ?,
|
||||
DownloadOrderDOB = ?,
|
||||
DownloadOrderJSON = ?
|
||||
WHERE
|
||||
DownloadOrderID = ?
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql,array(
|
||||
$value['nik'],
|
||||
$value['tanggal_lahir'],
|
||||
json_encode($rspn),
|
||||
$lastID));
|
||||
if(!$qry){
|
||||
$this->sys_error_db("update download_order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT T_OrderHeaderID, M_PatientID,M_PatientIDNumber,DownloadOrderNIK,M_PatientDOB,DownloadOrderDOB
|
||||
FROM t_orderheader
|
||||
JOIN itb_yankes.sys_config ON T_OrderHeaderM_MouID IN (SysConfigM_MouID)
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN itb_yankes.download_order
|
||||
ON REPLACE(m_patient.M_PatientIDNumber, UNHEX('E2808C'), '') = TRIM(download_order.DownloadOrderNIK)
|
||||
AND M_PatientDOB = DownloadOrderDOB
|
||||
WHERE DownloadOrderID = ? AND T_OrderHeaderIsActive = 'Y';
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql,array($lastID));
|
||||
if(!$qry){
|
||||
$this->sys_error_db("select order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows_order_lab = $qry->result_array();
|
||||
if(count($rows_order_lab)> 0){
|
||||
$data_map = $rows_order_lab[0];
|
||||
$sql = "UPDATE m_patient
|
||||
SET M_PatientIDNumber = REPLACE(M_PatientIDNumber, UNHEX('E2808C'), '')
|
||||
WHERE M_PatientID = ?";
|
||||
$qry = $this->db_onedev->query($sql,array($data_map['M_PatientID']));
|
||||
if(!$qry){
|
||||
$this->sys_error_db("select order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$this->mapping_order($lastID,$data_map['T_OrderHeaderID'],$value['no_order'],555);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//echo json_encode($rspn);
|
||||
|
||||
|
||||
}
|
||||
$result = array(
|
||||
|
||||
"records" => json_encode($rspn['response_1'])
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function mapping_order($orderID,$orderLabID,$noOrder,$userID){
|
||||
$sql = "INSERT INTO itb_yankes.order_map (
|
||||
orderMapDownloadOrderID,
|
||||
orderMapT_OrderHeaderID,
|
||||
orderMapCreated,
|
||||
orderMapCreatedUserID
|
||||
) VALUES(?,?,NOW(),?)";
|
||||
$qry = $this->db_onedev->query($sql,array($orderID,$orderLabID,$userID));
|
||||
if(!$qry){
|
||||
$this->sys_error_db("select order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->update_status($orderID,'mapped');
|
||||
|
||||
$sql = "UPDATE t_orderheaderaddon SET T_OrderHeaderAddOnLabNumberOrigin = ?
|
||||
WHERE T_OrderHeaderAddOnT_OrderHeaderID = ?";
|
||||
$qry = $this->db_onedev->query($sql,array($noOrder,$orderLabID));
|
||||
if(!$qry){
|
||||
$this->sys_error_db("select order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function update_status($orderID,$status){
|
||||
$sql = "UPDATE itb_yankes.download_order SET DownloadOrderStatus = ?
|
||||
WHERE DownloadOrderID = ?";
|
||||
$qry = $this->db_onedev->query($sql,array($status,$orderID));
|
||||
if(!$qry){
|
||||
$this->sys_error_db("update order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function send_result_all(){
|
||||
$sql="SELECT DownloadOrderID as order_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_lab_id,
|
||||
DownloadOrderNIK as nik,
|
||||
DownloadOrderName as patient_name,
|
||||
DownloadOrderNumber as order_number,
|
||||
T_OrderDetailT_TestCode as bisone_test_code,
|
||||
test_yankes_code as yenkes_test_code,
|
||||
test_name as yankes_test,
|
||||
T_OrderDetailT_TestName as bisone_test,
|
||||
T_OrderDetailResult as result
|
||||
FROM t_orderdetail
|
||||
JOIN itb_yankes.map_test ON T_OrderDetailT_TestCode = test_bisone_code
|
||||
JOIN itb_yankes.order_map ON orderMapT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
JOIN itb_yankes.download_order ON orderMapDownloadOrderID = DownloadOrderID AND
|
||||
DownloadOrderStatus = 'mapped'
|
||||
WHERE
|
||||
T_OrderDetailT_TestIsResult = 'Y' AND
|
||||
T_OrderDetailValidation = 'Y' AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_OrderDetailT_OrderHeaderID";
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if(!$qry){
|
||||
$this->sys_error_db("select order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data_send = $qry->result_array();
|
||||
|
||||
}
|
||||
|
||||
function send_result($orderLabID,$userID){
|
||||
$sql="SELECT DownloadOrderID as order_id,
|
||||
T_OrderDetailT_OrderHeaderID as order_lab_id,
|
||||
DownloadOrderNIK as nik,
|
||||
DownloadOrderName as patient_name,
|
||||
DownloadOrderNumber as order_number,
|
||||
T_OrderDetailT_TestCode as bisone_test_code,
|
||||
test_yankes_code as yenkes_test_code,
|
||||
test_name as yankes_test,
|
||||
T_OrderDetailT_TestName as bisone_test,
|
||||
T_OrderDetailResult as result
|
||||
FROM t_orderdetail
|
||||
JOIN itb_yankes.map_test ON T_OrderDetailT_TestCode = test_bisone_code
|
||||
JOIN itb_yankes.order_map ON orderMapT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
JOIN itb_yankes.download_order ON orderMapDownloadOrderID = DownloadOrderID
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND
|
||||
T_OrderDetailT_TestIsResult = 'Y' AND
|
||||
T_OrderDetailValidation = 'Y' AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY T_OrderDetailID
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql,[$orderLabID]);
|
||||
if(!$qry){
|
||||
$this->sys_error_db("select order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$details = $qry->result_array();
|
||||
if(count($details) > 0){
|
||||
$orderID = '';
|
||||
$no_order = '';
|
||||
$results = [];
|
||||
foreach ($details as $key => $value) {
|
||||
$orderID = $value['order_id'];
|
||||
$no_order = $value['order_number'];
|
||||
$results[] = ['test_id' => $value['yenkes_test_code'],'result' => $value['result'] ];
|
||||
}
|
||||
|
||||
$json_dt = array(
|
||||
array('no_order' => $no_order,'order_test' => $results)
|
||||
);
|
||||
$this->do_send_results($orderID,$no_order,$json_dt,$userID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function send_lab_results($json_data, $bearer_token) {
|
||||
// Base URL
|
||||
$baseUrl = 'https://yankes.itb.ac.id/data-services';// Ganti dengan base URL Anda
|
||||
$url = $baseUrl . "/api/update_hasil_lab";
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init($url);
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $bearer_token
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($json_data));
|
||||
|
||||
// Execute cURL request
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Check for errors
|
||||
if (curl_errno($ch)) {
|
||||
echo 'cURL Error: ' . curl_error($ch);
|
||||
} else {
|
||||
// Decode the response if needed
|
||||
$response_data = json_decode($response, true);
|
||||
return $response_data;
|
||||
//echo json_encode($response_data);
|
||||
//print_r($response_data);
|
||||
}
|
||||
|
||||
// Close cURL session
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
function do_send_results($orderID,$no_order,$datas,$userID){
|
||||
// Contoh penggunaan fungsi
|
||||
/*$json_data = [
|
||||
"params" => [
|
||||
[
|
||||
"no_order" => "B2B-ITB-a2q002687",
|
||||
"order_test" => [
|
||||
["test_id" => "A001HE", "result" => "15.2"],
|
||||
["test_id" => "A002HE", "result" => "44"],
|
||||
["test_id" => "A003HE", "result" => "3.9"],
|
||||
// ... masukkan seluruh data lainnya sesuai kebutuhan
|
||||
]
|
||||
]
|
||||
]
|
||||
];*/
|
||||
|
||||
$json_data = [
|
||||
"params" => $datas
|
||||
];
|
||||
// Bearer token
|
||||
$bearer_token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wveWFua2VzLml0Yi5hYy5pZFwvZGV2LXNlcnZpY2VzXC9hcGlcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNzI3MDg0NTcyLCJleHAiOjE3NTg2MjA1NzIsIm5iZiI6MTcyNzA4NDU3MiwianRpIjoiOWpGc3A0TmFIbnZWQkdrVyIsInN1YiI6NzcsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.eduGs9bz64uD8paGYxJ1zxJ0du6lQ9yTFT7BzYTFg4A';
|
||||
// Ganti dengan token yang sesuai
|
||||
|
||||
// Panggil fungsi untuk mengirim data
|
||||
$rspn = $this->send_lab_results($json_data, $bearer_token);
|
||||
if($rspn){
|
||||
$status = 'success';
|
||||
if(!$rspn['success'])
|
||||
$status = 'failed';
|
||||
|
||||
$sql = "INSERT INTO itb_yankes.send_results (
|
||||
Send_ResultsOrderNumber,
|
||||
SendResultsJsonBefore,
|
||||
SendResultsJsonAfter,
|
||||
SendResultsStatus,
|
||||
SendResultsCreated,
|
||||
SendResultsCreatedUserID
|
||||
) VALUES(?,?,?,?,NOW(),?)";
|
||||
$qry = $this->db_onedev->query($sql,[$no_order,json_encode($json_data),json_encode($rspn),$status,$userID]);
|
||||
if(!$qry){
|
||||
$this->sys_error_db("insert send result error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$this->update_status($orderID,'send_result');
|
||||
|
||||
return $rspn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function sendresultorder(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$rspn = $this->send_result($prm['T_OrderHeaderID'],$xuserid);
|
||||
$result = array(
|
||||
|
||||
"records" => $rspn
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getlogs(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$sql="SELECT *
|
||||
FROM itb_yankes.send_results
|
||||
WHERE
|
||||
Send_ResultsOrderNumber = ?";
|
||||
$qry = $this->db_onedev->query($sql,$prm['order_number_yankes']);
|
||||
if(!$qry){
|
||||
$this->sys_error_db("select order error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data_send = $qry->result_array();
|
||||
$result = array(
|
||||
"records" => $data_send
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function rePushOrderXXX(){
|
||||
$prm = $this->sys_input;
|
||||
$this->load->library('Apilis');
|
||||
$kesimpulan = $this->apilis->GetOrderDetail($prm['T_OrderHeaderLabNumber']);
|
||||
if($kesimpulan){
|
||||
$this->sys_ok(array("status" => "OK", "message" => "success"));
|
||||
}else{
|
||||
$this->sys_error(array("status" => "ERR", "message" => "failed"));
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
194
application/controllers/his/listpatient/Patient.php
Normal file
194
application/controllers/his/listpatient/Patient.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function add_notes($orderid){
|
||||
$sql = " SELECT F_PaymentT_OrderHeaderID as note_order_id,
|
||||
F_PaymentID as note_id,
|
||||
F_PaymentDate as note_date,
|
||||
F_PaymentNumber as note_number,
|
||||
GROUP_CONCAT(M_PaymentTypeName separator ' , ') as paymenttypes_name,
|
||||
SUM(F_PaymentDetailAmount) as note_amount,
|
||||
M_UserUsername as note_user,
|
||||
F_PaymentDetailIsActive as note_active
|
||||
FROM f_payment
|
||||
JOIN f_paymentdetail ON F_PaymentDetailF_PaymentID = F_PaymentID
|
||||
JOIN m_paymenttype ON F_PaymentDetailM_PaymentTypeID = M_PaymentTypeID
|
||||
LEFT JOIN m_user ON F_PaymentDetailUserID = M_UserID
|
||||
WHERE
|
||||
F_PaymentT_OrderHeaderID = {$orderid}
|
||||
GROUP BY F_PaymentID";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
return $rows;
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("get notes", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$startdate = $prm['startdate'];
|
||||
//$enddate = $prm['enddate'] ;
|
||||
$search = $prm["search"];
|
||||
$status = $prm["status"];
|
||||
$filter_company = isset($prm["CorporateID"])?$prm["CorporateID"]:0;
|
||||
$and_corporate = "";
|
||||
if(intval($filter_company) > 0){
|
||||
$and_corporate = " AND T_OrderHeaderCorporateID = {$filter_company}";
|
||||
}
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT T_OrderHeaderLabNumber
|
||||
FROM t_orderheader
|
||||
LEFT JOIN api_push ON Api_PushT_OrderHeaderLabNumber = T_OrderHeaderLabNumber AND
|
||||
( ? = 'A' OR Api_PushStatus = ? ) $and_corporate
|
||||
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN m_patient ON T_orderHeaderM_PatientID = M_PatientID AND
|
||||
(Api_PushT_OrderHeaderLabNumber LIKE CONCAT('%',?,'%') OR M_PatientName Like CONCAT('%',?,'%'))
|
||||
WHERE T_OrderHeaderIsActive = 'Y' AND DATE(T_OrderHeaderDate) = ?
|
||||
) x";
|
||||
$query = $this->db_onedev->query($sql, array($status,$status,$search,$search,$startdate));
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
|
||||
$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("t_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT T_OrderHeaderID,T_OrderHeaderLabNumber,
|
||||
M_PatientName,
|
||||
M_PatientNoReg,
|
||||
CorporateName,
|
||||
DATE_FORMAT(Api_PushDateTime,'%d-%m-%Y') as push_date,
|
||||
Api_PushParams,
|
||||
Api_PushResponse,
|
||||
Api_PushRetry,
|
||||
Api_PushLISLabNumber,
|
||||
IFNULL(Api_PushStatus,'') as Api_PushStatus,
|
||||
if(M_PatientIdentifierValue <> '',M_PatientIdentifierValue, M_PatientNIP) as nik
|
||||
FROM t_orderheader
|
||||
LEFT JOIN api_push ON Api_PushT_OrderHeaderLabNumber = T_OrderHeaderLabNumber AND
|
||||
( ? = 'A' OR Api_PushStatus = ? ) $and_corporate
|
||||
JOIN corporate ON T_OrderHeaderCorporateID = CorporateID
|
||||
JOIN m_patient ON T_orderHeaderM_PatientID = M_PatientID AND
|
||||
(Api_PushT_OrderHeaderLabNumber LIKE CONCAT('%',?,'%') OR M_PatientName Like CONCAT('%',?,'%'))
|
||||
WHERE T_OrderHeaderIsActive = 'Y' AND DATE(T_OrderHeaderDate) = ?
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
//echo $this->db_onedev->last_query();
|
||||
$query = $this->db_onedev->query($sql, array($status,$status,$search,$search,$startdate));
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function rePushOrder(){
|
||||
$prm = $this->sys_input;
|
||||
$this->load->library('Apilis');
|
||||
$kesimpulan = $this->apilis->GetOrderDetail($prm['T_OrderHeaderLabNumber']);
|
||||
if($kesimpulan){
|
||||
$this->sys_ok(array("status" => "OK", "message" => "success"));
|
||||
}else{
|
||||
$this->sys_error(array("status" => "ERR", "message" => "failed"));
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function searchcompany(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM corporate
|
||||
WHERE
|
||||
CorporateName like ?
|
||||
AND CorporateIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$rows = array('id'=>0,'name'=>'Semua');
|
||||
$sql = "
|
||||
SELECT CorporateID as id, CorporateName as name
|
||||
FROM corporate
|
||||
WHERE
|
||||
CorporateName like ?
|
||||
AND CorporateIsActive = 'Y'
|
||||
ORDER BY CorporateName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
array_push($rows,array('id'=>0,'name'=>'Semua'));
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
504
application/controllers/his/listpatient/Payment.php
Normal file
504
application/controllers/his/listpatient/Payment.php
Normal file
@@ -0,0 +1,504 @@
|
||||
<?php
|
||||
|
||||
class Payment extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function getlanguages()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT Nat_LangID as id,
|
||||
Nat_LangCode as code,
|
||||
Nat_LangName as name
|
||||
FROM nat_lang WHERE Nat_LangIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
$this->sys_ok($rows);
|
||||
exit;
|
||||
}
|
||||
|
||||
function lookup_type()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT M_PaymentTypeID as id,
|
||||
M_PaymentTypeCode as code,
|
||||
'N' as chex,
|
||||
M_PaymentTypeName as chexlabel,
|
||||
'Jumlah' as leftlabel,
|
||||
'' as selected_card,
|
||||
'' as selected_edc,
|
||||
'' as selected_account,
|
||||
CASE
|
||||
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
|
||||
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'TRANSFER' THEN 'No. Rekening'
|
||||
ELSE 'Nomor Voucher'
|
||||
END as rightlabel,
|
||||
0 as leftvalue,
|
||||
0 as rightvalue
|
||||
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['selected_card'] = array('id'=>0,'name'=>'');
|
||||
$rows[$k]['selected_edc'] = array('id'=>0,'name'=>'');
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function lookup_banks()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT Nat_BankID as id, Nat_BankCode as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankCode DESC";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function lookup_accounts()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT M_BankAccountID as id, CONCAT(Nat_BankCode,' (',M_BankAccountNo,')') as name
|
||||
FROM m_bank_account
|
||||
JOIN nat_bank ON M_BankAccountNat_BankID = Nat_BankID
|
||||
WHERE
|
||||
M_BankAccountIsActive = 'Y'
|
||||
ORDER BY Nat_BankCode DESC";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function searchcard(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
if($prm['search'] != ''){
|
||||
$sql = "
|
||||
SELECT count(*) as total
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankName like ?
|
||||
AND Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
else{
|
||||
$sql = "
|
||||
SELECT count(*) as total
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
if($prm['search'] != ''){
|
||||
$sql = "
|
||||
SELECT Nat_BankID as id, Nat_BankName as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankName like ?
|
||||
AND Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
else{
|
||||
$sql = "
|
||||
SELECT Nat_BankID as id, Nat_BankName as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pay()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$orderid = $prm['orderid'];
|
||||
$payments = $prm['payments'];
|
||||
//$xnumber = $this->db_onedev->query("SELECT `fn_numbering`('PAY') as numberx")->row()->numberx;
|
||||
$sql = "INSERT INTO f_payment(F_PaymentT_OrderHeaderID,F_PaymentDate,F_PaymentCreated,F_PaymentM_UserID) VALUES (?,CURDATE(),NOW(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid, $xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_payment insert");
|
||||
exit;
|
||||
}
|
||||
$headerid = $this->db_onedev->insert_id();
|
||||
|
||||
foreach($payments as $k => $v){
|
||||
if($v['chex']){
|
||||
$actual = 0;
|
||||
$change = 0;
|
||||
$amount = $v['leftvalue'];
|
||||
if($v['code'] == 'CASH'){
|
||||
$actual = $v['leftvalue'];
|
||||
$change = $v['rightvalue'];
|
||||
if($actual > 0){
|
||||
$amount = intval($v['leftvalue']) - intval($v['rightvalue']);
|
||||
}
|
||||
else{
|
||||
$amount = $actual;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO f_paymentdetail(
|
||||
F_PaymentDetailF_PaymentID,
|
||||
F_PaymentDetailM_PaymentTypeID,
|
||||
F_PaymentDetailAmount,
|
||||
F_PaymentDetailActual,
|
||||
F_PaymentDetailChange,
|
||||
F_PaymentDetailCreated,
|
||||
F_PaymentDetailLastUpdated,
|
||||
F_PaymentDetailUserID)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now(),
|
||||
?
|
||||
)";
|
||||
//echo $sql;
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$headerid,
|
||||
$v['id'],
|
||||
$amount,
|
||||
$actual,
|
||||
$change,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail cash insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
//if(intval($v['leftvalue']) > 0){
|
||||
$actual = 0;
|
||||
$change = 0;
|
||||
$amount = $v['leftvalue'];
|
||||
$selected_card = 0;
|
||||
$selected_edc = 0;
|
||||
$selected_account = 0;
|
||||
if($v['code'] == 'DEBIT' || $v['code'] == 'CREDIT' || $v['code'] == 'TRANSFER'){
|
||||
$selected_card = $v['selected_card']['id'];
|
||||
$selected_edc = $v['selected_edc']['id'];
|
||||
if($v['code'] == 'TRANSFER')
|
||||
$selected_edc = $v['selected_account']['id'];
|
||||
}
|
||||
$sql = "INSERT INTO f_paymentdetail(
|
||||
F_PaymentDetailF_PaymentID,
|
||||
F_PaymentDetailM_PaymentTypeID,
|
||||
F_PaymentDetailAmount,
|
||||
F_PaymentDetailActual,
|
||||
F_PaymentDetailChange,
|
||||
F_PaymentDetailCardNat_BankID,
|
||||
F_PaymentDetailEDCNat_BankID,
|
||||
F_PaymentDetailM_BankAccountID,
|
||||
F_PaymentDetailCreated,
|
||||
F_PaymentDetailLastUpdated,
|
||||
F_PaymentDetailUserID)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now(),
|
||||
?
|
||||
)";
|
||||
//echo $sql;
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$headerid,
|
||||
$v['id'],
|
||||
$amount,
|
||||
$actual,
|
||||
$change,
|
||||
$selected_card,
|
||||
0,
|
||||
$selected_edc,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail non cash insert");
|
||||
exit;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query = "SELECT M_PaymentTypeID as id,
|
||||
M_PaymentTypeCode as code,
|
||||
IF(M_PaymentTypeCode = 'CASH','Y','N') as chex,
|
||||
M_PaymentTypeName as chexlabel,
|
||||
'Jumlah' as leftlabel,
|
||||
CASE
|
||||
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
|
||||
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'TRANSFER' THEN 'Nomor Rekening'
|
||||
ELSE 'Nomor Voucher'
|
||||
END as rightlabel,
|
||||
0 as leftvalue,
|
||||
0 as rightvalue
|
||||
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
$xdata = $this->db_onedev->query("SELECT F_PaymentID as idx, F_PaymentNumber as numberx FROM f_payment WHERE F_PaymentID = {$headerid}")->row();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => array('payments'=>$payments,'types'=>$rows,'data'=>$xdata)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function delete_note()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$prmnota = $prm['nota'];
|
||||
$catatan = $prm['catatan'];
|
||||
$sql = "UPDATE f_payment SET F_PaymentIsActive = 'N', F_PaymentNote = '{$catatan}' WHERE F_PaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_payment delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE f_paymentdetail SET F_PaymentDetailIsActive = 'N' WHERE F_PaymentDetailF_PaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('prm'=>$prm)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getLocations()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$station_location = [];
|
||||
$locations = [];
|
||||
$sql = "SELECT T_OrderDetailT_OrderHeaderID as order_id, T_SampleStationID as station_id, T_SampleStationName as station_name,
|
||||
fn_get_location(T_SampleStationID,T_OrderDetailT_OrderHeaderID) as location_id, '' locations
|
||||
FROM (
|
||||
SELECT distinct T_OrderDetailT_OrderHeaderID,T_SampleStationID, T_SampleStationName
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_SampleTypeID = T_TestT_SampleTypeID
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID
|
||||
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
|
||||
|
||||
) x";
|
||||
$query = $this->db_onedev->query($sql,array($prm['order_id']));
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query)
|
||||
{
|
||||
$datas = $query->result_array();
|
||||
foreach ($datas as $key => $value) {
|
||||
$sql = "SELECT M_LocationID as location_id, M_LocationName as location_name FROM m_location WHERE M_LocationT_SampleStationID = ? AND M_LocationIsActive = 'Y' ";
|
||||
$query = $this->db_onedev->query($sql,array($value['station_id']));
|
||||
if ($query)
|
||||
{
|
||||
$datas[$key]['locations'] = $query->result_array();
|
||||
}
|
||||
else
|
||||
{
|
||||
$datas[$key]['locations'] = [];
|
||||
}
|
||||
}
|
||||
$this->sys_ok(["datas"=> $datas]);
|
||||
|
||||
}
|
||||
else{
|
||||
echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("gagal ambil data", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function save_control()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
if($prm['data'] && count($prm['data']) > 0){
|
||||
foreach ($prm['data'] as $key => $value) {
|
||||
$sql="INSERT INTO t_order_location (
|
||||
T_OrderLocationT_OrderHeaderID,
|
||||
T_OrderLocationM_LocationID,
|
||||
T_OrderLocationT_SampleStationID,
|
||||
T_OrderLocationCreated,
|
||||
T_OrderLocationLastUpdated,
|
||||
T_OrderLocationUserID
|
||||
)
|
||||
VALUES (?,?,?,NOW(),NOW(),?)
|
||||
ON DUPLICATE KEY
|
||||
UPDATE T_OrderLocationT_OrderHeaderID = ?,
|
||||
T_OrderLocationM_LocationID = ?,
|
||||
T_OrderLocationT_SampleStationID = ?,
|
||||
T_OrderLocationLastUpdated = NOW(),
|
||||
T_OrderLocationUserID = ?";
|
||||
$query = $this->db_onedev->query($sql,array($value['order_id'],$value['location_id'],$value['station_id'],$userid,$value['order_id'],$value['location_id'],$value['station_id'],$userid));
|
||||
}
|
||||
$this->sys_ok(["datas"=> '']);
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db("data not valid", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
//echo $sql;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
400
application/controllers/his/listpatient/Payment.php--160920
Normal file
400
application/controllers/his/listpatient/Payment.php--160920
Normal file
@@ -0,0 +1,400 @@
|
||||
<?php
|
||||
|
||||
class Payment extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookup_type()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT M_PaymentTypeID as id,
|
||||
M_PaymentTypeCode as code,
|
||||
'N' as chex,
|
||||
M_PaymentTypeName as chexlabel,
|
||||
'Jumlah' as leftlabel,
|
||||
'' as selected_card,
|
||||
'' as selected_edc,
|
||||
'' as selected_account,
|
||||
CASE
|
||||
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
|
||||
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'TRANSFER' THEN 'No. Rekening'
|
||||
ELSE 'Nomor Voucher'
|
||||
END as rightlabel,
|
||||
0 as leftvalue,
|
||||
0 as rightvalue
|
||||
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['selected_card'] = array('id'=>0,'name'=>'');
|
||||
$rows[$k]['selected_edc'] = array('id'=>0,'name'=>'');
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function lookup_banks()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT Nat_BankID as id, Nat_BankCode as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankCode DESC";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function lookup_accounts()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT M_BankAccountID as id, CONCAT(Nat_BankCode,' (',M_BankAccountNo,')') as name
|
||||
FROM m_bank_account
|
||||
JOIN nat_bank ON M_BankAccountNat_BankID = Nat_BankID
|
||||
WHERE
|
||||
M_BankAccountIsActive = 'Y'
|
||||
ORDER BY Nat_BankCode DESC";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function searchcard(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
if($prm['search'] != ''){
|
||||
$sql = "
|
||||
SELECT count(*) as total
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankName like ?
|
||||
AND Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
else{
|
||||
$sql = "
|
||||
SELECT count(*) as total
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
if($prm['search'] != ''){
|
||||
$sql = "
|
||||
SELECT Nat_BankID as id, Nat_BankName as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankName like ?
|
||||
AND Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
else{
|
||||
$sql = "
|
||||
SELECT Nat_BankID as id, Nat_BankName as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pay()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$orderid = $prm['orderid'];
|
||||
$payments = $prm['payments'];
|
||||
//$xnumber = $this->db_onedev->query("SELECT `fn_numbering`('PAY') as numberx")->row()->numberx;
|
||||
$sql = "INSERT INTO f_payment(F_PaymentT_OrderHeaderID,F_PaymentDate,F_PaymentCreated,F_PaymentM_UserID) VALUES (?,CURDATE(),NOW(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid, $xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_payment insert");
|
||||
exit;
|
||||
}
|
||||
$headerid = $this->db_onedev->insert_id();
|
||||
|
||||
foreach($payments as $k => $v){
|
||||
if($v['chex']){
|
||||
$actual = 0;
|
||||
$change = 0;
|
||||
$amount = $v['leftvalue'];
|
||||
if($v['code'] == 'CASH'){
|
||||
$actual = $v['leftvalue'];
|
||||
$change = $v['rightvalue'];
|
||||
if($actual > 0){
|
||||
$amount = intval($v['leftvalue']) - intval($v['rightvalue']);
|
||||
}
|
||||
else{
|
||||
$amount = $actual;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO f_paymentdetail(
|
||||
F_PaymentDetailF_PaymentID,
|
||||
F_PaymentDetailM_PaymentTypeID,
|
||||
F_PaymentDetailAmount,
|
||||
F_PaymentDetailActual,
|
||||
F_PaymentDetailChange,
|
||||
F_PaymentDetailCreated,
|
||||
F_PaymentDetailLastUpdated,
|
||||
F_PaymentDetailUserID)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now(),
|
||||
?
|
||||
)";
|
||||
//echo $sql;
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$headerid,
|
||||
$v['id'],
|
||||
$amount,
|
||||
$actual,
|
||||
$change,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail cash insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
//if(intval($v['leftvalue']) > 0){
|
||||
$actual = 0;
|
||||
$change = 0;
|
||||
$amount = $v['leftvalue'];
|
||||
$selected_card = 0;
|
||||
$selected_edc = 0;
|
||||
$selected_account = 0;
|
||||
if($v['code'] == 'DEBIT' || $v['code'] == 'CREDIT' || $v['code'] == 'TRANSFER'){
|
||||
$selected_card = $v['selected_card']['id'];
|
||||
$selected_edc = $v['selected_edc']['id'];
|
||||
$selected_account = $v['selected_account']['id'];
|
||||
}
|
||||
$sql = "INSERT INTO f_paymentdetail(
|
||||
F_PaymentDetailF_PaymentID,
|
||||
F_PaymentDetailM_PaymentTypeID,
|
||||
F_PaymentDetailAmount,
|
||||
F_PaymentDetailActual,
|
||||
F_PaymentDetailChange,
|
||||
F_PaymentDetailCardNat_BankID,
|
||||
F_PaymentDetailEDCNat_BankID,
|
||||
F_PaymentDetailM_BankAccountID,
|
||||
F_PaymentDetailCreated,
|
||||
F_PaymentDetailLastUpdated,
|
||||
F_PaymentDetailUserID)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now(),
|
||||
?
|
||||
)";
|
||||
//echo $sql;
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$headerid,
|
||||
$v['id'],
|
||||
$amount,
|
||||
$actual,
|
||||
$change,
|
||||
$selected_card,
|
||||
$selected_edc,
|
||||
$selected_account,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail non cash insert");
|
||||
exit;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query = "SELECT M_PaymentTypeID as id,
|
||||
M_PaymentTypeCode as code,
|
||||
IF(M_PaymentTypeCode = 'CASH','Y','N') as chex,
|
||||
M_PaymentTypeName as chexlabel,
|
||||
'Jumlah' as leftlabel,
|
||||
CASE
|
||||
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
|
||||
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'TRANSFER' THEN 'Nomor Rekening'
|
||||
ELSE 'Nomor Voucher'
|
||||
END as rightlabel,
|
||||
0 as leftvalue,
|
||||
0 as rightvalue
|
||||
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
$xdata = $this->db_onedev->query("SELECT F_PaymentID as idx, F_PaymentNumber as numberx FROM f_payment WHERE F_PaymentID = {$headerid}")->row();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => array('payments'=>$payments,'types'=>$rows,'data'=>$xdata)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function delete_note()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$prmnota = $prm['nota'];
|
||||
$catatan = $prm['catatan'];
|
||||
$sql = "UPDATE f_payment SET F_PaymentIsActive = 'N', F_PaymentNote = '{$catatan}' WHERE F_PaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_payment delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE f_paymentdetail SET F_PaymentDetailIsActive = 'N' WHERE F_PaymentDetailF_PaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('prm'=>$prm)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
46
application/controllers/his/try.http
Normal file
46
application/controllers/his/try.http
Normal file
@@ -0,0 +1,46 @@
|
||||
### Post Order Request
|
||||
POST http://10.9.10.207:23381/PushOrder
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"CorporateID": "46",
|
||||
"CorporateName": "PT Astra Daihatsu Motor",
|
||||
"outletId": "I",
|
||||
"BranchCode": "000619",
|
||||
"BranchName": "Westerindo Cikarang",
|
||||
"PatientCode": "CP2407270227",
|
||||
"patientName": "Bpk Ahmad Roni Setiawan",
|
||||
"mobileNumber": "",
|
||||
"email": "admin@gmail.com",
|
||||
"idNIK": "",
|
||||
"sexId": "l",
|
||||
"sexName": "Male",
|
||||
"dob": "1995/05/05",
|
||||
"addressName": "CpOne Address",
|
||||
"orderNumber": "I2412060003",
|
||||
"orderDT": "2024/12/06 11:06:54",
|
||||
"DoctorOrderCode": "CpOne001",
|
||||
"DoctorOrderName": "Dr CpOne",
|
||||
"GuarantorID": "000619",
|
||||
"GuarantorName": "Westerindo Cikarang",
|
||||
"AgreementID": "Cp1",
|
||||
"AgreementName": "CpOne",
|
||||
"ReceivedFlag": false,
|
||||
"LabRegNo": null,
|
||||
"ReceivedDateTime": null,
|
||||
"orderItemList": [
|
||||
{"OrderItemId": "00000055", "OrderItemName": "SGPT"},
|
||||
{"OrderItemId": "00000062", "OrderItemName": "Asam Urat"},
|
||||
{"OrderItemId": "00000065", "OrderItemName": "SGOT"},
|
||||
{"OrderItemId": "00000083", "OrderItemName": "LDL Cholesterol"},
|
||||
{"OrderItemId": "00000101", "OrderItemName": "Cholesterol"},
|
||||
{"OrderItemId": "00000102", "OrderItemName": "HDL Cholesterol"},
|
||||
{"OrderItemId": "00000109", "OrderItemName": "Trigliserida"},
|
||||
{"OrderItemId": "00000112", "OrderItemName": "Ureum"},
|
||||
{"OrderItemId": "00000250", "OrderItemName": "Glukosa Darah Puasa"},
|
||||
{"OrderItemId": "00000506", "OrderItemName": "Urine Lengkap"},
|
||||
{"OrderItemId": "00000686", "OrderItemName": "Hematologi Lengkap"},
|
||||
{"OrderItemId": "00001283", "OrderItemName": "HBs Ag (Kualitatif)"},
|
||||
{"OrderItemId": "00001598", "OrderItemName": "Panel Creatinin"}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user