Initial import
This commit is contained in:
356
one-api/application/controllers/v1/one-doctor/Doctortest.php
Normal file
356
one-api/application/controllers/v1/one-doctor/Doctortest.php
Normal file
@@ -0,0 +1,356 @@
|
||||
<?php
|
||||
|
||||
class Doctortest extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "API DOCTOR TEST";
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT COUNT(*) as total
|
||||
FROM one_doctor.m_user a
|
||||
JOIN m_doctor b ON a.M_UserM_DoctorID = b.M_DoctorID
|
||||
AND M_UserIsActive = 'Y'
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
JOIN m_mou c ON a.M_UserM_MouID = c.M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
JOIN m_company d ON c.M_MouM_CompanyID = d.M_CompanyID
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
WHERE fn_get_doctor_fullname(M_UserM_DoctorID) like ?
|
||||
OR M_MouNumber like ? OR M_CompanyName like ?";
|
||||
|
||||
$qry_filter = $this->db->query($sql_filter, [$search, $search, $search]);
|
||||
// $last_query = $this->db->last_query();
|
||||
// echo ($last_query);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT M_UserID as user_id,
|
||||
M_DoctorID as doctor_id,
|
||||
fn_get_doctor_fullname(M_UserM_DoctorID) as doctorName,
|
||||
M_UserM_MouID,
|
||||
M_UserUsername,
|
||||
M_MouName,
|
||||
M_MouNumber,
|
||||
M_CompanyID,
|
||||
M_CompanyName
|
||||
FROM one_doctor.m_user a
|
||||
JOIN m_doctor b ON a.M_UserM_DoctorID = b.M_DoctorID
|
||||
AND M_UserIsActive = 'Y'
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
JOIN m_mou c ON a.M_UserM_MouID = c.M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
JOIN m_company d ON c.M_MouM_CompanyID = d.M_CompanyID
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
WHERE fn_get_doctor_fullname(M_UserM_DoctorID) like ?
|
||||
OR M_MouName like ? OR M_CompanyName like ?
|
||||
limit ? offset ?";
|
||||
|
||||
$qry = $this->db->query($sql, array($search, $search, $search, $number_limit, $number_offset));
|
||||
// $last_query = $this->db->last_query();
|
||||
// echo ($last_query);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookuptestold()
|
||||
{
|
||||
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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$doctor_id = 0;
|
||||
if (isset($prm['doctor_id'])) {
|
||||
$doctor_id = trim($prm["doctor_id"]);
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT COUNT(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN one_doctor.doctor_test ON T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y'
|
||||
AND (T_TestSasCode LIKE ?
|
||||
OR T_TestName LIKE ?)";
|
||||
|
||||
$qry_filter = $this->db->query($sql_filter, [$doctor_id, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test count error", $this->db);
|
||||
}
|
||||
|
||||
$sql = "SELECT T_TestID as testid,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
FROM t_test
|
||||
LEFT JOIN one_doctor.doctor_test ON T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y'
|
||||
AND (T_TestSasCode LIKE ?
|
||||
OR T_TestName LIKE ?)
|
||||
LIMIT ? OFFSET ?";
|
||||
|
||||
$qry = $this->db->query($sql, [$doctor_id, $search, $search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookuptest()
|
||||
{
|
||||
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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$doctor_id = 0;
|
||||
if (isset($prm['doctor_id'])) {
|
||||
$doctor_id = trim($prm["doctor_id"]);
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT COUNT(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN one_doctor.doctor_test ON T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y'
|
||||
AND (T_TestSasCode LIKE ?
|
||||
OR T_TestName LIKE ?)";
|
||||
|
||||
$qry_filter = $this->db->query($sql_filter, [$doctor_id, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test count error", $this->db);
|
||||
}
|
||||
|
||||
$sql_user = "SELECT * FROM one_doctor.m_user WHERE M_UserM_DoctorID = ?";
|
||||
|
||||
$qry_user = $this->db->query($sql_user, [$doctor_id]);
|
||||
if ($qry_user) {
|
||||
$rows_user = $qry_user->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("user select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
$mouid = $rows_user[0]["M_UserM_MouID"];
|
||||
|
||||
$sql = "SELECT a.T_TestID as testid,
|
||||
a.T_TestSasCode,
|
||||
a.T_TestName,
|
||||
IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
FROM t_test as a
|
||||
JOIN ss_price_mou ON ss_price_mou.T_TestID = a.T_TestID
|
||||
AND Ss_PriceMouM_MouID = ?
|
||||
LEFT JOIN one_doctor.doctor_test ON a.T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y'
|
||||
AND (T_TestSasCode LIKE ?
|
||||
OR a.T_TestName LIKE ?)
|
||||
LIMIT ? OFFSET ?";
|
||||
|
||||
$qry = $this->db->query($sql, [$mouid, $doctor_id, $search, $search, $number_limit, $number_offset]);
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveeditstatus()
|
||||
{
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$test_id = $prm["test_id"];
|
||||
$doctor_id = $prm["doctor_id"];
|
||||
$status = $prm["status"];
|
||||
//cari test id dan doctor id
|
||||
$sql = "SELECT DoctorTestID, DoctorTestM_DoctorID, DoctorTestT_TestID
|
||||
FROM one_doctor.doctor_test
|
||||
WHERE DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestT_TestID = ?";
|
||||
$qry = $this->db->query($sql, array($doctor_id, $test_id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("doctor test error", $this->db);
|
||||
exit;
|
||||
}
|
||||
if (count($rows) > 0) {
|
||||
// sudah ada
|
||||
$doctortestid = $rows[0]["DoctorTestID"];
|
||||
$sql_update = "UPDATE one_doctor.doctor_test SET
|
||||
DoctorTestCreated = NOW(),
|
||||
DoctorTestLastUpdated = NOW(),
|
||||
DoctorTestIsActive = ?
|
||||
WHERE DoctorTestID = ?";
|
||||
$qry_update = $this->db->query($sql_update, array($status, $doctortestid));
|
||||
if (!$qry_update) {
|
||||
$this->sys_error_db("doctor test update", $this->db);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// belum ada
|
||||
$sql_insert = "INSERT INTO one_doctor.doctor_test(
|
||||
DoctorTestM_DoctorID,
|
||||
DoctorTestT_TestID,
|
||||
DoctorTestCreated,
|
||||
DoctorTestLastUpdated,
|
||||
DoctorTestIsActive) VALUES(?,?,NOW(),NOW(),'Y')";
|
||||
$qry_insert = $this->db->query($sql_insert, array($doctor_id, $test_id));
|
||||
if (!$qry_insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor test insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
468
one-api/application/controllers/v1/one-doctor/Doctortestv2.php
Normal file
468
one-api/application/controllers/v1/one-doctor/Doctortestv2.php
Normal file
@@ -0,0 +1,468 @@
|
||||
<?php
|
||||
|
||||
class Doctortestv2 extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "API DOCTOR TEST";
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT COUNT(*) as total
|
||||
FROM one_doctor.m_user a
|
||||
JOIN m_doctor b ON a.M_UserM_DoctorID = b.M_DoctorID
|
||||
AND M_UserIsActive = 'Y'
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
JOIN m_mou c ON a.M_UserM_MouID = c.M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
JOIN m_company d ON c.M_MouM_CompanyID = d.M_CompanyID
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
WHERE fn_get_doctor_fullname(M_UserM_DoctorID) like ?
|
||||
OR M_MouNumber like ? OR M_CompanyName like ?";
|
||||
|
||||
$qry_filter = $this->db->query($sql_filter, [$search, $search, $search]);
|
||||
// $last_query = $this->db->last_query();
|
||||
// echo ($last_query);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT M_UserID as user_id,
|
||||
M_DoctorID as doctor_id,
|
||||
fn_get_doctor_fullname(M_UserM_DoctorID) as doctorName,
|
||||
M_UserM_MouID,
|
||||
M_UserUsername,
|
||||
M_MouName,
|
||||
M_MouNumber,
|
||||
M_CompanyID,
|
||||
M_CompanyName
|
||||
FROM one_doctor.m_user a
|
||||
JOIN m_doctor b ON a.M_UserM_DoctorID = b.M_DoctorID
|
||||
AND M_UserIsActive = 'Y'
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
JOIN m_mou c ON a.M_UserM_MouID = c.M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
JOIN m_company d ON c.M_MouM_CompanyID = d.M_CompanyID
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
WHERE fn_get_doctor_fullname(M_UserM_DoctorID) like ?
|
||||
OR M_MouName like ? OR M_CompanyName like ?
|
||||
limit ? offset ?";
|
||||
|
||||
$qry = $this->db->query($sql, array($search, $search, $search, $number_limit, $number_offset));
|
||||
// $last_query = $this->db->last_query();
|
||||
// echo ($last_query);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookuptestold()
|
||||
{
|
||||
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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$doctor_id = 0;
|
||||
if (isset($prm['doctor_id'])) {
|
||||
$doctor_id = trim($prm["doctor_id"]);
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT COUNT(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN one_doctor.doctor_test ON T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y'
|
||||
AND (T_TestSasCode LIKE ?
|
||||
OR T_TestName LIKE ?)";
|
||||
|
||||
$qry_filter = $this->db->query($sql_filter, [$doctor_id, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test count error", $this->db);
|
||||
}
|
||||
|
||||
$sql = "SELECT T_TestID as testid,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
FROM t_test
|
||||
LEFT JOIN one_doctor.doctor_test ON T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y'
|
||||
AND (T_TestSasCode LIKE ?
|
||||
OR T_TestName LIKE ?)
|
||||
LIMIT ? OFFSET ?";
|
||||
|
||||
$qry = $this->db->query($sql, [$doctor_id, $search, $search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookuptest()
|
||||
{
|
||||
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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$doctor_id = 0;
|
||||
if (isset($prm['doctor_id'])) {
|
||||
$doctor_id = trim($prm["doctor_id"]);
|
||||
}
|
||||
$status = $prm['status'];
|
||||
$filter = '';
|
||||
if($status == 'Y'){
|
||||
$filter .= "AND DoctorTestM_DoctorID IS NOT NULL AND DoctorTestM_DoctorID = $doctor_id";
|
||||
}else{
|
||||
if($status == 'N'){
|
||||
$filter .= "AND DoctorTestM_DoctorID IS NULL ";
|
||||
}else{
|
||||
$filter .= "";
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
// $sql_filter = "SELECT COUNT(*) as total
|
||||
// FROM(SELECT *, IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
// FROM t_test
|
||||
// LEFT JOIN one_doctor.doctor_test ON T_TestID = DoctorTestT_TestID
|
||||
// AND DoctorTestM_DoctorID = ?
|
||||
// AND DoctorTestIsActive = 'Y'
|
||||
// WHERE T_TestIsActive = 'Y') a
|
||||
// WHERE
|
||||
// (T_TestSasCode LIKE ?
|
||||
// OR T_TestName LIKE ?) $filter";
|
||||
|
||||
// $qry_filter = $this->db->query($sql_filter, [$doctor_id, $search, $search]);
|
||||
// $tot_count = 0;
|
||||
// $tot_page = 0;
|
||||
// if ($qry_filter) {
|
||||
// $tot_count = $qry_filter->result_array()[0]["total"];
|
||||
// $tot_page = ceil($tot_count/$number_limit);
|
||||
|
||||
// } else {
|
||||
// $this->sys_error_db("test count error", $this->db);
|
||||
// }
|
||||
|
||||
$sql_user = "SELECT * FROM one_doctor.m_user WHERE M_UserM_DoctorID = ?";
|
||||
|
||||
$qry_user = $this->db->query($sql_user, [$doctor_id]);
|
||||
if ($qry_user) {
|
||||
$rows_user = $qry_user->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("user select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
$mouid = $rows_user[0]["M_UserM_MouID"];
|
||||
|
||||
// $sql = "SELECT * FROM (SELECT a.T_TestID as testid,
|
||||
// a.T_TestSasCode,
|
||||
// a.T_TestName,
|
||||
// IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
// FROM t_test as a
|
||||
// JOIN ss_price_mou ON ss_price_mou.T_TestID = a.T_TestID
|
||||
// AND Ss_PriceMouM_MouID = ?
|
||||
// LEFT JOIN one_doctor.doctor_test ON a.T_TestID = DoctorTestT_TestID
|
||||
// AND DoctorTestM_DoctorID = ?
|
||||
// AND DoctorTestIsActive = 'Y'
|
||||
// AND T_PriceIsCito = 'N'
|
||||
// WHERE T_TestIsActive = 'Y') a
|
||||
// WHERE
|
||||
// (T_TestSasCode LIKE ?
|
||||
// OR a.T_TestName LIKE ?) $filter
|
||||
// LIMIT ? OFFSET ?";
|
||||
|
||||
$sql_dasar = "
|
||||
SELECT a.T_TestID as testid, a.T_TestSasCode, a.T_TestName, IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
FROM t_test as a
|
||||
JOIN ss_price_mou ON ss_price_mou.T_TestID = a.T_TestID AND Ss_PriceMouM_MouID = $mouid
|
||||
AND T_PriceIsCito = 'N'
|
||||
left JOIN one_doctor.doctor_test ON a.T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = $doctor_id
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y' and ( T_TestSasCode LIKE '$search' OR a.T_TestName LIKE '$search' ) $filter
|
||||
AND DoctorTestT_TestID is not null
|
||||
UNION
|
||||
SELECT a.T_TestID as testid, a.T_TestSasCode, a.T_TestName, IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
FROM t_test as a
|
||||
JOIN ss_price_mou ON ss_price_mou.T_TestID = a.T_TestID AND Ss_PriceMouM_MouID = $mouid
|
||||
AND T_PriceIsCito = 'N'
|
||||
left JOIN one_doctor.doctor_test ON a.T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = $doctor_id
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y' and ( T_TestSasCode LIKE '$search' OR a.T_TestName LIKE '$search') $filter
|
||||
AND a.T_TestID NOT IN (
|
||||
select DoctorTestT_TestID
|
||||
from one_doctor.doctor_test
|
||||
where DoctorTestM_DoctorID = $doctor_id
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
)";
|
||||
|
||||
$sql_filter = "SELECT COUNT(*) as total from ($sql_dasar) as x";
|
||||
|
||||
$qry_filter = $this->db->query($sql_filter);
|
||||
// echo $this->db->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("test count error", $this->db);
|
||||
}
|
||||
|
||||
// echo $tot_count;
|
||||
|
||||
|
||||
$sql = $sql_dasar." ORDER BY T_TestSasCode LIMIT $number_limit OFFSET $number_offset";
|
||||
|
||||
// $qry = $this->db->query($sql, [
|
||||
// $mouid,
|
||||
// $doctor_id,
|
||||
// $search,
|
||||
// $search,
|
||||
// $mouid,
|
||||
// $doctor_id,
|
||||
// $search,
|
||||
// $search,
|
||||
// $number_limit, $number_offset]);
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
// $tot_page = ceil(count($rows)/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getstatus()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
|
||||
$query ="
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
$qry = $this->db->query($query);
|
||||
if ($qry) {
|
||||
$rows['f_statuss'] = $qry->result_array();
|
||||
}else{
|
||||
$this->sys_error_db("select status error", $this->db);
|
||||
exit;
|
||||
}
|
||||
// print_r($rows);
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveeditstatus()
|
||||
{
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$test_id = $prm["test_id"];
|
||||
$doctor_id = $prm["doctor_id"];
|
||||
$status = $prm["status"];
|
||||
//cari test id dan doctor id
|
||||
$sql = "SELECT DoctorTestID, DoctorTestM_DoctorID, DoctorTestT_TestID
|
||||
FROM one_doctor.doctor_test
|
||||
WHERE DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestT_TestID = ?";
|
||||
$qry = $this->db->query($sql, array($doctor_id, $test_id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("doctor test error", $this->db);
|
||||
exit;
|
||||
}
|
||||
if (count($rows) > 0) {
|
||||
// sudah ada
|
||||
$doctortestid = $rows[0]["DoctorTestID"];
|
||||
$sql_update = "UPDATE one_doctor.doctor_test SET
|
||||
DoctorTestCreated = NOW(),
|
||||
DoctorTestLastUpdated = NOW(),
|
||||
DoctorTestIsActive = ?
|
||||
WHERE DoctorTestID = ?";
|
||||
$qry_update = $this->db->query($sql_update, array($status, $doctortestid));
|
||||
if (!$qry_update) {
|
||||
$this->sys_error_db("doctor test update", $this->db);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// belum ada
|
||||
$sql_insert = "INSERT INTO one_doctor.doctor_test(
|
||||
DoctorTestM_DoctorID,
|
||||
DoctorTestT_TestID,
|
||||
DoctorTestCreated,
|
||||
DoctorTestLastUpdated,
|
||||
DoctorTestIsActive) VALUES(?,?,NOW(),NOW(),'Y')";
|
||||
$qry_insert = $this->db->query($sql_insert, array($doctor_id, $test_id));
|
||||
if (!$qry_insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor test insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
574
one-api/application/controllers/v1/one-doctor/Doctortestv3.php
Normal file
574
one-api/application/controllers/v1/one-doctor/Doctortestv3.php
Normal file
@@ -0,0 +1,574 @@
|
||||
<?php
|
||||
|
||||
class Doctortestv3 extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "API DOCTOR TEST";
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT COUNT(*) as total
|
||||
FROM one_doctor.m_user a
|
||||
JOIN m_doctor b ON a.M_UserM_DoctorID = b.M_DoctorID
|
||||
AND M_UserIsActive = 'Y'
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
JOIN m_mou c ON a.M_UserM_MouID = c.M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
JOIN m_company d ON c.M_MouM_CompanyID = d.M_CompanyID
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
WHERE fn_get_doctor_fullname(M_UserM_DoctorID) like ?
|
||||
OR M_MouNumber like ? OR M_CompanyName like ?";
|
||||
|
||||
$qry_filter = $this->db->query($sql_filter, [$search, $search, $search]);
|
||||
// $last_query = $this->db->last_query();
|
||||
// echo ($last_query);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT M_UserID as user_id,
|
||||
M_DoctorID as doctor_id,
|
||||
fn_get_doctor_fullname(M_UserM_DoctorID) as doctorName,
|
||||
M_UserM_MouID,
|
||||
M_UserUsername,
|
||||
M_MouName,
|
||||
M_MouNumber,
|
||||
M_CompanyID,
|
||||
M_CompanyName
|
||||
FROM one_doctor.m_user a
|
||||
JOIN m_doctor b ON a.M_UserM_DoctorID = b.M_DoctorID
|
||||
AND M_UserIsActive = 'Y'
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
JOIN m_mou c ON a.M_UserM_MouID = c.M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
JOIN m_company d ON c.M_MouM_CompanyID = d.M_CompanyID
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
WHERE fn_get_doctor_fullname(M_UserM_DoctorID) like ?
|
||||
OR M_MouName like ? OR M_CompanyName like ?
|
||||
limit ? offset ?";
|
||||
|
||||
$qry = $this->db->query($sql, array($search, $search, $search, $number_limit, $number_offset));
|
||||
// $last_query = $this->db->last_query();
|
||||
// echo ($last_query);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookuptestold()
|
||||
{
|
||||
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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$doctor_id = 0;
|
||||
if (isset($prm['doctor_id'])) {
|
||||
$doctor_id = trim($prm["doctor_id"]);
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT COUNT(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN one_doctor.doctor_test ON T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y'
|
||||
AND (T_TestSasCode LIKE ?
|
||||
OR T_TestName LIKE ?)";
|
||||
|
||||
$qry_filter = $this->db->query($sql_filter, [$doctor_id, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test count error", $this->db);
|
||||
}
|
||||
|
||||
$sql = "SELECT T_TestID as testid,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
FROM t_test
|
||||
LEFT JOIN one_doctor.doctor_test ON T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y'
|
||||
AND (T_TestSasCode LIKE ?
|
||||
OR T_TestName LIKE ?)
|
||||
LIMIT ? OFFSET ?";
|
||||
|
||||
$qry = $this->db->query($sql, [$doctor_id, $search, $search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookuptest()
|
||||
{
|
||||
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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$doctor_id = 0;
|
||||
if (isset($prm['doctor_id'])) {
|
||||
$doctor_id = trim($prm["doctor_id"]);
|
||||
}
|
||||
$status = $prm['status'];
|
||||
$filter = '';
|
||||
if ($status == 'Y') {
|
||||
$filter .= "AND DoctorTestM_DoctorID IS NOT NULL AND DoctorTestM_DoctorID = $doctor_id";
|
||||
} else {
|
||||
if ($status == 'N') {
|
||||
$filter .= "AND DoctorTestM_DoctorID IS NULL ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
// $sql_filter = "SELECT COUNT(*) as total
|
||||
// FROM(SELECT *, IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
// FROM t_test
|
||||
// LEFT JOIN one_doctor.doctor_test ON T_TestID = DoctorTestT_TestID
|
||||
// AND DoctorTestM_DoctorID = ?
|
||||
// AND DoctorTestIsActive = 'Y'
|
||||
// WHERE T_TestIsActive = 'Y') a
|
||||
// WHERE
|
||||
// (T_TestSasCode LIKE ?
|
||||
// OR T_TestName LIKE ?) $filter";
|
||||
|
||||
// $qry_filter = $this->db->query($sql_filter, [$doctor_id, $search, $search]);
|
||||
// $tot_count = 0;
|
||||
// $tot_page = 0;
|
||||
// if ($qry_filter) {
|
||||
// $tot_count = $qry_filter->result_array()[0]["total"];
|
||||
// $tot_page = ceil($tot_count/$number_limit);
|
||||
|
||||
// } else {
|
||||
// $this->sys_error_db("test count error", $this->db);
|
||||
// }
|
||||
|
||||
$sql_user = "SELECT * FROM one_doctor.m_user WHERE M_UserM_DoctorID = ?";
|
||||
|
||||
$qry_user = $this->db->query($sql_user, [$doctor_id]);
|
||||
if ($qry_user) {
|
||||
$rows_user = $qry_user->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("user select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
$mouid = $rows_user[0]["M_UserM_MouID"];
|
||||
|
||||
// $sql = "SELECT * FROM (SELECT a.T_TestID as testid,
|
||||
// a.T_TestSasCode,
|
||||
// a.T_TestName,
|
||||
// IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
// FROM t_test as a
|
||||
// JOIN ss_price_mou ON ss_price_mou.T_TestID = a.T_TestID
|
||||
// AND Ss_PriceMouM_MouID = ?
|
||||
// LEFT JOIN one_doctor.doctor_test ON a.T_TestID = DoctorTestT_TestID
|
||||
// AND DoctorTestM_DoctorID = ?
|
||||
// AND DoctorTestIsActive = 'Y'
|
||||
// AND T_PriceIsCito = 'N'
|
||||
// WHERE T_TestIsActive = 'Y') a
|
||||
// WHERE
|
||||
// (T_TestSasCode LIKE ?
|
||||
// OR a.T_TestName LIKE ?) $filter
|
||||
// LIMIT ? OFFSET ?";
|
||||
|
||||
$sql_dasar = "
|
||||
SELECT a.T_TestID as testid, a.T_TestSasCode, a.T_TestName, IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
FROM t_test as a
|
||||
JOIN ss_price_mou ON ss_price_mou.T_TestID = a.T_TestID AND Ss_PriceMouM_MouID = $mouid
|
||||
AND T_PriceIsCito = 'N'
|
||||
left JOIN one_doctor.doctor_test ON a.T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = $doctor_id
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
JOIN m_doctor ON DoctorTestM_DoctorID = M_DoctorID
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y' and ( T_TestSasCode LIKE '$search' OR a.T_TestName LIKE '$search' ) $filter
|
||||
AND DoctorTestT_TestID is not null
|
||||
UNION
|
||||
SELECT a.T_TestID as testid, a.T_TestSasCode, a.T_TestName, IF(DoctorTestM_DoctorID IS NULL, 'N', 'Y') as status
|
||||
FROM t_test as a
|
||||
JOIN ss_price_mou ON ss_price_mou.T_TestID = a.T_TestID AND Ss_PriceMouM_MouID = $mouid
|
||||
AND T_PriceIsCito = 'N'
|
||||
left JOIN one_doctor.doctor_test ON a.T_TestID = DoctorTestT_TestID
|
||||
AND DoctorTestM_DoctorID = $doctor_id
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y' and ( T_TestSasCode LIKE '$search' OR a.T_TestName LIKE '$search') $filter
|
||||
AND a.T_TestID NOT IN (
|
||||
select DoctorTestT_TestID
|
||||
from one_doctor.doctor_test
|
||||
where DoctorTestM_DoctorID = $doctor_id
|
||||
AND DoctorTestIsActive = 'Y'
|
||||
)";
|
||||
|
||||
$sql_filter = "SELECT COUNT(*) as total from ($sql_dasar) as x";
|
||||
|
||||
$qry_filter = $this->db->query($sql_filter);
|
||||
// echo $this->db->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test count error", $this->db);
|
||||
}
|
||||
|
||||
// echo $tot_count;
|
||||
|
||||
|
||||
$sql = $sql_dasar . " ORDER BY T_TestSasCode LIMIT $number_limit OFFSET $number_offset";
|
||||
|
||||
// $qry = $this->db->query($sql, [
|
||||
// $mouid,
|
||||
// $doctor_id,
|
||||
// $search,
|
||||
// $search,
|
||||
// $mouid,
|
||||
// $doctor_id,
|
||||
// $search,
|
||||
// $search,
|
||||
// $number_limit, $number_offset]);
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
// echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
// $tot_page = ceil(count($rows)/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getstatus()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
|
||||
$query = "
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
$qry = $this->db->query($query);
|
||||
if ($qry) {
|
||||
$rows['f_statuss'] = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select status error", $this->db);
|
||||
exit;
|
||||
}
|
||||
// print_r($rows);
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveeditstatus()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$test_id = $prm["test_id"];
|
||||
$doctor_id = $prm["doctor_id"];
|
||||
$status = $prm["status"];
|
||||
//cari test id dan doctor id
|
||||
$sql = "SELECT DoctorTestID, DoctorTestM_DoctorID, DoctorTestT_TestID
|
||||
FROM one_doctor.doctor_test
|
||||
WHERE DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestT_TestID = ?";
|
||||
$qry = $this->db->query($sql, array($doctor_id, $test_id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("doctor test error", $this->db);
|
||||
exit;
|
||||
}
|
||||
if (count($rows) > 0) {
|
||||
// sudah ada
|
||||
$doctortestid = $rows[0]["DoctorTestID"];
|
||||
$sql_update = "UPDATE one_doctor.doctor_test SET
|
||||
DoctorTestCreated = NOW(),
|
||||
DoctorTestLastUpdated = NOW(),
|
||||
DoctorTestIsActive = ?
|
||||
WHERE DoctorTestID = ?";
|
||||
$qry_update = $this->db->query($sql_update, array($status, $doctortestid));
|
||||
if (!$qry_update) {
|
||||
$this->sys_error_db("doctor test update", $this->db);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// belum ada
|
||||
$sql_insert = "INSERT INTO one_doctor.doctor_test(
|
||||
DoctorTestM_DoctorID,
|
||||
DoctorTestT_TestID,
|
||||
DoctorTestCreated,
|
||||
DoctorTestLastUpdated,
|
||||
DoctorTestIsActive) VALUES(?,?,NOW(),NOW(),'Y')";
|
||||
$qry_insert = $this->db->query($sql_insert, array($doctor_id, $test_id));
|
||||
if (!$qry_insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor test insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getdoctor()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$mouid = $prm["mouid"];
|
||||
|
||||
$sql = "SELECT M_UserID as user_id,
|
||||
M_DoctorID as doctor_id,
|
||||
fn_get_doctor_fullname(M_UserM_DoctorID) as doctorName,
|
||||
M_UserM_MouID,
|
||||
M_UserUsername,
|
||||
M_MouName,
|
||||
M_MouNumber,
|
||||
M_CompanyID,
|
||||
M_CompanyName
|
||||
FROM one_doctor.m_user a
|
||||
JOIN m_doctor b ON a.M_UserM_DoctorID = b.M_DoctorID
|
||||
AND M_UserIsActive = 'Y'
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
JOIN m_mou c ON a.M_UserM_MouID = c.M_MouID
|
||||
AND M_UserM_MouID = ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
JOIN m_company d ON c.M_MouM_CompanyID = d.M_CompanyID
|
||||
AND M_CompanyIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql, $mouid);
|
||||
// $last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor select", $this->db);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
// print_r($rows);
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function copyfromdoctor()
|
||||
{
|
||||
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$doctoridfrom = $prm["doctoridfrom"];
|
||||
$doctoridto = $prm["doctoridto"];
|
||||
$this->db->trans_begin();
|
||||
|
||||
// pilih test
|
||||
$sql = "SELECT DoctorTestT_TestID
|
||||
FROM one_doctor.doctor_test WHERE
|
||||
DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestIsActive = 'Y' AND DoctorTestT_TestID NOT IN (
|
||||
select DoctorTestT_TestID
|
||||
from one_doctor.doctor_test
|
||||
where DoctorTestM_DoctorID = ?
|
||||
AND DoctorTestIsActive = 'Y' )";
|
||||
$qry = $this->db->query($sql, array($doctoridfrom, $doctoridto));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("doctor test error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows) > 0) {
|
||||
foreach ($rows as $key => $value) {
|
||||
// print_r($value);
|
||||
$testid = $value["DoctorTestT_TestID"];
|
||||
$sql_insert = "INSERT INTO one_doctor.doctor_test(
|
||||
DoctorTestM_DoctorID,
|
||||
DoctorTestT_TestID,
|
||||
DoctorTestCreated,
|
||||
DoctorTestLastUpdated,
|
||||
DoctorTestIsActive) VALUES(?,?,NOW(),NOW(),'Y')";
|
||||
$qry_insert = $this->db->query($sql_insert, array($doctoridto, $testid));
|
||||
if (!$qry_insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("doctor test insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// $this->db->trans_rollback();
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => count($rows)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
2061
one-api/application/controllers/v1/one-doctor/Dokterapi.php
Normal file
2061
one-api/application/controllers/v1/one-doctor/Dokterapi.php
Normal file
File diff suppressed because it is too large
Load Diff
2193
one-api/application/controllers/v1/one-doctor/Dokterapiall.php
Normal file
2193
one-api/application/controllers/v1/one-doctor/Dokterapiall.php
Normal file
File diff suppressed because it is too large
Load Diff
1195
one-api/application/controllers/v1/one-doctor/Dokterapiv2.php
Normal file
1195
one-api/application/controllers/v1/one-doctor/Dokterapiv2.php
Normal file
File diff suppressed because it is too large
Load Diff
1194
one-api/application/controllers/v1/one-doctor/Doktercoba.php
Normal file
1194
one-api/application/controllers/v1/one-doctor/Doktercoba.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user