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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user