Initial import
This commit is contained in:
1798
application/controllers/klinik/Anamnese.php
Normal file
1798
application/controllers/klinik/Anamnese.php
Normal file
File diff suppressed because it is too large
Load Diff
434
application/controllers/klinik/Order.php
Normal file
434
application/controllers/klinik/Order.php
Normal file
@@ -0,0 +1,434 @@
|
||||
<?php
|
||||
class Order extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_klinik = $this->load->database("onedev", true);
|
||||
$one_db = "one_aditya";
|
||||
}
|
||||
|
||||
function calculateAge($tanggal_lahir) {
|
||||
// Ambil tanggal sekarang
|
||||
$tanggal_sekarang = new DateTime();
|
||||
|
||||
// Ubah tanggal lahir ke objek DateTime
|
||||
$tanggal_lahir = new DateTime($tanggal_lahir);
|
||||
|
||||
// Hitung selisih antara tanggal sekarang dan tanggal lahir
|
||||
$perbedaan = $tanggal_sekarang->diff($tanggal_lahir);
|
||||
|
||||
// Dapatkan tahun, bulan, dan hari dari selisih
|
||||
$umur_tahun = $perbedaan->y;
|
||||
$umur_bulan = $perbedaan->m;
|
||||
$umur_hari = $perbedaan->d;
|
||||
|
||||
return array($umur_tahun, $umur_bulan, $umur_hari);
|
||||
}
|
||||
function createOrder(){
|
||||
try{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM m_patient
|
||||
WHERE
|
||||
M_PatientID = ?";
|
||||
$query = $this->db_klinik->query($sql,array(
|
||||
$prm['patient_id'],
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error select patient",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data_patient = $query->row_array();
|
||||
list($umur_tahun, $umur_bulan, $umur_hari) = $this->calculateAge($data_patient['M_PatientDOB']);
|
||||
|
||||
$sql = "INSERT INTO one_klinik.order (
|
||||
orderNumber,
|
||||
orderM_PatientID,
|
||||
orderAge,
|
||||
orderM_DoctorID,
|
||||
orderDiagnosisAwal,
|
||||
orderDiagnosisAkhir,
|
||||
orderSubtotal,
|
||||
orderDiscountAmount,
|
||||
orderDiscountPercent,
|
||||
orderDiscountTotal,
|
||||
orderTotal,
|
||||
orderCreated,
|
||||
orderUserID
|
||||
)
|
||||
VALUES (
|
||||
fn_numbering('K'),
|
||||
?,?,?,?,?,?,?,?,?,?,NOW(),?
|
||||
)";
|
||||
$query = $this->db_klinik->query($sql,array(
|
||||
$prm['patient_id'],
|
||||
$umur_tahun.' Tahun '.$umur_bulan.' Bulan '. $umur_hari.' Hari',
|
||||
$prm['doctor_id'],
|
||||
$prm['diagnosis_awal'],
|
||||
$prm['diagnosis_akhir'],
|
||||
$prm['subtotal'],
|
||||
$prm['discount_amount'],
|
||||
$prm['diagnosis_percent'],
|
||||
$prm['diagnosis_total'],
|
||||
$prm['total'],
|
||||
$userID
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error create order",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $this->db_klinik->insert_id();
|
||||
$sql = "INSERT INTO one_klinik.`order_status`(
|
||||
orderStatusOrderID,
|
||||
orderStatusOrderID,
|
||||
orderStatusValue,
|
||||
orderStatusUserID
|
||||
)
|
||||
VALUES(
|
||||
'R',?,'D',?
|
||||
)";
|
||||
$query = $this->db_klinik->query($sql,array($last_id,$userID));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error insert order status",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO one_klinik.`order_status`(
|
||||
orderStatusOrderID,
|
||||
orderStatusOrderID,
|
||||
orderStatusValue,
|
||||
orderStatusUserID
|
||||
)
|
||||
VALUES(
|
||||
'SA',?,'D',?
|
||||
)";
|
||||
$query = $this->db_klinik->query($sql,array($last_id,$userID));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error insert order status",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT * FROM one_klinik.order WHERE orderID = ?";
|
||||
$query = $this->db_klinik->query($sql,array($last_id));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error select order",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = $query->row_array();
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getOrder($orderID){
|
||||
try{
|
||||
|
||||
$sql = "SELECT orderID,
|
||||
orderNumber,
|
||||
orderM_PatientID,
|
||||
orderM_DoctorID,
|
||||
orderDiagnosisAwal,
|
||||
orderDiagnosisAkhir,
|
||||
orderSubtotal,
|
||||
orderDiscountAmount,
|
||||
orderDiscountPercent,
|
||||
orderDiscountTotal,
|
||||
orderTotal,
|
||||
CONCAT(IF(M_TitleName IS NULL,'',CONCAT(M_TitleName,'. ')),IF(M_PatientPrefix IS NULL,'',CONCAT(M_PatientPrefix,'. ')),M_PatientName,IF(M_PatientSuffix IS NULL,'',CONCAT(M_PatientSuffix,'. '))) as patient_fullname,
|
||||
M_PatientName as patient_name,
|
||||
M_DoctorName as doctor_name,
|
||||
CONCAT(IF(M_DoctorPrefix IS NULL,'',CONCAT(M_DoctorPrefix,'. ')),IF(M_DoctorPrefix2 IS NULL,'',CONCAT(M_DoctorPrefix2,'. ')),M_DoctorName,IF(M_DoctorSufix IS NULL,'',CONCAT(M_DoctorSufix,'. ')),IF(M_DoctorSufix2 IS NULL,'',CONCAT(M_DoctorSufix2,'. ')),IF(M_DoctorSufix3 IS NULL,'',CONCAT(M_DoctorSufix3,'. '))) as doctor_fullname
|
||||
FROM one_klinik.order
|
||||
JOIN m_patient ON orderM_PatientID = M_PatientID
|
||||
JOIN m_doctor ON orderM_DoctorID = M_DoctorID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE
|
||||
orderID = ?";
|
||||
$query = $this->db_klinik->query($sql,array(
|
||||
$orderID
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error get order",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = $query->row_array();
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveAnamnesis(){
|
||||
try{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql = "INSERT INTO one_klinik.order_anamnesis (
|
||||
orderAnamnesisOrderID,
|
||||
orderAnamnesisKeluhanUtama,
|
||||
orderAnamnesisRiwayatPenyakitDahulu,
|
||||
orderAnamnesisRiwayatPenyakitSekarang,
|
||||
orderAnamnesisRiwayatPenyakitKeluarga,
|
||||
orderAnamnesisRiwayatPengobatan,
|
||||
orderAnamnesisRiwayatSosial,
|
||||
orderAnamnesisRiwayatOperasi,
|
||||
orderAnamnesisRiwayatAlergi,
|
||||
orderAnamnesisCreated,
|
||||
orderAnamnesisUserID
|
||||
)
|
||||
VALUES (
|
||||
?,?,?,?,?,?,?,?,?,NOW(),?
|
||||
)";
|
||||
$query = $this->db_klinik->query($sql,array(
|
||||
$prm['order_id'],
|
||||
$prm['keluhan_utama'],
|
||||
$prm['penyakit_dahulu'],
|
||||
$prm['penyakit_sekarang'],
|
||||
$prm['penyakit_keluarga'],
|
||||
$prm['pengobatan'],
|
||||
$prm['sosial'],
|
||||
$prm['operasi'],
|
||||
$prm['alergi'],
|
||||
$userID
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error create order_anamnesis",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array('status' => true);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function updateAnamnesis(){
|
||||
try{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql = "UPDATE one_klinik.order_anamnesis SET
|
||||
orderAnamnesisOrderID = ?,
|
||||
orderAnamnesisKeluhanUtama = ?,
|
||||
orderAnamnesisRiwayatPenyakitDahulu = ?,
|
||||
orderAnamnesisRiwayatPenyakitSekarang = ?,
|
||||
orderAnamnesisRiwayatPenyakitKeluarga = ?,
|
||||
orderAnamnesisRiwayatPengobatan = ?,
|
||||
orderAnamnesisRiwayatSosial = ?,
|
||||
orderAnamnesisRiwayatOperasi = ?,
|
||||
orderAnamnesisRiwayatAlergi = ? ,
|
||||
orderAnamnesisLastUpdated = NOW(),
|
||||
orderAnamnesisUserID = ?
|
||||
WHERE
|
||||
orderAnamnesisID = ?";
|
||||
$query = $this->db_klinik->query($sql,array(
|
||||
$prm['orderID'],
|
||||
$prm['orderAnamnesisKeluhanUtama'],
|
||||
$prm['orderAnamnesisRiwayatPenyakitDahulu'],
|
||||
$prm['orderAnamnesisRiwayatPenyakitSekarang'],
|
||||
$prm['orderAnamnesisRiwayatPenyakitKeluarga'],
|
||||
$prm['orderAnamnesisRiwayatPengobatan'],
|
||||
$prm['orderAnamnesisRiwayatSosial'],
|
||||
$prm['orderAnamnesisRiwayatOperasi'],
|
||||
$prm['orderAnamnesisRiwayatAlergi'],
|
||||
$userID
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error update order_anamnesis",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array('status' => true);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveDoctorPage(){
|
||||
try{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql = "UPDATE one_klinik.order SET
|
||||
orderDiagnosisAwal = ?,
|
||||
orderDiagnosisAkhir = ?,
|
||||
orderLastUpdated = NOW(),
|
||||
orderUserID = ?
|
||||
WHERE
|
||||
orderID = ?";
|
||||
$query = $this->db_klinik->query($sql,array(
|
||||
$prm['orderDiagnosisAwal'],
|
||||
$prm['orderDiagnosisAkhir'],
|
||||
$userID,
|
||||
$prm['orderID']
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error update order diagnosis",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
if($prm['orderReceiptText'] && $prm['orderReceiptText'] != ''){
|
||||
$sql = "INSERT INTO one_klinik.order_receipt (
|
||||
orderReceiptOrderID,
|
||||
orderReceiptText,
|
||||
orderReceiptCreated,
|
||||
orderReceiptUserID
|
||||
)
|
||||
VALUES(
|
||||
?,?,NOW(),?
|
||||
) ON DUPLICATE KEY UPDATE orderReceiptText = ?, orderReceiptUserID = ?";
|
||||
$query = $this->db_klinik->query($sql,array(
|
||||
$prm['orderID'],
|
||||
$prm['orderReceiptText'],
|
||||
$userID,
|
||||
$prm['orderReceiptText'],
|
||||
$userID
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error insert/update order_receipt",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if(count($prm['order_penunjang']) > 0){
|
||||
$sql = "UPDATE one_klinik.order_penunjang SET
|
||||
orderPenunjangIsActive = 'N',
|
||||
orderPenunjangUserID= ?,
|
||||
orderPenunjangLastUpdated = NOW()
|
||||
WHERE
|
||||
orderPenunjangOrderID = ?";
|
||||
$query = $this->db_klinik->query($sql,array(
|
||||
$prm['orderID'],
|
||||
$userID
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error nonactive order_penunjang",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($prm['order_penunjang'] as $key => $value) {
|
||||
$sql = "INSERT INTO one_klinik.order_penunjang (
|
||||
orderPenunjangOrderID,
|
||||
orderPenunjangT_TestID,
|
||||
orderPenunjangCreated,
|
||||
orderPenunjangUserID
|
||||
)
|
||||
VALUES(
|
||||
?,?,NOW(),?
|
||||
) ";
|
||||
$query = $this->db_klinik->query($sql,array(
|
||||
$prm['orderID'],
|
||||
$prm['orderPenunjangT_TestID'],
|
||||
$userID
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("error insert/update order_penunjang",$this->db_klinik);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = array('status' => true);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function searchTest()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] == '') {
|
||||
$rows = array();
|
||||
$result = array("total" => 1, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
$sql = "SELECT T_TestID as id, T_TestName as name, T_TestSasCode as code
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ? AND
|
||||
T_TestIsPrice = 'Y' AND
|
||||
T_TestIsActive = 'Y'
|
||||
ORDER BY T_TestName ASC, T_TestSasCode ASC
|
||||
";
|
||||
$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("t_test rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
283
application/controllers/klinik/Patient.php
Normal file
283
application/controllers/klinik/Patient.php
Normal file
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "LIST PATIENT ORDER";
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm["search"])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = "%" . $prm["search"] . "%";
|
||||
} else {
|
||||
$search = "%%";
|
||||
}
|
||||
}
|
||||
$start_date = $prm['start_date'];
|
||||
$end_date = $prm['end_date'];
|
||||
|
||||
$filter_date = " AND (DATE(orderDate) BETWEEN '{$start_date}' AND '{$end_date}')";
|
||||
|
||||
$where = " orderIsActive = 'Y' $filter_date";
|
||||
|
||||
if ($search != "") {
|
||||
$where .= " AND (orderNumber LIKE '{$search}' OR M_PatientName LIKE '{$search}')";
|
||||
}
|
||||
|
||||
$sql_total = "SELECT COUNT(*) as total FROM (
|
||||
SELECT `order`.*,S_MenuUrl,
|
||||
DATE_FORMAT(orderDate, '%d-%m-%Y %H:%i') as order_date,
|
||||
CONCAT(M_TitleName,'. ',M_PatientName) as patient_fullname,
|
||||
IFNULL(T_OrderHeaderLabNumber,'-') as labnumber
|
||||
FROM one_klinik.order
|
||||
JOIN m_patient ON orderM_PatientID = M_PatientID
|
||||
AND M_PatientIsActive = 'Y'
|
||||
JOIN s_menu ON S_MenuName = 'Registration' AND S_MenuIsActive = 'Y'
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
AND M_TitleIsActive = 'Y'
|
||||
LEFT JOIN t_orderheader ON orderT_OrderHeaderID = T_OrderHeaderID
|
||||
WHERE $where
|
||||
GROUP BY orderID) x";
|
||||
$qry_total = $this->db->query($sql_total);
|
||||
$last_query = $this->db->last_query();
|
||||
//echo $last_query;
|
||||
// exit;
|
||||
|
||||
$tot_count = 0;
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("count order error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM (
|
||||
SELECT `order`.*,S_MenuUrl,
|
||||
DATE_FORMAT(orderDate, '%d-%m-%Y %H:%i') as order_date,
|
||||
CONCAT(M_TitleName,'. ',M_PatientName) as patient_fullname,
|
||||
IFNULL(T_OrderHeaderLabNumber,'-') as labnumber
|
||||
FROM one_klinik.order
|
||||
JOIN m_patient ON orderM_PatientID = M_PatientID
|
||||
AND M_PatientIsActive = 'Y'
|
||||
JOIN s_menu ON S_MenuName = 'Registration' AND S_MenuIsActive = 'Y'
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
AND M_TitleIsActive = 'Y'
|
||||
LEFT JOIN t_orderheader ON orderT_OrderHeaderID = T_OrderHeaderID
|
||||
WHERE $where
|
||||
GROUP BY orderID) x
|
||||
ORDER BY orderID ASC
|
||||
limit 0, $tot_count";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
$last_query = $this->db->last_query();
|
||||
// echo $last_query;
|
||||
// exit;
|
||||
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("Select order error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchcompany()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = "";
|
||||
$number_limit = 10;
|
||||
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT M_CompanyID,
|
||||
M_CompanyName, '' as mous
|
||||
FROM m_company
|
||||
WHERE M_CompanyIsActive = 'Y'
|
||||
AND M_CompanyName LIKE ?
|
||||
LIMIT ?";
|
||||
$qry = $this->db->query($sql, [$search, $number_limit]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if($rows){
|
||||
foreach ($rows as $key => $value) {
|
||||
$mous = [];
|
||||
$sql = "SELECT M_MouID, M_MouName
|
||||
FROM m_mou
|
||||
WHERE M_MouIsActive = 'Y' AND M_MouIsApproved = 'Y' AND M_MouIsReleased = 'Y'
|
||||
AND M_MouStartDate <= date(now()) AND M_MouEndDate >= date(now()) AND M_MouM_CompanyID = ?";
|
||||
$mous = $this->db->query($sql,array($value['M_CompanyID']))->result_array();
|
||||
$rows[$key]['mous'] = $mous;
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("company select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function savesetting()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$mouid = "";
|
||||
if (isset($prm["mouid"])) {
|
||||
$mouid = trim($prm["mouid"]);
|
||||
}
|
||||
|
||||
|
||||
$sql = "UPDATE one_klinik.order SET
|
||||
orderM_MouID = {$mouid},
|
||||
orderUserID = {$userid},
|
||||
orderLastUpdated = NOW()
|
||||
WHERE
|
||||
orderID = {$prm['orderid']}";
|
||||
// echo $sql;
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db_oneklinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getdefaultmou()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$row_results = [];
|
||||
$rtn_mou = [];
|
||||
$sql = "SELECT M_CompanyID,
|
||||
M_CompanyName, '' as mous, settingM_MouID
|
||||
FROM m_company
|
||||
JOIN one_klinik.setting ON settingIsActive = 'Y'
|
||||
JOIN m_mou ON M_MouID = settingM_MouID AND M_MouM_CompanyID = M_CompanyID AND
|
||||
M_MouIsActive = 'Y' AND M_MouIsApproved = 'Y' AND M_MouIsReleased = 'Y'
|
||||
AND M_MouStartDate <= date(now()) AND M_MouEndDate >= date(now())
|
||||
WHERE M_CompanyIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if($rows){
|
||||
foreach ($rows as $key => $value) {
|
||||
$mous = [];
|
||||
$sql = "SELECT M_MouID, M_MouName
|
||||
FROM m_mou
|
||||
WHERE M_MouIsActive = 'Y' AND M_MouIsApproved = 'Y' AND M_MouIsReleased = 'Y'
|
||||
AND M_MouStartDate <= date(now()) AND M_MouEndDate >= date(now()) AND M_MouM_CompanyID = ?";
|
||||
$mous = $this->db->query($sql,array($value['M_CompanyID']))->result_array();
|
||||
$data_result = [];
|
||||
$data_result['M_CompanyID'] = $value['M_CompanyID'];
|
||||
$data_result['M_CompanyName'] = $value['M_CompanyName'];
|
||||
$data_result['mous'] = $mous;
|
||||
$row_results[] = $data_result;
|
||||
foreach ($mous as $k => $v) {
|
||||
if($v['M_MouID'] == $value['settingM_MouID']){
|
||||
$rtn_mou = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("company select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $row_results,
|
||||
"mou" => $rtn_mou
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
1077
application/controllers/klinik/Registration.php
Normal file
1077
application/controllers/klinik/Registration.php
Normal file
File diff suppressed because it is too large
Load Diff
1204
application/controllers/klinik/Registrationv2.php
Normal file
1204
application/controllers/klinik/Registrationv2.php
Normal file
File diff suppressed because it is too large
Load Diff
252
application/controllers/klinik/Setting.php
Normal file
252
application/controllers/klinik/Setting.php
Normal file
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
class Setting extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_oneklinik = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "Default Setting Klinik";
|
||||
|
||||
}
|
||||
|
||||
function searchmou()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = "";
|
||||
$number_limit = 10;
|
||||
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$companyid = "";
|
||||
if (isset($prm["companyid"])) {
|
||||
$companyid = trim($prm["companyid"]);
|
||||
}
|
||||
|
||||
$sql = "SELECT M_MouID,
|
||||
M_MouName
|
||||
FROM m_mou
|
||||
JOIN m_company ON M_CompanyID = M_MouM_CompanyID
|
||||
AND M_CompanyID = ?
|
||||
ANd M_CompanyIsActive = 'Y'
|
||||
WHERE M_MouIsActive = 'Y'
|
||||
AND M_MouIsApproved = 'Y'
|
||||
AND M_MouStartDate <= date(now()) AND M_MouEndDate >= date(now())
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND (M_MouName LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry = $this->db->query($sql, [$companyid, $search, $number_limit]);
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("mou select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function savesetting()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$mouid = "";
|
||||
if (isset($prm["mouid"])) {
|
||||
$mouid = trim($prm["mouid"]);
|
||||
}
|
||||
$price = "";
|
||||
if (isset($prm["price"])) {
|
||||
$price = trim($prm["price"]);
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*) as xcount FROM one_klinik.`setting` WHERE SettingIsActive = 'Y'";
|
||||
$xcount = $this->db_oneklinik->query($sql)->row()->xcount;
|
||||
// echo $xcount;
|
||||
|
||||
if($xcount == 0){
|
||||
$sql = "INSERT INTO one_klinik.`setting`(
|
||||
settingM_MouID,
|
||||
settingPriceDefault,
|
||||
settingIsActive,
|
||||
settingUserID,
|
||||
settingCreated,
|
||||
settingLastUpdated) VALUES(?,?,'Y',?,NOW(),NOW())";
|
||||
$qry = $this->db_oneklinik->query($sql, array(
|
||||
$mouid,
|
||||
$price,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db_oneklinik->last_query();
|
||||
// echo $last_qry;
|
||||
if (!$qry) {
|
||||
$this->db_oneklinik->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db_oneklinik->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db_oneklinik);
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$sql = "UPDATE one_klinik.`setting` SET
|
||||
settingM_MouID = ?,
|
||||
settingPriceDefault = ?,
|
||||
settingUserID = ?,
|
||||
settingLastUpdated = NOW()
|
||||
WHERE
|
||||
settingIsActive = 'Y'";
|
||||
$qry = $this->db_oneklinik->query($sql, array(
|
||||
$mouid,
|
||||
$price,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db_oneklinik->last_query();
|
||||
if (!$qry) {
|
||||
$this->db_oneklinik->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db_oneklinik->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db_oneklinik);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->db_oneklinik->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchcompany()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = "";
|
||||
$number_limit = 10;
|
||||
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT M_CompanyID,
|
||||
M_CompanyName
|
||||
FROM m_company
|
||||
WHERE M_CompanyIsActive = 'Y'
|
||||
AND M_CompanyName LIKE ?
|
||||
LIMIT ?";
|
||||
$qry = $this->db->query($sql, [$search, $number_limit]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("company select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function get_data()
|
||||
{
|
||||
try {
|
||||
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT setting.*,
|
||||
M_CompanyID,
|
||||
M_CompanyName,
|
||||
M_MouName
|
||||
FROM one_klinik.`setting`
|
||||
JOIN m_mou ON M_MouID = settingM_MouID
|
||||
JOIN m_company ON M_MouM_CompanyID = M_CompanyID
|
||||
WHERE settingIsActive = 'Y'";
|
||||
$qry = $this->db_oneklinik->query($sql);
|
||||
//echo $this->db_oneklinik->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->row_array();
|
||||
} else {
|
||||
$this->db_oneklinik->trans_rollback();
|
||||
$this->sys_error_db("setting select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
308
application/controllers/klinik/Settingv3.php
Normal file
308
application/controllers/klinik/Settingv3.php
Normal file
@@ -0,0 +1,308 @@
|
||||
<?php
|
||||
class Settingv3 extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
var $load;
|
||||
var $db_oneklinik;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_oneklinik = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "Default Setting Klinik";
|
||||
}
|
||||
|
||||
function searchmou()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = "";
|
||||
$number_limit = 10;
|
||||
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$companyid = "";
|
||||
if (isset($prm["companyid"])) {
|
||||
$companyid = trim($prm["companyid"]);
|
||||
}
|
||||
|
||||
$sql = "SELECT M_MouID,
|
||||
M_MouName
|
||||
FROM m_mou
|
||||
JOIN m_company ON M_CompanyID = M_MouM_CompanyID
|
||||
AND M_CompanyID = ?
|
||||
ANd M_CompanyIsActive = 'Y'
|
||||
WHERE M_MouIsActive = 'Y'
|
||||
AND M_MouIsApproved = 'Y'
|
||||
AND M_MouStartDate <= date(now()) AND M_MouEndDate >= date(now())
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND (M_MouName LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry = $this->db->query($sql, [$companyid, $search, $number_limit]);
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("mou select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function savesetting()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$mouid = "";
|
||||
if (isset($prm["mouid"])) {
|
||||
$mouid = trim($prm["mouid"]);
|
||||
}
|
||||
$price = "";
|
||||
if (isset($prm["price"])) {
|
||||
$price = trim($prm["price"]);
|
||||
}
|
||||
$stationID = "0";
|
||||
if (isset($prm["stationid"])) {
|
||||
$stationID = trim($prm["stationid"]);
|
||||
}
|
||||
$locationID = "0";
|
||||
if (isset($prm["locationid"])) {
|
||||
$locationID = trim($prm["locationid"]);
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*) as xcount FROM one_klinik.`setting` WHERE SettingIsActive = 'Y'";
|
||||
$xcount = $this->db_oneklinik->query($sql)->row()->xcount;
|
||||
// echo $xcount;
|
||||
|
||||
if ($xcount == 0) {
|
||||
$sql = "INSERT INTO one_klinik.`setting`(
|
||||
settingM_MouID,
|
||||
settingPriceDefault,
|
||||
settingIsActive,
|
||||
settingUserID,
|
||||
settingCreated,
|
||||
settingLastUpdated,
|
||||
settingM_LocationID,
|
||||
settingT_SampleStationID) VALUES(?,?,'Y',?,NOW(),NOW(),?,?)";
|
||||
$qry = $this->db_oneklinik->query($sql, array(
|
||||
$mouid,
|
||||
$price,
|
||||
$userid,
|
||||
$locationID,
|
||||
$stationID
|
||||
));
|
||||
$last_qry = $this->db_oneklinik->last_query();
|
||||
// echo $last_qry;
|
||||
if (!$qry) {
|
||||
$this->db_oneklinik->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db_oneklinik->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db_oneklinik);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql = "UPDATE one_klinik.`setting` SET
|
||||
settingM_MouID = ?,
|
||||
settingPriceDefault = ?,
|
||||
settingUserID = ?,
|
||||
settingLastUpdated = NOW(),
|
||||
settingT_SampleStationID = ?,
|
||||
settingM_LocationID = ?
|
||||
WHERE
|
||||
settingIsActive = 'Y'";
|
||||
$qry = $this->db_oneklinik->query($sql, array(
|
||||
$mouid,
|
||||
$price,
|
||||
$userid,
|
||||
$stationID,
|
||||
$locationID
|
||||
));
|
||||
$last_qry = $this->db_oneklinik->last_query();
|
||||
if (!$qry) {
|
||||
$this->db_oneklinik->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db_oneklinik->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db_oneklinik);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->db_oneklinik->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchcompany()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = "";
|
||||
$number_limit = 10;
|
||||
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT M_CompanyID,
|
||||
M_CompanyName
|
||||
FROM m_company
|
||||
WHERE M_CompanyIsActive = 'Y'
|
||||
AND M_CompanyName LIKE ?
|
||||
LIMIT ?";
|
||||
$qry = $this->db->query($sql, [$search, $number_limit]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("company select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function get_data()
|
||||
{
|
||||
try {
|
||||
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT setting.*,
|
||||
M_CompanyID,
|
||||
M_CompanyName,
|
||||
M_MouName,
|
||||
M_LocationName
|
||||
FROM one_klinik.`setting`
|
||||
JOIN m_mou ON M_MouID = settingM_MouID
|
||||
JOIN m_company ON M_MouM_CompanyID = M_CompanyID
|
||||
LEFT JOIN m_location ON settingM_LocationID = M_LocationID
|
||||
AND settingT_SampleStationID = M_LocationT_SampleStationID
|
||||
AND M_LocationIsActive = 'Y'
|
||||
WHERE settingIsActive = 'Y'";
|
||||
$qry = $this->db_oneklinik->query($sql);
|
||||
//echo $this->db_oneklinik->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->row_array();
|
||||
} else {
|
||||
$this->db_oneklinik->trans_rollback();
|
||||
$this->sys_error_db("setting select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function getLocationList()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$sql = "SELECT
|
||||
M_LocationID,
|
||||
M_LocationT_SampleStationID,
|
||||
M_LocationName
|
||||
FROM m_location
|
||||
JOIN t_samplestation
|
||||
ON M_LocationT_SampleStationID = T_SampleStationID
|
||||
AND T_SampleStationIsActive = 'Y'
|
||||
AND T_SampleStationIsNonLab = 'OTHERS'
|
||||
WHERE M_LocationIsActive = 'Y'";
|
||||
$qry = $this->db_oneklinik->query($sql);
|
||||
//echo $this->db_oneklinik->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->db_oneklinik->trans_rollback();
|
||||
$this->sys_error_db("setting select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
213
application/controllers/klinik/cashierklinik/Patient.php
Normal file
213
application/controllers/klinik/cashierklinik/Patient.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?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);
|
||||
//$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function add_notes($orderid){
|
||||
$sql = " SELECT PaymentOrderID as note_order_id,
|
||||
PaymentID as note_id,
|
||||
PaymentDate as note_date,
|
||||
PaymentNumber as note_number,
|
||||
GROUP_CONCAT(M_PaymentTypeName separator ' , ') as paymenttypes_name,
|
||||
SUM(PaymentDetailAmount) as note_amount,
|
||||
M_UserUsername as note_user,
|
||||
PaymentDetailIsActive as note_active
|
||||
FROM one_klinik.`payment`
|
||||
JOIN one_klinik.`paymentdetail` ON PaymentDetailPaymentID = PaymentID
|
||||
JOIN `m_paymenttype` ON PaymentDetailM_PaymentTypeID = M_PaymentTypeID
|
||||
LEFT JOIN `m_user` ON PaymentDetailUserID = M_UserID
|
||||
WHERE
|
||||
PaymentOrderID = {$orderid}
|
||||
GROUP BY PaymentID";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $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'] . " 23:59:59";
|
||||
$search = $prm["search"];
|
||||
$status = $prm["status"];
|
||||
/*$company = $prm["company"];
|
||||
$filter_company = '';
|
||||
if($company != '0' || $company != 0)
|
||||
$filter_company = " AND M_CompanyID = {$company}";
|
||||
*/
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$where = " ( DATE(orderDate) = '{$startdate}' ) AND ";
|
||||
if($search != ''){
|
||||
$where = "( M_PatientName LIKE '%{$search}%' OR orderNumber LIKE '%{$search}%' ) AND ";
|
||||
if(strlen($search) == 11){
|
||||
$where = "orderNumber = '{$search}' AND ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM one_klinik.`order`
|
||||
JOIN m_patient ON orderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
WHERE
|
||||
$where
|
||||
( ('{$status}' = 'N' AND orderIsLunas = 'N') OR ('{$status}' = 'Y' AND orderIsLunas = 'Y') )";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
//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 orderID,
|
||||
orderDate,
|
||||
orderNumber,
|
||||
orderM_PatientID,
|
||||
M_PatientNoReg,
|
||||
orderKeluhan,
|
||||
DATE_FORMAT(orderDate,'%d-%m-%Y %H:%i') as order_date,
|
||||
CONCAT(M_TitleName,'. ',M_PatientName) as M_PatientName,
|
||||
CONCAT(M_TitleLangName,'. ',M_PatientName) as M_PatientName_eng,
|
||||
M_TitleName,
|
||||
orderTotal as totalbill,
|
||||
0 as paid,
|
||||
0 as unpaid,
|
||||
orderIsLunas as flaglunas,
|
||||
'' as notes,
|
||||
100 as mindp_percent,
|
||||
settingPriceDefault as mindp_amount,
|
||||
0 as F_BillDetailID
|
||||
FROM one_klinik.`order`
|
||||
JOIN m_patient ON orderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN one_klinik.`setting` ON settingIsActive = 'Y'
|
||||
WHERE
|
||||
$where
|
||||
( ('{$status}' = 'N' AND orderIsLunas = 'N') OR ('{$status}' = 'Y' AND orderIsLunas = 'Y') )
|
||||
GROUP BY orderID
|
||||
ORDER BY orderID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$sql = "SELECT IFNULL(SUM(PaymentTotal),0) as total
|
||||
FROM one_klinik.payment
|
||||
WHERE
|
||||
PaymentOrderID = ? AND PaymentIsActive = 'Y'";
|
||||
$data_payment = $this->db_onedev->query($sql, array($v['orderID']))->row();
|
||||
$unpaid = $v['totalbill'] - $data_payment->total;
|
||||
$rows[$k]['unpaid'] = $unpaid;
|
||||
$rows[$k]['paid'] = $data_payment->total;
|
||||
|
||||
$rows[$k]['notes'] = $this->add_notes($v['orderID']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
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 m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = '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 M_CompanyID as id, M_CompanyName as name
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC
|
||||
";
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
531
application/controllers/klinik/cashierklinik/Payment.php
Normal file
531
application/controllers/klinik/cashierklinik/Payment.php
Normal file
@@ -0,0 +1,531 @@
|
||||
<?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);
|
||||
//$this->db_onedev = $this->load->database("klinik", 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 one_klinik.`payment`(PaymentOrderID,PaymentDate,PaymentCreated,PaymentM_UserID) VALUES (?,CURDATE(),NOW(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid, $xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("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 one_klinik.`paymentdetail`(
|
||||
PaymentDetailPaymentID,
|
||||
PaymentDetailM_PaymentTypeID,
|
||||
PaymentDetailAmount,
|
||||
PaymentDetailActual,
|
||||
PaymentDetailChange,
|
||||
PaymentDetailCreated,
|
||||
PaymentDetailLastUpdated,
|
||||
PaymentDetailUserID)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now(),
|
||||
?
|
||||
)";
|
||||
//echo $sql;
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$headerid,
|
||||
$v['id'],
|
||||
$amount,
|
||||
$actual,
|
||||
$change,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
|
||||
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 one_klinik.`paymentdetail`(
|
||||
PaymentDetailPaymentID,
|
||||
PaymentDetailM_PaymentTypeID,
|
||||
PaymentDetailAmount,
|
||||
PaymentDetailActual,
|
||||
PaymentDetailChange,
|
||||
PaymentDetailCardNat_BankID,
|
||||
PaymentDetailEDCNat_BankID,
|
||||
PaymentDetailM_BankAccountID,
|
||||
PaymentDetailCreated,
|
||||
PaymentDetailLastUpdated,
|
||||
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;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT SUM(PaymentDetailAmount) as total
|
||||
FROM one_klinik.`paymentdetail`
|
||||
WHERE
|
||||
PaymentDetailPaymentID = ? AND PaymentDetailIsActive = 'Y'";
|
||||
$total_paid = $this->db_onedev->query($sql,array($headerid))->row()->total;
|
||||
//echo $this->db_onedev->last_query();
|
||||
|
||||
$sql = "UPDATE one_klinik.`payment` SET PaymentTotal = ? WHERE PaymentID = ?";
|
||||
$this->db_onedev->query($sql,array($total_paid,$headerid));
|
||||
|
||||
$sql = "SELECT SUM(PaymentTotal) as paid,
|
||||
orderTotal as total
|
||||
FROM one_klinik.`payment`
|
||||
JOIN one_klinik.`order` ON orderID = PaymentOrderID
|
||||
WHERE
|
||||
PaymentOrderID = ? AND PaymentIsActive = 'Y' ";
|
||||
$xtotal_all_paid = $this->db_onedev->query($sql,array($orderid))->row_array();
|
||||
|
||||
if($xtotal_all_paid['paid'] >= $xtotal_all_paid['total']){
|
||||
$sql = "UPDATE one_klinik.`order` SET orderIsLunas = 'Y' WHERE orderID = ?";
|
||||
$this->db_onedev->query($sql,array($orderid));
|
||||
}
|
||||
|
||||
|
||||
$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 PaymentID as idx, PaymentNumber as numberx FROM one_klinik.payment WHERE 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 one_klinik.payment SET PaymentIsActive = 'N', PaymentNote = '{$catatan}' WHERE PaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_payment delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE one_klinik.paymentdetail SET PaymentDetailIsActive = 'N' WHERE 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/klinik/cashierklinik/Payment.php--160920
Normal file
400
application/controllers/klinik/cashierklinik/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;
|
||||
}
|
||||
}
|
||||
1756
application/controllers/klinik/doctor/Anamnesedoctor.php
Normal file
1756
application/controllers/klinik/doctor/Anamnesedoctor.php
Normal file
File diff suppressed because it is too large
Load Diff
1639
application/controllers/klinik/doctor/Anamnesedoctor.php_10012024
Normal file
1639
application/controllers/klinik/doctor/Anamnesedoctor.php_10012024
Normal file
File diff suppressed because it is too large
Load Diff
1156
application/controllers/klinik/doctor/Doctor.php
Normal file
1156
application/controllers/klinik/doctor/Doctor.php
Normal file
File diff suppressed because it is too large
Load Diff
1110
application/controllers/klinik/doctor/Doctor.php_281223
Normal file
1110
application/controllers/klinik/doctor/Doctor.php_281223
Normal file
File diff suppressed because it is too large
Load Diff
1043
application/controllers/klinik/doctorschedule/Config.php
Normal file
1043
application/controllers/klinik/doctorschedule/Config.php
Normal file
File diff suppressed because it is too large
Load Diff
1812
application/controllers/klinik/doctorv2/Anamnesedoctor.php
Normal file
1812
application/controllers/klinik/doctorv2/Anamnesedoctor.php
Normal file
File diff suppressed because it is too large
Load Diff
1804
application/controllers/klinik/doctorv2/Anamnesedoctor.php_060224
Normal file
1804
application/controllers/klinik/doctorv2/Anamnesedoctor.php_060224
Normal file
File diff suppressed because it is too large
Load Diff
1639
application/controllers/klinik/doctorv2/Anamnesedoctor.php_10012024
Normal file
1639
application/controllers/klinik/doctorv2/Anamnesedoctor.php_10012024
Normal file
File diff suppressed because it is too large
Load Diff
1756
application/controllers/klinik/doctorv2/Anamnesedoctor.php_28jan24
Normal file
1756
application/controllers/klinik/doctorv2/Anamnesedoctor.php_28jan24
Normal file
File diff suppressed because it is too large
Load Diff
1156
application/controllers/klinik/doctorv2/Doctor.php
Normal file
1156
application/controllers/klinik/doctorv2/Doctor.php
Normal file
File diff suppressed because it is too large
Load Diff
1110
application/controllers/klinik/doctorv2/Doctor.php_281223
Normal file
1110
application/controllers/klinik/doctorv2/Doctor.php_281223
Normal file
File diff suppressed because it is too large
Load Diff
191
application/controllers/klinik/resumemedic/Patient.php
Normal file
191
application/controllers/klinik/resumemedic/Patient.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?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);
|
||||
$this->db_oneklinik = $this->load->database("onedev", true);
|
||||
$one_db = "one_aditya";
|
||||
}
|
||||
|
||||
|
||||
function search()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 100;
|
||||
$tot_count =0;
|
||||
$number_limit = 10;
|
||||
$number_offset = (!isset($prm['current_page'])?1:$prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$q = [
|
||||
'noreg' => "",
|
||||
'name' => '',
|
||||
'hp' => '',
|
||||
'dob' => '',
|
||||
'address' => '',
|
||||
'nik' =>''
|
||||
];
|
||||
|
||||
$q_pid = "";
|
||||
|
||||
if ($prm['noreg'] != '')
|
||||
$q['noreg'] = "AND M_PatientNoReg like '%{$prm['noreg']}%'";
|
||||
|
||||
if($prm['snorm'] == ''){
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$e = explode('+', $prm['search']);
|
||||
if (isset($e[0])){
|
||||
$e[0] = str_replace("'", "\\'", $e[0]);
|
||||
$q['name'] = "AND M_PatientName LIKE '%{$e[0]}%'";
|
||||
}
|
||||
if (isset($e[1]))
|
||||
$q['hp'] = "AND ((M_PatientHP LIKE '%{$e[1]}%' and M_PatientHP IS NOT NULL) OR (M_PatientHP IS NULL AND '{$e[1]}' = ''))";
|
||||
if (isset($e[2]))
|
||||
$q['dob'] = "AND ((DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') LIKE '%{$e[2]}%' and M_PatientDOB IS NOT NULL) OR (M_PatientDOB IS NULL AND '{$e[2]}' = ''))";
|
||||
if (isset($e[3]))
|
||||
$q['address'] = "AND M_PatientAddressDescription LIKE '%{$e[3]}%'";
|
||||
if (isset($e[4]))
|
||||
$q['nik'] = "AND M_PatientIDNumber = '{$e[4]}'";
|
||||
}
|
||||
}else{
|
||||
$q_pid = "AND M_PatientNoReg = '{$prm['snorm']}'";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT 'N' divider,M_PatientID,
|
||||
M_PatientNoReg,
|
||||
M_PatientPrefix,
|
||||
M_PatientName,
|
||||
M_PatientSuffix,
|
||||
M_PatientHP,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientPhone,
|
||||
M_PatientIDNumber,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
||||
M_PatientNote,
|
||||
M_PatientNIK,
|
||||
M_PatientJabatan,
|
||||
M_PatientKedudukan,
|
||||
M_PatientPJ,
|
||||
M_PatientLocation,
|
||||
M_PatientJob,
|
||||
M_PatientM_SexID,
|
||||
M_SexName,
|
||||
M_PatientM_TitleID,
|
||||
M_TitleName,
|
||||
M_PatientM_ReligionID,
|
||||
M_PatientM_IdTypeID,
|
||||
M_IdTypeName,
|
||||
M_PatientIDNumber,
|
||||
M_PatientPhoto,
|
||||
M_PatientAddressM_KelurahanID M_KelurahanID,
|
||||
0 M_DistrictID, 0 M_CityID, 0 M_ProvinceID
|
||||
FROM m_patient
|
||||
JOIN one_klinik.`order` ON orderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN m_branch ON M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'
|
||||
JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressIsActive = 'Y'
|
||||
LEFT JOIN m_idtype ON M_IdTypeID = M_PatientM_IdTypeID AND M_IdTypeIsActive = 'Y'
|
||||
WHERE
|
||||
M_PatientIsActive = 'Y'
|
||||
{$q['address']}
|
||||
{$q['noreg']}
|
||||
{$q['name']}
|
||||
{$q['hp']}
|
||||
{$q['dob']}
|
||||
{$q['nik']}
|
||||
{$q_pid}
|
||||
|
||||
GROUP BY M_PatientID
|
||||
LIMIT $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['M_PatientName'] = stripslashes($rows[$k]['M_PatientName']);
|
||||
$rows[$k]['M_PatientAddressDescription'] = stripslashes($v['M_PatientAddressDescription']);
|
||||
$patient_name = str_replace("'", "\\'", $prm['M_PatientName']);
|
||||
$sql = "SELECT *, concat('{$rows[$k]['M_PatientAddressDescription'] }', '\n\n',
|
||||
m_kelurahanname, ', ',
|
||||
m_districtname,'\n',
|
||||
m_cityname, ', ',
|
||||
m_provincename) as xaddress
|
||||
FROM m_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
JOIN m_province ON M_CityM_ProvinceID = M_ProvinceID
|
||||
WHERE
|
||||
M_KelurahanID = {$v['M_KelurahanID']} ";
|
||||
//echo $sql;
|
||||
$row_address = $this->db_onedev->query($sql)->row_array();
|
||||
$rows[$k]['M_PatientAddress'] = stripslashes($row_address['xaddress']);
|
||||
$rows[$k]['M_DistrictID'] = $row_address['M_DistrictID'];
|
||||
$rows[$k]['M_CityID'] = $row_address['M_CityID'];
|
||||
$rows[$k]['M_ProvinceID'] = $row_address['M_ProvinceID'];
|
||||
$info = $this->db_onedev->query("SELECT fn_fo_patient_visit(?) info", [$v['M_PatientID']])->row();
|
||||
$rows[$k]['info'] = json_decode($info->info);
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function get_resume_medics()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT one_klinik.`order`.*, date_format(orderDate,'%d-%m-%Y %H:%i') as order_date
|
||||
FROM one_klinik.`order`
|
||||
WHERE
|
||||
orderIsActive = 'Y' AND orderM_PatientID = ?
|
||||
ORDER BY orderDate DESC";
|
||||
//echo $sql;
|
||||
$query = $this->db_oneklinik->query($sql,array($prm['id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_oneklinik->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("resume medic rows",$this->db_oneklinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
191
application/controllers/klinik/resumemedicv2/Patient.php
Normal file
191
application/controllers/klinik/resumemedicv2/Patient.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?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);
|
||||
$this->db_oneklinik = $this->load->database("onedev", true);
|
||||
$one_db = "one_aditya";
|
||||
}
|
||||
|
||||
|
||||
function search()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 100;
|
||||
$tot_count =0;
|
||||
$number_limit = 10;
|
||||
$number_offset = (!isset($prm['current_page'])?1:$prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$q = [
|
||||
'noreg' => "",
|
||||
'name' => '',
|
||||
'hp' => '',
|
||||
'dob' => '',
|
||||
'address' => '',
|
||||
'nik' =>''
|
||||
];
|
||||
|
||||
$q_pid = "";
|
||||
|
||||
if ($prm['noreg'] != '')
|
||||
$q['noreg'] = "AND M_PatientNoReg like '%{$prm['noreg']}%'";
|
||||
|
||||
if($prm['snorm'] == ''){
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$e = explode('+', $prm['search']);
|
||||
if (isset($e[0])){
|
||||
$e[0] = str_replace("'", "\\'", $e[0]);
|
||||
$q['name'] = "AND M_PatientName LIKE '%{$e[0]}%'";
|
||||
}
|
||||
if (isset($e[1]))
|
||||
$q['hp'] = "AND ((M_PatientHP LIKE '%{$e[1]}%' and M_PatientHP IS NOT NULL) OR (M_PatientHP IS NULL AND '{$e[1]}' = ''))";
|
||||
if (isset($e[2]))
|
||||
$q['dob'] = "AND ((DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') LIKE '%{$e[2]}%' and M_PatientDOB IS NOT NULL) OR (M_PatientDOB IS NULL AND '{$e[2]}' = ''))";
|
||||
if (isset($e[3]))
|
||||
$q['address'] = "AND M_PatientAddressDescription LIKE '%{$e[3]}%'";
|
||||
if (isset($e[4]))
|
||||
$q['nik'] = "AND M_PatientIDNumber = '{$e[4]}'";
|
||||
}
|
||||
}else{
|
||||
$q_pid = "AND M_PatientNoReg = '{$prm['snorm']}'";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT 'N' divider,M_PatientID,
|
||||
M_PatientNoReg,
|
||||
M_PatientPrefix,
|
||||
M_PatientName,
|
||||
M_PatientSuffix,
|
||||
M_PatientHP,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientPhone,
|
||||
M_PatientIDNumber,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
||||
M_PatientNote,
|
||||
M_PatientNIK,
|
||||
M_PatientJabatan,
|
||||
M_PatientKedudukan,
|
||||
M_PatientPJ,
|
||||
M_PatientLocation,
|
||||
M_PatientJob,
|
||||
M_PatientM_SexID,
|
||||
M_SexName,
|
||||
M_PatientM_TitleID,
|
||||
M_TitleName,
|
||||
M_PatientM_ReligionID,
|
||||
M_PatientM_IdTypeID,
|
||||
M_IdTypeName,
|
||||
M_PatientIDNumber,
|
||||
M_PatientPhoto,
|
||||
M_PatientAddressM_KelurahanID M_KelurahanID,
|
||||
0 M_DistrictID, 0 M_CityID, 0 M_ProvinceID
|
||||
FROM m_patient
|
||||
JOIN one_klinik.`order` ON orderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN m_branch ON M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'
|
||||
JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressIsActive = 'Y'
|
||||
LEFT JOIN m_idtype ON M_IdTypeID = M_PatientM_IdTypeID AND M_IdTypeIsActive = 'Y'
|
||||
WHERE
|
||||
M_PatientIsActive = 'Y'
|
||||
{$q['address']}
|
||||
{$q['noreg']}
|
||||
{$q['name']}
|
||||
{$q['hp']}
|
||||
{$q['dob']}
|
||||
{$q['nik']}
|
||||
{$q_pid}
|
||||
|
||||
GROUP BY M_PatientID
|
||||
LIMIT $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['M_PatientName'] = stripslashes($rows[$k]['M_PatientName']);
|
||||
$rows[$k]['M_PatientAddressDescription'] = stripslashes($v['M_PatientAddressDescription']);
|
||||
$patient_name = str_replace("'", "\\'", $prm['M_PatientName']);
|
||||
$sql = "SELECT *, concat('{$rows[$k]['M_PatientAddressDescription'] }', '\n\n',
|
||||
m_kelurahanname, ', ',
|
||||
m_districtname,'\n',
|
||||
m_cityname, ', ',
|
||||
m_provincename) as xaddress
|
||||
FROM m_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
JOIN m_province ON M_CityM_ProvinceID = M_ProvinceID
|
||||
WHERE
|
||||
M_KelurahanID = {$v['M_KelurahanID']} ";
|
||||
//echo $sql;
|
||||
$row_address = $this->db_onedev->query($sql)->row_array();
|
||||
$rows[$k]['M_PatientAddress'] = stripslashes($row_address['xaddress']);
|
||||
$rows[$k]['M_DistrictID'] = $row_address['M_DistrictID'];
|
||||
$rows[$k]['M_CityID'] = $row_address['M_CityID'];
|
||||
$rows[$k]['M_ProvinceID'] = $row_address['M_ProvinceID'];
|
||||
$info = $this->db_onedev->query("SELECT fn_fo_patient_visit(?) info", [$v['M_PatientID']])->row();
|
||||
$rows[$k]['info'] = json_decode($info->info);
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function get_resume_medics()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT one_klinik.`order`.*, date_format(orderDate,'%d-%m-%Y %H:%i') as order_date
|
||||
FROM one_klinik.`order`
|
||||
WHERE
|
||||
orderIsActive = 'Y' AND orderM_PatientID = ?
|
||||
ORDER BY orderDate DESC";
|
||||
//echo $sql;
|
||||
$query = $this->db_oneklinik->query($sql,array($prm['id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_oneklinik->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("resume medic rows",$this->db_oneklinik);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
425
application/controllers/klinik/screening/Screening.php
Normal file
425
application/controllers/klinik/screening/Screening.php
Normal file
@@ -0,0 +1,425 @@
|
||||
<?php
|
||||
class Screening 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);
|
||||
$this->db_oneklinik = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$sql = "SELECT orderID,
|
||||
orderDate,
|
||||
orderNumber,
|
||||
orderIsScreening,
|
||||
orderIsAnamnese,
|
||||
orderIsCheck,
|
||||
orderAge as patient_age,
|
||||
DATE_FORMAT(orderDate,'%d-%m-%Y') as order_date,
|
||||
'N' divider,
|
||||
M_PatientID,
|
||||
M_PatientNoReg,
|
||||
M_PatientPrefix,
|
||||
M_PatientName,
|
||||
M_PatientSuffix,
|
||||
M_PatientHP,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientPhone,
|
||||
M_PatientIDNumber,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
||||
M_PatientNote,
|
||||
M_PatientNIK,
|
||||
M_PatientJabatan,
|
||||
M_PatientKedudukan,
|
||||
M_PatientPJ,
|
||||
M_PatientLocation,
|
||||
M_PatientJob,
|
||||
M_PatientM_SexID,
|
||||
M_SexName,
|
||||
M_PatientM_TitleID,
|
||||
M_TitleName,
|
||||
M_PatientM_ReligionID,
|
||||
M_ReligionName,
|
||||
M_PatientM_IdTypeID,
|
||||
M_IdTypeName,
|
||||
M_PatientIDNumber,
|
||||
IF(ISNULL(M_PatientSuspendID),'active','suspend' ) as status,
|
||||
M_PatientAddressM_KelurahanID M_KelurahanID,
|
||||
0 M_DistrictID,
|
||||
0 M_CityID,
|
||||
0 M_ProvinceID
|
||||
FROM one_klinik.order
|
||||
JOIN m_patient ON M_PatientID = orderM_PatientID AND M_PatientIsActive = 'Y'
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN m_branch ON M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'
|
||||
JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressIsActive = 'Y'
|
||||
LEFT JOIN m_idtype ON M_IdTypeID = M_PatientM_IdTypeID AND M_IdTypeIsActive = 'Y'
|
||||
LEFT JOIN m_religion ON m_patientm_religionid = m_religionid
|
||||
LEFT JOIN m_patientsuspend ON M_PatientSuspendM_PatientID = M_PatientID AND M_PatientSuspendIsActive = 'Y'
|
||||
WHERE
|
||||
orderNumber = '{$id}' AND
|
||||
M_PatientSuspendID IS NULL
|
||||
|
||||
GROUP BY M_PatientID";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['M_PatientName'] = stripslashes($rows[$k]['M_PatientName']);
|
||||
$rows[$k]['M_PatientAddressDescription'] = stripslashes($v['M_PatientAddressDescription']);
|
||||
$patient_name = str_replace("'", "\\'", $prm['M_PatientName']);
|
||||
$sql = "SELECT *, concat('{$rows[$k]['M_PatientAddressDescription'] }', '\n\n',
|
||||
m_kelurahanname, ', ',
|
||||
m_districtname,'\n',
|
||||
m_cityname, ', ',
|
||||
m_provincename) as xaddress
|
||||
FROM m_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
JOIN m_province ON M_CityM_ProvinceID = M_ProvinceID
|
||||
WHERE
|
||||
M_KelurahanID = {$v['M_KelurahanID']} ";
|
||||
//echo $sql;
|
||||
$row_address = $this->db_onedev->query($sql)->row_array();
|
||||
$rows[$k]['M_PatientAddress'] = stripslashes($row_address['xaddress']);
|
||||
$rows[$k]['M_DistrictID'] = $row_address['M_DistrictID'];
|
||||
$rows[$k]['M_CityID'] = $row_address['M_CityID'];
|
||||
$rows[$k]['M_ProvinceID'] = $row_address['M_ProvinceID'];
|
||||
$info = $this->db_onedev->query("SELECT fn_fo_patient_visit(?) info", [$v['M_PatientID']])->row();
|
||||
$rows[$k]['info'] = json_decode($info->info);
|
||||
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function get_data(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$result = array('data' => '');
|
||||
|
||||
$sql = "SELECT orderScreeningKesanUmum as kesan_umum,
|
||||
orderScreeningValueKesadaran as kesadaran,
|
||||
orderScreeningValuePernafasan as pernafasan,
|
||||
orderScreeningValueResikoJatuh as resiko_jatuh,
|
||||
orderScreeningValueNyeriDada as nyeri_dada,
|
||||
orderScreeningValueSkalaNyeri as skala_nyeri,
|
||||
orderScreeningValueBatuk as batuk,
|
||||
orderScreeningValueKeputusan as keputusan
|
||||
FROM one_klinik.order_screening
|
||||
WHERE
|
||||
orderScreeningOrderID = ? AND orderScreeningIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$query = $this->db_oneklinik->query($sql,array($prm['orderid']));
|
||||
if(!$query){
|
||||
$this->sys_error("Gagal get data");
|
||||
echo $this->db_oneklinik->last_query();
|
||||
}
|
||||
$result = $query->row_array();
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
protected function objToArray($obj)
|
||||
{
|
||||
// Not an object or array
|
||||
if (!is_object($obj) && !is_array($obj)) {
|
||||
return $obj;
|
||||
}
|
||||
|
||||
// Parse array
|
||||
foreach ($obj as $key => $value) {
|
||||
$arr[$key] = $this->objToArray($value);
|
||||
}
|
||||
|
||||
// Return parsed array
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
public function list_patient()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 20;
|
||||
$tot_count = 0;
|
||||
$number_limit = 20;
|
||||
$number_offset = (!isset($prm['current_page'])?1:$prm['current_page'] - 1) * $number_limit ;
|
||||
$xdate = $prm['date'];
|
||||
$status = $prm['status'];
|
||||
|
||||
$sql = "SELECT 'N' divider,
|
||||
CONCAT(M_TitleName,' ',IF(ISNULL(M_PatientPrefix),'',CONCAT(M_PatientPrefix,' ')),M_PatientName,IF(ISNULL(M_PatientPrefix),'',CONCAT(ISNULL(M_PatientSuffix),' '))) as patient_name,
|
||||
`order`.*,DATE_FORMAT(orderDate,'%d-%m-%Y') as date_order,
|
||||
'' as kode_status, '' as status
|
||||
FROM one_klinik.`order`
|
||||
JOIN m_patient ON orderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE
|
||||
orderIsActive = 'Y' AND DATE(orderDate) = ? AND orderIsScreening = ?
|
||||
LIMIT $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_oneklinik->query($sql,array($xdate,$status));
|
||||
//echo $this->db_oneklinik->last_query();
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function process_now(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
//print_r($prm['subgroup']);
|
||||
|
||||
$sql = "INSERT INTO one_klinik.order_status (
|
||||
orderStatusOrderID,
|
||||
orderStatusCode,
|
||||
orderStatusValue,
|
||||
orderStatusUserID
|
||||
)
|
||||
VALUES(
|
||||
?,?,?,?
|
||||
)";
|
||||
|
||||
$query = $this->db_oneklinik->query($sql,array($prm['orderID'],'S','Y',$userID));
|
||||
if(!$query){
|
||||
$this->sys_error("Gagal Process");
|
||||
}
|
||||
|
||||
$sql = "UPDATE one_klinik.`order` SET orderIsScreening = 'Y', orderUserID = ?
|
||||
WHERE
|
||||
orderID = ?";
|
||||
|
||||
$query = $this->db_oneklinik->query($sql,array($userID,$prm['orderID']));
|
||||
if(!$query){
|
||||
$this->sys_error("Gagal Update");
|
||||
}
|
||||
|
||||
|
||||
$result = array('process'=>'OK');
|
||||
|
||||
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function cancel_now(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
//print_r($prm['subgroup']);
|
||||
|
||||
$sql = "INSERT INTO one_klinik.order_status (
|
||||
orderStatusOrderID,
|
||||
orderStatusCode,
|
||||
orderStatusValue,
|
||||
orderStatusUserID
|
||||
)
|
||||
VALUES(
|
||||
?,?,?,?
|
||||
)";
|
||||
|
||||
$query = $this->db_oneklinik->query($sql,array($prm['orderID'],'S','N',$userID));
|
||||
if(!$query){
|
||||
$this->sys_error("Gagal Process");
|
||||
}
|
||||
|
||||
$sql = "UPDATE one_klinik.`order` SET orderIsScreening = 'N', orderUserID = ?
|
||||
WHERE
|
||||
orderID = ?";
|
||||
|
||||
$query = $this->db_oneklinik->query($sql,array($userID,$prm['orderID']));
|
||||
if(!$query){
|
||||
$this->sys_error("Gagal Process");
|
||||
}
|
||||
|
||||
|
||||
$result = array('process'=>'OK');
|
||||
|
||||
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function end_session(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
//print_r($prm['subgroup']);
|
||||
|
||||
$sql = "SELECT COUNT(*) as xcount
|
||||
FROM one_klinik.order_screening
|
||||
WHERE
|
||||
orderScreeningOrderID = ? AND orderScreeningIsActive = 'Y'";
|
||||
$query = $this->db_oneklinik->query($sql,array($prm['orderID']));
|
||||
if(!$query){
|
||||
|
||||
$this->sys_error("count exist");
|
||||
echo $this->db_oneklinik->last_query();
|
||||
}
|
||||
|
||||
$check_exist = $query->row()->xcount;
|
||||
|
||||
if($check_exist == 0){
|
||||
$sql = "INSERT one_klinik.order_screening (
|
||||
orderScreeningOrderID,
|
||||
orderScreeningKesanUmum,
|
||||
orderScreeningValueKesadaran,
|
||||
orderScreeningValuePernafasan,
|
||||
orderScreeningValueResikoJatuh,
|
||||
orderScreeningValueNyeriDada,
|
||||
orderScreeningValueSkalaNyeri,
|
||||
orderScreeningValueBatuk,
|
||||
orderScreeningValueKeputusan,
|
||||
orderScreeningCreated,
|
||||
orderScreeningUserID
|
||||
)
|
||||
VALUES(
|
||||
?,?,?,?,?,?,?,?,?,NOW(),?
|
||||
)";
|
||||
$query = $this->db_oneklinik->query($sql,array(
|
||||
$prm['orderID'],
|
||||
$prm['kesan_umum'],
|
||||
$prm['kesadaran'],
|
||||
$prm['pernafasan'],
|
||||
$prm['resiko_jatuh'],
|
||||
$prm['nyeri_dada'],
|
||||
$prm['skala_nyeri'],
|
||||
$prm['batuk'],
|
||||
$prm['keputusan'],
|
||||
$userID)
|
||||
);
|
||||
if(!$query){
|
||||
$this->sys_error("Gagal insert");
|
||||
}
|
||||
}else{
|
||||
$sql = "UPDATE one_klinik.order_screening SET
|
||||
orderScreeningKesanUmum = ?,
|
||||
orderScreeningValueKesadaran = ?,
|
||||
orderScreeningValuePernafasan = ?,
|
||||
orderScreeningValueResikoJatuh = ?,
|
||||
orderScreeningValueNyeriDada = ?,
|
||||
orderScreeningValueSkalaNyeri = ?,
|
||||
orderScreeningValueBatuk = ?,
|
||||
orderScreeningValueKeputusan = ?,
|
||||
orderScreeningUserID = ?
|
||||
WHERE
|
||||
orderScreeningOrderID = ?
|
||||
";
|
||||
$query = $this->db_oneklinik->query($sql,[
|
||||
$prm['kesan_umum'],
|
||||
$prm['kesadaran'],
|
||||
$prm['pernafasan'],
|
||||
$prm['resiko_jatuh'],
|
||||
$prm['nyeri_dada'],
|
||||
$prm['skala_nyeri'],
|
||||
$prm['batuk'],
|
||||
$prm['keputusan'],
|
||||
$userID,
|
||||
$prm['orderID']
|
||||
]);
|
||||
if(!$query){
|
||||
echo $this->db_oneklinik->last_query();
|
||||
$this->sys_error("Gagal Update");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sql = "INSERT INTO one_klinik.order_status (
|
||||
orderStatusOrderID,
|
||||
orderStatusCode,
|
||||
orderStatusValue,
|
||||
orderStatusUserID
|
||||
)
|
||||
VALUES(
|
||||
?,?,?,?
|
||||
)";
|
||||
|
||||
$query = $this->db_oneklinik->query($sql,array($prm['orderID'],'S','D',$userID));
|
||||
if(!$query){
|
||||
$this->sys_error("Gagal End");
|
||||
}
|
||||
|
||||
$sql = "UPDATE one_klinik.`order` SET orderIsScreening = 'D', orderUserID = ?
|
||||
WHERE
|
||||
orderID = ?";
|
||||
|
||||
$query = $this->db_oneklinik->query($sql,array($userID,$prm['orderID']));
|
||||
if(!$query){
|
||||
$this->sys_error("Gagal ENd");
|
||||
}
|
||||
|
||||
|
||||
$result = array('process'=>'OK');
|
||||
|
||||
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user