Initial import
This commit is contained in:
451
one-api/application/controllers/v1/fo/Register.php
Normal file
451
one-api/application/controllers/v1/fo/Register.php
Normal file
@@ -0,0 +1,451 @@
|
||||
<?php
|
||||
/*
|
||||
### Register API
|
||||
- Functions
|
||||
- login x
|
||||
- logout
|
||||
- search_patient x
|
||||
- search_doctor x
|
||||
- search_px x
|
||||
- last_px x
|
||||
- search_patient_type x
|
||||
- search_delivery_type x
|
||||
- do_register
|
||||
- get_barcode
|
||||
- update_barcode
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Register extends MY_Controller {
|
||||
function index() {
|
||||
echo "isLogin : {$this->isLogin} \n";
|
||||
print_r($this->sys_input);
|
||||
print_r($this->sys_user);
|
||||
}
|
||||
|
||||
function new_patient(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//# ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//#ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//# generate no reg pasien
|
||||
$rstNoreg = $this->db->query('select `fn_get_numbering`(\'P\') as nomor')->row();
|
||||
$prm['M_PatientNoReg'] = $rstNoreg->nomor;
|
||||
|
||||
//# insert data pasien
|
||||
$sql = "insert into m_patient(
|
||||
M_PatientNoReg,
|
||||
M_PatientM_TitleID,
|
||||
M_PatientName,
|
||||
M_PatientM_SexID,
|
||||
M_PatientDOB,
|
||||
M_PatientNationality,
|
||||
M_PatientUserID,
|
||||
M_PatientLastUpdate)
|
||||
values( ?, ?, ?, ?, ?, ?,?, now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm["M_PatientNoReg"],
|
||||
$prm["M_PatientM_TitleID"],
|
||||
$prm["M_PatientName"],
|
||||
$prm["M_PatientM_SexID"],
|
||||
$prm["M_PatientDOB"],
|
||||
$prm["M_PatientNationality"],
|
||||
$tokenM_UserID
|
||||
)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_patient insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function new_patient_address(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//# ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//# insert data alamat pasien
|
||||
$sql = "insert into m_patientaddress(
|
||||
M_PatientAddressM_PatientID,
|
||||
M_PatientAddressType,
|
||||
M_PatientAddressName,
|
||||
M_PatientAddressNote,
|
||||
M_PatientAddressPostCode,
|
||||
M_PatientAddressUserID,
|
||||
M_PatientAddressLastUpdate)
|
||||
values( ?, ?, ?, ?, ?, ?, now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm["M_PatientAddressM_PatientID"],
|
||||
$prm["M_PatientAddressType"],
|
||||
$prm["M_PatientAddressName"],
|
||||
$prm["M_PatientAddressNote"],
|
||||
$prm["M_PatientAddressPostCode"],
|
||||
$tokenM_UserID
|
||||
)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_patientaddress insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_patient() {
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//# jumlah baris per page default 10 jika tidak di set
|
||||
$row_per_page = 10;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
array_push($sql_param,$s_query);
|
||||
|
||||
//# hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_patient
|
||||
where ( M_PatientNoReg like ? OR M_PatientName like ? ) and M_PatientIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patient count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_patient
|
||||
where ( M_PatientNoReg like ? OR M_PatientName like ? ) and M_PatientIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_patient rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function new_doctor_sender(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//# ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//#ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//# insert data dokter pengirim
|
||||
$sql = "insert into m_doctor(
|
||||
M_DoctorCode,
|
||||
M_DoctorName,
|
||||
M_DoctorSpecialization,
|
||||
M_DoctorHP,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorUserID,
|
||||
M_DoctorLastUpdate)
|
||||
values( ?, ?, ?, ?, ?, ?, now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm["M_DoctorCode"],
|
||||
$prm["M_DoctorName"],
|
||||
$prm["M_DoctorSpecialization"],
|
||||
$prm["M_DoctorHP"],
|
||||
$prm["M_DoctorM_SexID"],
|
||||
$tokenM_UserID
|
||||
)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function new_doctor_sender_address(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//# ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//# insert data alamat pasien
|
||||
$sql = "insert into m_doctoraddress(
|
||||
M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressType,
|
||||
M_DoctorAddressName,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressPostCode,
|
||||
M_DoctorAddressUserID,
|
||||
M_DoctorAddressLastUpdate)
|
||||
values( ?, ?, ?, ?, ?, ?, now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm["M_DoctorAddressM_DoctorID"],
|
||||
$prm["M_DoctorAddressType"],
|
||||
$prm["M_DoctorAddressName"],
|
||||
$prm["M_DoctorAddressNote"],
|
||||
$prm["M_DoctorAddressPostCode"],
|
||||
$tokenM_UserID
|
||||
)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_doctor_sender() {
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//# jumlah baris per page default 10 jika tidak di set
|
||||
$row_per_page = 10;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
array_push($sql_param,$s_query);
|
||||
|
||||
//# hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_doctor
|
||||
where ( M_DoctorCode like ? OR M_DoctorName like ? ) and M_DoctorIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_doctor
|
||||
where ( M_DoctorCode like ? OR M_DoctorName like ? ) and M_DoctorIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_doctor_pj() {
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//# jumlah baris per page default 10 jika tidak di set
|
||||
$row_per_page = 10;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
array_push($sql_param,$s_query);
|
||||
|
||||
//# hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_doctor
|
||||
where ( M_DoctorCode like ? OR M_DoctorName like ? ) and M_DoctorIsPJ = 'Y' and M_DoctorIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_doctor
|
||||
where ( M_DoctorCode like ? OR M_DoctorName like ? ) and M_DoctorIsPJ = 'Y' and M_DoctorIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
432
one-api/application/controllers/v1/fo/Register_old.php
Normal file
432
one-api/application/controllers/v1/fo/Register_old.php
Normal file
@@ -0,0 +1,432 @@
|
||||
<?php
|
||||
/*
|
||||
### Register API
|
||||
- Functions
|
||||
- login x
|
||||
- logout
|
||||
- search_patient x
|
||||
- search_doctor x
|
||||
- search_px x
|
||||
- last_px x
|
||||
- search_patient_type x
|
||||
- search_delivery_type x
|
||||
- do_register
|
||||
- get_barcode
|
||||
- update_barcode
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Register extends MY_Controller {
|
||||
function index() {
|
||||
echo "isLogin : {$this->isLogin} \n";
|
||||
print_r($this->sys_input);
|
||||
print_r($this->sys_user);
|
||||
}
|
||||
function last_test() {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$patientID = $prm["M_PatientID"];
|
||||
$orderHeaderID = 0;
|
||||
$sql = "select T_OrderHeaderID
|
||||
from
|
||||
t_orderheader
|
||||
where
|
||||
T_OrderHeaderM_PatientID = ? and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0,1";
|
||||
$query = $this->db->query($sql,array($patientID));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) > 0 ) $orderHeaderID = $rows[0]["T_OrderHeaderID"];
|
||||
} else {
|
||||
$this->sys_error_db("find last order");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($orderHeaderID > 0 ) {
|
||||
$sql = "select T_TestID,T_TestName
|
||||
from
|
||||
t_orderdetail
|
||||
join t_test on T_OrderDetailT_OrderHeaderID =? and
|
||||
T_TestIsActive ='Y' and T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestIsPrice = 'Y' and T_OrderDetailIsActive='Y'";
|
||||
$query = $this->db->query($sql,array($orderHeaderID));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("find last test");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function search_delivery_type() {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
$max = 25;
|
||||
if (isset($prm["max_row"]) && $prm["max_row"] < $max ) $max = $prm["max_row"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
$sql = "select count(*) as tot
|
||||
from m_deliveryservice
|
||||
where M_DeliveryServiceName like ? and M_DeliveryServiceIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("delivery type count");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
$sql = "select *
|
||||
from m_deliveryservice
|
||||
where M_DeliveryServiceName like ? and M_DeliveryServiceIsActive='Y'
|
||||
limit 0,$max";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("delivery type count");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function search_patient_type() {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
$max = 25;
|
||||
if (isset($prm["max_row"]) && $prm["max_row"] < $max ) $max = $prm["max_row"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
$sql = "select count(*) as tot
|
||||
from m_patienttype
|
||||
where M_PatientTypeName like ? and M_PatientTypeIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("test/panel count");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
$sql = "select *
|
||||
from m_patienttype
|
||||
where M_PatientTypeName like ? and M_PatientTypeIsActive='Y'
|
||||
limit 0,$max";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("test/panel count");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function search_test() {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
$max = 25;
|
||||
if (isset($prm["max_row"]) && $prm["max_row"] < $max ) $max = $prm["max_row"];
|
||||
//name
|
||||
$sql = "select count(*) as tot
|
||||
from
|
||||
(
|
||||
select T_TestID
|
||||
from
|
||||
t_test
|
||||
where T_TestName like ? and T_TestIsActive = 'Y'
|
||||
union
|
||||
select T_TestPanelID
|
||||
from
|
||||
t_testpanel
|
||||
where
|
||||
T_TestPanelName like ? and T_TestPanelIsActive = 'Y'
|
||||
) x
|
||||
";
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query, $s_query);
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("test/panel count");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
$sql = "select *
|
||||
from
|
||||
(
|
||||
select T_TestID X_ID, T_TestName X_Name, 'N' IsPanel , concat('\'',T_TestID,'\'') as A_Test
|
||||
from
|
||||
t_test
|
||||
where T_TestName like ? and T_TestIsActive = 'Y'
|
||||
union
|
||||
select T_TestPanelID X_ID, T_TestPanelName X_Name, 'Y' IsPanel,
|
||||
group_concat(T_TestPanelDetailT_TestID) as A_Test
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelDetailIsActive = 'Y'
|
||||
where
|
||||
T_TestPanelName like ? and T_TestPanelIsActive = 'Y'
|
||||
group by T_TestPanelID
|
||||
) x
|
||||
limit 0, $max
|
||||
";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $idx => $r) {
|
||||
$a_test = explode(",",$r["A_Test"]);
|
||||
$rows[$idx]["A_Test"] = $a_test;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("test/panel data");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_doctor() {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
//name+address+phone
|
||||
$a_param = explode("+",$prm["query"]);
|
||||
$sql_where = " M_DoctorIsActive='Y' ";
|
||||
$sql_param = array();
|
||||
foreach($a_param as $idx => $inp) {
|
||||
if (trim($inp) == "") continue;
|
||||
if ($sql_where != "") $sql_where .= " and ";
|
||||
switch($idx) {
|
||||
case 0 :
|
||||
$sql_where .= " M_DoctorName like ? ";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
case 1 :
|
||||
$sql_where .= " ( M_DoctorHomeAddress like ? or M_DoctorPracticeAddress like ? ) ";
|
||||
$sql_param[] = "%$inp%";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
case 2 :
|
||||
$sql_where .= " M_DoctorPhone like ? ";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($sql_where != "" ) $sql_where = " where $sql_where";
|
||||
$max = 25;
|
||||
if (isset($prm["max_row"]) && $prm["max_row"] < $max ) $max = $prm["max_row"];
|
||||
|
||||
$sql = "select count(*) as tot from m_doctor $sql_where";
|
||||
$tot_count = 0;
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("search_doctor count");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
$sql = "select * from m_doctor $sql_where limit 0,$max";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("search_doctor data");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function search_patient() {
|
||||
// $this->sys_debug();
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//name+address+phone+dob(ddmmyy)
|
||||
|
||||
$a_param = explode("+",$prm["query"]);
|
||||
$sql_where = " M_PatientIsActive='Y' ";
|
||||
$sql_param = array();
|
||||
foreach($a_param as $idx => $inp) {
|
||||
if (trim($inp) == "") continue;
|
||||
if ($sql_where != "") $sql_where .= " and ";
|
||||
switch($idx) {
|
||||
case 0 :
|
||||
$sql_where .= " M_PatientName like ? ";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
case 1 :
|
||||
$sql_where .= " M_PatientAddress like ? ";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
case 2 :
|
||||
$sql_where .= " M_PatientPhone like ? ";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
case 3 :
|
||||
$sql_where .= " M_PatientDOB like ? ";
|
||||
//ddmmyy
|
||||
if (strlen($inp) == 6) {
|
||||
$year = substr($inp,4,2);
|
||||
if ($year > 20) {
|
||||
$year = "19$year";
|
||||
} else {
|
||||
$year = "20$year";
|
||||
}
|
||||
$dob = "$year-" . substr($inp,2,2) . "-" . substr($inp,0,2);
|
||||
}
|
||||
$sql_param[] = $dob;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($sql_where != "" ) $sql_where = " where $sql_where";
|
||||
$max = 25;
|
||||
if (isset($prm["max_row"]) && $prm["max_row"] < $max ) $max = $prm["max_row"];
|
||||
|
||||
$sql = "select count(*) as tot from m_patient $sql_where";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("search patient count");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($tot_count > 0 ) {
|
||||
$sql = "select * from m_patient $sql_where limit 0,$max";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("search patient data");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array("total" => $tot_count , "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function login() {
|
||||
$prm = $this->sys_input;
|
||||
try {
|
||||
//existing password enc
|
||||
$sm_password = md5($this->smartlab_salt . $prm["userPassword"] .
|
||||
$this->smartlab_salt);
|
||||
$query = $this->db->query("select M_UserID,M_UserUserName
|
||||
from m_user
|
||||
where M_UserUserName=? and M_UserPassword=?
|
||||
and M_UserIsActive = 'Y'
|
||||
",array($prm["userName"], $sm_password));
|
||||
if (!$query) {
|
||||
$message = $this->db->error();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$user = $rows[0];
|
||||
$token = JWT::encode($user,$this->SECRET_KEY);
|
||||
$data = array(
|
||||
"user" => $user,
|
||||
"token" => $token
|
||||
);
|
||||
$this->sys_ok($data);
|
||||
exit;
|
||||
}
|
||||
$this->sys_error_db("Invalid UserName / Password");
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function logout() {
|
||||
$this->sys_error("ok");
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user