Initial import
This commit is contained in:
317
application/controllers/v1/adhi/fisik/Fisik01.php
Normal file
317
application/controllers/v1/adhi/fisik/Fisik01.php
Normal file
@@ -0,0 +1,317 @@
|
||||
<?php
|
||||
class Fisik01 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Fisik 01";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
function json($start, $end, $company = 0, $mou = 0)
|
||||
{
|
||||
$start = $start . " 00:00:01";
|
||||
$end = $end . " 23:59:59";
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderDate >= ? and T_OrderHeaderDate <= ?
|
||||
and ( T_OrderHeaderM_CompanyID = $company or $company = 0 )
|
||||
and ( T_OrderHeaderM_MouID = $mou or $mou = 0 )
|
||||
";
|
||||
$qry = $this->db->query($sql, [$start, $end]);
|
||||
if (!$qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $db_err["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$sid = "0";
|
||||
foreach ($rows as $r) {
|
||||
$sid .= ", " . $r["T_OrderHeaderID"];
|
||||
}
|
||||
$sql = "select
|
||||
fn_global_patient_name(T_OrderHeaderM_PatientID) M_PatientName,
|
||||
fn_get_patient_atribute(T_OrderHeaderM_PatientID) attr,
|
||||
T_OrderHeaderDate,T_OrderHeaderLabNumber, T_OrderHeaderLabNumberExt,T_OrderHeaderM_PatientAge,
|
||||
M_CompanyName, M_MouName,
|
||||
T_TestName,
|
||||
So_ResultEntryFisikUmumType,
|
||||
So_ResultEntryFisikUmumDetails
|
||||
from t_orderheader
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID= T_OrderHeaderID and T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_TestID = T_OrderDetailT_TestID and T_TestIsActive = 'Y' and T_TestNat_GroupID = '4'
|
||||
join so_resultentry on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID and So_ResultEntryT_OrderDetailID = T_OrderDetailID
|
||||
join so_resultentry_fisik_umum on So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
||||
where T_OrderHeaderID in ($sid) order by So_ResultEntryFisikUmumID ";
|
||||
$qry = $this->db->query($sql, [$headerID]);
|
||||
if (!$qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $db_err["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$data = [];
|
||||
$new_d = [];
|
||||
$a_title = [];
|
||||
$have_gigi = false;
|
||||
foreach ($rows as $r) {
|
||||
$attr = json_decode($r["attr"], true);
|
||||
unset($r["attr"]);
|
||||
$r_details = json_decode(
|
||||
$r["So_ResultEntryFisikUmumDetails"],
|
||||
true
|
||||
);
|
||||
unset($r["So_ResultEntryFisikUmumDetails"]);
|
||||
//$new_r = array();
|
||||
foreach ($r_details as $idx => $d) {
|
||||
$details = $d["details"];
|
||||
unset($d["details"]);
|
||||
$d["T_TestName"] = $r["T_TestName"];
|
||||
$d["T_OrderHeaderDate"] = $r["T_OrderHeaderDate"];
|
||||
$d["T_OrderHeaderLabNumber"] = $r["T_OrderHeaderLabNumber"];
|
||||
$d["T_OrderHeaderLabNumberExt"] =
|
||||
$r["T_OrderHeaderLabNumberExt"];
|
||||
$d["M_PatientName"] = $r["M_PatientName"];
|
||||
$d["M_PatientDOB"] = $attr["M_PatientDOB"];
|
||||
$d["M_PatientAge"] = $r["T_OrderHeaderM_PatientAge"];
|
||||
$d["M_SexName"] = $attr["M_SexName"];
|
||||
$d["M_CompanyName"] = $r["M_CompanyName"];
|
||||
$d["M_MouName"] = $r["M_MouName"];
|
||||
|
||||
$d["So_ResultEntryFisikUmumType"] =
|
||||
$r["So_ResultEntryFisikUmumType"];
|
||||
|
||||
/* if ($d["title"] == "GIGI") {
|
||||
$dx = $details[0];
|
||||
$dy = $dx["details"][0];
|
||||
$dy["label"] = "kesimpulan";
|
||||
$dy["value"] = $this->hasil_gigi($dx["details"]);
|
||||
$new_d[] = array_merge($d,$dy);
|
||||
continue;
|
||||
} */
|
||||
|
||||
foreach ($details as $dx) {
|
||||
if (isset($dx["details"])) {
|
||||
$dy_details = $dx["details"];
|
||||
unset($dx["details"]);
|
||||
foreach ($dy_details as $dy_detail) {
|
||||
if (
|
||||
$d["title"] == "ANGGOTA GERAK" ||
|
||||
$d["title"] == "MULUT" ||
|
||||
$d["title"] == "JANTUNG" ||
|
||||
$d["title"] == "PERUT / ABDOMEN" ||
|
||||
$d["title"] == "SISTEM PERSYARAFAN" ||
|
||||
$d["title"] == "SISTEM INTEGUMEN"
|
||||
) {
|
||||
if ($dy_detail["chx"] == "1") {
|
||||
$dy_detail["value"] = $dy_detail["label"];
|
||||
$dy_detail["label"] =
|
||||
$dy_detail["segment_name"];
|
||||
$new_d[] = array_merge($d, $dx, $dy_detail);
|
||||
}
|
||||
}
|
||||
if ($d["title"] == "RIWAYAT KEBIASAAN HIDUP") {
|
||||
if ($dy_detail["chx"] == "1") {
|
||||
$dy_detail["value"] = $dy_detail["label"];
|
||||
$dy_detail["label"] =
|
||||
$dy_detail["segment_name"];
|
||||
$new_d[] = array_merge($d, $dx, $dy_detail);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//if ($dy["value"] == "") continue;
|
||||
if (
|
||||
isset($dy_detail["unit"]) &&
|
||||
isset($dy_detail["value"])
|
||||
) {
|
||||
$dy_detail["value"] =
|
||||
$dy_detail["value"] .
|
||||
" " .
|
||||
$dy_detail["unit"];
|
||||
}
|
||||
if ($d["title"] == "GIGI") {
|
||||
if (!$have_gigi) {
|
||||
$dy_detail["label"] = "kesimpulan";
|
||||
$dy_detail["value"] = $this->hasil_gigi(
|
||||
$dy_details
|
||||
);
|
||||
$new_d[] = array_merge($d, $dx, $dy_detail);
|
||||
}
|
||||
$have_gigi = true;
|
||||
} else {
|
||||
$new_d[] = array_merge($d, $dx, $dy_detail);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($dx["value"] != "") {
|
||||
if (isset($dx["unit"]) && isset($dx["value"])) {
|
||||
$dx["value"] = $dx["value"] . " " . $dx["unit"];
|
||||
}
|
||||
$new_d[] = array_merge($d, $dx);
|
||||
}
|
||||
if ($dx["chx_y"] == 1) {
|
||||
$dx["value"] = $dx["label_y"];
|
||||
$new_d[] = array_merge($d, $dx);
|
||||
}
|
||||
if ($dx["chx_x"] == 1) {
|
||||
$dx["value"] = $dx["label_x"];
|
||||
$new_d[] = array_merge($d, $dx);
|
||||
}
|
||||
if ($dx["chx"] == 1) {
|
||||
$dx["value"] = $dx["label"] . " " . $d["value"];
|
||||
$new_d[] = array_merge($d, $dx);
|
||||
}
|
||||
}
|
||||
}
|
||||
//$new_r[] = $new_d;
|
||||
}
|
||||
}
|
||||
$x_d = usort($new_d, ["Fisik01", "cmp"]);
|
||||
echo json_encode($new_d);
|
||||
}
|
||||
function hasil_gigi($da)
|
||||
{
|
||||
$arr_gigi = [];
|
||||
foreach ($da["details"] as $db) {
|
||||
foreach ($db["details"] as $dc) {
|
||||
$dc["value"] = strtoupper($dc["value"]);
|
||||
if ($dc["value"] != "" && isset($kode_gigi[$dc["value"]])) {
|
||||
$value = $kode_gigi[$dc["value"]];
|
||||
if (!isset($arr_gigi[$value])) {
|
||||
$arr_gigi[$value] = [];
|
||||
}
|
||||
$kode = $dc["id_code"];
|
||||
$pos = substr($kode, -1);
|
||||
|
||||
if (strpos($kode, "atas")) {
|
||||
if (strpos($kode, "kiri")) {
|
||||
$arr_gigi[$value][] = "└" . $pos;
|
||||
} else {
|
||||
$arr_gigi[$value][] = $pos . "┘";
|
||||
}
|
||||
} else {
|
||||
if (strpos($kode, "kiri")) {
|
||||
$arr_gigi[$value][] = "┌" . $pos;
|
||||
} else {
|
||||
$arr_gigi[$value][] = $pos . "┐";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$r_gigi = "";
|
||||
foreach ($arr_gigi as $v => $g) {
|
||||
if ($r_gigi != "") {
|
||||
$r_gigi .= "\n";
|
||||
}
|
||||
$r_gigi .= $v . " " . join(",", $g);
|
||||
}
|
||||
return $r_gigi;
|
||||
}
|
||||
function cmp($a, $b)
|
||||
{
|
||||
$a_key = substr($a["title"], 1, 3) . "-" . $a["label"];
|
||||
$b_key = substr($b["title"], 1, 3) . "-" . $b["label"];
|
||||
return strcmp($a_key, $b_key);
|
||||
}
|
||||
function json_single($headerID)
|
||||
{
|
||||
$sql = "select
|
||||
fn_global_patient_name(T_OrderHeaderM_PatientID) M_PatientName,
|
||||
fn_get_patient_atribute(T_OrderHeaderM_PatientID) attr,
|
||||
T_OrderHeaderDate,T_OrderHeaderLabNumber, T_OrderHeaderLabNumberExt,T_OrderHeaderM_PatientAge,
|
||||
M_CompanyName, M_MouName,
|
||||
T_TestName,
|
||||
So_ResultEntryFisikUmumType,
|
||||
So_ResultEntryFisikUmumDetails
|
||||
from t_orderheader
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID= T_OrderHeaderID and T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_TestID = T_OrderDetailT_TestID and T_TestIsActive = 'Y' and T_TestNat_GroupID = '4'
|
||||
join so_resultentry on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID and So_ResultEntryT_OrderDetailID = T_OrderDetailID
|
||||
join so_resultentry_fisik_umum on So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
||||
where T_OrderHeaderID =?";
|
||||
$qry = $this->db->query($sql, [$headerID]);
|
||||
if (!$qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $db_err["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$data = [];
|
||||
echo "<pre>";
|
||||
$new_d = [];
|
||||
foreach ($rows as $r) {
|
||||
$attr = json_decode($r["attr"], true);
|
||||
unset($r["attr"]);
|
||||
$r_details = json_decode(
|
||||
$r["So_ResultEntryFisikUmumDetails"],
|
||||
true
|
||||
);
|
||||
unset($r["So_ResultEntryFisikUmumDetails"]);
|
||||
$new_r = [];
|
||||
foreach ($r_details as $idx => $d) {
|
||||
$details = $d["details"];
|
||||
unset($d["details"]);
|
||||
$d["T_TestName"] = $r["T_TestName"];
|
||||
$d["T_OrderHeaderDate"] = $r["T_OrderHeaderDate"];
|
||||
$d["T_OrderHeaderLabNumber"] = $r["T_OrderHeaderLabNumber"];
|
||||
$d["T_OrderHeaderLabNumberExt"] =
|
||||
$r["T_OrderHeaderLabNumberExt"];
|
||||
$d["M_PatientName"] = $r["M_PatientName"];
|
||||
$d["M_PatientDOB"] = $attr["M_PatientDOB"];
|
||||
$d["M_PatientAge"] = $r["T_OrderHeaderM_PatientAge"];
|
||||
$d["M_SexName"] = $attr["M_SexName"];
|
||||
$d["M_CompanyName"] = $r["M_CompanyName"];
|
||||
$d["M_MouName"] = $r["M_MouName"];
|
||||
|
||||
$d["So_ResultEntryFisikUmumType"] =
|
||||
$r["So_ResultEntryFisikUmumType"];
|
||||
foreach ($details as $dx) {
|
||||
if (isset($dx["details"])) {
|
||||
$dy_details = $dx["details"];
|
||||
unset($dx["details"]);
|
||||
foreach ($dy_details as $dy_detail) {
|
||||
if (
|
||||
isset($dy_detail["unit"]) &&
|
||||
isset($dy_detail["value"])
|
||||
) {
|
||||
$dy_detail["value"] =
|
||||
$dy_detail["value"] .
|
||||
" " .
|
||||
$dy_detail["unit"];
|
||||
}
|
||||
$new_d[] = array_merge($d, $dx, $dy_detail);
|
||||
}
|
||||
} else {
|
||||
if (isset($dx["unit"]) && isset($dx["value"])) {
|
||||
$dx["value"] = $dx["value"] . " " . $dx["unit"];
|
||||
}
|
||||
$new_d[] = array_merge($d, $dx);
|
||||
}
|
||||
}
|
||||
$new_r[] = $new_d;
|
||||
}
|
||||
}
|
||||
print_r($new_d);
|
||||
}
|
||||
}
|
||||
285
application/controllers/v1/adhi/fisik/Fisik02.php
Normal file
285
application/controllers/v1/adhi/fisik/Fisik02.php
Normal file
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
class Fisik02 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Fisik 01";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
function json($start,$end,$company = 0 , $mou = 0) {
|
||||
$kode_gigi = array(
|
||||
"X" => "Berlubang" ,
|
||||
"C" => "Tambalan",
|
||||
"O" => "Tanggal",
|
||||
"R" => "Sisa akar",
|
||||
"A" => "Gigi Palsu" ,
|
||||
"K" => "Karang Gigi"
|
||||
);
|
||||
|
||||
$start = $start . " 00:00:01";
|
||||
$end = $end . " 23:59:59";
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderDate >= ? and T_OrderHeaderDate <= ?
|
||||
and ( T_OrderHeaderM_CompanyID = $company or $company = 0 )
|
||||
and ( T_OrderHeaderM_MouID = $mou or $mou = 0 )
|
||||
";
|
||||
$qry = $this->db->query($sql, array($start,$end));
|
||||
if (! $qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode( array( "status" => "ERR",
|
||||
"message" => $db_err["message"]
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$sid = "0";
|
||||
|
||||
foreach($rows as $r) {
|
||||
$sid .= ", " . $r["T_OrderHeaderID"];
|
||||
break;
|
||||
}
|
||||
$sql = "select
|
||||
fn_global_patient_name(T_OrderHeaderM_PatientID) M_PatientName,
|
||||
fn_get_patient_atribute(T_OrderHeaderM_PatientID) attr,
|
||||
T_OrderHeaderDate,T_OrderHeaderLabNumber, T_OrderHeaderLabNumberExt,T_OrderHeaderM_PatientAge,
|
||||
M_CompanyName, M_MouName,
|
||||
T_TestName,
|
||||
So_ResultEntryFisikUmumType,
|
||||
So_ResultEntryFisikUmumDetails
|
||||
from t_orderheader
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID= T_OrderHeaderID and T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_TestID = T_OrderDetailT_TestID and T_TestIsActive = 'Y' and T_TestNat_GroupID = '4'
|
||||
join so_resultentry on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID and So_ResultEntryT_OrderDetailID = T_OrderDetailID
|
||||
join so_resultentry_fisik_umum on So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
||||
where T_OrderHeaderID in ($sid) order by So_ResultEntryFisikUmumID ";
|
||||
$qry = $this->db->query($sql, array($headerID));
|
||||
if (! $qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode( array( "status" => "ERR",
|
||||
"message" => $db_err["message"]
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$data = array();
|
||||
$new_d = array();
|
||||
$a_title = array();
|
||||
foreach($rows as $r) {
|
||||
$attr = json_decode($r["attr"],true);
|
||||
unset($r["attr"]);
|
||||
$r_details = json_decode($r["So_ResultEntryFisikUmumDetails"],true);
|
||||
unset($r["So_ResultEntryFisikUmumDetails"]);
|
||||
//$new_r = array();
|
||||
foreach($r_details as $idx => $d) {
|
||||
$details = $d["details"];
|
||||
unset($d["details"]);
|
||||
$d["T_TestName"] = $r["T_TestName"];
|
||||
$d["T_OrderHeaderDate"] = $r["T_OrderHeaderDate"];
|
||||
$d["T_OrderHeaderLabNumber"] = $r["T_OrderHeaderLabNumber"];
|
||||
$d["T_OrderHeaderLabNumberExt"] = $r["T_OrderHeaderLabNumberExt"];
|
||||
$d["M_PatientName"] = $r["M_PatientName"];
|
||||
$d["M_PatientDOB"] = $attr["M_PatientDOB"];
|
||||
$d["M_PatientAge"] = $r["T_OrderHeaderM_PatientAge"];
|
||||
$d["M_SexName"] = $attr["M_SexName"];
|
||||
$d["M_CompanyName"] = $r["M_CompanyName"];
|
||||
$d["M_MouName"] = $r["M_MouName"];
|
||||
|
||||
$d["So_ResultEntryFisikUmumType"] = $r["So_ResultEntryFisikUmumType"];
|
||||
|
||||
$have_gigi = false;
|
||||
foreach($details as $dx) {
|
||||
|
||||
if (isset($dx["details"])) {
|
||||
$dy_details = $dx["details"];
|
||||
unset($dx["details"]);
|
||||
foreach($dy_details as $idx => $dy_detail) {
|
||||
if ( $d["title"] == "ANGGOTA GERAK" || $d["title"] == "MULUT" || $d["title"] == "JANTUNG"
|
||||
|| $d["title"] == "PERUT / ABDOMEN" || $d["title"] == "SISTEM PERSYARAFAN"
|
||||
|| $d["title"] == "SISTEM INTEGUMEN"
|
||||
|| $d["title"] == "KEADAAN UMUM"
|
||||
) {
|
||||
if ($dy_detail["chx"] == "1" ) {
|
||||
$dy_detail["value"] = $dy_detail["label"];
|
||||
$dy_detail["label"] = $dy_detail["segment_name"];
|
||||
$new_d[] = array_merge($d,$dx,$dy_detail);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($dy_detail["unit"]) && isset($dy_detail["value"])) {
|
||||
$dy_detail["value"] = $dy_detail["value"] . " " . $dy_detail["unit"];
|
||||
}
|
||||
if ($d["title"] == "GIGI") {
|
||||
if (! $have_gigi ) {
|
||||
$dy_detail["label"] = "kesimpulan";
|
||||
$dy_detail["value"] = $this->hasil_gigi($dy_details);
|
||||
$new_d[] = array_merge($d,$dx,$dy_detail);
|
||||
}
|
||||
$have_gigi = true;
|
||||
} else {
|
||||
$new_d[] = array_merge($d,$dx,$dy_detail);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if ($dx["value"] != "") {
|
||||
if(isset($dx["unit"]) && isset($dx["value"])) {
|
||||
$dx["value"] = $dx["value"] . " " . $dx["unit"];
|
||||
}
|
||||
$new_d[] = array_merge($d,$dx);
|
||||
}
|
||||
if($dx["chx_y"] == 1) {
|
||||
$dx["value"] = $dx["label_y"];
|
||||
$new_d[] = array_merge($d,$dx);
|
||||
}
|
||||
if($dx["chx_x"] == 1) {
|
||||
$dx["value"] = $dx["label_x"];
|
||||
$new_d[] = array_merge($d,$dx);
|
||||
}
|
||||
if ($dx["chx"] == 1) {
|
||||
$dx["value"] = $dx["label"];
|
||||
$new_d[] = array_merge($d,$dx);
|
||||
}
|
||||
}
|
||||
}
|
||||
//$new_r[] = $new_d;
|
||||
}
|
||||
}
|
||||
$x_d = usort($new_d, array("Fisik01","cmp"));
|
||||
echo json_encode($new_d);
|
||||
}
|
||||
function cmp($a,$b) {
|
||||
$a_key = substr($a["title"],1,3) . "-" . $a["label"];
|
||||
$b_key = substr($b["title"],1,3) . "-" . $b["label"];
|
||||
return strcmp($a_key, $b_key);
|
||||
}
|
||||
|
||||
function hasil_gigi($da) {
|
||||
$arr_gigi= array();
|
||||
foreach($da["details"] as $db) {
|
||||
foreach($db["details"] as $dc) {
|
||||
$dc["value"] = strtoupper($dc["value"]);
|
||||
if ($dc["value"] != "" && isset($kode_gigi[$dc["value"]])) {
|
||||
$value = $kode_gigi[$dc["value"]];
|
||||
if (! isset($arr_gigi[$value]) ) $arr_gigi[$value] = array();
|
||||
$kode = $dc["id_code"];
|
||||
$pos = substr($kode,-1);
|
||||
|
||||
if ( strpos($kode,"atas")) {
|
||||
if (strpos($kode,"kiri")) {
|
||||
$arr_gigi[$value][] = "└" . $pos ;
|
||||
} else {
|
||||
$arr_gigi[$value][] = $pos . "┘" ;
|
||||
}
|
||||
} else {
|
||||
if (strpos($kode,"kiri")) {
|
||||
$arr_gigi[$value][] = "┌" .$pos;
|
||||
} else {
|
||||
$arr_gigi[$value][] = $pos . "┐" ;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$r_gigi = "";
|
||||
foreach($arr_gigi as $v => $g) {
|
||||
if ($r_gigi != "") $r_gigi .= "\n";
|
||||
$r_gigi .= $v." ".join(",",$g);
|
||||
}
|
||||
return $r_gigi;
|
||||
}
|
||||
function json_single($headerID) {
|
||||
$sql = "select
|
||||
fn_global_patient_name(T_OrderHeaderM_PatientID) M_PatientName,
|
||||
fn_get_patient_atribute(T_OrderHeaderM_PatientID) attr,
|
||||
T_OrderHeaderDate,T_OrderHeaderLabNumber, T_OrderHeaderLabNumberExt,T_OrderHeaderM_PatientAge,
|
||||
M_CompanyName, M_MouName,
|
||||
T_TestName,
|
||||
So_ResultEntryFisikUmumType,
|
||||
So_ResultEntryFisikUmumDetails
|
||||
from t_orderheader
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID= T_OrderHeaderID and T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_TestID = T_OrderDetailT_TestID and T_TestIsActive = 'Y' and T_TestNat_GroupID = '4'
|
||||
join so_resultentry on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID and So_ResultEntryT_OrderDetailID = T_OrderDetailID
|
||||
join so_resultentry_fisik_umum on So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
||||
where T_OrderHeaderID =?";
|
||||
$qry = $this->db->query($sql, array($headerID));
|
||||
if (! $qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode( array( "status" => "ERR",
|
||||
"message" => $db_err["message"]
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$data = array();
|
||||
echo "<pre>";
|
||||
$new_d = array();
|
||||
$hasil_mentah_gigi = array();
|
||||
foreach($rows as $r) {
|
||||
$attr = json_decode($r["attr"],true);
|
||||
unset($r["attr"]);
|
||||
$r_details = json_decode($r["So_ResultEntryFisikUmumDetails"],true);
|
||||
unset($r["So_ResultEntryFisikUmumDetails"]);
|
||||
$new_r = array();
|
||||
|
||||
foreach($r_details as $idx => $d) {
|
||||
$details = $d["details"];
|
||||
unset($d["details"]);
|
||||
$d["T_TestName"] = $r["T_TestName"];
|
||||
$d["T_OrderHeaderDate"] = $r["T_OrderHeaderDate"];
|
||||
$d["T_OrderHeaderLabNumber"] = $r["T_OrderHeaderLabNumber"];
|
||||
$d["T_OrderHeaderLabNumberExt"] = $r["T_OrderHeaderLabNumberExt"];
|
||||
$d["M_PatientName"] = $r["M_PatientName"];
|
||||
$d["M_PatientDOB"] = $attr["M_PatientDOB"];
|
||||
$d["M_PatientAge"] = $r["T_OrderHeaderM_PatientAge"];
|
||||
$d["M_SexName"] = $attr["M_SexName"];
|
||||
$d["M_CompanyName"] = $r["M_CompanyName"];
|
||||
$d["M_MouName"] = $r["M_MouName"];
|
||||
|
||||
$d["So_ResultEntryFisikUmumType"] = $r["So_ResultEntryFisikUmumType"];
|
||||
if ($d["title"] == "GIGI") {
|
||||
$hasil_mentah_gigi = $details;
|
||||
$dx = $details[0];
|
||||
$dx["value"] = $this->hasil_gigi($hasil_mentah_gigi);
|
||||
$new_d[] = array_merge($d,$dx);
|
||||
continue;
|
||||
}
|
||||
foreach($details as $dx) {
|
||||
|
||||
if (isset($dx["details"])) {
|
||||
$dy_details = $dx["details"];
|
||||
unset($dx["details"]);
|
||||
foreach($dy_details as $dy_detail) {
|
||||
if(isset($dy_detail["unit"]) && isset($dy_detail["value"])) {
|
||||
$dy_detail["value"] = $dy_detail["value"] . " " . $dy_detail["unit"];
|
||||
}
|
||||
$new_d[] = array_merge($d,$dx,$dy_detail);
|
||||
}
|
||||
} else {
|
||||
if(isset($dx["unit"]) && isset($dx["value"])) {
|
||||
$dx["value"] = $dx["value"] . " " . $dx["unit"];
|
||||
}
|
||||
$new_d[] = array_merge($d,$dx);
|
||||
}
|
||||
}
|
||||
$new_r[] = $new_d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
469
application/controllers/v1/adhi/fisik/Fisik03.php
Normal file
469
application/controllers/v1/adhi/fisik/Fisik03.php
Normal file
@@ -0,0 +1,469 @@
|
||||
<?php
|
||||
class Fisik03 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Fisik 01";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function kesimpulanv4($orderHeaderID, $langid = 1)
|
||||
{
|
||||
//mata visus gigi
|
||||
$sql = "select So_ResultEntryID,So_ResultEntrySo_TemplateName
|
||||
from so_resultentry
|
||||
where So_ResultEntryT_OrderHeaderID= ? and So_ResultEntryIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
return ["", "", ""];
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$id = 0;
|
||||
foreach ($rows as $r) {
|
||||
if ($r["So_ResultEntrySo_TemplateName"] == "FISIK UMUM") {
|
||||
$id = $r["So_ResultEntryID"];
|
||||
break;
|
||||
}
|
||||
if (substr($r["So_ResultEntrySo_TemplateName"], 0, 5) == "FISIK") {
|
||||
$id = $r["So_ResultEntryID"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sql = "SELECT *
|
||||
FROM so_resultentry_fisik_umum
|
||||
WHERE
|
||||
So_ResultEntryFisikUmumSo_ResultEntryID = ? AND
|
||||
So_ResultEntryFisikUmumM_LangID = ? AND
|
||||
So_ResultEntryFisikUmumType = 'riwayat'
|
||||
";
|
||||
$qry = $this->db->query($sql, array($id, $langid));
|
||||
$data_rows = $qry->result_array();
|
||||
if (count($data_rows) == 0) return '';
|
||||
$riwayat_data = json_decode($data_rows[0]["So_ResultEntryFisikUmumDetails"], true);
|
||||
|
||||
$kode_gigi = array(
|
||||
"X" => "Berlubang",
|
||||
"C" => "Tambalan",
|
||||
"O" => "Tanggal",
|
||||
"R" => "Sisa akar",
|
||||
"A" => "Gigi Palsu",
|
||||
"K" => "Karang Gigi"
|
||||
);
|
||||
$sql = "SELECT so_resultentry_fisik_umum.*, M_SexCode
|
||||
FROM so_resultentry_fisik_umum
|
||||
JOIN so_resultentry ON So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
||||
JOIN t_orderheader ON So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
WHERE So_ResultEntryFisikUmumSo_ResultEntryID = ?
|
||||
AND So_ResultEntryFisikUmumM_LangID = ?
|
||||
AND So_ResultEntryFisikUmumType = 'fisik'";
|
||||
$qry = $this->db->query($sql, array($id, $langid));
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) return '';
|
||||
$data = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true);
|
||||
|
||||
$sexcode = $rows[0]["M_SexCode"];
|
||||
|
||||
$kesimpulan_mata = "";
|
||||
$kesimpulan_visus = "";
|
||||
$kesimpulan_gigi = "";
|
||||
foreach ($data as $da) {
|
||||
if ($da["title"] == "MATA") {
|
||||
$rst_x = '';
|
||||
foreach ($da["details"] as $db) {
|
||||
if ($db["chx"] == "1" && $db["is_normal"] == "N" && $db["label"] != "Lain-lain") {
|
||||
if ($rst_x != "") $rst_x .= ", ";
|
||||
$rst_x .= $db["label"] . " " . $db["value"];
|
||||
}
|
||||
if ($db["label"] == "Lain-lain" && $db["chx"] == "1") {
|
||||
if ($rst_x != "") $rst_x .= ", ";
|
||||
$rst_x .= $db["value"];
|
||||
}
|
||||
}
|
||||
|
||||
if ($rst_x !== '') {
|
||||
$kesimpulan_mata .= ucwords(strtolower($da["title"])) . " : " . $rst_x;
|
||||
}
|
||||
}
|
||||
if ($da["title"] == "VISUS JAUH") {
|
||||
$s_rst = '';
|
||||
foreach ($da["details"] as $db) {
|
||||
$str_data = "";
|
||||
$r_ods = '';
|
||||
$xr_ods = array();
|
||||
$kelainan = '';
|
||||
foreach ($db['details'] as $dc) {
|
||||
if ($dc['chx'] == '1' && $dc['segment_name'] == 'Tanpa kacamata' && ($dc['value'] != '' && $dc['value'] != '6/6')) {
|
||||
$r_ods .= $dc['label'] . " : " . $dc['value'] . " ";
|
||||
array_push($xr_ods, $dc['value']);
|
||||
}
|
||||
if ($dc['chx'] == '1' && $dc['segment_name'] == 'Dengan kacamata' && $dc['value'] != '') {
|
||||
if ($dc['value'] != '6/6')
|
||||
$r_ods .= $dc['label'] . " : " . $dc['value'] . " ";
|
||||
|
||||
array_push($r_ods);
|
||||
array_push($xr_ods, $dc['value']);
|
||||
}
|
||||
}
|
||||
//print_r($xr_ods);
|
||||
if (!empty($xr_ods)) {
|
||||
if ($db['name'] == 'Tanpa kacamata') {
|
||||
$kelainan = "Kelainan Refraksi";
|
||||
$str_data .= $kelainan . " " . $db['name'];
|
||||
}
|
||||
if ($db['name'] == 'Dengan kacamata') {
|
||||
$all66 = true;
|
||||
foreach ($xr_ods as $xd => $xv) {
|
||||
if ($xv != '6/6') {
|
||||
$all66 = false;
|
||||
}
|
||||
}
|
||||
if ($all66) {
|
||||
$kelainan = "Kelainan Refraksi Terkoreksi";
|
||||
} else {
|
||||
$kelainan = "Kelainan Refraksi";
|
||||
}
|
||||
if ($r_ods != '')
|
||||
$str_data .= $kelainan . " " . $db['name'];
|
||||
else
|
||||
$str_data .= $kelainan . " " . $db['name'];
|
||||
}
|
||||
$s_rst .= $str_data;
|
||||
}
|
||||
//echo $str_data;
|
||||
|
||||
}
|
||||
if ($s_rst != "") {
|
||||
$kesimpulan_visus .= $s_rst;
|
||||
}
|
||||
}
|
||||
if ($da["title"] == "GIGI") {
|
||||
$arr_gigi = array();
|
||||
foreach ($da["details"] as $db) {
|
||||
foreach ($db["details"] as $dc) {
|
||||
$dc["value"] = strtoupper($dc["value"]);
|
||||
if ($dc["value"] != "" && isset($kode_gigi[$dc["value"]])) {
|
||||
$value = $kode_gigi[$dc["value"]];
|
||||
if (!isset($arr_gigi[$value])) $arr_gigi[$value] = array();
|
||||
$kode = $dc["id_code"];
|
||||
$pos = substr($kode, -1);
|
||||
|
||||
if (strpos($kode, "atas")) {
|
||||
if (strpos($kode, "kiri")) {
|
||||
$arr_gigi[$value][] = "└" . $pos;
|
||||
} else {
|
||||
$arr_gigi[$value][] = $pos . "┘";
|
||||
}
|
||||
} else {
|
||||
if (strpos($kode, "kiri")) {
|
||||
$arr_gigi[$value][] = "┌" . $pos;
|
||||
} else {
|
||||
$arr_gigi[$value][] = $pos . "┐";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$r_gigi = "";
|
||||
foreach ($arr_gigi as $v => $g) {
|
||||
if ($r_gigi != "") $r_gigi .= " ";
|
||||
$r_gigi .= " " . $v . " " . join(",", $g) . " ";
|
||||
}
|
||||
if ($r_gigi != "") {
|
||||
$kesimpulan_gigi .= $r_gigi;
|
||||
|
||||
// $r_gigi = "";
|
||||
// foreach ($arr_gigi as $v => $g) {
|
||||
// if ($r_gigi != "") $r_gigi .= "<br/>";
|
||||
// $r_gigi .= "<span style='margin-left:25px'>" . $v . " " . join(",", $g) . "</span>";
|
||||
// }
|
||||
// if ($r_gigi != "") {
|
||||
// $kesimpulan_gigi .= $r_gigi;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = [$kesimpulan_mata, $kesimpulan_visus, $kesimpulan_gigi];
|
||||
return $result;
|
||||
}
|
||||
function json($orderID)
|
||||
{
|
||||
$start = $start . " 00:00:01";
|
||||
$end = $end . " 23:59:59";
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID=?
|
||||
";
|
||||
$qry = $this->db->query($sql, array($orderID));
|
||||
if (!$qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode(array(
|
||||
"status" => "ERR",
|
||||
"message" => $db_err["message"]
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$sid = "0";
|
||||
foreach ($rows as $r) {
|
||||
$sid .= ", " . $r["T_OrderHeaderID"];
|
||||
}
|
||||
$sql = "select
|
||||
fn_global_patient_name(T_OrderHeaderM_PatientID) M_PatientName,
|
||||
fn_get_patient_atribute(T_OrderHeaderM_PatientID) attr,
|
||||
T_OrderHeaderDate,T_OrderHeaderLabNumber,
|
||||
-- T_OrderHeaderLabNumberExt,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
'' M_CompanyName, '' M_MouName,
|
||||
T_TestName,
|
||||
-- So_ResultEntryFisikUmumType,
|
||||
So_ResultEntryFisikUmumDetails
|
||||
from t_orderheader
|
||||
-- join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
-- join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID= T_OrderHeaderID and T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_TestID = T_OrderDetailT_TestID and T_TestIsActive = 'Y' and T_TestNat_GroupID = '4'
|
||||
join so_resultentry on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID and So_ResultEntryT_OrderDetailID = T_OrderDetailID
|
||||
join so_resultentry_fisik_umum on So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
||||
where T_OrderHeaderID in ($sid) order by So_ResultEntryFisikUmumID ";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode(array(
|
||||
"status" => "ERR",
|
||||
"message" => $db_err["message"]
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$data = array();
|
||||
$new_d = array();
|
||||
$a_title = array();
|
||||
$have_gigi = false;
|
||||
list($kesimpulan_mata, $kesimpulan_visus, $kesimpulan_gigi) = $this->kesimpulanv4($orderID);
|
||||
foreach ($rows as $r) {
|
||||
$attr = json_decode($r["attr"], true);
|
||||
unset($r["attr"]);
|
||||
$r_details = json_decode($r["So_ResultEntryFisikUmumDetails"], true);
|
||||
unset($r["So_ResultEntryFisikUmumDetails"]);
|
||||
//$new_r = array();
|
||||
$is_gigi = false;
|
||||
foreach ($r_details as $idx => $d) {
|
||||
$details = $d["details"];
|
||||
if (isset($d["details"])) unset($d["details"]);
|
||||
$d["T_TestName"] = $r["T_TestName"];
|
||||
$d["T_OrderHeaderDate"] = $r["T_OrderHeaderDate"];
|
||||
$d["T_OrderHeaderLabNumber"] = $r["T_OrderHeaderLabNumber"];
|
||||
$d["T_OrderHeaderLabNumberExt"] = $r["T_OrderHeaderLabNumberExt"];
|
||||
$d["M_PatientName"] = $r["M_PatientName"];
|
||||
$d["M_PatientDOB"] = $attr["M_PatientDOB"];
|
||||
$d["M_PatientAge"] = $r["T_OrderHeaderM_PatientAge"];
|
||||
$d["M_SexName"] = $attr["M_SexName"];
|
||||
$d["M_CompanyName"] = $r["M_CompanyName"];
|
||||
$d["M_MouName"] = $r["M_MouName"];
|
||||
|
||||
$d["So_ResultEntryFisikUmumType"] = $r["So_ResultEntryFisikUmumType"];
|
||||
|
||||
/* if ($d["title"] == "GIGI") {
|
||||
$dx = $details[0];
|
||||
$dy = $dx["details"][0];
|
||||
$dy["label"] = "kesimpulan";
|
||||
$dy["value"] = $this->hasil_gigi($dx["details"]);
|
||||
$new_d[] = array_merge($d,$dy);
|
||||
continue;
|
||||
} */
|
||||
|
||||
foreach ($details as $dx) {
|
||||
if (isset($dx["details"])) {
|
||||
$dy_details = $dx["details"];
|
||||
unset($dx["details"]);
|
||||
foreach ($dy_details as $dy_detail) {
|
||||
if (
|
||||
$d["title"] == "ANGGOTA GERAK" || $d["title"] == "MULUT" || $d["title"] == "JANTUNG"
|
||||
|| $d["title"] == "PERUT / ABDOMEN" || $d["title"] == "SISTEM PERSYARAFAN" || $d["title"] == "SISTEM INTEGUMEN"
|
||||
) {
|
||||
if ($dy_detail["chx"] == "1") {
|
||||
$dy_detail["value"] = $dy_detail["label"];
|
||||
$dy_detail["label"] = $dy_detail["segment_name"];
|
||||
$new_d[] = array_merge($d, $dx, $dy_detail);
|
||||
}
|
||||
}
|
||||
//if ($dy["value"] == "") continue;
|
||||
if (isset($dy_detail["unit"]) && isset($dy_detail["value"])) {
|
||||
$dy_detail["value"] = $dy_detail["value"] . " " . $dy_detail["unit"];
|
||||
}
|
||||
if ($d["title"] == "VISUS JAUH") {
|
||||
$dy_detail["kesimpulan"] = $kesimpulan_visus;
|
||||
}
|
||||
if ($d["title"] == "GIGI") {
|
||||
// if (!$have_gigi) {
|
||||
// $dy_detail["label"] = "kesimpulan";
|
||||
// $dy_detail["value"] = $this->hasil_gigi($dy_details);
|
||||
// $new_d[] = array_merge($d, $dx, $dy_detail);
|
||||
// }
|
||||
if ($kesimpulan_gigi != "" && !$is_gigi) {
|
||||
$is_gigi = true;
|
||||
$dy_detail["label"] = "kesimpulan";
|
||||
$dy_detail["value"] = $kesimpulan_gigi;
|
||||
$new_d[] = array_merge($d, $dx, $dy_detail);
|
||||
}
|
||||
$have_gigi = true;
|
||||
} else {
|
||||
$new_d[] = array_merge($d, $dx, $dy_detail);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($dx["value"] != "") {
|
||||
if (isset($dx["unit"]) && isset($dx["value"])) {
|
||||
$dx["value"] = $dx["value"];
|
||||
}
|
||||
$new_d[] = array_merge($d, $dx);
|
||||
}
|
||||
if ($dx["chx_y"] == 1) {
|
||||
$dx["value"] = $dx["label_y"];
|
||||
$new_d[] = array_merge($d, $dx);
|
||||
}
|
||||
if ($dx["chx_x"] == 1) {
|
||||
$dx["value"] = $dx["label_x"];
|
||||
$new_d[] = array_merge($d, $dx);
|
||||
}
|
||||
if ($dx["chx"] == 1) {
|
||||
$dx["value"] = $dx["label"] . " " . $d["value"];
|
||||
$new_d[] = array_merge($d, $dx);
|
||||
}
|
||||
}
|
||||
}
|
||||
//$new_r[] = $new_d;
|
||||
}
|
||||
}
|
||||
$x_d = usort($new_d, array("Fisik01", "cmp"));
|
||||
echo json_encode($new_d);
|
||||
}
|
||||
function hasil_gigi($da)
|
||||
{
|
||||
$arr_gigi = array();
|
||||
foreach ($da["details"] as $db) {
|
||||
foreach ($db["details"] as $dc) {
|
||||
$dc["value"] = strtoupper($dc["value"]);
|
||||
if ($dc["value"] != "" && isset($kode_gigi[$dc["value"]])) {
|
||||
$value = $kode_gigi[$dc["value"]];
|
||||
if (!isset($arr_gigi[$value])) $arr_gigi[$value] = array();
|
||||
$kode = $dc["id_code"];
|
||||
$pos = substr($kode, -1);
|
||||
|
||||
if (strpos($kode, "atas")) {
|
||||
if (strpos($kode, "kiri")) {
|
||||
$arr_gigi[$value][] = "└" . $pos;
|
||||
} else {
|
||||
$arr_gigi[$value][] = $pos . "┘";
|
||||
}
|
||||
} else {
|
||||
if (strpos($kode, "kiri")) {
|
||||
$arr_gigi[$value][] = "┌" . $pos;
|
||||
} else {
|
||||
$arr_gigi[$value][] = $pos . "┐";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$r_gigi = "";
|
||||
foreach ($arr_gigi as $v => $g) {
|
||||
if ($r_gigi != "") $r_gigi .= "\n";
|
||||
$r_gigi .= $v . " " . join(",", $g);
|
||||
}
|
||||
return $r_gigi;
|
||||
}
|
||||
function cmp($a, $b)
|
||||
{
|
||||
$a_key = substr($a["title"], 1, 3) . "-" . $a["label"];
|
||||
$b_key = substr($b["title"], 1, 3) . "-" . $b["label"];
|
||||
return strcmp($a_key, $b_key);
|
||||
}
|
||||
function json_single($headerID)
|
||||
{
|
||||
$sql = "select
|
||||
fn_global_patient_name(T_OrderHeaderM_PatientID) M_PatientName,
|
||||
fn_get_patient_atribute(T_OrderHeaderM_PatientID) attr,
|
||||
T_OrderHeaderDate,T_OrderHeaderLabNumber, T_OrderHeaderLabNumberExt,T_OrderHeaderM_PatientAge,
|
||||
' ' M_CompanyName, M_MouName,
|
||||
T_TestName,
|
||||
So_ResultEntryFisikUmumType,
|
||||
So_ResultEntryFisikUmumDetails
|
||||
from t_orderheader
|
||||
-- join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID= T_OrderHeaderID and T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_TestID = T_OrderDetailT_TestID and T_TestIsActive = 'Y' and T_TestNat_GroupID = '4'
|
||||
join so_resultentry on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID and So_ResultEntryT_OrderDetailID = T_OrderDetailID
|
||||
join so_resultentry_fisik_umum on So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
||||
where T_OrderHeaderID =?";
|
||||
$qry = $this->db->query($sql, array($headerID));
|
||||
if (!$qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode(array(
|
||||
"status" => "ERR",
|
||||
"message" => $db_err["message"]
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$data = array();
|
||||
echo "<pre>";
|
||||
$new_d = array();
|
||||
foreach ($rows as $r) {
|
||||
$attr = json_decode($r["attr"], true);
|
||||
unset($r["attr"]);
|
||||
$r_details = json_decode($r["So_ResultEntryFisikUmumDetails"], true);
|
||||
unset($r["So_ResultEntryFisikUmumDetails"]);
|
||||
$new_r = array();
|
||||
foreach ($r_details as $idx => $d) {
|
||||
$details = $d["details"];
|
||||
unset($d["details"]);
|
||||
$d["T_TestName"] = $r["T_TestName"];
|
||||
$d["T_OrderHeaderDate"] = $r["T_OrderHeaderDate"];
|
||||
$d["T_OrderHeaderLabNumber"] = $r["T_OrderHeaderLabNumber"];
|
||||
$d["T_OrderHeaderLabNumberExt"] = $r["T_OrderHeaderLabNumberExt"];
|
||||
$d["M_PatientName"] = $r["M_PatientName"];
|
||||
$d["M_PatientDOB"] = $attr["M_PatientDOB"];
|
||||
$d["M_PatientAge"] = $r["T_OrderHeaderM_PatientAge"];
|
||||
$d["M_SexName"] = $attr["M_SexName"];
|
||||
$d["M_CompanyName"] = $r["M_CompanyName"];
|
||||
$d["M_MouName"] = $r["M_MouName"];
|
||||
|
||||
$d["So_ResultEntryFisikUmumType"] = $r["So_ResultEntryFisikUmumType"];
|
||||
foreach ($details as $dx) {
|
||||
if (isset($dx["details"])) {
|
||||
$dy_details = $dx["details"];
|
||||
unset($dx["details"]);
|
||||
foreach ($dy_details as $dy_detail) {
|
||||
if (isset($dy_detail["unit"]) && isset($dy_detail["value"])) {
|
||||
$dy_detail["value"] = $dy_detail["value"];
|
||||
}
|
||||
$new_d[] = array_merge($d, $dx, $dy_detail);
|
||||
}
|
||||
} else {
|
||||
if (isset($dx["unit"]) && isset($dx["value"])) {
|
||||
$dx["value"] = $dx["value"];
|
||||
}
|
||||
$new_d[] = array_merge($d, $dx);
|
||||
}
|
||||
}
|
||||
$new_r[] = $new_d;
|
||||
}
|
||||
}
|
||||
print_r($new_d);
|
||||
}
|
||||
}
|
||||
196
application/controllers/v1/adhi/fisik/Fisik_id.php
Normal file
196
application/controllers/v1/adhi/fisik/Fisik_id.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
class Fisik_id extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Fisik 01";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
function json($id) {
|
||||
$start = $start . " 00:00:01";
|
||||
$end = $end . " 23:59:59";
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderLabNumber = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, array($id));
|
||||
if (! $qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode( array( "status" => "ERR",
|
||||
"message" => $db_err["message"]
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$sid = "0";
|
||||
foreach($rows as $r) {
|
||||
$sid .= ", " . $r["T_OrderHeaderID"];
|
||||
}
|
||||
$sql = "select
|
||||
fn_global_patient_name(T_OrderHeaderM_PatientID) M_PatientName,
|
||||
fn_get_patient_atribute(T_OrderHeaderM_PatientID) attr,
|
||||
T_OrderHeaderDate,T_OrderHeaderLabNumber, T_OrderHeaderLabNumberExt,T_OrderHeaderM_PatientAge,
|
||||
M_CompanyName, M_MouName,
|
||||
T_TestName,
|
||||
So_ResultEntryFisikUmumType,
|
||||
So_ResultEntryFisikUmumDetails
|
||||
from t_orderheader
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID= T_OrderHeaderID and T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_TestID = T_OrderDetailT_TestID and T_TestIsActive = 'Y' and T_TestNat_GroupID = '4'
|
||||
join so_resultentry on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID and So_ResultEntryT_OrderDetailID = T_OrderDetailID
|
||||
join so_resultentry_fisik_umum on So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
||||
where T_OrderHeaderID in ($sid) order by So_ResultEntryFisikUmumID ";
|
||||
$qry = $this->db->query($sql, array($headerID));
|
||||
if (! $qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode( array( "status" => "ERR",
|
||||
"message" => $db_err["message"]
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$data = array();
|
||||
$new_d = array();
|
||||
$a_title = array();
|
||||
foreach($rows as $r) {
|
||||
$attr = json_decode($r["attr"],true);
|
||||
unset($r["attr"]);
|
||||
$r_details = json_decode($r["So_ResultEntryFisikUmumDetails"],true);
|
||||
unset($r["So_ResultEntryFisikUmumDetails"]);
|
||||
//$new_r = array();
|
||||
foreach($r_details as $idx => $d) {
|
||||
$details = $d["details"];
|
||||
unset($d["details"]);
|
||||
$d["T_TestName"] = $r["T_TestName"];
|
||||
$d["T_OrderHeaderDate"] = $r["T_OrderHeaderDate"];
|
||||
$d["T_OrderHeaderLabNumber"] = $r["T_OrderHeaderLabNumber"];
|
||||
$d["T_OrderHeaderLabNumberExt"] = $r["T_OrderHeaderLabNumberExt"];
|
||||
$d["M_PatientName"] = $r["M_PatientName"];
|
||||
$d["M_PatientDOB"] = $attr["M_PatientDOB"];
|
||||
$d["M_PatientAge"] = $r["T_OrderHeaderM_PatientAge"];
|
||||
$d["M_SexName"] = $attr["M_SexName"];
|
||||
$d["M_CompanyName"] = $r["M_CompanyName"];
|
||||
$d["M_MouName"] = $r["M_MouName"];
|
||||
|
||||
$d["So_ResultEntryFisikUmumType"] = $r["So_ResultEntryFisikUmumType"];
|
||||
foreach($details as $dx) {
|
||||
if (isset($dx["details"])) {
|
||||
$dy_details = $dx["details"];
|
||||
unset($dx["details"]);
|
||||
foreach($dy_details as $dy_detail) {
|
||||
if ($d["title"] == "ANGGOTA GERAK") {
|
||||
if ($dy_detail["chx"] == "1" ) {
|
||||
$dy_detail["value"] = $dy_detail["label"];
|
||||
$new_d[] = array_merge($d,$dx,$dy_detail);
|
||||
}
|
||||
}
|
||||
if ($dy["value"] == "") continue;
|
||||
if(isset($dy_detail["unit"]) && isset($dy_detail["value"])) {
|
||||
$dy_detail["value"] = $dy_detail["value"] . " " . $dy_detail["unit"];
|
||||
}
|
||||
$new_d[] = array_merge($d,$dx,$dy_detail);
|
||||
}
|
||||
} else {
|
||||
if ($dx["value"] == "") continue;
|
||||
if(isset($dx["unit"]) && isset($dx["value"])) {
|
||||
$dx["value"] = $dx["value"] . " " . $dx["unit"];
|
||||
}
|
||||
$new_d[] = array_merge($d,$dx);
|
||||
}
|
||||
}
|
||||
//$new_r[] = $new_d;
|
||||
}
|
||||
}
|
||||
$x_d = usort($new_d, array("Fisik01","cmp"));
|
||||
// echo "<pre>"; print_r($new_d);
|
||||
echo json_encode($new_d);
|
||||
}
|
||||
function cmp($a,$b) {
|
||||
$a_key = substr($a["title"],1,3) . "-" . $a["label"];
|
||||
$b_key = substr($b["title"],1,3) . "-" . $b["label"];
|
||||
return strcmp($a_key, $b_key);
|
||||
}
|
||||
function json_single($headerID) {
|
||||
$sql = "select
|
||||
fn_global_patient_name(T_OrderHeaderM_PatientID) M_PatientName,
|
||||
fn_get_patient_atribute(T_OrderHeaderM_PatientID) attr,
|
||||
T_OrderHeaderDate,T_OrderHeaderLabNumber, T_OrderHeaderLabNumberExt,T_OrderHeaderM_PatientAge,
|
||||
M_CompanyName, M_MouName,
|
||||
T_TestName,
|
||||
So_ResultEntryFisikUmumType,
|
||||
So_ResultEntryFisikUmumDetails
|
||||
from t_orderheader
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID= T_OrderHeaderID and T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_TestID = T_OrderDetailT_TestID and T_TestIsActive = 'Y' and T_TestNat_GroupID = '4'
|
||||
join so_resultentry on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID and So_ResultEntryT_OrderDetailID = T_OrderDetailID
|
||||
join so_resultentry_fisik_umum on So_ResultEntryFisikUmumSo_ResultEntryID = So_ResultEntryID
|
||||
where T_OrderHeaderID =?";
|
||||
$qry = $this->db->query($sql, array($headerID));
|
||||
if (! $qry) {
|
||||
//Error Query
|
||||
$db_err = $this->db->error();
|
||||
echo json_encode( array( "status" => "ERR",
|
||||
"message" => $db_err["message"]
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$data = array();
|
||||
$new_d = array();
|
||||
foreach($rows as $r) {
|
||||
$attr = json_decode($r["attr"],true);
|
||||
unset($r["attr"]);
|
||||
$r_details = json_decode($r["So_ResultEntryFisikUmumDetails"],true);
|
||||
unset($r["So_ResultEntryFisikUmumDetails"]);
|
||||
$new_r = array();
|
||||
foreach($r_details as $idx => $d) {
|
||||
$details = $d["details"];
|
||||
unset($d["details"]);
|
||||
$d["T_TestName"] = $r["T_TestName"];
|
||||
$d["T_OrderHeaderDate"] = $r["T_OrderHeaderDate"];
|
||||
$d["T_OrderHeaderLabNumber"] = $r["T_OrderHeaderLabNumber"];
|
||||
$d["T_OrderHeaderLabNumberExt"] = $r["T_OrderHeaderLabNumberExt"];
|
||||
$d["M_PatientName"] = $r["M_PatientName"];
|
||||
$d["M_PatientDOB"] = $attr["M_PatientDOB"];
|
||||
$d["M_PatientAge"] = $r["T_OrderHeaderM_PatientAge"];
|
||||
$d["M_SexName"] = $attr["M_SexName"];
|
||||
$d["M_CompanyName"] = $r["M_CompanyName"];
|
||||
$d["M_MouName"] = $r["M_MouName"];
|
||||
|
||||
$d["So_ResultEntryFisikUmumType"] = $r["So_ResultEntryFisikUmumType"];
|
||||
foreach($details as $dx) {
|
||||
if (isset($dx["details"])) {
|
||||
$dy_details = $dx["details"];
|
||||
unset($dx["details"]);
|
||||
foreach($dy_details as $dy_detail) {
|
||||
if(isset($dy_detail["unit"]) && isset($dy_detail["value"])) {
|
||||
$dy_detail["value"] = $dy_detail["value"] . " " . $dy_detail["unit"];
|
||||
}
|
||||
$new_d[] = array_merge($d,$dx,$dy_detail);
|
||||
}
|
||||
} else {
|
||||
if(isset($dx["unit"]) && isset($dx["value"])) {
|
||||
$dx["value"] = $dx["value"] . " " . $dx["unit"];
|
||||
}
|
||||
$new_d[] = array_merge($d,$dx);
|
||||
}
|
||||
}
|
||||
$new_r[] = $new_d;
|
||||
}
|
||||
}
|
||||
print_r($new_d);
|
||||
}
|
||||
|
||||
}
|
||||
1155
application/controllers/v1/adhi/fisik/sample.json
Normal file
1155
application/controllers/v1/adhi/fisik/sample.json
Normal file
File diff suppressed because it is too large
Load Diff
1332
application/controllers/v1/db
Normal file
1332
application/controllers/v1/db
Normal file
File diff suppressed because it is too large
Load Diff
451
application/controllers/v1/fo/Register.php
Normal file
451
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
application/controllers/v1/fo/Register_old.php
Normal file
432
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");
|
||||
}
|
||||
}
|
||||
?>
|
||||
146
application/controllers/v1/itf/Portserver.php
Normal file
146
application/controllers/v1/itf/Portserver.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
class Portserver extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_one = $this->load->database("onedev", true);
|
||||
}
|
||||
function raw() {
|
||||
$param = $this->sys_input;
|
||||
try {
|
||||
$instrumentID = $param["instrumentID"];
|
||||
$data = $param["data"];
|
||||
$sql = "insert into itf_raw(itf_RawNat_InstrumentID,itf_RawData)
|
||||
values(?,?)";
|
||||
$this->db_one->query($sql, array($instrumentID, base64_decode($data)));
|
||||
echo json_encode(
|
||||
array("status" => "OK" , "id" => $this->db_one->insert_id() , "message" => "")
|
||||
);
|
||||
} catch(exception $e) {
|
||||
echo json_encode(
|
||||
array("status" => "ERR" , "id" => 0, "message" => $e.message() )
|
||||
);
|
||||
}
|
||||
}
|
||||
function result() {
|
||||
$param = $this->sys_input;
|
||||
try {
|
||||
$instrumentID = $param["instrumentID"];
|
||||
$rawID = $param["rawID"];
|
||||
$result= $param["result"];
|
||||
$noreg = $result["nolab"];
|
||||
$sql = "insert into itf_result(itf_ResultNat_InstrumentID, itf_ResultItf_RawID,
|
||||
Itf_ResultNoreg, Itf_ResultInstrumentDate, itf_ResultKode, itf_ResultResult, itf_ResultFlag)
|
||||
values(?,?,?,?,?,?,?)";
|
||||
foreach($result["result"] as $r) {
|
||||
$tgl = $r["date"];
|
||||
$px = $r["px"];
|
||||
$result = $r["result"];
|
||||
$this->db_one->query($sql,
|
||||
array($instrumentID, $rawID, $noreg, $tgl , $px,
|
||||
$result,$r["flag"]));
|
||||
}
|
||||
if ($instrumentID == 1) {
|
||||
$sql = "call sp_itf_result_alinity(?)";
|
||||
} else {
|
||||
$sql = "call sp_itf_result(?)";
|
||||
}
|
||||
$this->db->query($sql, array($rawID));
|
||||
|
||||
// auto calc
|
||||
$s_noreg = substr($noreg,0,10);
|
||||
$sql = "select T_OrderHeaderID from t_orderheader where T_OrderHeaderLabNumber = ? ";
|
||||
$qry = $this->db->query($sql,array($s_noreg));
|
||||
$order_id = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$order_id = $rows[0]["T_OrderHeaderID"];
|
||||
$this->load->library("Resultcalc");
|
||||
$this->resultcalc->auto($order_id);
|
||||
//file_put_contents("/xtmp/re-query.sql",$order_id);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(
|
||||
array("status" => "OK" , "message" => "")
|
||||
);
|
||||
} catch(exception $e) {
|
||||
echo json_encode(
|
||||
array("status" => "ERR" , "message" => $e->message() )
|
||||
);
|
||||
}
|
||||
}
|
||||
function order() {
|
||||
$param = $this->sys_input;
|
||||
$sampleID = $param["sampleID"];
|
||||
$instrumentID = $param["instrumentID"];
|
||||
$sql = "call sp_itf_order(?,?)";
|
||||
try {
|
||||
$qry = $this->db->query($sql, array($instrumentID,$sampleID));
|
||||
if (isset($qry->result_id->num_rows)) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode(
|
||||
array("status" => "OK" , "order" => $rows)
|
||||
);
|
||||
} else {
|
||||
echo json_encode(
|
||||
array("status" => "OK" , "order" => array())
|
||||
);
|
||||
}
|
||||
} catch(exception $e) {
|
||||
echo json_encode(
|
||||
array("status" => "ERR" , "message" => $e->message() )
|
||||
);
|
||||
}
|
||||
}
|
||||
function update_order() {
|
||||
$param = $this->sys_input;
|
||||
$sampleID = $param["sampleID"];
|
||||
$instrumentID = $param["instrumentID"];
|
||||
$status = $param["status"];
|
||||
$sql = "call sp_itf_order_update(?,?,?)";
|
||||
try {
|
||||
$qry = $this->db->query($sql, array($instrumentID,$sampleID,$status));
|
||||
if ($qry) {
|
||||
echo json_encode(
|
||||
array("status" => "OK" , "message" => "")
|
||||
);
|
||||
} else {
|
||||
$msg = print_r($this->db->error(),true);
|
||||
echo json_encode(
|
||||
array("status" => "OK" , "message" => $msg )
|
||||
);
|
||||
}
|
||||
} catch(exception $e) {
|
||||
echo json_encode(
|
||||
array("status" => "ERR" , "message" => $e->message() )
|
||||
);
|
||||
}
|
||||
}
|
||||
function reset_order() {
|
||||
$param = $this->sys_input;
|
||||
$sampleID = $param["sampleID"];
|
||||
$instrumentID = $param["instrumentID"];
|
||||
$status = $param["status"];
|
||||
$sql = "call sp_itf_order_reset(?,?,?)";
|
||||
try {
|
||||
$qry = $this->db->query($sql, array($instrumentID,$sampleID,$status));
|
||||
if ($qry) {
|
||||
echo json_encode(
|
||||
array("status" => "OK" , "message" => "")
|
||||
);
|
||||
} else {
|
||||
$msg = print_r($this->db->error(),true);
|
||||
echo json_encode(
|
||||
array("status" => "OK" , "message" => $msg )
|
||||
);
|
||||
}
|
||||
} catch(exception $e) {
|
||||
echo json_encode(
|
||||
array("status" => "ERR" , "message" => $e->message() )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
226
application/controllers/v1/master/Bank.php
Normal file
226
application/controllers/v1/master/Bank.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/*
|
||||
### Bank API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
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 Bank extends MY_Controller {
|
||||
function index() {
|
||||
echo "Bank Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 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);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_bank
|
||||
where M_BankName like ? and M_BankIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_bank count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. 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_bank
|
||||
where M_BankName like ? and M_BankIsActive='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_bank rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_BankCode harus belum ada
|
||||
$sql = "select count(*) tot
|
||||
from m_bank
|
||||
where M_BankIsActive='Y' and M_BankCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_BankCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "BankCode : " . $prm["M_BankCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_bank bankCode validation");
|
||||
exit;
|
||||
}
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_bank(M_BankCode, M_BankName, M_BankAddress, M_BankBranch, M_BankHISDefault,
|
||||
M_BankUserID, M_BankLastUpdate) values( ?, ?, ?, ?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_BankCode"], $prm["M_BankName"], $prm["M_BankAddress"], $prm["M_BankBranch"], $prm["M_BankHisIsDefault"],
|
||||
$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_bank insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_bank
|
||||
set M_BankCode = ? , M_BankName = ?, M_BankAddress = ? , M_BankBranch = ?, M_BankHISDefault = ?,
|
||||
M_BankLastUpdate = now() , M_BankUserID = ?
|
||||
where M_BankID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_BankCode"], $prm["M_BankName"], $prm["M_BankAddress"], $prm["M_BankBranch"], $prm["M_BankHISDefault"],
|
||||
$tokenM_UserID, $prm["M_BankID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_bank update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_bank
|
||||
set M_BankIsActive = 'N', M_BankLastUpdate = now(),
|
||||
M_BankUserID = ?
|
||||
where M_BankID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_BankID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_bank delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
209
application/controllers/v1/master/Pamorfology.php
Normal file
209
application/controllers/v1/master/Pamorfology.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/*
|
||||
### Sex API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
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 Pamorfology extends MY_Controller {
|
||||
function index() {
|
||||
echo "Pamorfology Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 25;
|
||||
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);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from pa_morfology
|
||||
where Pa_MorfologyName like ? and Pa_MorfologyIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. 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 pa_morfology
|
||||
where Pa_MorfologyName like ? and Pa_MorfologyIsActive='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("pa_morfology rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["Pa_MorfologyUserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into pa_morfology(Pa_MorfologyName, Pa_MorfologyUserID, Pa_MorfologyLastUpdate) values( ?,?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["Pa_MorfologyName"],$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("pa_morfology insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["Pa_MorfologyUserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update pa_morfology
|
||||
set Pa_MorfologyName = ?,
|
||||
Pa_MorfologyLastUpdate = now() , Pa_MorfologyUserID = ?
|
||||
where Pa_MorfologyID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["Pa_MorfologyName"],
|
||||
$tokenM_UserID, $prm["Pa_MorfologyID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["Pa_MorfologyUserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update pa_morfology
|
||||
set Pa_MorfologyIsActive = 'N', Pa_MorfologyLastUpdate = now(),
|
||||
Pa_MorfologyUserID = ?
|
||||
where Pa_MorfologyID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["Pa_MorfologyID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
95
application/controllers/v1/master/Province.php
Normal file
95
application/controllers/v1/master/Province.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Province extends MY_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
|
||||
// $this->sys_debug();
|
||||
try
|
||||
{
|
||||
// Token validation
|
||||
if (! $this->isLogin)
|
||||
{
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Getting inputs
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
// Predefined values
|
||||
$row_per_page = 25;
|
||||
$page = 1;
|
||||
$tot_count = 0;
|
||||
|
||||
$sqlc = "SELECT COUNT(*) as n
|
||||
FROM m_province
|
||||
WHERE M_ProvinceName LIKE ? AND M_ProvinceIsActive='Y'";
|
||||
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
|
||||
$sql_param = array($s_query);
|
||||
|
||||
// Getting total rows
|
||||
$sql = $sqlc;
|
||||
$query = $this->db->query($sql, $sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->row()->n;
|
||||
} else {
|
||||
$this->sys_error_db("m_sex count");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Getting records if count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0)
|
||||
{
|
||||
// Start_limit < 0 ? > 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_province
|
||||
WHERE M_ProvinceName like ? and M_ProvinceIsActive='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_sex rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
|
||||
catch(Exception $exc)
|
||||
{
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
229
application/controllers/v1/master/Religion.php
Normal file
229
application/controllers/v1/master/Religion.php
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/*
|
||||
### Religion API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
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 Religion extends MY_Controller {
|
||||
function index() {
|
||||
echo "Religion Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 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);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_religion
|
||||
where M_ReligionName like ? and M_ReligionIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_religion count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. 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_religion
|
||||
where M_ReligionName like ? and M_ReligionIsActive='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_religion rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_ReligionCode harus belum ada
|
||||
/*
|
||||
$sql = "select count(*) tot
|
||||
from m_religion
|
||||
where M_ReligionIsActive='Y' and M_ReligionCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_ReligionCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "ReligionCode : " . $prm["M_ReligionCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_religion religionCode validation");
|
||||
exit;
|
||||
}
|
||||
|
||||
*/
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_religion(M_ReligionName, M_ReligionHISDefault,
|
||||
M_ReligionUserID, M_ReligionLastUpdate) values(?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_ReligionName"], $prm["M_ReligionHISDefault"],
|
||||
$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_religion insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_religion
|
||||
set M_ReligionName = ?, M_ReligionHISDefault = ?,
|
||||
M_ReligionLastUpdate = now() , M_ReligionUserID = ?
|
||||
where M_ReligionID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_ReligionName"], $prm["M_ReligionHISDefault"],
|
||||
$tokenM_UserID, $prm["M_ReligionID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_religion update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_religion
|
||||
set M_ReligionIsActive = 'N', M_ReligionLastUpdate = now(),
|
||||
M_ReligionUserID = ?
|
||||
where M_ReligionID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_ReligionID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_religion delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
226
application/controllers/v1/master/Sex.php
Normal file
226
application/controllers/v1/master/Sex.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/*
|
||||
### Sex API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
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 Sex extends MY_Controller {
|
||||
function index() {
|
||||
echo "Sex Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 25;
|
||||
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);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_sex
|
||||
where M_SexName like ? and M_SexIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_sex count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. 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_sex
|
||||
where M_SexName like ? and M_SexIsActive='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_sex rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_SexCode harus belum ada
|
||||
$sql = "select count(*) tot
|
||||
from m_sex
|
||||
where M_SexIsActive='Y' and M_SexCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_SexCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "SexCode : " . $prm["M_SexCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_sex sexCode validation");
|
||||
exit;
|
||||
}
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_sex(M_SexCode, M_SexName, M_SexHISDefault,
|
||||
M_SexUserID, M_SexLastUpdate) values( ?, ?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_SexCode"], $prm["M_SexName"], $prm["M_SexHisIsDefault"],
|
||||
$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_sex insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_sex
|
||||
set M_SexCode = ? , M_SexName = ?, M_SexHISDefault = ?,
|
||||
M_SexLastUpdate = now() , M_SexUserID = ?
|
||||
where M_SexID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_SexCode"], $prm["M_SexName"], $prm["M_SexHISDefault"],
|
||||
$tokenM_UserID, $prm["M_SexID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_sex update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_sex
|
||||
set M_SexIsActive = 'N', M_SexLastUpdate = now(),
|
||||
M_SexUserID = ?
|
||||
where M_SexID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_SexID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_sex delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
231
application/controllers/v1/master/Title.php
Normal file
231
application/controllers/v1/master/Title.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/*
|
||||
### Title API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
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 Title extends MY_Controller {
|
||||
function index() {
|
||||
echo "Title Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
$s_query2 = "%" . $prm["query2"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 25;
|
||||
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,$s_query2);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_title
|
||||
left join m_sex on M_TitleM_SexID = M_SexID
|
||||
where M_TitleName like ? and M_SexName like ? and M_TitleIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_title count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. 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 *, M_SexName
|
||||
from m_title
|
||||
left join m_sex on M_TitleM_SexID = M_SexID
|
||||
where M_TitleName like ? and M_SexName like ? and M_TitleIsActive='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_title rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_TitleCode harus belum ada
|
||||
/*
|
||||
$sql = "select count(*) tot
|
||||
from m_title
|
||||
where M_TitleIsActive='Y' and M_TitleCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_TitleCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "TitleCode : " . $prm["M_TitleCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_title titleCode validation");
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_title(M_TitleM_SexID, M_TitleName, M_TitleHISDefault,
|
||||
M_TitleUserID, M_TitleLastUpdate) values( ?, ?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_TitleM_SexID"], $prm["M_TitleName"], $prm["M_TitleHISDefault"],
|
||||
$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_title insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_title
|
||||
set M_TitleM_SexID = ? , M_TitleName = ?, M_TitleHISDefault = ?,
|
||||
M_TitleLastUpdate = now() , M_TitleUserID = ?
|
||||
where M_TitleID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_TitleM_SexID"], $prm["M_TitleName"], $prm["M_TitleHISDefault"],
|
||||
$tokenM_UserID, $prm["M_TitleID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_title update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_title
|
||||
set M_TitleIsActive = 'N', M_TitleLastUpdate = now(),
|
||||
M_TitleUserID = ?
|
||||
where M_TitleID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_TitleID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_title delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
878
application/controllers/v1/masterdata/Advicefisik.php
Normal file
878
application/controllers/v1/masterdata/Advicefisik.php
Normal file
@@ -0,0 +1,878 @@
|
||||
<?php
|
||||
|
||||
class Advicefisik extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ABNORMAL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupfisikbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from m_advice_fisik
|
||||
WHERE
|
||||
M_AdviceFisikIsActive = 'Y' AND
|
||||
M_AdviceFisikLabel like '%{$name}%'
|
||||
GROUP BY M_AdviceFisikID) a";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//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("m_advice_fisik count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT m_advice_fisik.*,
|
||||
M_AdviceFisikID as id
|
||||
from m_advice_fisik
|
||||
WHERE
|
||||
M_AdviceFisikIsActive = 'Y' AND
|
||||
M_AdviceFisikLabel like '%{$name}%'
|
||||
GROUP BY M_AdviceFisikID
|
||||
ORDER BY M_AdviceFisikLabel ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("m_advice_fisik select");
|
||||
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 lookupadvicebyid(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$status = $prm['status'];
|
||||
$all = $prm['all'];
|
||||
$filter = '';
|
||||
if($status != 'A'){
|
||||
$filter .= "AND status = '{$status}' ";
|
||||
}else{
|
||||
$filter .= "";
|
||||
}
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *, IF(IFNULL(Nat_AdvicefisikID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_fisik ON Nat_AdviceID = Nat_AdvicefisikNat_AdviceID AND Nat_AdvicefisikM_AdviceFisikID = $id AND Nat_AdvicefisikIsActive = 'Y'
|
||||
LEFT JOIN m_advice_fisik ON Nat_AdvicefisikM_AdviceFisikID = M_AdviceFisikID AND M_AdviceFisikIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' GROUP BY Nat_AdviceID) a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select Nat_AdviceID as id,
|
||||
Nat_AdviceID,
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdvicefisikID,
|
||||
M_AdviceFisikCode,
|
||||
M_AdviceFisikLabel,
|
||||
Nat_AdvicefisikM_AdviceFisikID,
|
||||
Nat_AdvicefisikNat_AdviceID,
|
||||
IF(IFNULL(Nat_AdvicefisikID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_fisik ON Nat_AdviceID = Nat_AdvicefisikNat_AdviceID AND Nat_AdvicefisikM_AdviceFisikID = $id AND Nat_AdvicefisikIsActive = 'Y'
|
||||
LEFT JOIN m_advice_fisik ON Nat_AdvicefisikM_AdviceFisikID = M_AdviceFisikID AND M_AdviceFisikIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y') a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter
|
||||
GROUP BY Nat_AdviceID
|
||||
ORDER BY Nat_AdviceID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_advice select");
|
||||
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 listingadvice(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'
|
||||
ORDER BY Nat_AdviceID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_advice select");
|
||||
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 getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM m_advice_fisiktype
|
||||
WHERE
|
||||
M_AdviceFisikTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['minageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['maxageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$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
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getstatus(){
|
||||
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
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function addnewfisik()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into m_advice_fisik(
|
||||
M_AdviceFisikCode,
|
||||
M_AdviceFisikLabel,
|
||||
M_AdviceFisikUserID,
|
||||
M_AdviceFisikCreated,
|
||||
M_AdviceFisikLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function editfisik(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE m_advice_fisik SET
|
||||
M_AdviceFisikCode = '{$prm['code']}',
|
||||
M_AdviceFisikLabel = '{$prm['name']}',
|
||||
M_AdviceFisikUserID = {$userid}
|
||||
WHERE
|
||||
M_AdviceFisikID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
public function addnewadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$fisikid = $prm['fisikid'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into nat_advice(
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdviceUserID,
|
||||
Nat_AdviceCreated,
|
||||
Nat_AdviceLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$adviceina,
|
||||
$adviceeng,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function saveaddeditadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$fisikid = $prm['fisikid'];
|
||||
$adviceid = $prm['Nat_AdviceID'];
|
||||
$advicefisikid = $prm['Nat_AdvicefisikID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into nat_advice_fisik(
|
||||
Nat_AdvicefisikM_AdviceFisikID,
|
||||
Nat_AdvicefisikNat_AdviceID,
|
||||
Nat_AdvicefisikUserID,
|
||||
Nat_AdvicefisikCreated,
|
||||
Nat_AdvicefisikLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fisikid,
|
||||
$adviceid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_fisik insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}else{
|
||||
$sql = "UPDATE nat_advice_fisik SET
|
||||
Nat_AdvicefisikIsActive = 'N',
|
||||
Nat_AdvicefisikUserID = ?,
|
||||
Nat_AdvicefisikCreated = now(),
|
||||
Nat_AdvicefisikLastUpdated = now()
|
||||
WHERE Nat_AdvicefisikID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$advicefisikid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_fisik insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveeditsaran(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_advice SET
|
||||
Nat_AdviceIna = '{$prm['ina']}',
|
||||
Nat_AdviceEng = '{$prm['eng']}',
|
||||
Nat_AdviceIsActive = '{$prm['status']}',
|
||||
Nat_AdviceUserID = {$userid}
|
||||
WHERE
|
||||
Nat_AdviceID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
function savealladvice(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$details = $prm['details'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach($details as $k => $v){
|
||||
$query = "UPDATE nat_advice_fisik SET
|
||||
Nat_AdvicefisikM_AdviceFisikID = '{$v['Nat_AdvicefisikM_AdviceFisikID']}',
|
||||
Nat_AdvicefisikAdviceIna = '{$v['Nat_AdvicefisikAdviceIna']}',
|
||||
Nat_AdvicefisikAdviceEng = '{$v['Nat_AdvicefisikAdviceEng']}',
|
||||
Nat_AdvicefisikUserID = {$userid},
|
||||
Nat_AdvicefisikCreated = now(),
|
||||
Nat_AdvicefisikLastUpdated = now()
|
||||
WHERE Nat_AdvicefisikID = {$v['Nat_AdvicefisikID']}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
public function deletefisik()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update m_advice_fisik SET
|
||||
M_AdviceFisikIsActive = 'N'
|
||||
WHERE
|
||||
M_AdviceFisikID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update nat_advice_fisik SET
|
||||
Nat_AdvicefisikIsActive = 'N'
|
||||
WHERE
|
||||
Nat_AdvicefisikM_AdviceFisikID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_fisik delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deleteadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update m_advice_fisik SET
|
||||
M_AdviceFisikIsActive = 'N'
|
||||
WHERE
|
||||
M_AdviceFisikID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchfisik(){
|
||||
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 nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = '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("nat_methode count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName 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("nat_methode rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchfisikbyname(){
|
||||
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 nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = '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("nat_methode count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName 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("nat_methode rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = '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("t_test count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
ORDER BY T_TestName 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
863
application/controllers/v1/masterdata/Advicekelainan.php
Normal file
863
application/controllers/v1/masterdata/Advicekelainan.php
Normal file
@@ -0,0 +1,863 @@
|
||||
<?php
|
||||
|
||||
class Advicekelainan extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ABNORMAL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db_onedev = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupkelainanbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from mcu_kelainan
|
||||
WHERE
|
||||
Mcu_KelainanIsActive = 'Y' AND
|
||||
Mcu_KelainanName like '%{$name}%'
|
||||
GROUP BY Mcu_KelainanID) a";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//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("mcu_kelainan count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT mcu_kelainan.*,
|
||||
Mcu_KelainanID as id
|
||||
from mcu_kelainan
|
||||
WHERE
|
||||
Mcu_KelainanIsActive = 'Y' AND
|
||||
Mcu_KelainanName like '%{$name}%'
|
||||
GROUP BY Mcu_KelainanID
|
||||
ORDER BY Mcu_KelainanName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("mcu_kelainan select");
|
||||
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 lookupadvicebyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$status = $prm['status'];
|
||||
$all = $prm['all'];
|
||||
$filter = '';
|
||||
if ($status != 'A') {
|
||||
$filter .= "AND status = '{$status}' ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *, IF(IFNULL(Nat_AdvicekelainanID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_kelainan ON Nat_AdviceID = Nat_AdvicekelainanNat_AdviceID AND Nat_AdvicekelainanMcu_KelainanID = $id AND Nat_AdvicekelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_kelainan ON Nat_AdvicekelainanMcu_KelainanID = Mcu_KelainanID AND Mcu_KelainanIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' GROUP BY Nat_AdviceID) a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select Nat_AdviceID as id,
|
||||
Nat_AdviceID,
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdvicekelainanID,
|
||||
Mcu_KelainanClasification,
|
||||
Mcu_KelainanName,
|
||||
Nat_AdvicekelainanMcu_KelainanID,
|
||||
Nat_AdvicekelainanNat_AdviceID,
|
||||
IF(IFNULL(Nat_AdvicekelainanID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_kelainan ON Nat_AdviceID = Nat_AdvicekelainanNat_AdviceID AND Nat_AdvicekelainanMcu_KelainanID = $id AND Nat_AdvicekelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_kelainan ON Nat_AdvicekelainanMcu_KelainanID = Mcu_KelainanID AND Mcu_KelainanIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y') a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter
|
||||
GROUP BY Nat_AdviceID
|
||||
ORDER BY Nat_AdviceID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_advice select");
|
||||
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 listingadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'
|
||||
ORDER BY Nat_AdviceID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_advice select");
|
||||
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 getsexreg()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query = " SELECT *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_advice_fisiktype
|
||||
WHERE
|
||||
M_AdviceFisikTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['minageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['maxageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = "
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = "
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$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
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getstatus()
|
||||
{
|
||||
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
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function addnewkelainan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into mcu_kelainan(
|
||||
Mcu_KelainanClasification,
|
||||
Mcu_KelainanName,
|
||||
M_AdviceKelainanUserID,
|
||||
Mcu_KelainanCreated,
|
||||
Mcu_KelainanLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function editkelainan()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE mcu_kelainan SET
|
||||
Mcu_KelainanClasification = '{$prm['code']}',
|
||||
Mcu_KelainanName = '{$prm['name']}',
|
||||
M_AdviceKelainanUserID = {$userid}
|
||||
WHERE
|
||||
Mcu_KelainanID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function addnewadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$kelainanid = $prm['kelainanid'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into nat_advice(
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdviceUserID,
|
||||
Nat_AdviceCreated,
|
||||
Nat_AdviceLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$adviceina,
|
||||
$adviceeng,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function saveaddeditadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$kelainanid = $prm['kelainanid'];
|
||||
$adviceid = $prm['Nat_AdviceID'];
|
||||
$advicekelainanid = $prm['Nat_AdvicekelainanID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($status == 'Y') {
|
||||
$sql = "insert into nat_advice_kelainan(
|
||||
Nat_AdvicekelainanMcu_KelainanID,
|
||||
Nat_AdvicekelainanNat_AdviceID,
|
||||
Nat_AdvicekelainanUserID,
|
||||
Nat_AdvicekelainanCreated,
|
||||
Nat_AdvicekelainanLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$kelainanid,
|
||||
$adviceid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanIsActive = 'N',
|
||||
Nat_AdvicekelainanUserID = ?,
|
||||
Nat_AdvicekelainanCreated = now(),
|
||||
Nat_AdvicekelainanLastUpdated = now()
|
||||
WHERE Nat_AdvicekelainanID = ?";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$userid,
|
||||
$advicekelainanid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveeditsaran()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_advice SET
|
||||
Nat_AdviceIna = '{$prm['ina']}',
|
||||
Nat_AdviceEng = '{$prm['eng']}',
|
||||
Nat_AdviceIsActive = '{$prm['status']}',
|
||||
Nat_AdviceUserID = {$userid}
|
||||
WHERE
|
||||
Nat_AdviceID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function savealladvice()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$details = $prm['details'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach ($details as $k => $v) {
|
||||
$query = "UPDATE nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanMcu_KelainanID = '{$v['Nat_AdvicekelainanMcu_KelainanID']}',
|
||||
Nat_AdvicefisikAdviceIna = '{$v['Nat_AdvicefisikAdviceIna']}',
|
||||
Nat_AdvicefisikAdviceEng = '{$v['Nat_AdvicefisikAdviceEng']}',
|
||||
Nat_AdvicekelainanUserID = {$userid},
|
||||
Nat_AdvicekelainanCreated = now(),
|
||||
Nat_AdvicekelainanLastUpdated = now()
|
||||
WHERE Nat_AdvicekelainanID = {$v['Nat_AdvicekelainanID']}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function deletekelainan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update mcu_kelainan SET
|
||||
Mcu_KelainanIsActive = 'N'
|
||||
WHERE
|
||||
Mcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanIsActive = 'N'
|
||||
WHERE
|
||||
Nat_AdvicekelainanMcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deleteadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update mcu_kelainan SET
|
||||
Mcu_KelainanIsActive = 'N'
|
||||
WHERE
|
||||
Mcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchkelainan()
|
||||
{
|
||||
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 nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = '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("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName 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("nat_methode rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelainanbyname()
|
||||
{
|
||||
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 nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = '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("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName 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("nat_methode rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = '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("t_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
ORDER BY T_TestName 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
523
application/controllers/v1/masterdata/Bahan.php
Normal file
523
application/controllers/v1/masterdata/Bahan.php
Normal file
@@ -0,0 +1,523 @@
|
||||
<?php
|
||||
|
||||
class Bahan extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "BAHAN API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
|
||||
function lookupsampletype(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select Nat_SampleTypeID as id,
|
||||
Nat_SampleTypeNat_BahanID as bahanid,
|
||||
Nat_SampleTypeCode as code,
|
||||
Nat_SampleTypeName as name,
|
||||
Nat_SampleTypeSuffix as suffix,
|
||||
'xxx' as action
|
||||
from nat_sampletype
|
||||
where
|
||||
Nat_SampleTypeNat_BahanID = {$id} AND Nat_SampleTypeIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_bahan
|
||||
where
|
||||
Nat_BahanIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select Nat_BahanID as id, Nat_BahanCode as code, Nat_BahanName as name, CONCAT('[ ',Nat_BahanCode,' ]',' ', Nat_BahanName) as description , 'xxx' as bahansampletype
|
||||
from nat_bahan
|
||||
where
|
||||
( Nat_BahanCode LIKE CONCAT('%','{$search}','%') OR
|
||||
Nat_BahanName LIKE CONCAT('%','{$search}','%')
|
||||
)AND
|
||||
Nat_BahanIsActive = 'Y' $limit";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_bahan select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code_bahan = $prm['code'];
|
||||
$name_bahan = $prm['name'];
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanCode = '{$code_bahan}'";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanName = '{$name_bahan}'";
|
||||
$exist_name = $this->db->query($query)->row()->exist;
|
||||
//echo $exist_name;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into nat_bahan(
|
||||
Nat_BahanCode,
|
||||
Nat_BahanName,
|
||||
Nat_BahanCreated,
|
||||
Nat_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, now(), now())";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan insert");
|
||||
exit;
|
||||
}
|
||||
$sql = "insert into t_bahan(
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, now(), now())";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_bahan = $prm['id'];
|
||||
$code_bahan = $prm['code'];
|
||||
$name_bahan = $prm['name'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanCode = '{$code_bahan}' AND Nat_BahanID <> {$id_bahan}";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanName = '{$name_bahan}' AND Nat_BahanID <> {$id_bahan}";
|
||||
$exist_name = $this->db->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "update nat_bahan SET
|
||||
Nat_BahanCode = ?,
|
||||
Nat_BahanName = ?,
|
||||
Nat_BahanLastUpdated = now()
|
||||
where
|
||||
Nat_BahanID = ?
|
||||
";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan,
|
||||
$id_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan update");
|
||||
exit;
|
||||
}
|
||||
$sql = "update t_bahan SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where
|
||||
T_BahanID = ?
|
||||
";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan,
|
||||
$id_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_bahan));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewsampletype()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$bahanid = $prm['bahanid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$suffix = $prm['suffix'];
|
||||
//$agingonhold = $prm['agingonhold'];
|
||||
//$agingonholdtime = $prm['agingonholdtime'];
|
||||
// $sampleimgid = $prm['sampleimgid'];
|
||||
|
||||
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeCode = '{$code}'";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeName = '{$name}'";
|
||||
$exist_name = $this->db->query($query)->row()->exist;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into nat_sampletype(
|
||||
Nat_SampleTypeNat_BahanID,
|
||||
Nat_SampleTypeCode,
|
||||
Nat_SampleTypeName,
|
||||
Nat_SampleTypeSuffix,
|
||||
Nat_SampleTypeCreated,
|
||||
Nat_SampleTypeLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,now(),now())";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$bahanid,
|
||||
$code,
|
||||
$name,
|
||||
$suffix
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype insert");
|
||||
exit;
|
||||
}
|
||||
$sql = "insert into t_sampletype(
|
||||
T_SampleTypeT_BahanID,
|
||||
T_SampleTypeCode,
|
||||
T_SampleTypeName,
|
||||
T_SampleTypeSuffix,
|
||||
T_SampleTypeCreated,
|
||||
T_SampleTypeLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,now(),now())";
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$bahanid,
|
||||
$code,
|
||||
$name,
|
||||
$suffix
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_sampletype insert");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeCode = '{$code}' AND Nat_SampleTypeID <> {$prm['xid']}";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeName = '{$name}' AND Nat_SampleTypeID <> {$prm['xid']}";
|
||||
$exist_name = $this->db->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "UPDATE nat_sampletype SET Nat_SampleTypeCode = '{$code}', Nat_SampleTypeName = '{$name}', Nat_SampleTypeSuffix = '{$suffix}' WHERE Nat_SampleTypeID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
$sqllocal = "UPDATE t_sampletype SET T_SampleTypeCode = '{$code}', T_SampleTypeName = '{$name}', T_SampleTypeSuffix = '{$suffix}' WHERE T_SampleTypeID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$querylocal = $this->db->query($sqllocal);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deletesampletype()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_sampletype SET
|
||||
Nat_SampleTypeIsActive = 'N',
|
||||
Nat_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
Nat_SampleTypeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update t_sampletype SET
|
||||
T_SampleTypeIsActive = 'N',
|
||||
T_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
T_SampleTypeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deletebahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_bahan SET
|
||||
Nat_BahanIsActive = 'N',
|
||||
Nat_BahanLastUpdated = now()
|
||||
WHERE
|
||||
Nat_BahanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE nat_sampletype SET
|
||||
Nat_SampleTypeIsActive = 'N',
|
||||
Nat_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
Nat_SampleTypeNat_BahanID = ?
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "UPDATE t_sampletype SET
|
||||
T_SampleTypeIsActive = 'N',
|
||||
T_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
T_SampleTypeNat_BahanID = ?
|
||||
";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
754
application/controllers/v1/masterdata/Ekspose.php
Normal file
754
application/controllers/v1/masterdata/Ekspose.php
Normal file
@@ -0,0 +1,754 @@
|
||||
<?php
|
||||
class Ekspose extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " Nat_TestCode LIKE CONCAT('{$search_code}','%') ";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " Nat_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (SELECT *
|
||||
FROM nat_test
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestID AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultID = 4
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
LEFT JOIN m_eksposi ON Nat_TestID = M_EksposiNat_TestID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
GROUP BY Nat_TestID) x
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$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 *, IFNULL(M_EksposiID,0) as eksposiid
|
||||
FROM nat_test
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestID AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultID = 4
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
LEFT JOIN m_eksposi ON Nat_TestID = M_EksposiNat_TestID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
GROUP BY Nat_TestID
|
||||
ORDER BY Nat_TestCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getinitdatas(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroups'] = $this->db_onedev->query($query)->result_array();*/
|
||||
$query =" SELECT Nat_TestTypeID as id, Nat_TestTypeName as name
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("id"=>"","name"=>"LAB"),array("id"=>"XRAY","name"=>"XRAY"), array("id"=>"USG","name"=>"USG"),array("id"=>"ELECTROMEDIS","name"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
|
||||
function searchunit(){
|
||||
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 nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = '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;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_UnitId as id, Nat_UnitName as name
|
||||
FROM nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'
|
||||
ORDER BY Nat_UnitName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchsample(){
|
||||
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 nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = '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;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_SampleTypeID as id, Nat_SampleTypeName as name
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'
|
||||
ORDER BY Nat_SampleTypeName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$testid = $prm['id'];
|
||||
$expose = $prm['expose'];
|
||||
$tegangan = $prm['tegangan'];
|
||||
$arus = $prm['arus'];
|
||||
$waktu = $prm['waktu'];
|
||||
$mas = $prm['mas'];
|
||||
if($prm['eksposiid'] == 0){
|
||||
$sql = "insert into m_eksposi(
|
||||
M_EksposiNat_TestID,
|
||||
M_EksposiExpose,
|
||||
M_EksposiKV,
|
||||
M_EksposiMa,
|
||||
M_EksposiS,
|
||||
M_EksposiMaS,
|
||||
M_EksposiUserID,
|
||||
M_EksposiLastUpdated,
|
||||
M_EksposiCreated
|
||||
)
|
||||
values( ?,?,?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$expose,
|
||||
$tegangan,
|
||||
$arus,
|
||||
$waktu,
|
||||
$mas,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_eksposi insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
|
||||
//echo $query;
|
||||
$sql = "UPDATE m_eksposi SET M_EksposiExpose = '{$expose}', M_EksposiKV = '{$tegangan}',
|
||||
M_EksposiMa = '{$arus}',M_EksposiS = '{$waktu}',
|
||||
M_EksposiMaS = '{$mas}',
|
||||
M_EksposiUserID = '{$userid}' WHERE M_EksposiID = '{$prm['eksposiid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM nat_test
|
||||
WHERE Nat_TestCode = '{$prm['code']}' AND Nat_TestIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_onedev->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdataselected(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['Nat_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName as name,
|
||||
Nat_TestShortName as shortname,
|
||||
Nat_TestShortNameBarcode as codebarcode,
|
||||
'' as xgroup,
|
||||
Nat_GroupID as group_id,
|
||||
Nat_GroupName as group_name,
|
||||
'' as subgroup,
|
||||
Nat_SubGroupID as subgroup_id,
|
||||
Nat_SubGroupName as subgroup_name,
|
||||
'' as subsubgroup,
|
||||
Nat_SubSubGroupID as subsubgroup_id,
|
||||
Nat_SubSubGroupName as subsubgroup_name,
|
||||
'' as type,
|
||||
Nat_TestNat_TestTypeID as type_id,
|
||||
Nat_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
Nat_TestIsNonLab as nonlab,
|
||||
Nat_TestNat_SampleTypeID as sample_id,
|
||||
Nat_SampleTypeName as sample_name,
|
||||
Nat_TestFontSize as fontsize,
|
||||
Nat_TestFontColor as fontcolor,
|
||||
Nat_TestIsBold as flagbold,
|
||||
Nat_TestIsItalic as flagitalic,
|
||||
Nat_TestFlagGluc as flaggluc,
|
||||
Nat_TestIsQuantitative as flagquantitative,
|
||||
Nat_TestIsDeltaCheck as deltacheck,
|
||||
Nat_TestIsResult as isresult,
|
||||
Nat_TestIsPrice as isprice,
|
||||
Nat_TestIsPrintResult as printresult,
|
||||
Nat_TestIsPrintNota as printnote,
|
||||
Nat_TestIsTrendAnalysis as trendanalysis,
|
||||
Nat_TestIsWorklist as isworklist,
|
||||
Nat_TestIsLongResult as islongresult,
|
||||
Nat_TestIsEkspertisi as isekspertisi,
|
||||
Nat_TestWorklistName as worklistname,
|
||||
Nat_TestFlagLow as flaglow,
|
||||
Nat_TestFlagHigh as flaghigh,
|
||||
'' as groupsprice,
|
||||
Nat_TestPriceSumToNat_TestID as selected_group_price,
|
||||
Nat_TestFlagMcu as selected_flag_mcu,
|
||||
IFNULL(M_EksposiID,0) as eksposiid,
|
||||
IFNULL(M_EksposiExpose,0) as expose,
|
||||
IFNULL(M_EksposiKV,0) as tegangan,
|
||||
IFNULL(M_EksposiMa,0) as arus,
|
||||
IFNULL(M_EksposiS,0) as waktu,
|
||||
IFNULL(M_EksposiMaS,0) as mas
|
||||
FROM nat_test
|
||||
JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
LEFT JOIN m_eksposi ON Nat_TestID = M_EksposiNat_TestID
|
||||
WHERE Nat_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
if($rows['xform']['selected_flag_mcu'] == 'N')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'N','name'=>'Tidak ada');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'G')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Dengan perhitungan abnormal');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'A')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Sesuai hasil');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'C')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'C','name'=>'Berdasarkan SUBSUBGROUP');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'R')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'R','name'=>'Reaktif Tidak normal');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'P')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'P','name'=>'Positif Tidak normal');
|
||||
|
||||
$sevencode = substr($rows['xform']['code'],0,7);
|
||||
$sql = "SELECT 0 as id, '' as name
|
||||
UNION
|
||||
SELECT Nat_TestID as id, Nat_TestName as name FROM nat_test WHERE Nat_TestCode LIKE '{$sevencode}%'";
|
||||
$rows['xform']['groupsprice'] = $this->db_onedev->query($sql)->result_array();
|
||||
$selected_group_price = array();
|
||||
if($rows['xform']['groupsprice']){
|
||||
foreach($rows['xform']['groupsprice'] as $k =>$v){
|
||||
//echo $rows['xform']['selected_group_price'];echo '-';
|
||||
//echo $v['id'];echo '-';echo $rows['xform']['selected_group_price'];echo '&';
|
||||
if(intval($v['id']) == intval($rows['xform']['selected_group_price'])){
|
||||
//print_r($v);
|
||||
$selected_group_price = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows['xform']['selected_group_price'] = $selected_group_price;
|
||||
|
||||
$rows['xform']['unit'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['unit'] = array('id'=>$rows['xform']['unit_id'],'name'=>$rows['xform']['unit_name']);
|
||||
|
||||
$rows['xform']['sample'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['sample'] = array('id'=>$rows['xform']['sample_id'],'name'=>$rows['xform']['sample_name']);
|
||||
|
||||
$rows['xform']['xgroup'] = array('id'=>$rows['xform']['group_id'],'name'=>$rows['xform']['group_name']);
|
||||
$rows['xform']['subgroup'] = array('id'=>$rows['xform']['subgroup_id'],'name'=>$rows['xform']['subgroup_name']);
|
||||
$rows['xform']['subsubgroup'] = array('id'=>$rows['xform']['subsubgroup_id'],'name'=>$rows['xform']['subsubgroup_name']);
|
||||
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
|
||||
|
||||
|
||||
if($rows['xform']['nonlab'] == '')
|
||||
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
|
||||
else
|
||||
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
|
||||
|
||||
unset($rows['xform']['sample_id']);
|
||||
unset($rows['xform']['unit_id']);
|
||||
unset($rows['xform']['group_id']);
|
||||
unset($rows['xform']['subgroup_id']);
|
||||
unset($rows['xform']['subsubgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
unset($rows['xform']['subsubgroup_name']);
|
||||
}
|
||||
|
||||
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name FROM nat_subsubgroup WHERE Nat_SubSubGroupSubGroupID = {$prm['Nat_SubGroupID']} AND Nat_SubSubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subsubgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaddtest(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rtn = true;
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$codefrom = $prm['codefrom'];
|
||||
$codetoward = $prm['codetoward'];
|
||||
$leng = strlen($codetoward);
|
||||
$code_parent = substr($codetoward, 0,-2);
|
||||
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->existtest;
|
||||
if($xcount == 0){
|
||||
$sql = "
|
||||
select T_TestID ,T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
|
||||
UNION
|
||||
select T_TestID , T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
|
||||
";
|
||||
//echo $sql;
|
||||
$toupdate = $this->db_onedev->query($sql)->result();
|
||||
if($toupdate){
|
||||
foreach($toupdate as $k => $v){
|
||||
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
|
||||
$parentid = $this->db_onedev->query($sql)->row()->T_TestID;
|
||||
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestParentT_TestID,
|
||||
T_TestNat_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
SELECT
|
||||
{$parentid},
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
'{$codetoward}',
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM nat_test
|
||||
WHERE
|
||||
Nat_TestCode = '{$codefrom}' AND Nat_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
$sql = "SELECT T_TestID FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y' LIMIT 1";
|
||||
$data_parent = $this->db_onedev->query($sql)->row();
|
||||
if($data_parent){
|
||||
$testidparent = $data_parent->T_TestID;
|
||||
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$testidparent}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $xcount,
|
||||
"debug"=>$query
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
643
application/controllers/v1/masterdata/Groupresult.php
Normal file
643
application/controllers/v1/masterdata/Groupresult.php
Normal file
@@ -0,0 +1,643 @@
|
||||
<?php
|
||||
|
||||
class Groupresult extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "GROUP RESULT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupdetailbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupresult = $prm['groupresult'];
|
||||
$detail = $prm['detail'];;
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y' GROUP BY Group_ResultDetailID) a";
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->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("group_resultdetail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Group_ResultDetailID as id,
|
||||
Group_ResultName,
|
||||
CONCAT('[',T_TestSasCode,'] ',T_TestName) T_TestName,
|
||||
group_resultdetail.*
|
||||
from group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y'
|
||||
GROUP BY Group_ResultDetailID
|
||||
ORDER BY Group_ResultName ASC, T_TestName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("group_resultdetail select");
|
||||
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 lookupdetailbyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupresult = $prm['groupresult'];
|
||||
$detail = $prm['detail'];;
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
($groupresult = 0 or ($groupresult > 0 and Group_ResultDetailGroup_ResultID = $groupresult)) AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y' GROUP BY Group_ResultDetailID) a";
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->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("group_resultdetail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Group_ResultDetailID as id,
|
||||
Group_ResultName,
|
||||
CONCAT('[',T_TestSasCode,'] ',T_TestName) T_TestName,
|
||||
group_resultdetail.*
|
||||
from group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
($groupresult = 0 or ($groupresult > 0 and Group_ResultDetailGroup_ResultID = $groupresult)) AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y'
|
||||
GROUP BY Group_ResultDetailID
|
||||
ORDER BY Group_ResultName ASC, T_TestName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("group_resultdetail select");
|
||||
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);
|
||||
}
|
||||
}
|
||||
public function lookupgroupresultbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupresult = $prm['groupresult'];
|
||||
$detail = $prm['detail'];
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from group_result
|
||||
LEFT JOIN group_resultdetail ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultDetailIsActive = 'Y'
|
||||
LEFT JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
where
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
IFNULL(T_TestName,'') LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultIsActive = 'Y'
|
||||
GROUP BY Group_ResultID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql);
|
||||
$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("group_result count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Group_ResultID as id,
|
||||
Group_ResultName as name,
|
||||
Group_ResultName as namex,
|
||||
IF(Group_ResultFlagPerTest = 'Y','Ya','Tidak') as ispertest,
|
||||
IF(Group_ResultFlagNonLab = 'Y','Ya','Tidak') as isnonlab,
|
||||
group_result.*
|
||||
from group_result
|
||||
LEFT JOIN group_resultdetail ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultDetailIsActive = 'Y'
|
||||
LEFT JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
where
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
IFNULL(T_TestName,'') LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultIsActive = 'Y'
|
||||
GROUP BY Group_ResultID
|
||||
ORDER BY Group_ResultName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("group_result select");
|
||||
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);
|
||||
}
|
||||
}
|
||||
public function addnewgroupresult()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$ispertest = $prm['ispertest'];
|
||||
$isnonlab = $prm['isnonlab'];
|
||||
$sql = "insert into group_result(
|
||||
Group_ResultName,
|
||||
Group_ResultFlagPerTest,
|
||||
Group_ResultFlagNonLab
|
||||
)
|
||||
values( ?, ?, ?)";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$name,
|
||||
$ispertest,
|
||||
$isnonlab
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_result insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db->insert_id();
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editgroupresult()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$ispertest = $prm['ispertest'];
|
||||
$isnonlab = $prm['isnonlab'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update group_result SET
|
||||
Group_ResultName = ?,
|
||||
Group_ResultFlagPerTest = ?,
|
||||
Group_ResultFlagNonLab = ?
|
||||
where
|
||||
Group_ResultID = ?
|
||||
";
|
||||
$querycompany = $this->db->query(
|
||||
$sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$ispertest,
|
||||
$isnonlab,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("group_result update");
|
||||
exit;
|
||||
}
|
||||
$result = array("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewdetail()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$groupresultid = $prm['groupresultid'];
|
||||
$testid = $prm['testid'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if ($groupresultid == 0 || $testid == 0) {
|
||||
$errors = array();
|
||||
if ($groupresultid == 0) {
|
||||
array_push($errors, array('field' => 'groupresult', 'msg' => 'Kelompok hasil dipilih dulu dong'));
|
||||
}
|
||||
if ($testid == 0) {
|
||||
array_push($errors, array('field' => 'test', 'msg' => 'Pemeriksaan dipilih dulu dong'));
|
||||
}
|
||||
$result = array("total" => -1, "errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
if ($prm['xid'] == 0) {
|
||||
$sql = "insert into group_resultdetail(
|
||||
Group_ResultDetailGroup_ResultID,
|
||||
Group_ResultDetailT_TestID)
|
||||
values(?,?)";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$groupresultid,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_resultdetail insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE group_resultdetail SET Group_ResultDetailGroup_ResultID = '{$groupresultid}',
|
||||
Group_ResultDetailT_TestID = '{$testid}'
|
||||
WHERE Group_ResultDetailID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deletegroupresult()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update group_result SET
|
||||
Group_ResultIsActive = 'N'
|
||||
WHERE
|
||||
Group_ResultID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_result delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update group_resultdetail SET
|
||||
Group_ResultDetailIsActive = 'N'
|
||||
WHERE
|
||||
Group_ResultDetailGroup_ResultID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_resultdetail delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deletedetail()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update group_resultdetail SET
|
||||
Group_ResultDetailIsActive = 'N'
|
||||
WHERE
|
||||
Group_ResultDetailID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_resultdetail delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchgroupresult()
|
||||
{
|
||||
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 group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("group_result count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Group_ResultID, Group_ResultName
|
||||
FROM group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'
|
||||
ORDER BY Group_ResultName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("group_result rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchgroupresultbyname()
|
||||
{
|
||||
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 group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("group_result count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Group_ResultID, Group_ResultName
|
||||
FROM group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'
|
||||
ORDER BY Group_ResultName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("group_result rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("t_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT t_test.*, CONCAT('[',T_TestSasCode,'] ',T_TestName) as T_TestName
|
||||
FROM t_test
|
||||
WHERE
|
||||
CONCAT('[',T_TestCode,'] ',T_TestName) like ?
|
||||
AND T_TestIsActive = 'Y'
|
||||
ORDER BY T_TestName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->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);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
219
application/controllers/v1/masterdata/Methode.php
Normal file
219
application/controllers/v1/masterdata/Methode.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
class Methode extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$code = $prm["scode"];
|
||||
$nama = $prm["nama"];
|
||||
|
||||
// echo $nik;
|
||||
|
||||
$sql_where = "WHERE Nat_MethodeIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_MethodeName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
if ($code != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
if ($code == "xxx") {
|
||||
$sql_where .= " Nat_MethodeCode = Nat_MethodeOldCode ";
|
||||
$sql_param[] = "%$code%";
|
||||
} else {
|
||||
$sql_where .= " Nat_MethodeCode like ? ";
|
||||
$sql_param[] = "%$code%";
|
||||
}
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_StaffIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_methode
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM nat_methode
|
||||
$sql_where
|
||||
ORDER BY Nat_MethodeCode ASC
|
||||
limit 0,$tot_count";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_methode($v['M_StaffID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['Nat_MethodePriority'] == '')
|
||||
$prm['Nat_MethodePriority'] = 0;
|
||||
|
||||
$query ="UPDATE nat_methode SET
|
||||
Nat_MethodeName = '{$prm['Nat_MethodeName']}',
|
||||
Nat_MethodeNameInResult = '{$prm['Nat_MethodeNameInResult']}',
|
||||
Nat_MethodeCode = '{$prm['Nat_MethodeCode']}',
|
||||
Nat_MethodePriority = '{$prm['Nat_MethodePriority']}',
|
||||
Nat_MethodeM_UserID = '{$userid}',
|
||||
Nat_MethodeLastUpdated = now()
|
||||
WHERE Nat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function newmethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
if($prm['Nat_MethodePriority'] == '')
|
||||
$prm['Nat_MethodePriority'] = 0;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_methode (
|
||||
Nat_MethodeName,
|
||||
Nat_MethodeNameInResult,
|
||||
Nat_MethodeCode,
|
||||
Nat_MethodePriority,
|
||||
Nat_MethodeM_UserID,
|
||||
Nat_MethodeCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_MethodeName']}',
|
||||
'{$prm['Nat_MethodeNameInResult']}',
|
||||
'{$prm['Nat_MethodeCode']}',
|
||||
'{$prm['Nat_MethodePriority']}',
|
||||
'{$userid}',
|
||||
now()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function deletemethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE nat_methode SET
|
||||
Nat_MethodeIsActive = 'N'
|
||||
WHERE
|
||||
Nat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$query ="UPDATE nat_normalvalue SET
|
||||
Nat_NormalValueIsActive = 'N'
|
||||
WHERE
|
||||
Nat_NormalValueNat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM nat_methode
|
||||
WHERE Nat_MethodeCode = '{$prm['code']}' AND Nat_MethodeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_regional->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
301
application/controllers/v1/masterdata/Natinstrumentmethode.php
Normal file
301
application/controllers/v1/masterdata/Natinstrumentmethode.php
Normal file
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
class Natinstrumentmethode extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "NatInstrumentMethode API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_one= $this->load->database("regional", true);
|
||||
}
|
||||
function list_instrument() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_instrument where Nat_InstrumentIsActive='Y' and Nat_InstrumentName like ? ORDER BY Nat_InstrumentCode ASC";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatInstrument List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function list_test() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_test where Nat_TestIsResult = 'Y'
|
||||
and Nat_TestIsActive='Y' and Nat_TestName like ?";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatTest List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function delete_instrument() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
try {
|
||||
$sql = "update nat_instrument
|
||||
set
|
||||
Nat_InstrumentIsActive = 'N'
|
||||
,Nat_InstrumentUserID = ?
|
||||
where
|
||||
Nat_InstrumentID= ?";
|
||||
|
||||
$id = $param["Nat_InstrumentID"];
|
||||
|
||||
$qry = $this->db_one->query($sql, array($userid,$id));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("Nat_Instrument save", $this->db_one);
|
||||
}
|
||||
}
|
||||
|
||||
function save_instrument() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($param["Nat_InstrumentID"] == 0 ) {
|
||||
//add
|
||||
try {
|
||||
$sql = "insert into nat_instrument( Nat_InstrumentCode, Nat_InstrumentName
|
||||
,Nat_InstrumentUserID)
|
||||
values (?, ?, ? )
|
||||
";
|
||||
$code= $param["Nat_InstrumentCode"];
|
||||
$name = $param["Nat_InstrumentName"];
|
||||
$qry = $this->db_one->query($sql, array($code, $name, $userid ));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$sql = "update nat_instrument
|
||||
set
|
||||
Nat_InstrumentCode = ?
|
||||
,Nat_InstrumentName = ?
|
||||
,Nat_InstrumentUserID = ?
|
||||
where
|
||||
Nat_InstrumentID= ?";
|
||||
|
||||
$id = $param["Nat_InstrumentID"];
|
||||
$code= $param["Nat_InstrumentCode"];
|
||||
$name = $param["Nat_InstrumentName"];
|
||||
|
||||
$qry = $this->db_one->query($sql, array($code, $name, $userid,
|
||||
$id));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("Nat_Instrument save", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
function save() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($param["M_InstrumentMethodeID"] == 0 ) {
|
||||
//add
|
||||
try {
|
||||
$sql = "insert into m_instrumentmethode(M_InstrumentMethodeNat_InstrumentID,
|
||||
M_InstrumentMethodeNat_MethodeID, M_InstrumentMethodeNat_TestID,
|
||||
M_InstrumentMethodeResultFormatSF, M_InstrumentMethodeResultFormatAboveSF,
|
||||
M_InstrumentMethodePriority,
|
||||
M_InstrumentMethodeUserID)
|
||||
values (?, ?, ?, ?, ?, ?, ? ) ";
|
||||
$instrumentID = $param["Nat_InstrumentID"];
|
||||
$methodeID= $param["Nat_MethodeID"];
|
||||
$testID= $param["Nat_TestID"];
|
||||
$resultFormatSF= $param["ResultFormatSF"];
|
||||
$resultFormatAboveSF= $param["ResultFormatAboveSF"];
|
||||
$priority = $param["Priority"];
|
||||
$sql_param = array($instrumentID, $methodeID, $testID,
|
||||
$resultFormatSF, $resultFormatAboveSF,
|
||||
$priority, $userid);
|
||||
|
||||
$qry = $this->db_one->query($sql, $sql_param );
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$sql = "update m_instrumentmethode set M_InstrumentMethodeNat_InstrumentID = ?, M_InstrumentMethodeNat_MethodeID =?,
|
||||
M_InstrumentMethodeNat_TestID =?, M_InstrumentMethodeResultFormatSF = ?,M_InstrumentMethodeResultFormatAboveSF = ? ,
|
||||
M_InstrumentMethodePriority = ? , M_InstrumentMethodeUserID = ?
|
||||
where M_InstrumentMethodeID = ? ";
|
||||
|
||||
$methodePxID = $param["M_InstrumentMethodeID"];
|
||||
$instrumentID = $param["Nat_InstrumentID"];
|
||||
$methodeID= $param["Nat_MethodeID"];
|
||||
$testID= $param["Nat_TestID"];
|
||||
$resultFormatSF= $param["ResultFormatSF"];
|
||||
$resultFormatAboveSF= $param["ResultFormatAboveSF"];
|
||||
$priority = $param["Priority"];
|
||||
if ($resultFormatSF == "") $resultFormatSF = "0.00";
|
||||
if ($resultFormatAboveSF == "") $resultFormatAboveSF = "0";
|
||||
|
||||
$sql_param = array($instrumentID, $methodeID, $testID, $resultFormatSF,
|
||||
$resultFormatAboveSF, $priority, $userID, $methodePxID);
|
||||
$qry = $this->db_one->query($sql,$sql_param );
|
||||
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
function list_methode() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_methode where Nat_MethodeIsActive='Y' and Nat_MethodeName like ?";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function list_methodepx() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$instrumentID = $prm["Nat_InstrumentID"] ;
|
||||
try {
|
||||
$sql = "select * , Nat_TestName, Nat_MethodeName
|
||||
from m_instrumentmethode
|
||||
join nat_test on Nat_TestID = M_InstrumentMethodeNat_TestID
|
||||
join nat_methode on Nat_MethodeID = M_InstrumentMethodeNat_MethodeID
|
||||
where M_InstrumentMethodeIsActive='Y'
|
||||
and M_InstrumentMethodeNat_InstrumentID = ?";
|
||||
$qry = $this->db_one->query($sql, array($instrumentID));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
|
||||
function get_test_methode() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$id= $prm["Nat_TestID"] ;
|
||||
try {
|
||||
$sql = "select * from nat_test where Nat_TestID = ?";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $test= $rows[0];
|
||||
|
||||
$id= $prm["Nat_MethodeID"] ;
|
||||
$sql = "select * from nat_methode where Nat_MethodeID= ?";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $methode = $rows[0];
|
||||
|
||||
$result = array("status" => "OK" ,
|
||||
"data" => array("test" => $test , "methode" => $methode )
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$result = $this->sys_ok( array("status" => "ERR") );
|
||||
}
|
||||
} else {
|
||||
$result = $this->sys_ok( array("status" => "ERR") );
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
}
|
||||
function delete_methodepx() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$id= $prm["id"] ;
|
||||
try {
|
||||
$sql = "update
|
||||
m_instrumentmethode
|
||||
set M_InstrumentMethodeIsActive = 'N'
|
||||
where M_InstrumentMethodeID = ? ";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$result = array("records" => "");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
1355
application/controllers/v1/masterdata/Samplestation.php
Normal file
1355
application/controllers/v1/masterdata/Samplestation.php
Normal file
File diff suppressed because it is too large
Load Diff
277
application/controllers/v1/masterdata/Tbahan.php
Normal file
277
application/controllers/v1/masterdata/Tbahan.php
Normal file
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
|
||||
class Tbahan extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "SUB GROUP API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from t_bahan
|
||||
where
|
||||
T_BahanIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db->query($sql, $sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select T_BahanID as id,
|
||||
T_BahanCode as code,
|
||||
T_BahanName as name,
|
||||
T_BahanLangName as namelang,
|
||||
t_bahan.*
|
||||
from t_bahan
|
||||
where
|
||||
( T_BahanName LIKE CONCAT('%','{$search}','%') OR
|
||||
T_BahanCode LIKE CONCAT('%','{$search}','%')
|
||||
)AND
|
||||
T_BahanIsActive = 'Y'
|
||||
GROUP BY T_BahanID
|
||||
ORDER BY T_BahanID ASC $limit";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("t_bahan select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $total, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$namelang = $prm['namelang'];
|
||||
$code = $prm['code'];
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanCode = '{$code}'";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
if ($exist_code == 0) {
|
||||
$sql = "insert into t_bahan (
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanLangName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, now(), now())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$namelang
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db->insert_id();
|
||||
} else {
|
||||
$errors = array();
|
||||
if ($exist_code != 0) {
|
||||
// array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
|
||||
$sql = "insert into t_bahan(
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanLangName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, now(), now())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$namelang
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db->insert_id();
|
||||
}
|
||||
//$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
// $this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$namelang = $prm['namelang'];
|
||||
$code = $prm['code'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanCode = '{$code}' AND T_BahanID <> {$prm['id']}";
|
||||
$exist_code = $this->db->query($query)->row()->exist;
|
||||
if ($exist_code == 0) {
|
||||
$sqlcompany = "update t_bahan SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanLangName = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where
|
||||
T_BahanID = ?
|
||||
";
|
||||
$querycompany = $this->db->query(
|
||||
$sqlcompany,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$namelang,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("t_bahan update");
|
||||
exit;
|
||||
}
|
||||
$result = array("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$errors = array();
|
||||
if ($exist_code != 0) {
|
||||
|
||||
$sqlcompany = "update t_bahan SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanLangName = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where
|
||||
T_BahanID = ?
|
||||
";
|
||||
$querycompany = $this->db->query(
|
||||
$sqlcompany,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$namelang,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("t_bahan update");
|
||||
exit;
|
||||
}
|
||||
$result = array("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
// $result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
// $this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function deletebahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update t_bahan SET
|
||||
T_BahanIsActive = 'N',
|
||||
T_BahanLastUpdated = now()
|
||||
WHERE
|
||||
T_BahanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan delete");
|
||||
exit;
|
||||
}
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
776
application/controllers/v1/masterdata/Test_v3.php
Normal file
776
application/controllers/v1/masterdata/Test_v3.php
Normal file
@@ -0,0 +1,776 @@
|
||||
<?php
|
||||
class Test_v3 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Test API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$code = $prm["scode"];
|
||||
$nama = $prm["name"];
|
||||
$prm['current_page'] = isset($prm['current_page'])?$prm['current_page']:1;
|
||||
|
||||
// echo $nik;
|
||||
|
||||
$sql_where = "WHERE T_TestIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_TestName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
if ($code != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_TestSasCode like ? ";
|
||||
$sql_param[] = "%$code%";
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_StaffIsActive = 'Y' ";
|
||||
$number_limit = 50;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
LEFT JOIN nat_subsubgroup ON nat_subsubgroupID = Nat_Testnat_subsubgroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$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("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, T_TestIsNonLab as T_TestIsNonLabID,IF(T_TestIsNonLab = '', 'LAB',T_TestIsNonLab) as T_TestIsNonLabs, T_TestSasCode as db_T_TestSasCode
|
||||
FROM t_test
|
||||
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
LEFT JOIN nat_subsubgroup ON nat_subsubgroupID = Nat_Testnat_subsubgroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
$sql_where
|
||||
ORDER BY T_TestSasCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getsexreg(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['groupid']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroupes'] = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupSubGroupID = {$prm['subgroupid']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subsubgroupes'] = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("T_TestIsNonLabID"=>"","T_TestIsNonLab"=>"LAB"),array("T_TestIsNonLabID"=>"XRAY","T_TestIsNonLab"=>"XRAY"), array("T_TestIsNonLabID"=>"USG","T_TestIsNonLab"=>"USG"),array("T_TestIsNonLabID"=>"ELECTROMEDIS","T_TestIsNonLab"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getsubgroup(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['groupid']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroupes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getsubsubgroup(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupSubGroupID = {$prm['subgroupid']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subsubgroupes'] = $this->db_onedev->query($query)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getinitdatas(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroups'] = $this->db_onedev->query($query)->result_array();*/
|
||||
$query =" SELECT T_TestTypeID as id, T_TestTypeName as name
|
||||
FROM t_testtype
|
||||
WHERE
|
||||
T_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("T_TestIsNonLabID"=>"","T_TestIsNonLab"=>"LAB"),array("T_TestIsNonLabID"=>"XRAY","T_TestIsNonLab"=>"XRAY"), array("T_TestIsNonLabID"=>"USG","T_TestIsNonLab"=>"USG"),array("T_TestIsNonLabID"=>"ELECTROMEDIS","T_TestIsNonLab"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
|
||||
function searchunit(){
|
||||
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 nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = '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;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_UnitId as id, Nat_UnitName as name
|
||||
FROM nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'
|
||||
ORDER BY Nat_UnitName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchsample(){
|
||||
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 t_sampletype
|
||||
WHERE
|
||||
T_SampleTypeName like ?
|
||||
AND T_SampleTypeIsActive = '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("t_sampletype count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT T_SampleTypeID,T_SampleTypeName
|
||||
FROM t_sampletype
|
||||
WHERE
|
||||
T_SampleTypeName like ?
|
||||
AND T_SampleTypeIsActive = 'Y'
|
||||
ORDER BY T_SampleTypeName 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_sampletype rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['T_TestFontSize'] == '')
|
||||
$prm['T_TestFontSize'] = 10;
|
||||
|
||||
if($prm['T_TestIsPrice'] == 'N')
|
||||
$prm['T_TestIsPrintNota'] = 'N';
|
||||
|
||||
$sql = "SELECT T_TestID
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestSasCode = LEFT('{$prm['T_TestSasCode']}', LENGTH('{$prm['T_TestSasCode']}') - 2) ";
|
||||
$row_parent = $this->db_onedev->query($sql)->row();
|
||||
if($row_parent){
|
||||
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$row_parent->T_TestID}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
$query ="UPDATE t_test SET
|
||||
T_TestSasCode = '{$prm['T_TestSasCode']}',
|
||||
T_TestName = '{$prm['T_TestName']}',
|
||||
T_TestShortName = '{$prm['T_TestShortName']}',
|
||||
T_TestShortNameBarcode = '{$prm['T_TestShortNameBarcode']}',
|
||||
T_TestNat_GroupID = '{$prm['T_TestNat_GroupID']}',
|
||||
T_TestNat_SubgroupID = '{$prm['T_TestNat_SubgroupID']}',
|
||||
T_TestT_SampleTypeID = '{$prm['T_TestT_SampleTypeID']}',
|
||||
T_TestFontSize = '{$prm['T_TestFontSize']}',
|
||||
T_TestFontColor = '{$prm['T_TestFontColor']}',
|
||||
T_TestIsBold = '{$prm['T_TestIsBold']}',
|
||||
T_TestIsItalic = '{$prm['T_TestIsItalic']}',
|
||||
T_TestIsQuantitative = '{$prm['T_TestIsQuantitative']}',
|
||||
T_TestIsDeltaCheck = '{$prm['T_TestIsDeltaCheck']}',
|
||||
T_TestIsResult = '{$prm['T_TestIsResult']}',
|
||||
T_TestIsPrice = '{$prm['T_TestIsPrice']}',
|
||||
T_TestIsPrintResult = '{$prm['T_TestIsPrintResult']}',
|
||||
T_TestIsPrintNota = '{$prm['T_TestIsPrintNota']}',
|
||||
T_TestIsTrendAnalysis = '{$prm['T_TestIsTrendAnalysis']}',
|
||||
T_TestIsWorklist = '{$prm['T_TestIsWorklist']}',
|
||||
T_TestIsNonLab = '{$prm['T_TestIsNonLab']}',
|
||||
T_TestWorklistName = '{$prm['T_TestWorklistName']}',
|
||||
T_TestMaxDiscount = '{$prm['T_TestMaxDiscount']}'
|
||||
WHERE T_TestID = '{$prm['T_TestID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM t_test
|
||||
WHERE T_TestCode = '{$prm['code']}' AND T_TestIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_onedev->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdataselected(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['T_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
T_TestCode as code,
|
||||
T_TestName as name,
|
||||
T_TestShortName as shortname,
|
||||
T_TestShortNameBarcode as codebarcode,
|
||||
'' as xgroup,
|
||||
Nat_GroupID as group_id,
|
||||
Nat_GroupName as group_name,
|
||||
'' as subgroup,
|
||||
Nat_SubGroupID as subgroup_id,
|
||||
Nat_SubGroupName as subgroup_name,
|
||||
'' as type,
|
||||
T_TestT_TestTypeID as type_id,
|
||||
T_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
T_TestIsNonLab as nonlab,
|
||||
T_TestT_SampleTypeID as sample_id,
|
||||
T_SampleTypeName as sample_name,
|
||||
T_TestFontSize as fontsize,
|
||||
T_TestFontColor as fontcolor,
|
||||
T_TestIsBold as flagbold,
|
||||
T_TestIsItalic as flagitalic,
|
||||
T_TestFlagGluc as flaggluc,
|
||||
T_TestIsQuantitative as flagquantitative,
|
||||
T_TestIsDeltaCheck as deltacheck,
|
||||
T_TestIsResult as isresult,
|
||||
T_TestIsPrice as isprice,
|
||||
T_TestIsPrintResult as printresult,
|
||||
T_TestIsPrintNota as printnote,
|
||||
T_TestIsTrendAnalysis as trendanalysis,
|
||||
T_TestIsWorklist as isworklist,
|
||||
'N' as islongresult,
|
||||
T_TestWorklistName as worklistname,
|
||||
T_TestFlagLow as flaglow,
|
||||
T_TestFlagHigh as flaghigh
|
||||
FROM t_test
|
||||
JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
JOIN t_testtype ON T_TestT_TestTypeID = T_TestTypeID
|
||||
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
$rows['xform']['unit'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['unit'] = array('id'=>$rows['xform']['unit_id'],'name'=>$rows['xform']['unit_name']);
|
||||
|
||||
$rows['xform']['sample'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['sample'] = array('id'=>$rows['xform']['sample_id'],'name'=>$rows['xform']['sample_name']);
|
||||
|
||||
$rows['xform']['xgroup'] = array('id'=>$rows['xform']['group_id'],'name'=>$rows['xform']['group_name']);
|
||||
$rows['xform']['subgroup'] = array('id'=>$rows['xform']['subgroup_id'],'name'=>$rows['xform']['subgroup_name']);
|
||||
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
|
||||
|
||||
|
||||
if($rows['xform']['nonlab'] == '')
|
||||
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
|
||||
else
|
||||
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
|
||||
|
||||
unset($rows['xform']['sample_id']);
|
||||
unset($rows['xform']['unit_id']);
|
||||
unset($rows['xform']['group_id']);
|
||||
unset($rows['xform']['subgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
}
|
||||
|
||||
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaddtest(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rtn = true;
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$codefrom = $prm['codefrom'];
|
||||
$codetoward = $prm['codetoward'];
|
||||
$leng = strlen($codetoward);
|
||||
$code_parent = substr($codetoward, 0,-2);
|
||||
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->existtest;
|
||||
if($xcount == 0){
|
||||
$sql = "
|
||||
select T_TestID ,T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
|
||||
UNION
|
||||
select T_TestID , T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
|
||||
";
|
||||
//echo $sql;
|
||||
$toupdate = $this->db_onedev->query($sql)->result();
|
||||
if($toupdate){
|
||||
foreach($toupdate as $k => $v){
|
||||
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
|
||||
$parentid = $this->db_onedev->query($sql)->row()->T_TestID;
|
||||
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestParentT_TestID,
|
||||
T_TestT_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
SELECT
|
||||
{$parentid},
|
||||
T_TestID,
|
||||
T_TestCode,
|
||||
'{$codetoward}',
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
$sql = "SELECT T_TestID FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y' LIMIT 1";
|
||||
$data_parent = $this->db_onedev->query($sql)->row();
|
||||
if($data_parent){
|
||||
$testidparent = $data_parent->T_TestID;
|
||||
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$testidparent}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $xcount,
|
||||
"debug"=>$query
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function check_exist_code(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT COUNT(*) as x_count FROM t_test WHERE T_TestSasCode = '{$prm['newcode']}' AND T_TestID <> {$prm['trx']['T_TestID']} AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$x_count = $this->db_onedev->query($sql)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $x_count,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
1016
application/controllers/v1/masterdata/Testnas.php
Normal file
1016
application/controllers/v1/masterdata/Testnas.php
Normal file
File diff suppressed because it is too large
Load Diff
1012
application/controllers/v1/masterdata/Testnas.php--180320
Normal file
1012
application/controllers/v1/masterdata/Testnas.php--180320
Normal file
File diff suppressed because it is too large
Load Diff
1009
application/controllers/v1/masterdata/Testnas.php-beforepositif
Normal file
1009
application/controllers/v1/masterdata/Testnas.php-beforepositif
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,998 @@
|
||||
<?php
|
||||
class Testnas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " Nat_TestCode LIKE CONCAT('{$search_code}','%') ";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " Nat_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$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 *
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY Nat_TestCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getinitdatas(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroups'] = $this->db_onedev->query($query)->result_array();*/
|
||||
$query =" SELECT Nat_TestTypeID as id, Nat_TestTypeName as name
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("id"=>"","name"=>"LAB"),array("id"=>"XRAY","name"=>"XRAY"), array("id"=>"USG","name"=>"USG"),array("id"=>"ELECTROMEDIS","name"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
|
||||
function searchunit(){
|
||||
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 nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = '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;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_UnitId as id, Nat_UnitName as name
|
||||
FROM nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'
|
||||
ORDER BY Nat_UnitName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchsample(){
|
||||
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 nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = '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;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_SampleTypeID as id, Nat_SampleTypeName as name
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'
|
||||
ORDER BY Nat_SampleTypeName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sampletype = 0;
|
||||
$unit = 0;
|
||||
if($prm['isresult'] == 'Y'){
|
||||
$sampletype = $prm['sample']['id'];
|
||||
$unit = $prm['unit']['id'];
|
||||
}
|
||||
|
||||
if($prm['fontsize'] == '')
|
||||
$prm['fontsize'] = 10;
|
||||
|
||||
$query ="INSERT INTO nat_test (
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SubSubGroupID,
|
||||
Nat_TestNat_TestTypeID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestNat_UnitID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
Nat_TestUserID,
|
||||
Nat_TestCreated,
|
||||
Nat_TestPriceSumToNat_TestID,
|
||||
Nat_TestFlagMcu
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$prm['subsubgroup']['id']}',
|
||||
'{$prm['type']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$unit}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
'{$prm['selected_group_price']['id']}',
|
||||
'{$prm['Nat_TestFlagMcu']['id']}'
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_TestName = '{$prm['name']}',
|
||||
Nat_TestShortName = '{$prm['shortname']}',
|
||||
Nat_TestShortNameBarcode = '{$prm['codebarcode']}',
|
||||
Nat_TestNat_GroupID = '{$prm['xgroup']['id']}',
|
||||
Nat_TestNat_SubGroupID = '{$prm['subgroup']['id']}',
|
||||
Nat_TestNat_SubSubGroupID = '{$prm['subsubgroup']['id']}',
|
||||
Nat_TestNat_TestTypeID = '{$prm['type']['id']}',
|
||||
Nat_TestNat_SampleTypeID = '{$sampletype}',
|
||||
Nat_TestNat_UnitID = '{$unit}',
|
||||
Nat_TestFontSize = '{$prm['fontsize']}',
|
||||
Nat_TestFontColor = '{$prm['fontcolor']}',
|
||||
Nat_TestIsBold = '{$prm['flagbold']}',
|
||||
Nat_TestIsItalic = '{$prm['flagitalic']}',
|
||||
Nat_TestFlagGluc = '{$prm['flaggluc']}',
|
||||
Nat_TestIsQuantitative = '{$prm['flagquantitative']}',
|
||||
Nat_TestIsDeltaCheck = '{$prm['deltacheck']}',
|
||||
Nat_TestIsResult = '{$prm['isresult']}',
|
||||
Nat_TestIsPrice = '{$prm['isprice']}',
|
||||
Nat_TestIsPrintResult = '{$prm['printresult']}',
|
||||
Nat_TestIsPrintNota = '{$prm['printnote']}',
|
||||
Nat_TestIsTrendAnalysis = '{$prm['trendanalysis']}',
|
||||
Nat_TestIsWorklist = '{$prm['isworklist']}',
|
||||
Nat_TestIsNonLab = '{$prm['nonlab']['id']}',
|
||||
Nat_TestWorklistName = '{$prm['worklistname']}',
|
||||
Nat_TestFlagLow = '{$prm['flaglow']}',
|
||||
Nat_TestFlagHigh = '{$prm['flaghigh']}',
|
||||
Nat_TestUserID = '{$userid}',
|
||||
Nat_TestPriceSumToNat_TestID = '{$prm['selected_group_price']['id']}',
|
||||
Nat_TestFlagMcu = '{$prm['selected_flag_mcu']['id']}'
|
||||
";
|
||||
//echo $query;
|
||||
$savex = $this->db_onedev->query($query);
|
||||
if($prm['act'] == 'new'){
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT * FROM nat_test WHERE Nat_TestCode = '{$prm['code']}' AND Nat_TestIsActive = 'Y'";
|
||||
$last_id = $this->db_onedev->query($sql)->row()->Nat_TestID;
|
||||
}
|
||||
if($last_id ){
|
||||
if($prm['act'] == 'new' && ($prm['type']['id'] != 2 || $prm['type']['id'] != '2')){
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestNat_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
}else{
|
||||
$query = "UPDATE t_test SET
|
||||
T_TestName = '{$prm['name']}',
|
||||
T_TestShortName = '{$prm['shortname']}',
|
||||
T_TestShortNameBarcode = '{$prm['codebarcode']}',
|
||||
T_TestNat_GroupID = '{$prm['xgroup']['id']}',
|
||||
T_TestNat_SubGroupID = '{$prm['subgroup']['id']}',
|
||||
T_TestNat_SubSubGroupID = '{$prm['subsubgroup']['id']}',
|
||||
T_TestT_SampleTypeID = '{$sampletype}',
|
||||
T_TestFontSize = '{$prm['fontsize']}',
|
||||
T_TestFontColor = '{$prm['fontcolor']}',
|
||||
T_TestIsBold = '{$prm['flagbold']}',
|
||||
T_TestIsItalic = '{$prm['flagitalic']}',
|
||||
T_TestFlagGluc = '{$prm['flaggluc']}',
|
||||
T_TestIsQuantitative = '{$prm['flagquantitative']}',
|
||||
T_TestIsDeltaCheck = '{$prm['deltacheck']}',
|
||||
T_TestIsResult = '{$prm['isresult']}',
|
||||
T_TestIsPrintResult = '{$prm['printresult']}',
|
||||
T_TestIsPrintNota = '{$prm['printnote']}',
|
||||
T_TestIsTrendAnalysis = '{$prm['trendanalysis']}',
|
||||
T_TestIsWorklist = '{$prm['isworklist']}',
|
||||
T_TestIsNonLab = '{$prm['nonlab']['id']}',
|
||||
T_TestIsPrice = '{$prm['isprice']}',
|
||||
T_TestWorklistName = '{$prm['worklistname']}',
|
||||
T_TestFlagLow = '{$prm['flaglow']}',
|
||||
T_TestFlagHigh = '{$prm['flaghigh']}',
|
||||
T_TestUserID = '{$userid}'
|
||||
WHERE
|
||||
T_TestNat_TestID = {$last_id} AND T_TestIsActive = 'Y'
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
if(intval($prm['type']['id']) == 1){
|
||||
$sql = "SELECT COUNT(*) as xcount FROM t_test WHERE T_TestCode = '{$prm['code']}' AND T_TestSasCode = '{$prm['code']}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$x_exist = $this->db_onedev->query($sql)->row()->xcount;
|
||||
if($x_exist == 0){
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestNat_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
//echo $query;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//echo $query;
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM nat_test WHERE Nat_TestID = {$last_id}";
|
||||
//echo $sql;
|
||||
$xdata_log = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode($xdata_log);
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
//$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $data_log_header,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM nat_test
|
||||
WHERE Nat_TestCode = '{$prm['code']}' AND Nat_TestIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_onedev->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdataselected(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['Nat_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName as name,
|
||||
Nat_TestShortName as shortname,
|
||||
Nat_TestShortNameBarcode as codebarcode,
|
||||
'' as xgroup,
|
||||
Nat_GroupID as group_id,
|
||||
Nat_GroupName as group_name,
|
||||
'' as subgroup,
|
||||
Nat_SubGroupID as subgroup_id,
|
||||
Nat_SubGroupName as subgroup_name,
|
||||
'' as subsubgroup,
|
||||
Nat_SubSubGroupID as subsubgroup_id,
|
||||
Nat_SubSubGroupName as subsubgroup_name,
|
||||
'' as type,
|
||||
Nat_TestNat_TestTypeID as type_id,
|
||||
Nat_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
Nat_TestIsNonLab as nonlab,
|
||||
Nat_TestNat_SampleTypeID as sample_id,
|
||||
Nat_SampleTypeName as sample_name,
|
||||
Nat_TestFontSize as fontsize,
|
||||
Nat_TestFontColor as fontcolor,
|
||||
Nat_TestIsBold as flagbold,
|
||||
Nat_TestIsItalic as flagitalic,
|
||||
Nat_TestFlagGluc as flaggluc,
|
||||
Nat_TestIsQuantitative as flagquantitative,
|
||||
Nat_TestIsDeltaCheck as deltacheck,
|
||||
Nat_TestIsResult as isresult,
|
||||
Nat_TestIsPrice as isprice,
|
||||
Nat_TestIsPrintResult as printresult,
|
||||
Nat_TestIsPrintNota as printnote,
|
||||
Nat_TestIsTrendAnalysis as trendanalysis,
|
||||
Nat_TestIsWorklist as isworklist,
|
||||
Nat_TestWorklistName as worklistname,
|
||||
Nat_TestFlagLow as flaglow,
|
||||
Nat_TestFlagHigh as flaghigh,
|
||||
'' as groupsprice,
|
||||
Nat_TestPriceSumToNat_TestID as selected_group_price,
|
||||
Nat_TestFlagMcu as selected_flag_mcu
|
||||
FROM nat_test
|
||||
JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
if($rows['xform']['selected_flag_mcu'] == 'N')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'N','name'=>'Tidak ada');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'G')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Dengan perhitungan abnormal');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'A')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Sesuai hasil');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'C')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'C','name'=>'Berdasarkan SUBSUBGROUP');
|
||||
|
||||
$sevencode = substr($rows['xform']['code'],0,7);
|
||||
$sql = "SELECT 0 as id, '' as name
|
||||
UNION
|
||||
SELECT Nat_TestID as id, Nat_TestName as name FROM nat_test WHERE Nat_TestCode LIKE '{$sevencode}%'";
|
||||
$rows['xform']['groupsprice'] = $this->db_onedev->query($sql)->result_array();
|
||||
$selected_group_price = array();
|
||||
if($rows['xform']['groupsprice']){
|
||||
foreach($rows['xform']['groupsprice'] as $k =>$v){
|
||||
//echo $rows['xform']['selected_group_price'];echo '-';
|
||||
//echo $v['id'];echo '-';echo $rows['xform']['selected_group_price'];echo '&';
|
||||
if(intval($v['id']) == intval($rows['xform']['selected_group_price'])){
|
||||
//print_r($v);
|
||||
$selected_group_price = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows['xform']['selected_group_price'] = $selected_group_price;
|
||||
|
||||
$rows['xform']['unit'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['unit'] = array('id'=>$rows['xform']['unit_id'],'name'=>$rows['xform']['unit_name']);
|
||||
|
||||
$rows['xform']['sample'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['sample'] = array('id'=>$rows['xform']['sample_id'],'name'=>$rows['xform']['sample_name']);
|
||||
|
||||
$rows['xform']['xgroup'] = array('id'=>$rows['xform']['group_id'],'name'=>$rows['xform']['group_name']);
|
||||
$rows['xform']['subgroup'] = array('id'=>$rows['xform']['subgroup_id'],'name'=>$rows['xform']['subgroup_name']);
|
||||
$rows['xform']['subsubgroup'] = array('id'=>$rows['xform']['subsubgroup_id'],'name'=>$rows['xform']['subsubgroup_name']);
|
||||
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
|
||||
|
||||
|
||||
if($rows['xform']['nonlab'] == '')
|
||||
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
|
||||
else
|
||||
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
|
||||
|
||||
unset($rows['xform']['sample_id']);
|
||||
unset($rows['xform']['unit_id']);
|
||||
unset($rows['xform']['group_id']);
|
||||
unset($rows['xform']['subgroup_id']);
|
||||
unset($rows['xform']['subsubgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
unset($rows['xform']['subsubgroup_name']);
|
||||
}
|
||||
|
||||
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name FROM nat_subsubgroup WHERE Nat_SubSubGroupSubGroupID = {$prm['Nat_SubGroupID']} AND Nat_SubSubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subsubgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaddtest(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rtn = true;
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$codefrom = $prm['codefrom'];
|
||||
$codetoward = $prm['codetoward'];
|
||||
$leng = strlen($codetoward);
|
||||
$code_parent = substr($codetoward, 0,-2);
|
||||
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->existtest;
|
||||
if($xcount == 0){
|
||||
$sql = "
|
||||
select T_TestID ,T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
|
||||
UNION
|
||||
select T_TestID , T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
|
||||
";
|
||||
//echo $sql;
|
||||
$toupdate = $this->db_onedev->query($sql)->result();
|
||||
if($toupdate){
|
||||
foreach($toupdate as $k => $v){
|
||||
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
|
||||
$parentid = $this->db_onedev->query($sql)->row()->T_TestID;
|
||||
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestParentT_TestID,
|
||||
T_TestNat_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
SELECT
|
||||
{$parentid},
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
'{$codetoward}',
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM nat_test
|
||||
WHERE
|
||||
Nat_TestCode = '{$codefrom}' AND Nat_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
$sql = "SELECT T_TestID FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y' LIMIT 1";
|
||||
$data_parent = $this->db_onedev->query($sql)->row();
|
||||
if($data_parent){
|
||||
$testidparent = $data_parent->T_TestID;
|
||||
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$testidparent}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $xcount,
|
||||
"debug"=>$query
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
999
application/controllers/v1/masterdata/Testnas_bkp.php
Normal file
999
application/controllers/v1/masterdata/Testnas_bkp.php
Normal file
@@ -0,0 +1,999 @@
|
||||
<?php
|
||||
class Testnas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " Nat_TestCode LIKE CONCAT('{$search_code}','%') ";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " Nat_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$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 *
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY Nat_TestCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getinitdatas(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroups'] = $this->db_onedev->query($query)->result_array();*/
|
||||
$query =" SELECT Nat_TestTypeID as id, Nat_TestTypeName as name
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("id"=>"","name"=>"LAB"),array("id"=>"XRAY","name"=>"XRAY"), array("id"=>"USG","name"=>"USG"),array("id"=>"ELECTROMEDIS","name"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
|
||||
function searchunit(){
|
||||
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 nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = '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;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_UnitId as id, Nat_UnitName as name
|
||||
FROM nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'
|
||||
ORDER BY Nat_UnitName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchsample(){
|
||||
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 nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = '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;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_SampleTypeID as id, Nat_SampleTypeName as name
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'
|
||||
ORDER BY Nat_SampleTypeName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sampletype = 0;
|
||||
$unit = 0;
|
||||
if($prm['isresult'] == 'Y'){
|
||||
$sampletype = $prm['sample']['id'];
|
||||
$unit = $prm['unit']['id'];
|
||||
}
|
||||
|
||||
if($prm['fontsize'] == '')
|
||||
$prm['fontsize'] = 10;
|
||||
|
||||
if($prm['isprice'] == 'N')
|
||||
$prm['printnote'] = 'N';
|
||||
|
||||
$query ="INSERT INTO nat_test (
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SubSubGroupID,
|
||||
Nat_TestNat_TestTypeID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestNat_UnitID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
Nat_TestUserID,
|
||||
Nat_TestCreated,
|
||||
Nat_TestPriceSumToNat_TestID,
|
||||
Nat_TestFlagMcu
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$prm['subsubgroup']['id']}',
|
||||
'{$prm['type']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$unit}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
'{$prm['selected_group_price']['id']}',
|
||||
'{$prm['Nat_TestFlagMcu']['id']}'
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_TestName = '{$prm['name']}',
|
||||
Nat_TestShortName = '{$prm['shortname']}',
|
||||
Nat_TestShortNameBarcode = '{$prm['codebarcode']}',
|
||||
Nat_TestNat_GroupID = '{$prm['xgroup']['id']}',
|
||||
Nat_TestNat_SubGroupID = '{$prm['subgroup']['id']}',
|
||||
Nat_TestNat_SubSubGroupID = '{$prm['subsubgroup']['id']}',
|
||||
Nat_TestNat_TestTypeID = '{$prm['type']['id']}',
|
||||
Nat_TestNat_SampleTypeID = '{$sampletype}',
|
||||
Nat_TestNat_UnitID = '{$unit}',
|
||||
Nat_TestFontSize = '{$prm['fontsize']}',
|
||||
Nat_TestFontColor = '{$prm['fontcolor']}',
|
||||
Nat_TestIsBold = '{$prm['flagbold']}',
|
||||
Nat_TestIsItalic = '{$prm['flagitalic']}',
|
||||
Nat_TestFlagGluc = '{$prm['flaggluc']}',
|
||||
Nat_TestIsQuantitative = '{$prm['flagquantitative']}',
|
||||
Nat_TestIsDeltaCheck = '{$prm['deltacheck']}',
|
||||
Nat_TestIsResult = '{$prm['isresult']}',
|
||||
Nat_TestIsPrice = '{$prm['isprice']}',
|
||||
Nat_TestIsPrintResult = '{$prm['printresult']}',
|
||||
Nat_TestIsPrintNota = '{$prm['printnote']}',
|
||||
Nat_TestIsTrendAnalysis = '{$prm['trendanalysis']}',
|
||||
Nat_TestIsWorklist = '{$prm['isworklist']}',
|
||||
Nat_TestIsNonLab = '{$prm['nonlab']['id']}',
|
||||
Nat_TestWorklistName = '{$prm['worklistname']}',
|
||||
Nat_TestFlagLow = '{$prm['flaglow']}',
|
||||
Nat_TestFlagHigh = '{$prm['flaghigh']}',
|
||||
Nat_TestUserID = '{$userid}',
|
||||
Nat_TestPriceSumToNat_TestID = '{$prm['selected_group_price']['id']}',
|
||||
Nat_TestFlagMcu = '{$prm['selected_flag_mcu']['id']}'
|
||||
";
|
||||
//echo $query;
|
||||
$savex = $this->db_onedev->query($query);
|
||||
if($prm['act'] == 'new'){
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT * FROM nat_test WHERE Nat_TestCode = '{$prm['code']}' AND Nat_TestIsActive = 'Y'";
|
||||
$last_id = $this->db_onedev->query($sql)->row()->Nat_TestID;
|
||||
}
|
||||
if($last_id ){
|
||||
if($prm['act'] == 'new' && ($prm['type']['id'] != 2 || $prm['type']['id'] != '2')){
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestNat_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
}else{
|
||||
$query = "UPDATE t_test SET
|
||||
T_TestName = '{$prm['name']}',
|
||||
T_TestShortName = '{$prm['shortname']}',
|
||||
T_TestShortNameBarcode = '{$prm['codebarcode']}',
|
||||
T_TestNat_GroupID = '{$prm['xgroup']['id']}',
|
||||
T_TestNat_SubGroupID = '{$prm['subgroup']['id']}',
|
||||
T_TestNat_SubSubGroupID = '{$prm['subsubgroup']['id']}',
|
||||
T_TestT_SampleTypeID = '{$sampletype}',
|
||||
T_TestFontSize = '{$prm['fontsize']}',
|
||||
T_TestFontColor = '{$prm['fontcolor']}',
|
||||
T_TestIsBold = '{$prm['flagbold']}',
|
||||
T_TestIsItalic = '{$prm['flagitalic']}',
|
||||
T_TestFlagGluc = '{$prm['flaggluc']}',
|
||||
T_TestIsQuantitative = '{$prm['flagquantitative']}',
|
||||
T_TestIsDeltaCheck = '{$prm['deltacheck']}',
|
||||
T_TestIsResult = '{$prm['isresult']}',
|
||||
T_TestIsPrintResult = '{$prm['printresult']}',
|
||||
T_TestIsTrendAnalysis = '{$prm['trendanalysis']}',
|
||||
T_TestIsWorklist = '{$prm['isworklist']}',
|
||||
T_TestIsNonLab = '{$prm['nonlab']['id']}',
|
||||
T_TestWorklistName = '{$prm['worklistname']}',
|
||||
T_TestFlagLow = '{$prm['flaglow']}',
|
||||
T_TestFlagHigh = '{$prm['flaghigh']}',
|
||||
T_TestUserID = '{$userid}'
|
||||
WHERE
|
||||
T_TestNat_TestID = {$last_id} AND T_TestIsActive = 'Y'
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
if(intval($prm['type']['id']) == 1){
|
||||
$sql = "SELECT COUNT(*) as xcount FROM t_test WHERE T_TestCode = '{$prm['code']}' AND T_TestSasCode = '{$prm['code']}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$x_exist = $this->db_onedev->query($sql)->row()->xcount;
|
||||
if($x_exist == 0){
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestNat_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['code']}',
|
||||
'{$prm['name']}',
|
||||
'{$prm['shortname']}',
|
||||
'{$prm['codebarcode']}',
|
||||
'{$prm['xgroup']['id']}',
|
||||
'{$prm['subgroup']['id']}',
|
||||
'{$sampletype}',
|
||||
'{$prm['fontsize']}',
|
||||
'{$prm['fontcolor']}',
|
||||
'{$prm['flagbold']}',
|
||||
'{$prm['flagitalic']}',
|
||||
'{$prm['flaggluc']}',
|
||||
'{$prm['flagquantitative']}',
|
||||
'{$prm['deltacheck']}',
|
||||
'{$prm['isresult']}',
|
||||
'{$prm['isprice']}',
|
||||
'{$prm['printresult']}',
|
||||
'{$prm['printnote']}',
|
||||
'{$prm['trendanalysis']}',
|
||||
'{$prm['isworklist']}',
|
||||
'{$prm['nonlab']['id']}',
|
||||
'{$prm['worklistname']}',
|
||||
'{$prm['flaglow']}',
|
||||
'{$prm['flaghigh']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$this->db_onedev->query($query);
|
||||
//echo $query;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//echo $query;
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM nat_test WHERE Nat_TestID = {$last_id}";
|
||||
//echo $sql;
|
||||
$xdata_log = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode($xdata_log);
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
//$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $data_log_header,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM nat_test
|
||||
WHERE Nat_TestCode = '{$prm['code']}' AND Nat_TestIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_onedev->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdataselected(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['Nat_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName as name,
|
||||
Nat_TestShortName as shortname,
|
||||
Nat_TestShortNameBarcode as codebarcode,
|
||||
'' as xgroup,
|
||||
Nat_GroupID as group_id,
|
||||
Nat_GroupName as group_name,
|
||||
'' as subgroup,
|
||||
Nat_SubGroupID as subgroup_id,
|
||||
Nat_SubGroupName as subgroup_name,
|
||||
'' as subsubgroup,
|
||||
Nat_SubSubGroupID as subsubgroup_id,
|
||||
Nat_SubSubGroupName as subsubgroup_name,
|
||||
'' as type,
|
||||
Nat_TestNat_TestTypeID as type_id,
|
||||
Nat_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
Nat_TestIsNonLab as nonlab,
|
||||
Nat_TestNat_SampleTypeID as sample_id,
|
||||
Nat_SampleTypeName as sample_name,
|
||||
Nat_TestFontSize as fontsize,
|
||||
Nat_TestFontColor as fontcolor,
|
||||
Nat_TestIsBold as flagbold,
|
||||
Nat_TestIsItalic as flagitalic,
|
||||
Nat_TestFlagGluc as flaggluc,
|
||||
Nat_TestIsQuantitative as flagquantitative,
|
||||
Nat_TestIsDeltaCheck as deltacheck,
|
||||
Nat_TestIsResult as isresult,
|
||||
Nat_TestIsPrice as isprice,
|
||||
Nat_TestIsPrintResult as printresult,
|
||||
Nat_TestIsPrintNota as printnote,
|
||||
Nat_TestIsTrendAnalysis as trendanalysis,
|
||||
Nat_TestIsWorklist as isworklist,
|
||||
Nat_TestWorklistName as worklistname,
|
||||
Nat_TestFlagLow as flaglow,
|
||||
Nat_TestFlagHigh as flaghigh,
|
||||
'' as groupsprice,
|
||||
Nat_TestPriceSumToNat_TestID as selected_group_price,
|
||||
Nat_TestFlagMcu as selected_flag_mcu
|
||||
FROM nat_test
|
||||
JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
if($rows['xform']['selected_flag_mcu'] == 'N')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'N','name'=>'Tidak ada');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'G')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Dengan perhitungan abnormal');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'A')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Sesuai hasil');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'C')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'C','name'=>'Berdasarkan SUBSUBGROUP');
|
||||
|
||||
$sevencode = substr($rows['xform']['code'],0,7);
|
||||
$sql = "SELECT 0 as id, '' as name
|
||||
UNION
|
||||
SELECT Nat_TestID as id, Nat_TestName as name FROM nat_test WHERE Nat_TestCode LIKE '{$sevencode}%'";
|
||||
$rows['xform']['groupsprice'] = $this->db_onedev->query($sql)->result_array();
|
||||
$selected_group_price = array();
|
||||
if($rows['xform']['groupsprice']){
|
||||
foreach($rows['xform']['groupsprice'] as $k =>$v){
|
||||
//echo $rows['xform']['selected_group_price'];echo '-';
|
||||
//echo $v['id'];echo '-';echo $rows['xform']['selected_group_price'];echo '&';
|
||||
if(intval($v['id']) == intval($rows['xform']['selected_group_price'])){
|
||||
//print_r($v);
|
||||
$selected_group_price = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows['xform']['selected_group_price'] = $selected_group_price;
|
||||
|
||||
$rows['xform']['unit'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['unit'] = array('id'=>$rows['xform']['unit_id'],'name'=>$rows['xform']['unit_name']);
|
||||
|
||||
$rows['xform']['sample'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['sample'] = array('id'=>$rows['xform']['sample_id'],'name'=>$rows['xform']['sample_name']);
|
||||
|
||||
$rows['xform']['xgroup'] = array('id'=>$rows['xform']['group_id'],'name'=>$rows['xform']['group_name']);
|
||||
$rows['xform']['subgroup'] = array('id'=>$rows['xform']['subgroup_id'],'name'=>$rows['xform']['subgroup_name']);
|
||||
$rows['xform']['subsubgroup'] = array('id'=>$rows['xform']['subsubgroup_id'],'name'=>$rows['xform']['subsubgroup_name']);
|
||||
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
|
||||
|
||||
|
||||
if($rows['xform']['nonlab'] == '')
|
||||
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
|
||||
else
|
||||
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
|
||||
|
||||
unset($rows['xform']['sample_id']);
|
||||
unset($rows['xform']['unit_id']);
|
||||
unset($rows['xform']['group_id']);
|
||||
unset($rows['xform']['subgroup_id']);
|
||||
unset($rows['xform']['subsubgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
unset($rows['xform']['subsubgroup_name']);
|
||||
}
|
||||
|
||||
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name FROM nat_subsubgroup WHERE Nat_SubSubGroupSubGroupID = {$prm['Nat_SubGroupID']} AND Nat_SubSubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subsubgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaddtest(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rtn = true;
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$codefrom = $prm['codefrom'];
|
||||
$codetoward = $prm['codetoward'];
|
||||
$leng = strlen($codetoward);
|
||||
$code_parent = substr($codetoward, 0,-2);
|
||||
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->existtest;
|
||||
if($xcount == 0){
|
||||
$sql = "
|
||||
select T_TestID ,T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
|
||||
UNION
|
||||
select T_TestID , T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
|
||||
";
|
||||
//echo $sql;
|
||||
$toupdate = $this->db_onedev->query($sql)->result();
|
||||
if($toupdate){
|
||||
foreach($toupdate as $k => $v){
|
||||
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
|
||||
$parentid = $this->db_onedev->query($sql)->row()->T_TestID;
|
||||
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestParentT_TestID,
|
||||
T_TestNat_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
SELECT
|
||||
{$parentid},
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
'{$codetoward}',
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM nat_test
|
||||
WHERE
|
||||
Nat_TestCode = '{$codefrom}' AND Nat_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
$sql = "SELECT T_TestID FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y' LIMIT 1";
|
||||
$data_parent = $this->db_onedev->query($sql)->row();
|
||||
if($data_parent){
|
||||
$testidparent = $data_parent->T_TestID;
|
||||
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$testidparent}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $xcount,
|
||||
"debug"=>$query
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
1012
application/controllers/v1/masterdata/Testnas_old.php
Normal file
1012
application/controllers/v1/masterdata/Testnas_old.php
Normal file
File diff suppressed because it is too large
Load Diff
1009
application/controllers/v1/masterdata/Testnasv2.php
Normal file
1009
application/controllers/v1/masterdata/Testnasv2.php
Normal file
File diff suppressed because it is too large
Load Diff
304
application/controllers/v1/masterdata/Testsas.php
Normal file
304
application/controllers/v1/masterdata/Testsas.php
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
class Testsas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " ( T_TestSasCode LIKE CONCAT('{$search_code}','%') OR T_TestCode LIKE CONCAT('{$search_code}','%'))";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$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 *, if(T_TestParentT_TestID > 0 , fn_get_testname(T_TestParentT_TestID),'-') as parenttestname
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestSasCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
JOIN t_orderheader ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
304
application/controllers/v1/masterdata/Testsas_old.php
Normal file
304
application/controllers/v1/masterdata/Testsas_old.php
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
class Testsas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " ( T_TestSasCode LIKE CONCAT('{$search_code}','%') OR T_TestCode LIKE CONCAT('{$search_code}','%'))";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$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 *, if(T_TestParentT_TestID > 0 , fn_get_testname(T_TestParentT_TestID),'-') as parenttestname
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestSasCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
JOIN t_orderheader ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
304
application/controllers/v1/masterdata/Testsasv2.php
Normal file
304
application/controllers/v1/masterdata/Testsasv2.php
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
class Testsasv2 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " ( T_TestSasCode LIKE CONCAT('{$search_code}','%') OR T_TestCode LIKE CONCAT('{$search_code}','%'))";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$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 *, if(T_TestParentT_TestID > 0 , fn_get_testname(T_TestParentT_TestID),'-') as parenttestname
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestSasCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
JOIN t_orderheader ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
910
application/controllers/v1/masterdata/Unit.php
Normal file
910
application/controllers/v1/masterdata/Unit.php
Normal file
@@ -0,0 +1,910 @@
|
||||
<?php
|
||||
|
||||
class Unit extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "UNIT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("default", true);
|
||||
}
|
||||
|
||||
function lookupunitbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$unit = $prm['unit'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from nat_unit
|
||||
WHERE
|
||||
(Nat_UnitCode LIKE CONCAT('%','{$unit}','%') OR
|
||||
Nat_UnitName LIKE CONCAT('%','{$unit}','%')) AND
|
||||
Nat_UnitIsActive = 'Y' GROUP BY Nat_UnitID) a";
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->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("nat_unit count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Nat_UnitID as id,
|
||||
Nat_UnitName as name,
|
||||
Nat_UnitCode as code,nat_unit.*
|
||||
from nat_unit
|
||||
WHERE
|
||||
(Nat_UnitCode LIKE CONCAT('%','{$unit}','%') OR
|
||||
Nat_UnitName LIKE CONCAT('%','{$unit}','%')) AND
|
||||
Nat_UnitIsActive = 'Y'
|
||||
GROUP BY Nat_UnitID
|
||||
ORDER BY Nat_UnitCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
// $sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
// echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_unit select");
|
||||
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);
|
||||
}
|
||||
}
|
||||
public function lookupregionalbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$regional = $prm['regional'];
|
||||
$unit = $prm['unit'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from nat_group
|
||||
LEFT JOIN nat_unit ON Nat_GroupID = Nat_UnitNat_GroupID AND Nat_UnitIsActive = 'Y'
|
||||
where
|
||||
Nat_GroupName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Nat_UnitName,'') LIKE CONCAT('%','{$unit}','%') AND
|
||||
Nat_GroupIsActive = 'Y'
|
||||
GROUP BY Nat_GroupID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$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("nat_group count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Nat_GroupID as id,
|
||||
Nat_GroupName as name,
|
||||
Nat_GroupName as namex,
|
||||
nat_group.*
|
||||
from nat_group
|
||||
LEFT JOIN nat_unit ON Nat_GroupID = Nat_UnitNat_GroupID AND Nat_UnitIsActive = 'Y'
|
||||
where
|
||||
Nat_GroupName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Nat_UnitName,'') LIKE CONCAT('%','{$unit}','%') AND
|
||||
Nat_GroupIsActive = 'Y'
|
||||
GROUP BY Nat_GroupID
|
||||
ORDER BY Nat_GroupName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_group select");
|
||||
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);
|
||||
}
|
||||
}
|
||||
public function addnewregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$sql = "insert into nat_group(
|
||||
Nat_GroupName,
|
||||
Nat_GroupCreated,
|
||||
Nat_GroupLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$name
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_group insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update nat_group SET
|
||||
Nat_GroupName = ?,
|
||||
Nat_GroupLastUpdated = now()
|
||||
where
|
||||
Nat_GroupID = ?
|
||||
";
|
||||
$querycompany = $this->db_regional->query($sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("nat_group update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewunit()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$Nat_UnitCode = $prm['Nat_UnitCode'];
|
||||
$Nat_UnitName = $prm['Nat_UnitName'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_unit WHERE Nat_UnitIsActive = 'Y' AND Nat_UnitCode = '{$Nat_UnitCode}'";
|
||||
$exist_code = $this->db_regional->query($query)->row()->exist;
|
||||
if($exist_code == 0){
|
||||
$sql = "insert into nat_unit(
|
||||
Nat_UnitCode,
|
||||
Nat_UnitName,
|
||||
Nat_UnitLastUpdated,
|
||||
Nat_UnitCreated)
|
||||
values(?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$Nat_UnitCode,
|
||||
$Nat_UnitName)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_unit insert",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_unit WHERE Nat_UnitIsActive = 'Y' AND Nat_UnitCode = '{$Nat_UnitCode}' AND Nat_UnitID <> {$prm['xid']}";
|
||||
//echo $query;
|
||||
$exist_code = $this->db_regional->query($query)->row()->exist;
|
||||
// echo $exist_code;
|
||||
if($exist_code == 0){
|
||||
$sql = "UPDATE nat_unit SET
|
||||
Nat_UnitCode = '{$Nat_UnitCode}',
|
||||
Nat_UnitName = '{$Nat_UnitName}'
|
||||
WHERE Nat_UnitID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update nat_group SET
|
||||
Nat_GroupIsActive = 'N',
|
||||
Nat_GroupLastUpdated = now()
|
||||
WHERE
|
||||
Nat_GroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_group delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update nat_unit SET
|
||||
Nat_UnitIsActive = 'N',
|
||||
Nat_UnitLastUpdated = now()
|
||||
WHERE
|
||||
Nat_UnitNat_GroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_unit delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deleteunit()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update nat_unit SET
|
||||
Nat_UnitIsActive = 'N',
|
||||
Nat_UnitLastUpdated = now()
|
||||
WHERE
|
||||
Nat_UnitID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_unit delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchgroup(){
|
||||
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 nat_group
|
||||
WHERE
|
||||
Nat_GroupName like ?
|
||||
AND Nat_GroupIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_group count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_GroupID, Nat_GroupName
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupName like ?
|
||||
AND Nat_GroupIsActive = 'Y'
|
||||
ORDER BY Nat_GroupName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_group rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchregionalbyname(){
|
||||
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 nat_group
|
||||
WHERE
|
||||
Nat_GroupName like ?
|
||||
AND Nat_GroupIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_group count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_GroupID, Nat_GroupName
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupName like ?
|
||||
AND Nat_GroupIsActive = 'Y'
|
||||
ORDER BY Nat_GroupName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_group rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchcity(){
|
||||
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_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'";
|
||||
$query = $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function searchdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictM_CityID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictM_CityID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'
|
||||
ORDER BY M_DistrictName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'
|
||||
ORDER BY M_KelurahanName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_regional);
|
||||
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_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchmou(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'
|
||||
ORDER BY M_MouName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
// echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchdoctor(){
|
||||
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(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
ORDER BY M_DoctorName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectaddressdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query ="SELECT M_DoctorAddressID,
|
||||
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
|
||||
FROM
|
||||
m_doctoraddress
|
||||
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
|
||||
//echo $query;
|
||||
$rows['addressdoctors'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
1028
application/controllers/v1/masterdata/testmd/Testnas.php
Normal file
1028
application/controllers/v1/masterdata/testmd/Testnas.php
Normal file
File diff suppressed because it is too large
Load Diff
1027
application/controllers/v1/masterdata/testmd/Testnas.php--300425
Normal file
1027
application/controllers/v1/masterdata/testmd/Testnas.php--300425
Normal file
File diff suppressed because it is too large
Load Diff
331
application/controllers/v1/masterdata/testmd/Testsas.php
Normal file
331
application/controllers/v1/masterdata/testmd/Testsas.php
Normal file
@@ -0,0 +1,331 @@
|
||||
<?php
|
||||
class Testsas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " ( T_TestSasCode LIKE CONCAT('{$search_code}','%') OR T_TestCode LIKE CONCAT('{$search_code}','%'))";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$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 *, if(T_TestParentT_TestID > 0 , fn_get_testname(T_TestParentT_TestID),'-') as parenttestname
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestSasCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
JOIN t_orderheader ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function update_price(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "UPDATE t_test SET T_TestIsPrice = '{$prm['T_TestIsPrice']}',
|
||||
T_TestLastUpdatedUserID = {$userid},
|
||||
T_TestLastUpdated = NOW()
|
||||
WHERE T_TestID = {$prm['T_TestID']}";
|
||||
$query = $this->db_onedev->query($query);
|
||||
if(!$query){
|
||||
$this->sys_error_db("t_test update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $prm,
|
||||
"status" => "OK"
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
304
application/controllers/v1/masterdata/testmd/Testsas.php--250425
Normal file
304
application/controllers/v1/masterdata/testmd/Testsas.php--250425
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
class Testsas extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " ( T_TestSasCode LIKE CONCAT('{$search_code}','%') OR T_TestCode LIKE CONCAT('{$search_code}','%'))";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$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 *, if(T_TestParentT_TestID > 0 , fn_get_testname(T_TestParentT_TestID),'-') as parenttestname
|
||||
FROM t_test
|
||||
LEFT JOIN nat_test ON T_TestCode = Nat_TestCode
|
||||
LEFT JOIN nat_sampletype ON T_TestT_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY T_TestSasCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
JOIN t_orderheader ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
29
application/controllers/v1/old_report-dev/Agama.php
Normal file
29
application/controllers/v1/old_report-dev/Agama.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class Agama extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1868
application/controllers/v1/old_report-dev/Fisik.php
Normal file
1868
application/controllers/v1/old_report-dev/Fisik.php
Normal file
File diff suppressed because it is too large
Load Diff
352
application/controllers/v1/old_report-dev/Fisik0.php
Normal file
352
application/controllers/v1/old_report-dev/Fisik0.php
Normal file
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
class Fisik extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function pribadi($id,$langid) {
|
||||
//$id = So_ResultEntryID
|
||||
$sql = "select concat(M_TitleName,' ', M_PatientName) M_PatientName,
|
||||
T_OrderHeaderLabNumber RegNo, fn_numbering_external(T_OrderHeaderLabNumber) ExternalRegNo,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
date_format(M_PatientDOB,'%d-%m-%Y') M_PatientDOB ,
|
||||
date_format(T_OrderHeaderDate,'%d-%m-%Y') T_OrderHeaderDate,
|
||||
M_SexName,
|
||||
(SELECT concat(M_PatientAddressDescription,' ',M_KelurahanName,' ' ,M_DistrictName,' ',M_CityName) from m_patientaddress AS p
|
||||
left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
left join m_district on M_KelurahanM_DistrictID = M_DistrictID
|
||||
left join m_city on M_DistrictM_CityID = M_CityID
|
||||
WHERE M_PatientAddressM_PatientID = M_PatientID
|
||||
ORDER BY M_PatientAddressM_PatientID
|
||||
LIMIT 1) AS M_PatientAddressDescription
|
||||
from so_resultentry
|
||||
join t_orderheader on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
|
||||
and So_ResultEntryID = ?
|
||||
join m_patient on M_PatientID = T_OrderHeaderM_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
left join m_sex on M_PatientM_SexID = M_SexID
|
||||
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql,array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach($rows as $idx => $r ) {
|
||||
$rows[$idx]["keluhan_saat_ini"] = $this->keluhan_saat_ini($id,$langid);
|
||||
$rows[$idx]["phobia"] = $this->phobia($id,$langid);
|
||||
}
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
|
||||
function phobia($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$phobia = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT POBIA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$phobia = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $phobia != "" ) $phobia .= ", ";
|
||||
$phobia .= $xd["label"];
|
||||
if ($xd["value"] != "") $phobia .= " (" .$xd["value"] . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $phobia;
|
||||
}
|
||||
|
||||
function keluhan_saat_ini($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$keluhan_saat_ini = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "KELUHAN SAAT INI") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$keluhan_saat_ini = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $keluhan_saat_ini != "" ) $keluhan_saat_ini .= ", ";
|
||||
$keluhan_saat_ini .= $xd["label"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $keluhan_saat_ini;
|
||||
}
|
||||
|
||||
function riwayat_penyakit($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_penyakit = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_penyakit = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group == "Allergi" ) continue;
|
||||
$have_detail = false;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$have_detail = true;
|
||||
}
|
||||
}
|
||||
if ($have_detail) {
|
||||
$arr_result[] = array($group, "", "","") ;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result[] = array($xd["label"], "X", "",$xd["value"]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$riwayat_penyakit[] = array(
|
||||
"c1" => $left[0],
|
||||
"c2" => $left[1],
|
||||
"c3" => $left[2],
|
||||
"c4" => $left[3],
|
||||
"c5" => $right[0],
|
||||
"c6" => $right[1],
|
||||
"c7" => $right[2],
|
||||
"c8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($riwayat_penyakit);
|
||||
//return ($riwayat_penyakit);
|
||||
}
|
||||
|
||||
//riwayat penyakit keluarga
|
||||
function penyakit_keluarga($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$penyakit_keluarga = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT KELUARGA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$penyakit_keluarga = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "X", "",$gp["value"]) ;
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$penyakit_keluarga[] = array(
|
||||
"d1" => $left[0],
|
||||
"d2" => $left[1],
|
||||
"d3" => $left[2],
|
||||
"d4" => $left[3],
|
||||
"d5" => $right[0],
|
||||
"d6" => $right[1],
|
||||
"d7" => $right[2],
|
||||
"d8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($penyakit_keluarga);
|
||||
//return ($penyakit_keluarga);
|
||||
}
|
||||
|
||||
|
||||
function riwayat_alergi($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_alergi = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_alergi = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group != "Allergi" ) continue;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result = array($xd["label"], "Ya", "",$xd["value"]) ;
|
||||
} else {
|
||||
$arr_result = array($xd["label"], "Tidak", "X",$xd["value"]) ;
|
||||
}
|
||||
$riwayat_alergi[] = array(
|
||||
"a1" => $arr_result[0],
|
||||
"a2" => $arr_result[1],
|
||||
"a3" => $arr_result[2],
|
||||
"a4" => $arr_result[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_alergi);
|
||||
}
|
||||
|
||||
function riwayat_obat($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_obat = array();
|
||||
foreach($details as $d) {
|
||||
|
||||
if ($d["title"] == "RIWAYAT KONSUMSI OBAT TERATUR") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_obat = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "Ya", "Tidak",$gp["value"]) ;
|
||||
$riwayat_obat[] = array(
|
||||
"o1" => $gp["label"],
|
||||
"o2" => "Ya",
|
||||
"o3" => $gp["value"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_obat);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
50
application/controllers/v1/preorder/Imgqrcode.php
Normal file
50
application/controllers/v1/preorder/Imgqrcode.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
use Endroid\QrCode\ErrorCorrectionLevel;
|
||||
use Endroid\QrCode\LabelAlignment;
|
||||
use Endroid\QrCode\QrCode;
|
||||
use Endroid\QrCode\Response\QrCodeResponse;
|
||||
|
||||
class Imgqrcode extends CI_Controller {
|
||||
function test() {
|
||||
$qrCode = new QrCode('Life is too short to be generating QR codes');
|
||||
|
||||
header('Content-Type: '.$qrCode->getContentType());
|
||||
echo $qrCode->writeString();
|
||||
}
|
||||
function show($qrcode) {
|
||||
$qrCode = new QrCode("pre-order qrcode\ngenerated by s.a.s\n" . "[". $qrcode ."]");
|
||||
$qrCode->setSize(300);
|
||||
// Set advanced options
|
||||
$qrCode->setWriterByName('png');
|
||||
$qrCode->setMargin(10);
|
||||
$qrCode->setEncoding('UTF-8');
|
||||
$qrCode->setErrorCorrectionLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::HIGH));
|
||||
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
|
||||
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
|
||||
$qrCode->setLabel('S.A.S PreOrder', 16, FCPATH .'/assets/fonts/noto_sans.otf', LabelAlignment::CENTER);
|
||||
$qrCode->setLogoPath(FCPATH . '/assets/images/logo-sas.jpg');
|
||||
$qrCode->setLogoWidth(150);
|
||||
$qrCode->setValidateResult(false);
|
||||
header('Content-Type: '.$qrCode->getContentType());
|
||||
echo $qrCode->writeString();
|
||||
}
|
||||
function index() {
|
||||
$qrCode = new QrCode("TUV345");
|
||||
$qrCode->setSize(300);
|
||||
//
|
||||
// Set advanced options
|
||||
$qrCode->setWriterByName('png');
|
||||
$qrCode->setMargin(10);
|
||||
$qrCode->setEncoding('UTF-8');
|
||||
$qrCode->setErrorCorrectionLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::HIGH));
|
||||
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
|
||||
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
|
||||
$qrCode->setLabel('S.A.S PreOrder', 16, FCPATH .'/assets/fonts/noto_sans.otf', LabelAlignment::CENTER);
|
||||
$qrCode->setLogoPath(FCPATH . '/assets/images/logo-sas.jpg');
|
||||
$qrCode->setLogoWidth(150);
|
||||
$qrCode->setValidateResult(false);
|
||||
header('Content-Type: '.$qrCode->getContentType());
|
||||
echo $qrCode->writeString();
|
||||
}
|
||||
}
|
||||
?>
|
||||
193
application/controllers/v1/preorder/home-service/Android.php
Normal file
193
application/controllers/v1/preorder/home-service/Android.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
class Android extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $staffID, $userID;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->staffID = 0;
|
||||
$sql = "select M_UserM_StaffID from m_user where M_UserID = ?";
|
||||
$qry = $this->db_onedev->query($sql,array($this->sys_user["M_UserID"]));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) $this->staffID = $rows[0]["M_UserM_StaffID"];
|
||||
}
|
||||
$this->userID = $this->sys_user["M_UserID"];
|
||||
}
|
||||
// data yg di upload
|
||||
// status : Arrival , Cancel / Serve , Lokasi
|
||||
// data lain : Catatan tambahan
|
||||
/*
|
||||
drop table if exists address_loc;
|
||||
create table address_loc (
|
||||
Addres_LocID int not null auto_increment primary key,
|
||||
Address_LocM_PatientID int ,
|
||||
Address_LocM_PatientAddressID int,
|
||||
Address_LocLat decimal(12,9),
|
||||
Address_LocLng decimal(12,9),
|
||||
Address_LocM_UserID int,
|
||||
Address_LocCreated datetime default current_timestamp(),
|
||||
Address_LocUpdated datetime default current_timestamp()
|
||||
on update current_timestamp(),
|
||||
Address_LocIsActive varchar(1) default 'Y',
|
||||
key(Address_LocM_PatientID),
|
||||
key(Address_LocM_PatientAddressID),
|
||||
key(Address_LocIsActive),
|
||||
unique(Address_LocM_PatientAddressID)
|
||||
);
|
||||
*/
|
||||
function upload_order() {
|
||||
$orders = array();
|
||||
try {
|
||||
$orders= $this->sys_input["orders"];
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
$updated_no = "";
|
||||
$this->db_onedev->trans_start();
|
||||
|
||||
foreach($orders as $order) {
|
||||
$id = $order["PreOrder_HeaderID"];
|
||||
$patientID = $order["PreOrder_HeaderM_PatientID"];
|
||||
$addressID = $order["PreOrder_HeaderM_PatientAdrressID"];
|
||||
if ($updated_no != "") $updated_no .= ", ";
|
||||
$updated_no .= $order["PreOrder_HeaderNumber"];
|
||||
$updated_mark = "";
|
||||
if (isset($order["arrived"]) ) {
|
||||
//update arrival and lat lng
|
||||
if ($updated_mark != "") $updated_mark .= ",";
|
||||
$updated_mark .= "Dtg";
|
||||
}
|
||||
if (isset($order["note"])) {
|
||||
//add note
|
||||
if ($updated_mark != "") $updated_mark .= ",";
|
||||
$updated_mark .= "Cat";
|
||||
}
|
||||
if (isset($order["latlng"])) {
|
||||
$lat = $order["latlng"]["lat"];
|
||||
$lng = $order["latlng"]["lng"];
|
||||
$sql = "insert into address_loc(Address_LocM_PatientID, Address_LocM_PatientAddressID,
|
||||
Address_LocLat,Address_LocLng, Address_LocM_UserID)
|
||||
values(?,?,?,?,?)
|
||||
on duplicate key update
|
||||
set Address_LocLat = ? , Address_LocLng = ? , Address_LocM_UserID=?
|
||||
where Address_LocM_PatientAddressID = ? ";
|
||||
$this->db_onedev->query($sql, array($patientID, $addressID,
|
||||
$lat, $lng, $this->userID, $lat, $lng, $this->userID, $patientID) );
|
||||
}
|
||||
if (isset($order["status"])) {
|
||||
$status = $order["status"];
|
||||
foreach($status as $s) {
|
||||
$statusID = $s["statusID"];
|
||||
// 6 - ARRIVED , 3 - SERVE , 4 - DONE , 5 - CANCELLED
|
||||
// insert to log
|
||||
if ($status == 4 || $id == 5) {
|
||||
//update status
|
||||
$sql = "update one_preorder_dev.preorder_header
|
||||
set PreOrder_HeaderM_PreOrderStatusID = ?
|
||||
PreOrderM_UserID = ?
|
||||
where PreOrder_HeaderID = ?";
|
||||
}
|
||||
}
|
||||
//update status serve / cancel
|
||||
if ($updated_mark != "") $updated_mark .= ",";
|
||||
$is_cancel = false;
|
||||
if ($is_cancel) $updated_mark = "Cancel";
|
||||
$updated_mark .= "Serve";
|
||||
}
|
||||
}
|
||||
}
|
||||
function mark_order() {
|
||||
$ids = array();
|
||||
try {
|
||||
$ids= $this->sys_input["ids"];
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
foreach($ids as $id) {
|
||||
$sql = "update one_preorder_dev.preorder_header set PreOrder_HeaderDownloadedMobile='Y',
|
||||
PreOrder_HeaderM_UserID = ?
|
||||
where PreOrder_HeaderID = ?";
|
||||
$this->db_onedev->query($sql,array($this->sys_user["M_UserID"],$id));
|
||||
}
|
||||
echo json_encode( array(
|
||||
"status" => "OK"
|
||||
));
|
||||
}
|
||||
function download_order() {
|
||||
$date = date("Y-m-d");
|
||||
try {
|
||||
$date = $this->sys_input["date"];
|
||||
} catch(Exception $e) {
|
||||
|
||||
}
|
||||
$sql = "select PreOrder_HeaderID,PreOrder_HeaderNumbering, PreOrder_HeaderDate, PreOrder_HeaderTime,
|
||||
M_PatientAddressDescription,M_PatientAddressLat, M_PatientAddressLng,
|
||||
concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
PreOrder_HeaderPhone,M_KelurahanLat, M_KelurahanLng,
|
||||
concat(M_DoctorPrefix,' ',M_DoctorName,' ',M_DoctorSufix) M_DoctorName,
|
||||
M_KelurahanName,M_DistrictName,M_CityName
|
||||
from
|
||||
one_preorder_dev.preorder_header
|
||||
join m_patientaddress on M_PatientAddressID = PreOrder_HeaderM_PatientAdrressID
|
||||
join m_patient on PreOrder_HeaderM_PatientID = M_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_doctor on PreOrder_HeaderM_DoctorID = M_DoctorID
|
||||
left join m_kelurahan on PreOrder_HeaderM_KelurahanID = M_KelurahanID
|
||||
left join m_district on M_KelurahanM_DistrictID= M_DistrictID
|
||||
left join m_city on M_DistrictM_CityID = M_CityID
|
||||
where
|
||||
PreOrder_HeaderDate = ?
|
||||
and PreOrder_HeaderM_PreOrderStatusID=2
|
||||
and PreOrder_HeaderDownloadedMobile = 'N'
|
||||
and PreOrder_HeaderM_StaffID = ?";
|
||||
|
||||
$qry = $this->db_onedev->query($sql,array($date,$this->staffID));
|
||||
$order = array();
|
||||
if ($qry) {
|
||||
$order = $qry->result_array();
|
||||
foreach($order as $idx => $o) {
|
||||
$id = $o["PreOrder_HeaderID"];
|
||||
$order[$idx]["test"] = $this->get_test($id);
|
||||
$order[$idx]["delivery"] = $this->get_delivery($id);
|
||||
}
|
||||
}
|
||||
echo json_encode( array(
|
||||
"status" => "OK",
|
||||
"data" => $order
|
||||
));
|
||||
}
|
||||
function get_test($id) {
|
||||
$sql = "select PreOrder_TestID, PreOrder_TestT_TestCode, PreOrder_TestT_TestName,
|
||||
PreOrder_TestPrice, PreOrder_TestDisc , PreOrder_TestDiscRp , PreOrder_TestTotal
|
||||
from
|
||||
one_preorder_dev.preorder_test
|
||||
where
|
||||
PreOrder_TestPreOrder_HeaderID = ?
|
||||
and PreOrder_TestIsActive = 'Y'";
|
||||
$qry = $this->db_onedev->query($sql,array($id));
|
||||
if ($qry) {
|
||||
return $qry->result_array();
|
||||
}
|
||||
return array();
|
||||
}
|
||||
function get_delivery($id) {
|
||||
$sql = "select PreOrder_DeliveryID, M_DeliveryName, PreOrder_DeliveryDestination
|
||||
from
|
||||
one_preorder_dev.preorder_delivery
|
||||
join m_delivery on PreOrder_DeliveryM_DeliveryID = M_DeliveryID
|
||||
where PreOrder_DeliveryPreOrder_HeaderID = ?
|
||||
and PreOrder_DeliveryIsActive = 'Y'";
|
||||
$qry = $this->db_onedev->query($sql,array($id));
|
||||
if ($qry) {
|
||||
return $qry->result_array();
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
1652
application/controllers/v1/preorder/home-service/Order.php
Normal file
1652
application/controllers/v1/preorder/home-service/Order.php
Normal file
File diff suppressed because it is too large
Load Diff
1671
application/controllers/v1/preorder/home-service/Receive.php
Normal file
1671
application/controllers/v1/preorder/home-service/Receive.php
Normal file
File diff suppressed because it is too large
Load Diff
481
application/controllers/v1/preorder/home-service/Staff.php
Normal file
481
application/controllers/v1/preorder/home-service/Staff.php
Normal file
@@ -0,0 +1,481 @@
|
||||
<?php
|
||||
class Staff extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Staff Home Service API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = $prm["nama"];
|
||||
$status = $prm["status"];
|
||||
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "WHERE M_StaffIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_StaffName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM one.m_staff
|
||||
LEFT JOIN one_preorder_dev.m_staffhomeservice ON M_StaffID = M_StaffHomeServiceM_StaffID AND M_StaffHomeServiceIsActive = 'Y'
|
||||
$sql_where
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT one.m_staff.*,IFNULL(M_StaffHomeServiceID,0) as status
|
||||
FROM one.m_staff
|
||||
LEFT JOIN one_preorder_dev.m_staffhomeservice ON M_StaffID = M_StaffHomeServiceM_StaffID AND M_StaffHomeServiceIsActive = 'Y'
|
||||
$sql_where
|
||||
ORDER BY M_StaffName ASC
|
||||
limit 0,20";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows['all'] = $query->result_array();
|
||||
|
||||
$sql = "SELECT one.m_staff.*
|
||||
FROM one.m_staff
|
||||
JOIN one_preorder_dev.m_staffhomeservice ON M_StaffID = M_StaffHomeServiceM_StaffID AND M_StaffHomeServiceIsActive = 'Y'
|
||||
WHERE M_StaffIsActive = 'Y'
|
||||
ORDER BY M_StaffName ASC";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows['homeservice'] = $query->result_array();
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total_all" => $tot_count,"total_homeservice" => count($rows['homeservice']), "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function searchcity(){
|
||||
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_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = '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;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName 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 getdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
M_DoctorM_SexID = '{$prm['M_DoctorM_SexID']}',
|
||||
M_DoctorM_ReligionID = '{$prm['M_DoctorM_ReligionID']}',
|
||||
M_DoctorEmail = '{$prm['M_DoctorEmail']}',
|
||||
M_DoctorHP = '{$prm['M_DoctorHP']}',
|
||||
M_DoctorPhone = '{$prm['M_DoctorPhone']}',
|
||||
M_DoctorIsMarketingConfirm = '{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
M_DoctorIsPJ = '{$prm['M_DoctorIsPJ']}',
|
||||
M_DoctorIsDefaultPJ = '{$prm['M_DoctorIsDefaultPJ']}',
|
||||
M_DoctorIsClinic = '{$prm['M_DoctorIsClinic']}',
|
||||
M_DoctorIsDefault = '{$prm['M_DoctorIsDefault']}'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorIsPJ,
|
||||
M_DoctorIsDefaultPJ,
|
||||
M_DoctorIsClinic,
|
||||
M_DoctorIsDefault,
|
||||
M_DoctorCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_doctoraddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,
|
||||
'' as action
|
||||
FROM m_doctoraddress
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
WHERE
|
||||
M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_DoctorAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}' AND M_DoctorAddressNote = 'Utama' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_DoctorAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_DoctorAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_doctoraddress (
|
||||
M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID,
|
||||
M_DoctorAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
'{$prm['M_DoctorAddressNote']}',
|
||||
'{$prm['M_DoctorAddressDescription']}',
|
||||
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
M_DoctorAddressNote = '{$prm['M_DoctorAddressNote']}',
|
||||
M_DoctorAddressDescription = '{$prm['M_DoctorAddressDescription']}',
|
||||
M_DoctorAddressM_KelurahanID = '{$prm['M_DoctorAddressM_KelurahanID']}'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function settohomeservice(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "SELECT COUNT(*) as xcount FROM one_preorder_dev.m_staffhomeservice WHERE M_StaffHomeServiceM_StaffID = '{$prm['M_StaffID']}' AND M_StaffHomeServiceIsActive = 'Y'";
|
||||
$check_exist = $this->db_onedev->query($query)->row()->xcount;
|
||||
if($check_exist == 0){
|
||||
$query = "INSERT INTO one_preorder_dev.m_staffhomeservice (M_StaffHomeServiceM_StaffID,M_StaffHomeServiceIsActive,M_StaffHomeServiceUserID)
|
||||
VALUES({$prm['M_StaffID']},'Y',{$userid})";
|
||||
$this->db_onedev->query($query);
|
||||
}
|
||||
else{
|
||||
$query ="UPDATE one_preorder_dev.m_staffhomeservice SET
|
||||
M_StaffHomeServiceIsActive = 'N',
|
||||
M_StaffHomeServiceUserID = {$userid}
|
||||
WHERE
|
||||
M_StaffHomeServiceM_StaffID = '{$prm['M_StaffID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
32
application/controllers/v1/preorder/home-service/Status.php
Normal file
32
application/controllers/v1/preorder/home-service/Status.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class Status extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
public function lookup()
|
||||
{
|
||||
$query = " SELECT M_PreOrderStatusID as id, M_PreOrderStatusName as name, M_PreOrderStatusColor as color
|
||||
FROM one_preorder_dev.m_preorderstatus
|
||||
WHERE
|
||||
M_PreOrderStatusIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
659
application/controllers/v1/preorder/home-service/Supplies.php
Normal file
659
application/controllers/v1/preorder/home-service/Supplies.php
Normal file
@@ -0,0 +1,659 @@
|
||||
<?php
|
||||
class Supplies extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Supplies API";
|
||||
/*
|
||||
truncate preorder_suppliestrx;
|
||||
truncate preorder_supplies;
|
||||
truncate preorder_suppliesbuffer;
|
||||
*/
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
function getallsupplies(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = " SELECT M_SuppliesID as supplies_id,
|
||||
M_SuppliesName as supplies_name,
|
||||
'N' as status
|
||||
FROM m_supplies
|
||||
WHERE
|
||||
M_SuppliesIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getstaffbydate(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$xdate = date('Y-m-d',strtotime($prm['xdate']));
|
||||
$sql = " SELECT PreOrder_HeaderM_StaffID as id,
|
||||
M_StaffName as name
|
||||
FROM one_preorder_dev.preorder_header
|
||||
JOIN m_staff ON PreOrder_HeaderM_StaffID = M_StaffID
|
||||
WHERE
|
||||
PreOrder_HeaderDate = '{$xdate}' AND PreOrder_HeaderIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function getorderbydatestaff(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$xdate = date('Y-m-d',strtotime($prm['xdate']));
|
||||
$staffid = $prm['staffid'];
|
||||
|
||||
$sql = "SELECT Preorder_SampleID as trx_id,
|
||||
PreOrder_HeaderNumbering as trx_numbering,
|
||||
DATE_FORMAT(PreOrder_HeaderDate,'%d-%m-%Y') as trx_date,
|
||||
DATE_FORMAT(PreOrder_HeaderTime,'%H:%i') as trx_time,
|
||||
GROUP_CONCAT(DISTINCT T_TestName separator ',') as tests,
|
||||
T_SampleTypeName as sampletype_name,
|
||||
T_SampleTypeID as sampletype_id,
|
||||
IFNULL(Preorder_SuppliesTrxID,0) as supplies_trx_id,
|
||||
M_StaffName as staffname,
|
||||
M_PatientName as patient_name,
|
||||
if(ISNULL(Preorder_SuppliesTrxID),'N','Y') as status
|
||||
FROM one_preorder_dev.preorder_sample
|
||||
JOIN one_preorder_dev.preorder_header ON Preorder_SamplePreOrder_HeaderID = PreOrder_HeaderID AND PreOrder_HeaderIsActive = 'Y'
|
||||
JOIN m_patient ON PreOrder_HeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN one_preorder_dev.preorder_suppliestrx ON Preorder_SamplePreorder_SuppliesTrxID = Preorder_SuppliesTrxID AND
|
||||
Preorder_SuppliesTrxIsActive = 'Y'
|
||||
JOIN m_staff ON PreOrder_HeaderM_StaffID = M_StaffID
|
||||
JOIN one_preorder_dev.preorder_test ON PreOrder_TestPreOrder_HeaderID = PreOrder_HeaderID
|
||||
JOIN t_test ON PreOrder_TestT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID AND Preorder_SampleT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
PreOrder_HeaderM_StaffID = {$staffid} AND PreOrder_HeaderDate = '{$xdate}' AND PreOrder_HeaderFlagReceivedSupplies = 'N' AND Preorder_SampleIsActive = 'Y'
|
||||
GROUP BY Preorder_SampleID";
|
||||
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function getdetails($id,$xdate,$status){
|
||||
$rows = [];
|
||||
$joinheader = "LEFT JOIN one_preorder_dev.preorder_suppliestrx ON Preorder_SamplePreorder_SuppliesTrxID = Preorder_SuppliesTrxID AND
|
||||
Preorder_SuppliesTrxID = {$id} AND
|
||||
Preorder_SuppliesTrxIsActive = 'Y'";
|
||||
if($status == 'RCV'){
|
||||
$joinheader = "JOIN one_preorder_dev.preorder_suppliestrx ON Preorder_SamplePreorder_SuppliesTrxID = Preorder_SuppliesTrxID AND
|
||||
Preorder_SuppliesTrxID = {$id} AND
|
||||
Preorder_SuppliesTrxIsActive = 'Y'";
|
||||
}
|
||||
$sql = "SELECT Preorder_SampleID as trx_id,
|
||||
PreOrder_HeaderNumbering as trx_numbering,
|
||||
DATE_FORMAT(PreOrder_HeaderDate,'%d-%m-%Y') as trx_date,
|
||||
DATE_FORMAT(PreOrder_HeaderTime,'%H:%i') as trx_time,
|
||||
GROUP_CONCAT(DISTINCT T_TestName separator ',') as tests,
|
||||
T_SampleTypeName as sampletype_name,
|
||||
T_SampleTypeID as sampletype_id,
|
||||
IFNULL(Preorder_SuppliesTrxID,0) as supplies_trx_id,
|
||||
M_StaffName as staffname,
|
||||
M_PatientName as patient_name,
|
||||
if(ISNULL(Preorder_SuppliesTrxID),'N','Y') as status
|
||||
FROM one_preorder_dev.preorder_sample
|
||||
JOIN one_preorder_dev.preorder_header ON Preorder_SamplePreOrder_HeaderID = PreOrder_HeaderID AND PreOrder_HeaderIsActive = 'Y'
|
||||
JOIN m_patient ON PreOrder_HeaderM_PatientID = M_PatientID
|
||||
$joinheader
|
||||
JOIN m_staff ON PreOrder_HeaderM_StaffID = M_StaffID
|
||||
JOIN one_preorder_dev.preorder_test ON PreOrder_TestPreOrder_HeaderID = PreOrder_HeaderID
|
||||
JOIN t_test ON PreOrder_TestT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID AND Preorder_SampleT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
PreOrder_HeaderDate = '{$xdate}' AND Preorder_SampleIsActive = 'Y'
|
||||
GROUP BY Preorder_SampleID";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
function getsupplies($id){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT
|
||||
M_SuppliesID as supplies_id,
|
||||
M_SuppliesName as supplies_name,
|
||||
Preorder_SuppliesID as trx_id,
|
||||
Preorder_SuppliesQty as qty,
|
||||
'Y' as status
|
||||
FROM one_preorder_dev.preorder_supplies
|
||||
JOIN m_supplies ON Preorder_SuppliesM_SuppliesID = M_SuppliesID
|
||||
WHERE
|
||||
Preorder_SuppliesPreorder_SuppliesTrxID = {$id} AND Preorder_SuppliesIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
function getsuppliesbuffer($id){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT
|
||||
M_SuppliesID as supplies_id,
|
||||
M_SuppliesName as supplies_name,
|
||||
Preorder_SuppliesBufferID as trx_id,
|
||||
Preorder_SuppliesBufferQty as qty,
|
||||
'Y' as status
|
||||
FROM one_preorder_dev.preorder_suppliesbuffer
|
||||
JOIN m_supplies ON Preorder_SuppliesBufferM_SuppliesID = M_SuppliesID
|
||||
WHERE
|
||||
Preorder_SuppliesBufferPreorder_SuppliesTrxID = {$id} AND Preorder_SuppliesBufferIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$search = $prm["search"];
|
||||
$status = $prm["stationid"];
|
||||
$startdate = $prm["startdate"];
|
||||
$enddate = $prm["enddate"];
|
||||
|
||||
$sql_where = "WHERE Preorder_SuppliesTrxStatus = '{$status}' AND ( Preorder_SuppliesTrxDate BETWEEN '{$startdate} 00:00:00' AND '{$enddate} 23:59:59' ) AND Preorder_SuppliesTrxIsActive = 'Y'";
|
||||
|
||||
//$sql_param = array();
|
||||
if ($search != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " ( Preorder_SuppliesTrxNumbering like '%$search%' OR penerima.M_StaffName like '%$search%' ) ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT Preorder_SuppliesTrxID
|
||||
FROM one_preorder_dev.preorder_suppliestrx
|
||||
JOIN m_staff penyampling ON Preorder_SuppliesTrxM_StaffID = penyampling.M_StaffID
|
||||
LEFT JOIN m_staff penerima ON Preorder_SuppliesTrxReceiveM_StaffID = penerima.M_StaffID
|
||||
$sql_where
|
||||
GROUP BY Preorder_SuppliesTrxID
|
||||
) x
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT one_preorder_dev.preorder_suppliestrx.*,
|
||||
Preorder_SuppliesTrxID as trx_id,
|
||||
Preorder_SuppliesTrxNumbering as trx_numbering,
|
||||
Preorder_SuppliesTrxDate as trx_date,
|
||||
DATE_FORMAT(Preorder_SuppliesTrxDate ,'%d-%m-%Y') as trx_date_ina,
|
||||
Preorder_SuppliesTrxNote as trx_note,
|
||||
Preorder_SuppliesTrxStatus as status,
|
||||
penyampling.M_StaffName as penyampling_name,
|
||||
IFNULL(penerima.M_StaffName,'-') as penerima_name,
|
||||
'' as details,
|
||||
'' as supplies,
|
||||
'' as buffers,
|
||||
'' as staffs,
|
||||
CASE
|
||||
WHEN Preorder_SuppliesTrxStatus = 'NEW' THEN 'BARU'
|
||||
WHEN Preorder_SuppliesTrxStatus = 'RCV' THEN 'DITERIMA PETUGAS'
|
||||
END as status_name
|
||||
FROM one_preorder_dev.preorder_suppliestrx
|
||||
JOIN m_staff penyampling ON Preorder_SuppliesTrxM_StaffID = penyampling.M_StaffID
|
||||
LEFT JOIN m_staff penerima ON Preorder_SuppliesTrxReceiveM_StaffID = penerima.M_StaffID
|
||||
|
||||
$sql_where
|
||||
GROUP BY Preorder_SuppliesTrxID
|
||||
ORDER BY Preorder_SuppliesTrxID DESC
|
||||
limit 0,20";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['details'] = $this->getdetails($v['trx_id'],$v['trx_date'],$v['status']);
|
||||
$rows[$k]['supplies'] = $this->getsupplies($v['trx_id']);
|
||||
$rows[$k]['buffers'] = $this->getsuppliesbuffer($v['trx_id']);
|
||||
$rows[$k]['staffs'] = array(array('id'=>$v['Preorder_SuppliesTrxM_StaffID'],'name'=>$v['penyampling_name']));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getordersamples(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$doctorid = $prm['doctorid'];
|
||||
$doctoraddressid = $prm['doctoraddressid'];
|
||||
$sql = "SELECT
|
||||
0 as idx,
|
||||
M_SexName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
T_SampleTypeName as samplename,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_SampleTypeID as sampleid,
|
||||
'Y' as active,
|
||||
'N' as flag_image
|
||||
FROM t_samplingso
|
||||
JOIN t_orderheader ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_sampletype ON T_SamplingSoT_SampleTypeID = T_SampleTypeID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
WHERE
|
||||
T_SamplingSoM_DoctorID = {$doctorid} AND T_SamplingSoM_DoctorAddressID = {$doctoraddressid} AND T_SamplingSoFlagWL = 'N' AND T_SamplingSoIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function getstation(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT T_SampleStationID as id, T_SampleStationName as name
|
||||
FROM t_samplestation
|
||||
WHERE
|
||||
T_SampleStationIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
||||
//print_r($statuses);
|
||||
foreach($statuses as $k=>$v){
|
||||
array_push($rows['statuses'],$v);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdoctoraddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressM_DoctorID = {$prm['id']} AND M_DoctorAddressIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$xdate = date('Y-m-d',strtotime($prm["trx_date"]));
|
||||
if($prm['trx_id'] == '0' || $prm['trx_id'] == 0){
|
||||
$numbering = $this->db_onedev->query("SELECT one_preorder_dev.fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$query ="INSERT INTO one_preorder_dev.preorder_suppliestrx (
|
||||
Preorder_SuppliesTrxNumbering,
|
||||
Preorder_SuppliesTrxDate,
|
||||
Preorder_SuppliesTrxNote,
|
||||
Preorder_SuppliesTrxM_StaffID,
|
||||
Preorder_SuppliesTrxCreated,
|
||||
Preorder_SuppliesTrxLastUpdated,
|
||||
Preorder_SuppliesTrxUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['trx_note']}',
|
||||
'{$prm['staff']['id']}',
|
||||
NOW(),
|
||||
NOW(),
|
||||
'{$userid}'
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
}else{
|
||||
$numbering = $this->db_onedev->query("SELECT Preorder_SuppliesTrxNumbering as numbering FROM one_preorder_dev.preorder_suppliestrx WHERE Preorder_SuppliesTrxID = {$prm['trx_id']}")->row()->numbering;
|
||||
$query ="UPDATE one_preorder_dev.preorder_suppliestrx SET
|
||||
Preorder_SuppliesTrxNote = '{$prm['trx_note']}',
|
||||
Preorder_SuppliesTrxLastUpdated = NOW(),
|
||||
Preorder_SuppliesTrxUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesTrxID = {$prm['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $prm['trx_id'];
|
||||
}
|
||||
|
||||
if($saveheader){
|
||||
if($prm['details']){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
if($v['status'] === 'Y'){
|
||||
$query ="UPDATE one_preorder_dev.preorder_sample SET
|
||||
Preorder_SamplePreorder_SuppliesTrxID = {$last_id},
|
||||
Preorder_SampleLastUpdated = NOW(),
|
||||
Preorder_SampleUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SampleID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['status'] === 'N'){
|
||||
$query ="UPDATE one_preorder_dev.preorder_sample SET
|
||||
Preorder_SamplePreorder_SuppliesTrxID = 0,
|
||||
Preorder_SampleLastUpdated = NOW(),
|
||||
Preorder_SampleUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SampleID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['supplies']){
|
||||
foreach($prm['supplies'] as $k => $v){
|
||||
if($v['status'] === 'Y' && ( $v['trx_id'] == 0 || $v['trx_id'] == '0')){
|
||||
$query ="INSERT INTO one_preorder_dev.preorder_supplies (
|
||||
Preorder_SuppliesPreorder_SuppliesTrxID,
|
||||
Preorder_SuppliesM_SuppliesID,
|
||||
Preorder_SuppliesQty,
|
||||
Preorder_SuppliesUserID,
|
||||
Preorder_SuppliesCreated,
|
||||
Preorder_SuppliesLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
{$v['supplies_id']},
|
||||
{$v['qty']},
|
||||
{$userid},
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savesupplies = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['status'] === 'Y' && ( $v['trx_id'] != 0 || $v['trx_id'] != '0')){
|
||||
$query ="UPDATE one_preorder_dev.preorder_supplies SET
|
||||
Preorder_SuppliesQty = {$v['qty']},
|
||||
Preorder_SuppliesLastUpdated = NOW(),
|
||||
Preorder_SuppliesUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savesupplies = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['status'] === 'N' && ( $v['trx_id'] != 0 || $v['trx_id'] != '0')){
|
||||
$query ="UPDATE one_preorder_dev.preorder_supplies SET
|
||||
Preorder_SuppliesIsActive = 'N',
|
||||
Preorder_SuppliesLastUpdated = NOW(),
|
||||
Preorder_SuppliesUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savesupplies = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['buffers']){
|
||||
foreach($prm['buffers'] as $k => $v){
|
||||
if($v['status'] === 'Y' && ( $v['trx_id'] == 0 || $v['trx_id'] == '0')){
|
||||
$query ="INSERT INTO one_preorder_dev.preorder_suppliesbuffer (
|
||||
Preorder_SuppliesBufferPreorder_SuppliesTrxID,
|
||||
Preorder_SuppliesBufferM_SuppliesID,
|
||||
Preorder_SuppliesBufferQty,
|
||||
Preorder_SuppliesBufferUserID,
|
||||
Preorder_SuppliesBufferCreated,
|
||||
Preorder_SuppliesBufferLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
{$v['supplies_id']},
|
||||
{$v['qty']},
|
||||
{$userid},
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savebuffers = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['status'] === 'Y' && ( $v['trx_id'] != 0 || $v['trx_id'] != '0')){
|
||||
$query ="UPDATE one_preorder_dev.preorder_suppliesbuffer SET
|
||||
Preorder_SuppliesBufferQty = {$v['qty']},
|
||||
Preorder_SuppliesBufferLastUpdated = NOW(),
|
||||
Preorder_SuppliesBufferUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesBufferID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savebuffers = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['status'] === 'N' && ( $v['trx_id'] != 0 || $v['trx_id'] != '0')){
|
||||
$query ="UPDATE one_preorder_dev.preorder_suppliesbuffer SET
|
||||
Preorder_SuppliesBufferIsActive = 'N',
|
||||
Preorder_SuppliesBufferLastUpdated = NOW(),
|
||||
Preorder_SuppliesBufferUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesBufferID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savebuffers = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function deletetrx(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE one_preorder_dev.preorder_suppliestrx SET
|
||||
Preorder_SuppliesTrxIsActive = 'N',
|
||||
Preorder_SuppliesTrxUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesTrxID = {$prm['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $prm['trx_id'];
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $prm['trx_numbering'],
|
||||
"id" => $prm['trx_id']
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['act'] == 'RELEASEC' || $prm['act'] === 'RCVDOC' ){
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierStatus = '{$prm['act']}',
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
if($prm['act'] === 'DONE'){
|
||||
$details = $prm['details'];
|
||||
$count_n = 0;
|
||||
foreach($details as $k => $v){
|
||||
if($v['flag_image_receive'] === 'N'){
|
||||
$count_n++;
|
||||
}
|
||||
if($v['flag_result_receive'] === 'N'){
|
||||
$count_n++;
|
||||
}
|
||||
$query ="UPDATE so_walklettercourierdetail SET
|
||||
So_WalkLetterCourierDetailFlagReceiveImage = '{$v['flag_image_receive']}',
|
||||
So_WalkLetterCourierDetailFlagReceiveResult = '{$v['flag_result_receive']}',
|
||||
So_WalkLetterCourierDetailUserID = '{$userid}'
|
||||
WHERE
|
||||
So_WalkLetterCourierDetailID = {$v['idx']}
|
||||
";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
$status = 'DONE';
|
||||
if($count_n > 0){
|
||||
$status = 'PARTDONE';
|
||||
}
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierStatus = '{$status}',
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
if($prm['act'] == 'FORCEDONE'){
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierStatus = 'DONE',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
46
application/controllers/v1/preorder/home-service/Type.php
Normal file
46
application/controllers/v1/preorder/home-service/Type.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class Type extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
public function lookup()
|
||||
{
|
||||
$query = " SELECT M_PreOrderTypeID as id, M_PreOrderTypeName as name
|
||||
FROM one_preorder_dev.m_preordertype
|
||||
WHERE
|
||||
M_PreOrderTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function lookup_outbox()
|
||||
{
|
||||
$query = " SELECT typeID as id, typeCode as name
|
||||
FROM one_gateway.type
|
||||
WHERE
|
||||
typeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
79
application/controllers/v1/process/Fo_verification.php
Normal file
79
application/controllers/v1/process/Fo_verification.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
class Fo_verification extends MY_Controller {
|
||||
function index() {
|
||||
echo "FO Verification";
|
||||
}
|
||||
function listing_order() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_startdate = $prm["startdate"];
|
||||
$s_enddate = $prm["enddate"];
|
||||
$s_query= "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 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_startdate,$end);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from t_orderheader
|
||||
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
where (T_OrderHeaderNumber like ? OR M_PatientName like ?) and T_OrderHeaderIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("t_orderheader count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. 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 T_OrderHeaderDate, T_OrderHeaderNumber,M_PatientNoReg,M_PatientName,M_DoctorName
|
||||
from t_orderheader
|
||||
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_doctor ON T_OrderHeaderM_DoctorID = M_DoctorID
|
||||
where (T_OrderHeaderNumber like ? OR M_PatientName like ?) and T_OrderHeaderIsActive='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("t_orderheader rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
29
application/controllers/v1/report-cpone/Agama.php
Normal file
29
application/controllers/v1/report-cpone/Agama.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class Agama extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1878
application/controllers/v1/report-cpone/Fisik-bkp.php
Normal file
1878
application/controllers/v1/report-cpone/Fisik-bkp.php
Normal file
File diff suppressed because it is too large
Load Diff
2481
application/controllers/v1/report-cpone/Fisik.php
Normal file
2481
application/controllers/v1/report-cpone/Fisik.php
Normal file
File diff suppressed because it is too large
Load Diff
2129
application/controllers/v1/report-cpone/Fisik.php--010420
Normal file
2129
application/controllers/v1/report-cpone/Fisik.php--010420
Normal file
File diff suppressed because it is too large
Load Diff
2132
application/controllers/v1/report-cpone/Fisik.php--040420
Normal file
2132
application/controllers/v1/report-cpone/Fisik.php--040420
Normal file
File diff suppressed because it is too large
Load Diff
2132
application/controllers/v1/report-cpone/Fisik.php--04042020
Normal file
2132
application/controllers/v1/report-cpone/Fisik.php--04042020
Normal file
File diff suppressed because it is too large
Load Diff
2118
application/controllers/v1/report-cpone/Fisik.php--180320-m1l1m
Normal file
2118
application/controllers/v1/report-cpone/Fisik.php--180320-m1l1m
Normal file
File diff suppressed because it is too large
Load Diff
2154
application/controllers/v1/report-cpone/Fisik.php--180320-malam
Normal file
2154
application/controllers/v1/report-cpone/Fisik.php--180320-malam
Normal file
File diff suppressed because it is too large
Load Diff
2154
application/controllers/v1/report-cpone/Fisik.php-140320
Normal file
2154
application/controllers/v1/report-cpone/Fisik.php-140320
Normal file
File diff suppressed because it is too large
Load Diff
2154
application/controllers/v1/report-cpone/Fisik.php-170320
Normal file
2154
application/controllers/v1/report-cpone/Fisik.php-170320
Normal file
File diff suppressed because it is too large
Load Diff
2168
application/controllers/v1/report-cpone/Fisik.php-180220
Normal file
2168
application/controllers/v1/report-cpone/Fisik.php-180220
Normal file
File diff suppressed because it is too large
Load Diff
352
application/controllers/v1/report-cpone/Fisik0.php
Normal file
352
application/controllers/v1/report-cpone/Fisik0.php
Normal file
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
class Fisik extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function pribadi($id,$langid) {
|
||||
//$id = So_ResultEntryID
|
||||
$sql = "select concat(M_TitleName,' ', M_PatientName) M_PatientName,
|
||||
T_OrderHeaderLabNumber RegNo, fn_numbering_external(T_OrderHeaderLabNumber) ExternalRegNo,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
date_format(M_PatientDOB,'%d-%m-%Y') M_PatientDOB ,
|
||||
date_format(T_OrderHeaderDate,'%d-%m-%Y') T_OrderHeaderDate,
|
||||
M_SexName,
|
||||
(SELECT concat(M_PatientAddressDescription,' ',M_KelurahanName,' ' ,M_DistrictName,' ',M_CityName) from m_patientaddress AS p
|
||||
left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
left join m_district on M_KelurahanM_DistrictID = M_DistrictID
|
||||
left join m_city on M_DistrictM_CityID = M_CityID
|
||||
WHERE M_PatientAddressM_PatientID = M_PatientID
|
||||
ORDER BY M_PatientAddressM_PatientID
|
||||
LIMIT 1) AS M_PatientAddressDescription
|
||||
from so_resultentry
|
||||
join t_orderheader on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
|
||||
and So_ResultEntryID = ?
|
||||
join m_patient on M_PatientID = T_OrderHeaderM_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
left join m_sex on M_PatientM_SexID = M_SexID
|
||||
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql,array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach($rows as $idx => $r ) {
|
||||
$rows[$idx]["keluhan_saat_ini"] = $this->keluhan_saat_ini($id,$langid);
|
||||
$rows[$idx]["phobia"] = $this->phobia($id,$langid);
|
||||
}
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
|
||||
function phobia($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$phobia = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT POBIA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$phobia = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $phobia != "" ) $phobia .= ", ";
|
||||
$phobia .= $xd["label"];
|
||||
if ($xd["value"] != "") $phobia .= " (" .$xd["value"] . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $phobia;
|
||||
}
|
||||
|
||||
function keluhan_saat_ini($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$keluhan_saat_ini = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "KELUHAN SAAT INI") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$keluhan_saat_ini = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $keluhan_saat_ini != "" ) $keluhan_saat_ini .= ", ";
|
||||
$keluhan_saat_ini .= $xd["label"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $keluhan_saat_ini;
|
||||
}
|
||||
|
||||
function riwayat_penyakit($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_penyakit = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_penyakit = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group == "Allergi" ) continue;
|
||||
$have_detail = false;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$have_detail = true;
|
||||
}
|
||||
}
|
||||
if ($have_detail) {
|
||||
$arr_result[] = array($group, "", "","") ;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result[] = array($xd["label"], "X", "",$xd["value"]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$riwayat_penyakit[] = array(
|
||||
"c1" => $left[0],
|
||||
"c2" => $left[1],
|
||||
"c3" => $left[2],
|
||||
"c4" => $left[3],
|
||||
"c5" => $right[0],
|
||||
"c6" => $right[1],
|
||||
"c7" => $right[2],
|
||||
"c8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($riwayat_penyakit);
|
||||
//return ($riwayat_penyakit);
|
||||
}
|
||||
|
||||
//riwayat penyakit keluarga
|
||||
function penyakit_keluarga($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$penyakit_keluarga = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT KELUARGA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$penyakit_keluarga = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "X", "",$gp["value"]) ;
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$penyakit_keluarga[] = array(
|
||||
"d1" => $left[0],
|
||||
"d2" => $left[1],
|
||||
"d3" => $left[2],
|
||||
"d4" => $left[3],
|
||||
"d5" => $right[0],
|
||||
"d6" => $right[1],
|
||||
"d7" => $right[2],
|
||||
"d8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($penyakit_keluarga);
|
||||
//return ($penyakit_keluarga);
|
||||
}
|
||||
|
||||
|
||||
function riwayat_alergi($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_alergi = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_alergi = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group != "Allergi" ) continue;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result = array($xd["label"], "Ya", "",$xd["value"]) ;
|
||||
} else {
|
||||
$arr_result = array($xd["label"], "Tidak", "X",$xd["value"]) ;
|
||||
}
|
||||
$riwayat_alergi[] = array(
|
||||
"a1" => $arr_result[0],
|
||||
"a2" => $arr_result[1],
|
||||
"a3" => $arr_result[2],
|
||||
"a4" => $arr_result[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_alergi);
|
||||
}
|
||||
|
||||
function riwayat_obat($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_obat = array();
|
||||
foreach($details as $d) {
|
||||
|
||||
if ($d["title"] == "RIWAYAT KONSUMSI OBAT TERATUR") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_obat = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "Ya", "Tidak",$gp["value"]) ;
|
||||
$riwayat_obat[] = array(
|
||||
"o1" => $gp["label"],
|
||||
"o2" => "Ya",
|
||||
"o3" => $gp["value"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_obat);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
2508
application/controllers/v1/report-cpone/Fisik_2024.php
Normal file
2508
application/controllers/v1/report-cpone/Fisik_2024.php
Normal file
File diff suppressed because it is too large
Load Diff
2236
application/controllers/v1/report-cpone/Fisik_Oktober_surabaya.php
Normal file
2236
application/controllers/v1/report-cpone/Fisik_Oktober_surabaya.php
Normal file
File diff suppressed because it is too large
Load Diff
2508
application/controllers/v1/report-cpone/Fisik_bkpadhi2024.php
Normal file
2508
application/controllers/v1/report-cpone/Fisik_bkpadhi2024.php
Normal file
File diff suppressed because it is too large
Load Diff
2471
application/controllers/v1/report-cpone/Fisik_eng.php
Normal file
2471
application/controllers/v1/report-cpone/Fisik_eng.php
Normal file
File diff suppressed because it is too large
Load Diff
2245
application/controllers/v1/report-cpone/Fisik_old.php
Normal file
2245
application/controllers/v1/report-cpone/Fisik_old.php
Normal file
File diff suppressed because it is too large
Load Diff
68
application/controllers/v1/report-cpone/Hs_payment.php
Normal file
68
application/controllers/v1/report-cpone/Hs_payment.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
class Hs_payment extends MY_Controller {
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
function by_id($paymentID,$userID =3) {
|
||||
$sql = "select M_UserUserName from m_user where M_UserID = ?";
|
||||
$qry = $this->db->query($sql,[$userID]);
|
||||
if (!$qry) {
|
||||
// echo $this->db->error()["message"];
|
||||
echo json_encode([]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$userName = "RptAdmin";
|
||||
if (count($rows) > 0) {
|
||||
$userName = $rows[0]["M_UserUserName"];
|
||||
}
|
||||
$sql = "select
|
||||
? M_UserName,
|
||||
F_PaymentLogDetailsID ,
|
||||
F_PaymentLogDetailsHS_DeliveryOrderID ,
|
||||
F_PaymentLogDetailsF_PaymentID,
|
||||
F_PaymentLogDetailsJSON ,
|
||||
F_PaymentLogDetailsUserID ,
|
||||
F_PaymentLogDetailsUsername
|
||||
from one_hs.f_payment_log_details
|
||||
where F_PaymentLogDetailsF_PaymentID =?";
|
||||
$qry = $this->db->query($sql,[$userName,$paymentID]);
|
||||
if (!$qry) {
|
||||
// echo $this->db->error()["message"];
|
||||
echo json_encode([]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$result = [];
|
||||
foreach($rows as $r) {
|
||||
$json= json_decode($r["F_PaymentLogDetailsJSON"],true);
|
||||
unset($r["F_PaymentLogDetailsJSON"]);
|
||||
|
||||
$header= $json["details"][0];
|
||||
$patient_name = $json["details"][0]["patient_name"];
|
||||
$j_details = $json["details"][0]["details"];
|
||||
$payment = $json["payment"];
|
||||
unset($json["details"]);
|
||||
unset($json["payment"]);
|
||||
unset($payment["username"]);
|
||||
unset($payment["payment_id"]);
|
||||
$payment["payment_amount"] = $payment["amount"];
|
||||
unset($payment["amount"]);
|
||||
$r = array_merge($r,$json);
|
||||
$r = array_merge($r,$payment);
|
||||
foreach( $j_details as $j) {
|
||||
$arr = ["patient_name"=>$patient_name,
|
||||
"amount" => $j["amount"],
|
||||
"discount" => $j["discount"],
|
||||
"discountrp" => $j["discountrp"],
|
||||
"subtotal" => $j["subtotal"],
|
||||
"test_name" => $j["test_name"],
|
||||
"total" => $j["total"]
|
||||
];
|
||||
$result[] = array_merge($r,$arr) ;
|
||||
}
|
||||
$idx = count($result) - 1;
|
||||
}
|
||||
echo json_encode($result);
|
||||
}
|
||||
}
|
||||
492
application/controllers/v1/report-cpone/Medis.php
Normal file
492
application/controllers/v1/report-cpone/Medis.php
Normal file
@@ -0,0 +1,492 @@
|
||||
<?php
|
||||
class Medis extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
//$this->db = $this->load->database("one", true);
|
||||
}
|
||||
function pribadi($id, $langid)
|
||||
{
|
||||
//$id = orderID
|
||||
$sql = "SELECT
|
||||
orderID,
|
||||
orderDate,
|
||||
orderAge,
|
||||
orderNumber ,
|
||||
one.fn_get_name(orderM_PatientID) as M_PatientName,
|
||||
orderKeluhan,
|
||||
orderDiagnosisAwal,
|
||||
orderDiagnosisAkhir,
|
||||
CONCAT(ifnull( M_DoctorPrefix,''),' ', M_DoctorName,' ',ifnull( M_DoctorSufix,''),' ',ifnull( M_DoctorSufix2,''),' ',ifnull( M_DoctorSufix3,'')) AS M_DoctorName,
|
||||
orderDoctorVitalSign ,
|
||||
orderDoctorReceipt,
|
||||
orderDoctorDiagnosePrimer ,
|
||||
orderDoctorDiagnoseSekunder ,
|
||||
orderDoctorSaran
|
||||
|
||||
FROM one_klinik.`order`
|
||||
left join m_doctor ON order.orderM_DoctorID = M_DoctorID
|
||||
left join one_klinik.order_doctor on orderDoctorOrderID = OrderID and orderDoctorIsActive = 'Y'
|
||||
|
||||
where
|
||||
orderID = ?
|
||||
and
|
||||
orderDoctorType = 'TEXT'
|
||||
|
||||
";
|
||||
$qry = $this->db->query($sql, array($id));
|
||||
//echo $this->db->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
// foreach($rows as $idx => $r ) {
|
||||
// $rows[$idx]["keluhan_saat_ini"] = $this->keluhan_saat_ini($id,$langid,$type);
|
||||
// $rows[$idx]["phobia"] = $this->phobia($id,$langid,$type);
|
||||
// $rows[$idx]["kesimpulan"] = $this->kesimpulanv4($id,$langid);
|
||||
// }
|
||||
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function keluhan_saat_ini_new($id,$langid)
|
||||
{
|
||||
$sql = "select * from one_klinik.order_anamnesis
|
||||
left join one_klinik.`order` on orderAnamnesisOrderID = OrderID
|
||||
where OrderID = ?
|
||||
and orderM_LanguageID =?
|
||||
and orderAnamnesisTypeForm = 'FORM' ";
|
||||
|
||||
$qry = $this->db->query($sql, array($id,$langid));
|
||||
|
||||
if (!$qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
//print_r($rows[0]["orderAnamnesisKeluhanUtama"]);
|
||||
if (count($rows) == 0) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["orderAnamnesisKeluhanUtama"], true);
|
||||
|
||||
//keluhan saat ini
|
||||
$keluhan_saat_ini_new = array();
|
||||
foreach ($details[0]["details"] as $d) {
|
||||
if ($d["chx"] == 1) {
|
||||
$keluhan_saat_ini_new[] = array(
|
||||
"a1" => $d["label"],
|
||||
"a2" => $d["value"],
|
||||
);
|
||||
}
|
||||
}
|
||||
echo json_encode($keluhan_saat_ini_new);
|
||||
}
|
||||
|
||||
|
||||
function riwayat_penyakit($id,$langid) {
|
||||
$sql = "select * from one_klinik.order_anamnesis
|
||||
left join one_klinik.`order` on orderAnamnesisOrderID = OrderID
|
||||
where OrderID = ?
|
||||
and orderM_LanguageID =?
|
||||
and orderAnamnesisTypeForm = 'FORM' ";
|
||||
|
||||
$qry = $this->db->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["orderAnamnesisRiwayatPenyakitDanAlergiDahulu"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_penyakit = array();
|
||||
foreach ($details[0]["details"] as $d) {
|
||||
|
||||
|
||||
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result[] = array($xd["label"],$xd["value"],$xd["segment_name"],$xd["id"]) ;
|
||||
$riwayat_penyakit[] = array(
|
||||
"c1" => $xd["label"],
|
||||
"c2" => $xd["value"],
|
||||
"c3" => $xd["segment_name"],
|
||||
"c4" => $xd["id"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
echo json_encode($riwayat_penyakit);
|
||||
}
|
||||
|
||||
|
||||
function riwayat_penyakit_sekarang($id,$langid) {
|
||||
$sql = "select * from one_klinik.order_anamnesis
|
||||
left join one_klinik.`order` on orderAnamnesisOrderID = OrderID
|
||||
where OrderID = ?
|
||||
and orderM_LanguageID =?
|
||||
and orderAnamnesisTypeForm = 'FORM' ";
|
||||
|
||||
$qry = $this->db->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["orderAnamnesisRiwayatPenyakitDanAlergiSekarang"],true);
|
||||
|
||||
$riwayat_penyakit_sekarang = array();
|
||||
foreach ($details[0]["details"] as $d) {
|
||||
|
||||
|
||||
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result[] = array($xd["label"],$xd["value"],$xd["segment_name"],$xd["id"]) ;
|
||||
$riwayat_penyakit_sekarang[] = array(
|
||||
"cc1" => $xd["label"],
|
||||
"cc2" => $xd["value"],
|
||||
"cc3" => $xd["segment_name"],
|
||||
"cc4" => $xd["id"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
echo json_encode($riwayat_penyakit_sekarang);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function riwayat_keluarga($id, $langid)
|
||||
{
|
||||
$sql = "select * from one_klinik.order_anamnesis
|
||||
left join one_klinik.`order` on orderAnamnesisOrderID = OrderID
|
||||
where OrderID = ?
|
||||
and orderM_LanguageID =?
|
||||
and orderAnamnesisTypeForm = 'FORM' ";
|
||||
|
||||
|
||||
$qry = $this->db->query($sql, array($id, $langid));
|
||||
if (!$qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["orderAnamnesisRiwayatPenyakitKeluarga"], true);
|
||||
//keluhan saat ini
|
||||
$riwayat_keluarga = array();
|
||||
foreach ($details[0]["details"] as $d) {
|
||||
|
||||
// foreach ($d["details"] as $gp) {
|
||||
//echo print_r($d["details"]);
|
||||
if (true || $d["chx"] == 1) {
|
||||
$arr_result[] = array($d["label"], $d["value"], $d["id"]);
|
||||
foreach ($d["options"] as $gpd) {
|
||||
if ($gpd["selected"] == 1) {
|
||||
$riwayat_keluarga[] = array(
|
||||
"d1" => $d["label"],
|
||||
"d2" => $gpd["label"],
|
||||
"d3" => $d["id"],
|
||||
);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_keluarga);
|
||||
}
|
||||
|
||||
|
||||
function riwayat_obat($id, $langid)
|
||||
{
|
||||
$sql = "select * from one_klinik.order_anamnesis
|
||||
left join one_klinik.`order` on orderAnamnesisOrderID = OrderID
|
||||
where OrderID = ?
|
||||
and orderM_LanguageID =?
|
||||
and orderAnamnesisTypeForm = 'FORM' ";
|
||||
$qry = $this->db->query($sql, array($id, $langid));
|
||||
if (!$qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["orderAnamnesisRiwayatPengobatan"], true);
|
||||
//keluhan saat ini
|
||||
$riwayat_obat = array();
|
||||
foreach ($details[0]["details"] as $gp) {
|
||||
|
||||
// echo print_r($d);
|
||||
|
||||
if ($gp["chx"] == 1) {
|
||||
$arr_result[] = array($gp["label"], $gp["value"]);
|
||||
$riwayat_obat[] = array(
|
||||
"f1" => $gp["label"],
|
||||
"f2" => $gp["value"],
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
echo json_encode($riwayat_obat);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function riwayat_hidup($id, $langid )
|
||||
{
|
||||
$sql = "select * from one_klinik.order_anamnesis
|
||||
left join one_klinik.`order` on orderAnamnesisOrderID = OrderID
|
||||
where OrderID = ?
|
||||
and orderM_LanguageID =?
|
||||
and orderAnamnesisTypeForm = 'FORM' ";
|
||||
$qry = $this->db->query($sql, array($id, $langid ));
|
||||
if (!$qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["orderAnamnesisRiwayatSosial"], true);
|
||||
//keluhan saat ini
|
||||
$riwayat_hidup = array();
|
||||
foreach ($details[0]["details"] as $d) {
|
||||
|
||||
|
||||
|
||||
foreach ($d["details"] as $xd) {
|
||||
if ($xd["chx"] == 1) {
|
||||
$arr_result[] = array($xd["segment_name"], $xd["label"], $xd["value"]);
|
||||
$riwayat_hidup[] = array(
|
||||
"e1" => $xd["segment_name"],
|
||||
"e2" => $xd["label"] . ' ' . $xd["value"],
|
||||
"e3" => $xd["value"],
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_hidup);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function riwayat_imunisasi($id, $langid )
|
||||
{
|
||||
$sql = "select orderAnamnesisRiwayatImunisasi as details from one_klinik.order_anamnesis
|
||||
left join one_klinik.`order` on orderAnamnesisOrderID = OrderID
|
||||
where OrderID = ?
|
||||
and orderM_LanguageID =?
|
||||
and orderAnamnesisTypeForm = 'FORM' AND orderAnamnesisIsActive = 'Y' LIMIT 1";
|
||||
|
||||
$qry = $this->db->query($sql, array($id, $langid ));
|
||||
//echo $this->db->last_query(). "<br>";
|
||||
|
||||
if (!$qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->row_array();
|
||||
//print_r($rows['details']);
|
||||
$imunisasi = json_decode($rows["details"], true);
|
||||
//print_r($imunisasi );
|
||||
//keluhan saat ini
|
||||
$riwayat_imunisasi = array();
|
||||
// print_r($imunisasi['details']);
|
||||
|
||||
|
||||
foreach ($imunisasi[0]['details'] as $key => $d) {
|
||||
//print_r($d);
|
||||
foreach($d['details'] as $k => $xd){
|
||||
// echo $xd['id_code'];
|
||||
if ($xd["chx"] == 1) {
|
||||
$arr_result[] = array($xd["segment_name"], $xd["label"], $xd["value"]);
|
||||
//print_r($arr_result);
|
||||
$riwayat_imunisasi[] = array(
|
||||
"g1" => $xd["segment_name"],
|
||||
"g2" => $xd["label"] . ' ' . $xd["value"],
|
||||
"g3" => $xd["value"],
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_imunisasi);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//pemeriksaan Fisik
|
||||
function tanda_vital($id, $langid)
|
||||
{
|
||||
$sql = "select * from one_klinik.order_doctor
|
||||
left join one_klinik.`order` on orderDoctorOrderID = OrderID
|
||||
where orderDoctorOrderID = ?
|
||||
and orderM_LanguageID =?
|
||||
and orderDoctorType = 'FORM'
|
||||
";
|
||||
$qry = $this->db->query($sql, array($id, $langid));
|
||||
if (!$qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["orderDoctorVitalSign"], true);
|
||||
//keluhan saat ini
|
||||
$tanda_vital = array();
|
||||
foreach ($details as $d) {
|
||||
if ($d["title"] == "TANDA VITAL") {
|
||||
|
||||
foreach ($d["details"] as $gp) {
|
||||
$value = $gp["value"] . ' ' . $gp["unit"];
|
||||
if ($gp["chx_x"] == "1") $value = $gp["label_x"];
|
||||
|
||||
if ($gp["chx_y"] == "1") $value = $gp["label_y"] . ' ' . $gp["value"] . ' ' . $gp["unit"];
|
||||
|
||||
|
||||
$tanda_vital[] = array(
|
||||
"aa1" => $gp["label"],
|
||||
"aa2" => $value,
|
||||
"aa3" => ucwords(strtolower($gp["value_x"])),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($tanda_vital);
|
||||
}
|
||||
|
||||
function status_gizi($id, $langid)
|
||||
{
|
||||
$sql = "select * from one_klinik.order_doctor
|
||||
left join one_klinik.`order` on orderDoctorOrderID = OrderID
|
||||
where orderDoctorOrderID = ?
|
||||
and orderM_LanguageID =?
|
||||
and orderDoctorType = 'FORM'
|
||||
";
|
||||
$qry = $this->db->query($sql, array($id, $langid));
|
||||
if (!$qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["orderDoctorVitalSign"], true);
|
||||
//keluhan saat ini
|
||||
$status_gizi = array();
|
||||
foreach ($details as $d) {
|
||||
if ($d["title"] == "STATUS GIZI") {
|
||||
|
||||
foreach ($d["details"] as $gp) {
|
||||
$value = $gp["value"];
|
||||
if ($gp["chx_x"] == "1") $value = $gp["label_x"];
|
||||
if ($gp["chx_y"] == "1") $value = $gp["label_y"];
|
||||
|
||||
if ($gp["value"] == NaN) {
|
||||
$value = '-';
|
||||
}
|
||||
$status_gizi[] = array(
|
||||
"qq1" => $gp["label"],
|
||||
"qq2" => $value,
|
||||
"qq3" => $gp["unit"],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($status_gizi);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//k3
|
||||
function kesimpulanx2($id, $langid, $type)
|
||||
{
|
||||
$sql = "select * from one_klinik.so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType=?";
|
||||
$qry = $this->db->query($sql, array($id, $langid, $type));
|
||||
if (!$qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"], true);
|
||||
//keluhan saat ini
|
||||
$kesimpulanx = array("asdasdasdasdasd");
|
||||
foreach ($details as $d) {
|
||||
|
||||
if ($d["title"] == "") {
|
||||
|
||||
foreach ($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1) {
|
||||
$arr_result[] = array($gp["label"], $gp["value"]);
|
||||
$kesimpulanx[] = array(
|
||||
"nn1" => $gp["label"],
|
||||
"nn2" => $gp["value"]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode(array("abc" => $kesimpulanx));
|
||||
}
|
||||
|
||||
|
||||
function list()
|
||||
{
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id)
|
||||
{
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db->query($sql, $id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
29
application/controllers/v1/report-dev/Agama.php
Normal file
29
application/controllers/v1/report-dev/Agama.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class Agama extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1868
application/controllers/v1/report-dev/Fisik.php
Normal file
1868
application/controllers/v1/report-dev/Fisik.php
Normal file
File diff suppressed because it is too large
Load Diff
352
application/controllers/v1/report-dev/Fisik0.php
Normal file
352
application/controllers/v1/report-dev/Fisik0.php
Normal file
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
class Fisik extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function pribadi($id,$langid) {
|
||||
//$id = So_ResultEntryID
|
||||
$sql = "select concat(M_TitleName,' ', M_PatientName) M_PatientName,
|
||||
T_OrderHeaderLabNumber RegNo, fn_numbering_external(T_OrderHeaderLabNumber) ExternalRegNo,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
date_format(M_PatientDOB,'%d-%m-%Y') M_PatientDOB ,
|
||||
date_format(T_OrderHeaderDate,'%d-%m-%Y') T_OrderHeaderDate,
|
||||
M_SexName,
|
||||
(SELECT concat(M_PatientAddressDescription,' ',M_KelurahanName,' ' ,M_DistrictName,' ',M_CityName) from m_patientaddress AS p
|
||||
left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
left join m_district on M_KelurahanM_DistrictID = M_DistrictID
|
||||
left join m_city on M_DistrictM_CityID = M_CityID
|
||||
WHERE M_PatientAddressM_PatientID = M_PatientID
|
||||
ORDER BY M_PatientAddressM_PatientID
|
||||
LIMIT 1) AS M_PatientAddressDescription
|
||||
from so_resultentry
|
||||
join t_orderheader on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
|
||||
and So_ResultEntryID = ?
|
||||
join m_patient on M_PatientID = T_OrderHeaderM_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
left join m_sex on M_PatientM_SexID = M_SexID
|
||||
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql,array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach($rows as $idx => $r ) {
|
||||
$rows[$idx]["keluhan_saat_ini"] = $this->keluhan_saat_ini($id,$langid);
|
||||
$rows[$idx]["phobia"] = $this->phobia($id,$langid);
|
||||
}
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
|
||||
function phobia($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$phobia = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT POBIA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$phobia = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $phobia != "" ) $phobia .= ", ";
|
||||
$phobia .= $xd["label"];
|
||||
if ($xd["value"] != "") $phobia .= " (" .$xd["value"] . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $phobia;
|
||||
}
|
||||
|
||||
function keluhan_saat_ini($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$keluhan_saat_ini = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "KELUHAN SAAT INI") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$keluhan_saat_ini = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $keluhan_saat_ini != "" ) $keluhan_saat_ini .= ", ";
|
||||
$keluhan_saat_ini .= $xd["label"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $keluhan_saat_ini;
|
||||
}
|
||||
|
||||
function riwayat_penyakit($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_penyakit = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_penyakit = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group == "Allergi" ) continue;
|
||||
$have_detail = false;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$have_detail = true;
|
||||
}
|
||||
}
|
||||
if ($have_detail) {
|
||||
$arr_result[] = array($group, "", "","") ;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result[] = array($xd["label"], "X", "",$xd["value"]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$riwayat_penyakit[] = array(
|
||||
"c1" => $left[0],
|
||||
"c2" => $left[1],
|
||||
"c3" => $left[2],
|
||||
"c4" => $left[3],
|
||||
"c5" => $right[0],
|
||||
"c6" => $right[1],
|
||||
"c7" => $right[2],
|
||||
"c8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($riwayat_penyakit);
|
||||
//return ($riwayat_penyakit);
|
||||
}
|
||||
|
||||
//riwayat penyakit keluarga
|
||||
function penyakit_keluarga($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$penyakit_keluarga = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT KELUARGA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$penyakit_keluarga = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "X", "",$gp["value"]) ;
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$penyakit_keluarga[] = array(
|
||||
"d1" => $left[0],
|
||||
"d2" => $left[1],
|
||||
"d3" => $left[2],
|
||||
"d4" => $left[3],
|
||||
"d5" => $right[0],
|
||||
"d6" => $right[1],
|
||||
"d7" => $right[2],
|
||||
"d8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($penyakit_keluarga);
|
||||
//return ($penyakit_keluarga);
|
||||
}
|
||||
|
||||
|
||||
function riwayat_alergi($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_alergi = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_alergi = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group != "Allergi" ) continue;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result = array($xd["label"], "Ya", "",$xd["value"]) ;
|
||||
} else {
|
||||
$arr_result = array($xd["label"], "Tidak", "X",$xd["value"]) ;
|
||||
}
|
||||
$riwayat_alergi[] = array(
|
||||
"a1" => $arr_result[0],
|
||||
"a2" => $arr_result[1],
|
||||
"a3" => $arr_result[2],
|
||||
"a4" => $arr_result[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_alergi);
|
||||
}
|
||||
|
||||
function riwayat_obat($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_obat = array();
|
||||
foreach($details as $d) {
|
||||
|
||||
if ($d["title"] == "RIWAYAT KONSUMSI OBAT TERATUR") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_obat = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "Ya", "Tidak",$gp["value"]) ;
|
||||
$riwayat_obat[] = array(
|
||||
"o1" => $gp["label"],
|
||||
"o2" => "Ya",
|
||||
"o3" => $gp["value"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_obat);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
650
application/controllers/v1/report-usergroup/Usergroup.php
Normal file
650
application/controllers/v1/report-usergroup/Usergroup.php
Normal file
@@ -0,0 +1,650 @@
|
||||
<?php
|
||||
|
||||
class Usergroup extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "USER GROUP REPORT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookupuserbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupname = $prm['groupname'];
|
||||
$filter = '';
|
||||
if(isset($sexid)){
|
||||
$filter .= "AND ($sexid = 0 or ($sexid > 0 and Nat_SexID = $sexid)) ";
|
||||
}
|
||||
if(isset($flagid)){
|
||||
$filter .= "AND ($flagid = 0 or ($flagid > 0 and Nat_FlagID = $flagid))";
|
||||
}
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from m_usergroup
|
||||
WHERE
|
||||
M_UserGroupIsActive = 'Y' AND
|
||||
M_UserGroupName like '%{$groupname}%'
|
||||
$filter GROUP BY M_UserGroupID) a";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//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("m_usergroup count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT m_usergroup.*,
|
||||
M_UserGroupID as id,
|
||||
M_UserGroupID,
|
||||
M_UserGroupName
|
||||
FROM m_usergroup
|
||||
WHERE
|
||||
M_UserGroupIsActive = 'Y' AND
|
||||
M_UserGroupName like '%{$groupname}%'
|
||||
$filter
|
||||
GROUP BY M_UserGroupID
|
||||
ORDER BY M_UserGroupName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("m_usergroup select");
|
||||
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 lookupreportbyid(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$reportgroup = $prm['reportgroup'];
|
||||
$reportcode = $prm['reportcode'];
|
||||
$reportname = $prm['reportname'];
|
||||
$status = $prm['status'];
|
||||
$all = $prm['all'];
|
||||
$filter = '';
|
||||
if($status != 'A'){
|
||||
$filter .= "AND status = '{$status}' ";
|
||||
}else{
|
||||
$filter .= "";
|
||||
}
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *, IF(IFNULL(UserGroupReportID,0) > 0 , 'Y', 'N') as status
|
||||
from r_report
|
||||
LEFT JOIN usergroup_report ON R_ReportID = UserGroupReportR_ReportID AND UserGroupReportM_UserGroupID = $id AND UserGroupReportIsActive = 'Y'
|
||||
LEFT JOIN m_usergroup ON UserGroupReportM_UserGroupID = M_UserGroupID AND M_UserGroupIsActive = 'Y'
|
||||
LEFT JOIN r_reportgroup ON R_ReportR_ReportGroupID = R_ReportGroupID
|
||||
WHERE
|
||||
R_ReportIsActive = 'Y') a
|
||||
WHERE
|
||||
R_ReportGroupName like '%{$reportgroup}%' AND
|
||||
R_ReportCode like '%{$reportcode}%' AND
|
||||
R_ReportName like '%{$reportname}%' $filter";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//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("r_report count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select R_ReportID as id,
|
||||
R_ReportID,
|
||||
R_ReportCode,
|
||||
R_ReportName,
|
||||
R_ReportGroupName,
|
||||
UserGroupReportID,
|
||||
UserGroupReportM_UserGroupID,
|
||||
UserGroupReportR_ReportID,
|
||||
IF(IFNULL(UserGroupReportID,0) > 0 , 'Y', 'N') as status
|
||||
from r_report
|
||||
LEFT JOIN usergroup_report ON R_ReportID = UserGroupReportR_ReportID AND UserGroupReportM_UserGroupID = $id AND UserGroupReportIsActive = 'Y'
|
||||
LEFT JOIN m_usergroup ON UserGroupReportM_UserGroupID = M_UserGroupID AND M_UserGroupIsActive = 'Y'
|
||||
LEFT JOIN r_reportgroup ON R_ReportR_ReportGroupID = R_ReportGroupID
|
||||
WHERE
|
||||
R_ReportIsActive = 'Y') a
|
||||
WHERE
|
||||
R_ReportGroupName like '%{$reportgroup}%' AND
|
||||
R_ReportCode like '%{$reportcode}%' AND
|
||||
R_ReportName like '%{$reportname}%' $filter
|
||||
GROUP BY R_ReportID
|
||||
ORDER BY R_ReportGroupName ASC, R_ReportName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("r_report select");
|
||||
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 getsexreg(){
|
||||
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
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getstatus(){
|
||||
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
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function addnewreport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $prm['userid'];
|
||||
$reportcode = $prm['reportcode'];
|
||||
$reportname = $prm['reportname'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into r_report(
|
||||
R_ReportCode,
|
||||
R_ReportName,
|
||||
R_ReportUserID,
|
||||
R_ReportCreated,
|
||||
R_ReportLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$reportcode,
|
||||
$reportname,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function saveaddeditreport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$usergroupid = $prm['userid'];
|
||||
$reportid = $prm['R_ReportID'];
|
||||
$reportuserid = $prm['UserGroupReportID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into usergroup_report(
|
||||
UserGroupReportM_UserGroupID,
|
||||
UserGroupReportR_ReportID,
|
||||
UserGroupUserID,
|
||||
UserGroupReportCreated,
|
||||
UserGroupReportLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$usergroupid,
|
||||
$reportid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("usergroup_report insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}else{
|
||||
$sql = "UPDATE usergroup_report SET
|
||||
UserGroupReportIsActive = 'N',
|
||||
UserGroupUserID = ?,
|
||||
UserGroupReportCreated = now(),
|
||||
UserGroupReportLastUpdated = now()
|
||||
WHERE UserGroupReportID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$reportuserid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("usergroup_report insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveallreport(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$details = $prm['details'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach($details as $k => $v){
|
||||
$query = "UPDATE usergroup_report SET
|
||||
UserGroupReportM_UserGroupID = '{$v['UserGroupReportM_UserGroupID']}',
|
||||
UserGroupReportAdviceIna = '{$v['UserGroupReportAdviceIna']}',
|
||||
UserGroupReportAdviceEng = '{$v['UserGroupReportAdviceEng']}',
|
||||
UserGroupReportUserID = {$userid},
|
||||
UserGroupReportCreated = now(),
|
||||
UserGroupReportLastUpdated = now()
|
||||
WHERE UserGroupReportID = {$v['UserGroupReportID']}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
public function deleteuser()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update nat_methode SET
|
||||
Nat_MethodeIsActive = 'N'
|
||||
WHERE
|
||||
Nat_MethodeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_methode delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update m_usergroup SET
|
||||
M_UserGroupIsActive = 'N'
|
||||
WHERE
|
||||
M_UserGroupNat_MethodeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deletereport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update m_usergroup SET
|
||||
M_UserGroupIsActive = 'N'
|
||||
WHERE
|
||||
M_UserGroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchuser(){
|
||||
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 nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = '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("nat_methode count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName 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("nat_methode rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchuserbyname(){
|
||||
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 nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = '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("nat_methode count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName 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("nat_methode rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = '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("t_test count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
ORDER BY T_TestName 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
application/controllers/v1/report-v2/Agama.php
Normal file
29
application/controllers/v1/report-v2/Agama.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class Agama extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1878
application/controllers/v1/report-v2/Fisik-sipe.php
Normal file
1878
application/controllers/v1/report-v2/Fisik-sipe.php
Normal file
File diff suppressed because it is too large
Load Diff
1878
application/controllers/v1/report-v2/Fisik.php
Normal file
1878
application/controllers/v1/report-v2/Fisik.php
Normal file
File diff suppressed because it is too large
Load Diff
352
application/controllers/v1/report-v2/Fisik0.php
Normal file
352
application/controllers/v1/report-v2/Fisik0.php
Normal file
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
class Fisik extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function pribadi($id,$langid) {
|
||||
//$id = So_ResultEntryID
|
||||
$sql = "select concat(M_TitleName,' ', M_PatientName) M_PatientName,
|
||||
T_OrderHeaderLabNumber RegNo, fn_numbering_external(T_OrderHeaderLabNumber) ExternalRegNo,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
date_format(M_PatientDOB,'%d-%m-%Y') M_PatientDOB ,
|
||||
date_format(T_OrderHeaderDate,'%d-%m-%Y') T_OrderHeaderDate,
|
||||
M_SexName,
|
||||
(SELECT concat(M_PatientAddressDescription,' ',M_KelurahanName,' ' ,M_DistrictName,' ',M_CityName) from m_patientaddress AS p
|
||||
left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
left join m_district on M_KelurahanM_DistrictID = M_DistrictID
|
||||
left join m_city on M_DistrictM_CityID = M_CityID
|
||||
WHERE M_PatientAddressM_PatientID = M_PatientID
|
||||
ORDER BY M_PatientAddressM_PatientID
|
||||
LIMIT 1) AS M_PatientAddressDescription
|
||||
from so_resultentry
|
||||
join t_orderheader on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
|
||||
and So_ResultEntryID = ?
|
||||
join m_patient on M_PatientID = T_OrderHeaderM_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
left join m_sex on M_PatientM_SexID = M_SexID
|
||||
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql,array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach($rows as $idx => $r ) {
|
||||
$rows[$idx]["keluhan_saat_ini"] = $this->keluhan_saat_ini($id,$langid);
|
||||
$rows[$idx]["phobia"] = $this->phobia($id,$langid);
|
||||
}
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
|
||||
function phobia($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$phobia = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT POBIA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$phobia = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $phobia != "" ) $phobia .= ", ";
|
||||
$phobia .= $xd["label"];
|
||||
if ($xd["value"] != "") $phobia .= " (" .$xd["value"] . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $phobia;
|
||||
}
|
||||
|
||||
function keluhan_saat_ini($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$keluhan_saat_ini = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "KELUHAN SAAT INI") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$keluhan_saat_ini = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $keluhan_saat_ini != "" ) $keluhan_saat_ini .= ", ";
|
||||
$keluhan_saat_ini .= $xd["label"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $keluhan_saat_ini;
|
||||
}
|
||||
|
||||
function riwayat_penyakit($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_penyakit = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_penyakit = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group == "Allergi" ) continue;
|
||||
$have_detail = false;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$have_detail = true;
|
||||
}
|
||||
}
|
||||
if ($have_detail) {
|
||||
$arr_result[] = array($group, "", "","") ;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result[] = array($xd["label"], "X", "",$xd["value"]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$riwayat_penyakit[] = array(
|
||||
"c1" => $left[0],
|
||||
"c2" => $left[1],
|
||||
"c3" => $left[2],
|
||||
"c4" => $left[3],
|
||||
"c5" => $right[0],
|
||||
"c6" => $right[1],
|
||||
"c7" => $right[2],
|
||||
"c8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($riwayat_penyakit);
|
||||
//return ($riwayat_penyakit);
|
||||
}
|
||||
|
||||
//riwayat penyakit keluarga
|
||||
function penyakit_keluarga($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$penyakit_keluarga = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT KELUARGA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$penyakit_keluarga = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "X", "",$gp["value"]) ;
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$penyakit_keluarga[] = array(
|
||||
"d1" => $left[0],
|
||||
"d2" => $left[1],
|
||||
"d3" => $left[2],
|
||||
"d4" => $left[3],
|
||||
"d5" => $right[0],
|
||||
"d6" => $right[1],
|
||||
"d7" => $right[2],
|
||||
"d8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($penyakit_keluarga);
|
||||
//return ($penyakit_keluarga);
|
||||
}
|
||||
|
||||
|
||||
function riwayat_alergi($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_alergi = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_alergi = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group != "Allergi" ) continue;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result = array($xd["label"], "Ya", "",$xd["value"]) ;
|
||||
} else {
|
||||
$arr_result = array($xd["label"], "Tidak", "X",$xd["value"]) ;
|
||||
}
|
||||
$riwayat_alergi[] = array(
|
||||
"a1" => $arr_result[0],
|
||||
"a2" => $arr_result[1],
|
||||
"a3" => $arr_result[2],
|
||||
"a4" => $arr_result[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_alergi);
|
||||
}
|
||||
|
||||
function riwayat_obat($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_obat = array();
|
||||
foreach($details as $d) {
|
||||
|
||||
if ($d["title"] == "RIWAYAT KONSUMSI OBAT TERATUR") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_obat = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "Ya", "Tidak",$gp["value"]) ;
|
||||
$riwayat_obat[] = array(
|
||||
"o1" => $gp["label"],
|
||||
"o2" => "Ya",
|
||||
"o3" => $gp["value"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_obat);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1870
application/controllers/v1/report-v2/Fisikaa.php
Normal file
1870
application/controllers/v1/report-v2/Fisikaa.php
Normal file
File diff suppressed because it is too large
Load Diff
37
application/controllers/v1/report-v2/Lookup.php
Normal file
37
application/controllers/v1/report-v2/Lookup.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
class Lookup extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function dropdown($sp) {
|
||||
$sql = "call $sp";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if (! $qry) {
|
||||
echo json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo json_encode(array());
|
||||
}
|
||||
echo json_encode($rows);
|
||||
}
|
||||
|
||||
function ac($sp) {
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$sql = "call $sp(?)";
|
||||
$qry = $this->db_smartone->query($sql,array($search));
|
||||
if (! $qry) {
|
||||
echo json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo json_encode(array());
|
||||
exit;
|
||||
}
|
||||
echo json_encode($rows);
|
||||
}
|
||||
}
|
||||
181
application/controllers/v1/report-v2/Main.php
Normal file
181
application/controllers/v1/report-v2/Main.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
class Main extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Report Main API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_one= $this->load->database("onedev", true);
|
||||
}
|
||||
function detail(){
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select *
|
||||
from
|
||||
r_reportdetail
|
||||
join r_inputtype on R_ReportDetailR_InputTypeID = R_InputTypeID
|
||||
and R_ReportDetailIsActive = 'Y'
|
||||
where R_ReportDetailR_ReportID = ?
|
||||
order by R_ReportDetailID, R_ReportDetailPriority desc";
|
||||
|
||||
// echo $sql;
|
||||
$qry = $this->db_one->query($sql, array($id) );
|
||||
$last_q = $this->db_one->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $idx => $r) {
|
||||
$rows[$idx]["model"] = "";
|
||||
$rows[$idx]["items"] = "";
|
||||
$rows[$idx]["tmp_date"] = false;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$message = "Err Report Query";
|
||||
$this->sys_error($message,$this->db_one);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function list(){
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$q_search = "";
|
||||
$q_param = array();
|
||||
if ($search !== "") {
|
||||
$q_search = " where ( R_ReportCode like ? or R_ReportName like ? ) ";
|
||||
$q_param[] = "%$search%";
|
||||
$q_param[] = "%$search%";
|
||||
}
|
||||
$sql = "select
|
||||
R_ReportGroupID, R_ReportGroupName, R_ReportGroupColor,
|
||||
R_ReportID, R_ReportCode, R_ReportName, R_ReportUrl
|
||||
from r_report
|
||||
join r_reportgroup on R_ReportGroupID = R_ReportR_ReportGroupID
|
||||
|
||||
and R_ReportIsActive = 'Y'
|
||||
$q_search ORDER BY R_ReportGroupName ASC, R_ReportCode ASC";
|
||||
//echo $sql;
|
||||
if ($q_search == "" ) {
|
||||
$qry = $this->db_one->query($sql);
|
||||
} else {
|
||||
$qry = $this->db_one->query($sql,$q_param);
|
||||
}
|
||||
$last_q = $this->db_one->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$reports = array();
|
||||
$prev_group = 0;
|
||||
$idx = -1;
|
||||
foreach($rows as $r) {
|
||||
if ($prev_group != $r["R_ReportGroupID"] ) {
|
||||
$idx++;
|
||||
$reports[] = array("id"=>$r["R_ReportGroupID"], "name" => $r["R_ReportGroupName"],
|
||||
"color" => $r["R_ReportGroupColor"],
|
||||
"reports" => array());
|
||||
}
|
||||
$prev_group = $r["R_ReportGroupID"];
|
||||
$reports[$idx]["reports"][] = $r;
|
||||
}
|
||||
$result = array ("total" => count($reports), "records" => $reports);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$message = "Err Report Query";
|
||||
$this->sys_error($message,$this->db_one);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function lookupparam()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from r_reportparam
|
||||
LEFT JOIN r_inputtype ON R_ReportParamR_InputTypeID = R_InputTypeID AND R_InputTypeIsActive = 'Y'
|
||||
where
|
||||
(R_ReportParamName LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_InputTypeName,'') LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_ReportParamLabel,'') LIKE CONCAT('%','{$search}','%')) AND
|
||||
R_ReportParamIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$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("r_reportparam count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select R_ReportParamID as id,
|
||||
R_InputTypeName,
|
||||
r_reportparam.*
|
||||
from r_reportparam
|
||||
LEFT JOIN r_inputtype ON R_ReportParamR_InputTypeID = R_InputTypeID AND R_InputTypeIsActive = 'Y'
|
||||
where
|
||||
(R_ReportParamName LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_InputTypeName,'') LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_ReportParamLabel,'') LIKE CONCAT('%','{$search}','%')) AND
|
||||
R_ReportParamIsActive = 'Y'
|
||||
GROUP BY R_ReportParamID
|
||||
ORDER BY R_ReportParamName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("r_reportparam select");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
application/controllers/v1/report-v3/Agama.php
Normal file
29
application/controllers/v1/report-v3/Agama.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class Agama extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1878
application/controllers/v1/report-v3/Fisik-sipe.php
Normal file
1878
application/controllers/v1/report-v3/Fisik-sipe.php
Normal file
File diff suppressed because it is too large
Load Diff
1878
application/controllers/v1/report-v3/Fisik.php
Normal file
1878
application/controllers/v1/report-v3/Fisik.php
Normal file
File diff suppressed because it is too large
Load Diff
352
application/controllers/v1/report-v3/Fisik0.php
Normal file
352
application/controllers/v1/report-v3/Fisik0.php
Normal file
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
class Fisik extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function pribadi($id,$langid) {
|
||||
//$id = So_ResultEntryID
|
||||
$sql = "select concat(M_TitleName,' ', M_PatientName) M_PatientName,
|
||||
T_OrderHeaderLabNumber RegNo, fn_numbering_external(T_OrderHeaderLabNumber) ExternalRegNo,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
date_format(M_PatientDOB,'%d-%m-%Y') M_PatientDOB ,
|
||||
date_format(T_OrderHeaderDate,'%d-%m-%Y') T_OrderHeaderDate,
|
||||
M_SexName,
|
||||
(SELECT concat(M_PatientAddressDescription,' ',M_KelurahanName,' ' ,M_DistrictName,' ',M_CityName) from m_patientaddress AS p
|
||||
left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
left join m_district on M_KelurahanM_DistrictID = M_DistrictID
|
||||
left join m_city on M_DistrictM_CityID = M_CityID
|
||||
WHERE M_PatientAddressM_PatientID = M_PatientID
|
||||
ORDER BY M_PatientAddressM_PatientID
|
||||
LIMIT 1) AS M_PatientAddressDescription
|
||||
from so_resultentry
|
||||
join t_orderheader on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
|
||||
and So_ResultEntryID = ?
|
||||
join m_patient on M_PatientID = T_OrderHeaderM_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
left join m_sex on M_PatientM_SexID = M_SexID
|
||||
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql,array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach($rows as $idx => $r ) {
|
||||
$rows[$idx]["keluhan_saat_ini"] = $this->keluhan_saat_ini($id,$langid);
|
||||
$rows[$idx]["phobia"] = $this->phobia($id,$langid);
|
||||
}
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
|
||||
function phobia($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$phobia = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT POBIA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$phobia = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $phobia != "" ) $phobia .= ", ";
|
||||
$phobia .= $xd["label"];
|
||||
if ($xd["value"] != "") $phobia .= " (" .$xd["value"] . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $phobia;
|
||||
}
|
||||
|
||||
function keluhan_saat_ini($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$keluhan_saat_ini = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "KELUHAN SAAT INI") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$keluhan_saat_ini = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $keluhan_saat_ini != "" ) $keluhan_saat_ini .= ", ";
|
||||
$keluhan_saat_ini .= $xd["label"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $keluhan_saat_ini;
|
||||
}
|
||||
|
||||
function riwayat_penyakit($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_penyakit = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_penyakit = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group == "Allergi" ) continue;
|
||||
$have_detail = false;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$have_detail = true;
|
||||
}
|
||||
}
|
||||
if ($have_detail) {
|
||||
$arr_result[] = array($group, "", "","") ;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result[] = array($xd["label"], "X", "",$xd["value"]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$riwayat_penyakit[] = array(
|
||||
"c1" => $left[0],
|
||||
"c2" => $left[1],
|
||||
"c3" => $left[2],
|
||||
"c4" => $left[3],
|
||||
"c5" => $right[0],
|
||||
"c6" => $right[1],
|
||||
"c7" => $right[2],
|
||||
"c8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($riwayat_penyakit);
|
||||
//return ($riwayat_penyakit);
|
||||
}
|
||||
|
||||
//riwayat penyakit keluarga
|
||||
function penyakit_keluarga($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$penyakit_keluarga = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT KELUARGA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$penyakit_keluarga = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "X", "",$gp["value"]) ;
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$penyakit_keluarga[] = array(
|
||||
"d1" => $left[0],
|
||||
"d2" => $left[1],
|
||||
"d3" => $left[2],
|
||||
"d4" => $left[3],
|
||||
"d5" => $right[0],
|
||||
"d6" => $right[1],
|
||||
"d7" => $right[2],
|
||||
"d8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($penyakit_keluarga);
|
||||
//return ($penyakit_keluarga);
|
||||
}
|
||||
|
||||
|
||||
function riwayat_alergi($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_alergi = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_alergi = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group != "Allergi" ) continue;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result = array($xd["label"], "Ya", "",$xd["value"]) ;
|
||||
} else {
|
||||
$arr_result = array($xd["label"], "Tidak", "X",$xd["value"]) ;
|
||||
}
|
||||
$riwayat_alergi[] = array(
|
||||
"a1" => $arr_result[0],
|
||||
"a2" => $arr_result[1],
|
||||
"a3" => $arr_result[2],
|
||||
"a4" => $arr_result[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_alergi);
|
||||
}
|
||||
|
||||
function riwayat_obat($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_obat = array();
|
||||
foreach($details as $d) {
|
||||
|
||||
if ($d["title"] == "RIWAYAT KONSUMSI OBAT TERATUR") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_obat = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "Ya", "Tidak",$gp["value"]) ;
|
||||
$riwayat_obat[] = array(
|
||||
"o1" => $gp["label"],
|
||||
"o2" => "Ya",
|
||||
"o3" => $gp["value"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_obat);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1870
application/controllers/v1/report-v3/Fisikaa.php
Normal file
1870
application/controllers/v1/report-v3/Fisikaa.php
Normal file
File diff suppressed because it is too large
Load Diff
43
application/controllers/v1/report-v3/Lookup.php
Normal file
43
application/controllers/v1/report-v3/Lookup.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
class Lookup extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function dropdown($sp) {
|
||||
$sql = "call $sp";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if (! $qry) {
|
||||
echo json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo json_encode(array());
|
||||
}
|
||||
echo json_encode($rows);
|
||||
}
|
||||
|
||||
function ac($sp) {
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$sql = "call $sp(?)";
|
||||
if (isset($prm['dep'])) {
|
||||
$sql = "call $sp(?,?)";
|
||||
$value = $prm['value'];
|
||||
$qry = $this->db_smartone->query($sql,array($search,$value));
|
||||
} else {
|
||||
$qry = $this->db_smartone->query($sql,array($search));
|
||||
}
|
||||
if (! $qry) {
|
||||
echo json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo json_encode(array());
|
||||
exit;
|
||||
}
|
||||
echo json_encode($rows);
|
||||
}
|
||||
}
|
||||
181
application/controllers/v1/report-v3/Main.php
Normal file
181
application/controllers/v1/report-v3/Main.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
class Main extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Report Main API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_one= $this->load->database("onedev", true);
|
||||
}
|
||||
function detail(){
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select *
|
||||
from
|
||||
r_reportdetail
|
||||
join r_inputtype on R_ReportDetailR_InputTypeID = R_InputTypeID
|
||||
and R_ReportDetailIsActive = 'Y'
|
||||
where R_ReportDetailR_ReportID = ?
|
||||
order by R_ReportDetailID, R_ReportDetailPriority desc";
|
||||
|
||||
// echo $sql;
|
||||
$qry = $this->db_one->query($sql, array($id) );
|
||||
$last_q = $this->db_one->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $idx => $r) {
|
||||
$rows[$idx]["model"] = "";
|
||||
$rows[$idx]["items"] = "";
|
||||
$rows[$idx]["tmp_date"] = false;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$message = "Err Report Query";
|
||||
$this->sys_error($message,$this->db_one);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function list(){
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$q_search = "";
|
||||
$q_param = array();
|
||||
if ($search !== "") {
|
||||
$q_search = " where ( R_ReportCode like ? or R_ReportName like ? ) ";
|
||||
$q_param[] = "%$search%";
|
||||
$q_param[] = "%$search%";
|
||||
}
|
||||
$sql = "select
|
||||
R_ReportGroupID, R_ReportGroupName, R_ReportGroupColor,
|
||||
R_ReportID, R_ReportCode, R_ReportName, R_ReportUrl
|
||||
from r_report
|
||||
join r_reportgroup on R_ReportGroupID = R_ReportR_ReportGroupID
|
||||
|
||||
and R_ReportIsActive = 'Y'
|
||||
$q_search ORDER BY R_ReportGroupName ASC, R_ReportCode ASC";
|
||||
//echo $sql;
|
||||
if ($q_search == "" ) {
|
||||
$qry = $this->db_one->query($sql);
|
||||
} else {
|
||||
$qry = $this->db_one->query($sql,$q_param);
|
||||
}
|
||||
$last_q = $this->db_one->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$reports = array();
|
||||
$prev_group = 0;
|
||||
$idx = -1;
|
||||
foreach($rows as $r) {
|
||||
if ($prev_group != $r["R_ReportGroupID"] ) {
|
||||
$idx++;
|
||||
$reports[] = array("id"=>$r["R_ReportGroupID"], "name" => $r["R_ReportGroupName"],
|
||||
"color" => $r["R_ReportGroupColor"],
|
||||
"reports" => array());
|
||||
}
|
||||
$prev_group = $r["R_ReportGroupID"];
|
||||
$reports[$idx]["reports"][] = $r;
|
||||
}
|
||||
$result = array ("total" => count($reports), "records" => $reports);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$message = "Err Report Query";
|
||||
$this->sys_error($message,$this->db_one);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function lookupparam()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from r_reportparam
|
||||
LEFT JOIN r_inputtype ON R_ReportParamR_InputTypeID = R_InputTypeID AND R_InputTypeIsActive = 'Y'
|
||||
where
|
||||
(R_ReportParamName LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_InputTypeName,'') LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_ReportParamLabel,'') LIKE CONCAT('%','{$search}','%')) AND
|
||||
R_ReportParamIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$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("r_reportparam count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select R_ReportParamID as id,
|
||||
R_InputTypeName,
|
||||
r_reportparam.*
|
||||
from r_reportparam
|
||||
LEFT JOIN r_inputtype ON R_ReportParamR_InputTypeID = R_InputTypeID AND R_InputTypeIsActive = 'Y'
|
||||
where
|
||||
(R_ReportParamName LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_InputTypeName,'') LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_ReportParamLabel,'') LIKE CONCAT('%','{$search}','%')) AND
|
||||
R_ReportParamIsActive = 'Y'
|
||||
GROUP BY R_ReportParamID
|
||||
ORDER BY R_ReportParamName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("r_reportparam select");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
application/controllers/v1/report-v5/Agama.php
Normal file
29
application/controllers/v1/report-v5/Agama.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class Agama extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1878
application/controllers/v1/report-v5/Fisik-sipe.php
Normal file
1878
application/controllers/v1/report-v5/Fisik-sipe.php
Normal file
File diff suppressed because it is too large
Load Diff
1878
application/controllers/v1/report-v5/Fisik.php
Normal file
1878
application/controllers/v1/report-v5/Fisik.php
Normal file
File diff suppressed because it is too large
Load Diff
352
application/controllers/v1/report-v5/Fisik0.php
Normal file
352
application/controllers/v1/report-v5/Fisik0.php
Normal file
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
class Fisik extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function pribadi($id,$langid) {
|
||||
//$id = So_ResultEntryID
|
||||
$sql = "select concat(M_TitleName,' ', M_PatientName) M_PatientName,
|
||||
T_OrderHeaderLabNumber RegNo, fn_numbering_external(T_OrderHeaderLabNumber) ExternalRegNo,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
date_format(M_PatientDOB,'%d-%m-%Y') M_PatientDOB ,
|
||||
date_format(T_OrderHeaderDate,'%d-%m-%Y') T_OrderHeaderDate,
|
||||
M_SexName,
|
||||
(SELECT concat(M_PatientAddressDescription,' ',M_KelurahanName,' ' ,M_DistrictName,' ',M_CityName) from m_patientaddress AS p
|
||||
left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
left join m_district on M_KelurahanM_DistrictID = M_DistrictID
|
||||
left join m_city on M_DistrictM_CityID = M_CityID
|
||||
WHERE M_PatientAddressM_PatientID = M_PatientID
|
||||
ORDER BY M_PatientAddressM_PatientID
|
||||
LIMIT 1) AS M_PatientAddressDescription
|
||||
from so_resultentry
|
||||
join t_orderheader on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
|
||||
and So_ResultEntryID = ?
|
||||
join m_patient on M_PatientID = T_OrderHeaderM_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
left join m_sex on M_PatientM_SexID = M_SexID
|
||||
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql,array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach($rows as $idx => $r ) {
|
||||
$rows[$idx]["keluhan_saat_ini"] = $this->keluhan_saat_ini($id,$langid);
|
||||
$rows[$idx]["phobia"] = $this->phobia($id,$langid);
|
||||
}
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
|
||||
function phobia($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$phobia = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT POBIA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$phobia = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $phobia != "" ) $phobia .= ", ";
|
||||
$phobia .= $xd["label"];
|
||||
if ($xd["value"] != "") $phobia .= " (" .$xd["value"] . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $phobia;
|
||||
}
|
||||
|
||||
function keluhan_saat_ini($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$keluhan_saat_ini = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "KELUHAN SAAT INI") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$keluhan_saat_ini = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $keluhan_saat_ini != "" ) $keluhan_saat_ini .= ", ";
|
||||
$keluhan_saat_ini .= $xd["label"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $keluhan_saat_ini;
|
||||
}
|
||||
|
||||
function riwayat_penyakit($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_penyakit = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_penyakit = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group == "Allergi" ) continue;
|
||||
$have_detail = false;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$have_detail = true;
|
||||
}
|
||||
}
|
||||
if ($have_detail) {
|
||||
$arr_result[] = array($group, "", "","") ;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result[] = array($xd["label"], "X", "",$xd["value"]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$riwayat_penyakit[] = array(
|
||||
"c1" => $left[0],
|
||||
"c2" => $left[1],
|
||||
"c3" => $left[2],
|
||||
"c4" => $left[3],
|
||||
"c5" => $right[0],
|
||||
"c6" => $right[1],
|
||||
"c7" => $right[2],
|
||||
"c8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($riwayat_penyakit);
|
||||
//return ($riwayat_penyakit);
|
||||
}
|
||||
|
||||
//riwayat penyakit keluarga
|
||||
function penyakit_keluarga($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$penyakit_keluarga = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT KELUARGA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$penyakit_keluarga = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "X", "",$gp["value"]) ;
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$penyakit_keluarga[] = array(
|
||||
"d1" => $left[0],
|
||||
"d2" => $left[1],
|
||||
"d3" => $left[2],
|
||||
"d4" => $left[3],
|
||||
"d5" => $right[0],
|
||||
"d6" => $right[1],
|
||||
"d7" => $right[2],
|
||||
"d8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($penyakit_keluarga);
|
||||
//return ($penyakit_keluarga);
|
||||
}
|
||||
|
||||
|
||||
function riwayat_alergi($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_alergi = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_alergi = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group != "Allergi" ) continue;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result = array($xd["label"], "Ya", "",$xd["value"]) ;
|
||||
} else {
|
||||
$arr_result = array($xd["label"], "Tidak", "X",$xd["value"]) ;
|
||||
}
|
||||
$riwayat_alergi[] = array(
|
||||
"a1" => $arr_result[0],
|
||||
"a2" => $arr_result[1],
|
||||
"a3" => $arr_result[2],
|
||||
"a4" => $arr_result[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_alergi);
|
||||
}
|
||||
|
||||
function riwayat_obat($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_obat = array();
|
||||
foreach($details as $d) {
|
||||
|
||||
if ($d["title"] == "RIWAYAT KONSUMSI OBAT TERATUR") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_obat = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "Ya", "Tidak",$gp["value"]) ;
|
||||
$riwayat_obat[] = array(
|
||||
"o1" => $gp["label"],
|
||||
"o2" => "Ya",
|
||||
"o3" => $gp["value"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_obat);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1870
application/controllers/v1/report-v5/Fisikaa.php
Normal file
1870
application/controllers/v1/report-v5/Fisikaa.php
Normal file
File diff suppressed because it is too large
Load Diff
43
application/controllers/v1/report-v5/Lookup.php
Normal file
43
application/controllers/v1/report-v5/Lookup.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
class Lookup extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function dropdown($sp) {
|
||||
$sql = "call $sp";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if (! $qry) {
|
||||
echo json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo json_encode(array());
|
||||
}
|
||||
echo json_encode($rows);
|
||||
}
|
||||
|
||||
function ac($sp) {
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$sql = "call $sp(?)";
|
||||
if (isset($prm['dep'])) {
|
||||
$sql = "call $sp(?,?)";
|
||||
$value = $prm['value'];
|
||||
$qry = $this->db_smartone->query($sql,array($search,$value));
|
||||
} else {
|
||||
$qry = $this->db_smartone->query($sql,array($search));
|
||||
}
|
||||
if (! $qry) {
|
||||
echo json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo json_encode(array());
|
||||
exit;
|
||||
}
|
||||
echo json_encode($rows);
|
||||
}
|
||||
}
|
||||
181
application/controllers/v1/report-v5/Main.php
Normal file
181
application/controllers/v1/report-v5/Main.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
class Main extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Report Main API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_one= $this->load->database("onedev", true);
|
||||
}
|
||||
function detail(){
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select *
|
||||
from
|
||||
r_reportdetail
|
||||
join r_inputtype on R_ReportDetailR_InputTypeID = R_InputTypeID
|
||||
and R_ReportDetailIsActive = 'Y'
|
||||
where R_ReportDetailR_ReportID = ?
|
||||
order by R_ReportDetailID, R_ReportDetailPriority desc";
|
||||
|
||||
// echo $sql;
|
||||
$qry = $this->db_one->query($sql, array($id) );
|
||||
$last_q = $this->db_one->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $idx => $r) {
|
||||
$rows[$idx]["model"] = "";
|
||||
$rows[$idx]["items"] = "";
|
||||
$rows[$idx]["tmp_date"] = false;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$message = "Err Report Query";
|
||||
$this->sys_error($message,$this->db_one);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function list(){
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$q_search = "";
|
||||
$q_param = array();
|
||||
if ($search !== "") {
|
||||
$q_search = " where ( R_ReportCode like ? or R_ReportName like ? ) ";
|
||||
$q_param[] = "%$search%";
|
||||
$q_param[] = "%$search%";
|
||||
}
|
||||
$sql = "select
|
||||
R_ReportGroupID, R_ReportGroupName, R_ReportGroupColor,
|
||||
R_ReportID, R_ReportCode, R_ReportName, R_ReportUrl
|
||||
from r_report
|
||||
join r_reportgroup on R_ReportGroupID = R_ReportR_ReportGroupID
|
||||
|
||||
and R_ReportIsActive = 'Y'
|
||||
$q_search ORDER BY R_ReportGroupName ASC, R_ReportCode ASC";
|
||||
//echo $sql;
|
||||
if ($q_search == "" ) {
|
||||
$qry = $this->db_one->query($sql);
|
||||
} else {
|
||||
$qry = $this->db_one->query($sql,$q_param);
|
||||
}
|
||||
$last_q = $this->db_one->last_query();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$reports = array();
|
||||
$prev_group = 0;
|
||||
$idx = -1;
|
||||
foreach($rows as $r) {
|
||||
if ($prev_group != $r["R_ReportGroupID"] ) {
|
||||
$idx++;
|
||||
$reports[] = array("id"=>$r["R_ReportGroupID"], "name" => $r["R_ReportGroupName"],
|
||||
"color" => $r["R_ReportGroupColor"],
|
||||
"reports" => array());
|
||||
}
|
||||
$prev_group = $r["R_ReportGroupID"];
|
||||
$reports[$idx]["reports"][] = $r;
|
||||
}
|
||||
$result = array ("total" => count($reports), "records" => $reports);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$message = "Err Report Query";
|
||||
$this->sys_error($message,$this->db_one);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function lookupparam()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from r_reportparam
|
||||
LEFT JOIN r_inputtype ON R_ReportParamR_InputTypeID = R_InputTypeID AND R_InputTypeIsActive = 'Y'
|
||||
where
|
||||
(R_ReportParamName LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_InputTypeName,'') LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_ReportParamLabel,'') LIKE CONCAT('%','{$search}','%')) AND
|
||||
R_ReportParamIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$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("r_reportparam count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select R_ReportParamID as id,
|
||||
R_InputTypeName,
|
||||
r_reportparam.*
|
||||
from r_reportparam
|
||||
LEFT JOIN r_inputtype ON R_ReportParamR_InputTypeID = R_InputTypeID AND R_InputTypeIsActive = 'Y'
|
||||
where
|
||||
(R_ReportParamName LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_InputTypeName,'') LIKE CONCAT('%','{$search}','%') OR
|
||||
IFNULL(R_ReportParamLabel,'') LIKE CONCAT('%','{$search}','%')) AND
|
||||
R_ReportParamIsActive = 'Y'
|
||||
GROUP BY R_ReportParamID
|
||||
ORDER BY R_ReportParamName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("r_reportparam select");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
application/controllers/v1/report-v6/Agama.php
Normal file
29
application/controllers/v1/report-v6/Agama.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class Agama extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1878
application/controllers/v1/report-v6/Fisik-sipe.php
Normal file
1878
application/controllers/v1/report-v6/Fisik-sipe.php
Normal file
File diff suppressed because it is too large
Load Diff
1878
application/controllers/v1/report-v6/Fisik.php
Normal file
1878
application/controllers/v1/report-v6/Fisik.php
Normal file
File diff suppressed because it is too large
Load Diff
352
application/controllers/v1/report-v6/Fisik0.php
Normal file
352
application/controllers/v1/report-v6/Fisik0.php
Normal file
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
class Fisik extends MY_Controller
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function pribadi($id,$langid) {
|
||||
//$id = So_ResultEntryID
|
||||
$sql = "select concat(M_TitleName,' ', M_PatientName) M_PatientName,
|
||||
T_OrderHeaderLabNumber RegNo, fn_numbering_external(T_OrderHeaderLabNumber) ExternalRegNo,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
date_format(M_PatientDOB,'%d-%m-%Y') M_PatientDOB ,
|
||||
date_format(T_OrderHeaderDate,'%d-%m-%Y') T_OrderHeaderDate,
|
||||
M_SexName,
|
||||
(SELECT concat(M_PatientAddressDescription,' ',M_KelurahanName,' ' ,M_DistrictName,' ',M_CityName) from m_patientaddress AS p
|
||||
left join m_kelurahan on M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
left join m_district on M_KelurahanM_DistrictID = M_DistrictID
|
||||
left join m_city on M_DistrictM_CityID = M_CityID
|
||||
WHERE M_PatientAddressM_PatientID = M_PatientID
|
||||
ORDER BY M_PatientAddressM_PatientID
|
||||
LIMIT 1) AS M_PatientAddressDescription
|
||||
from so_resultentry
|
||||
join t_orderheader on So_ResultEntryT_OrderHeaderID = T_OrderHeaderID
|
||||
and So_ResultEntryID = ?
|
||||
join m_patient on M_PatientID = T_OrderHeaderM_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
left join m_sex on M_PatientM_SexID = M_SexID
|
||||
|
||||
";
|
||||
$qry = $this->db_smartone->query($sql,array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach($rows as $idx => $r ) {
|
||||
$rows[$idx]["keluhan_saat_ini"] = $this->keluhan_saat_ini($id,$langid);
|
||||
$rows[$idx]["phobia"] = $this->phobia($id,$langid);
|
||||
}
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
|
||||
function phobia($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$phobia = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT POBIA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$phobia = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $phobia != "" ) $phobia .= ", ";
|
||||
$phobia .= $xd["label"];
|
||||
if ($xd["value"] != "") $phobia .= " (" .$xd["value"] . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $phobia;
|
||||
}
|
||||
|
||||
function keluhan_saat_ini($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$keluhan_saat_ini = "";
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "KELUHAN SAAT INI") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$keluhan_saat_ini = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $xd) {
|
||||
if ($xd["chx"] == "1" ) {
|
||||
if ( $keluhan_saat_ini != "" ) $keluhan_saat_ini .= ", ";
|
||||
$keluhan_saat_ini .= $xd["label"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $keluhan_saat_ini;
|
||||
}
|
||||
|
||||
function riwayat_penyakit($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_penyakit = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_penyakit = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group == "Allergi" ) continue;
|
||||
$have_detail = false;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$have_detail = true;
|
||||
}
|
||||
}
|
||||
if ($have_detail) {
|
||||
$arr_result[] = array($group, "", "","") ;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result[] = array($xd["label"], "X", "",$xd["value"]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$riwayat_penyakit[] = array(
|
||||
"c1" => $left[0],
|
||||
"c2" => $left[1],
|
||||
"c3" => $left[2],
|
||||
"c4" => $left[3],
|
||||
"c5" => $right[0],
|
||||
"c6" => $right[1],
|
||||
"c7" => $right[2],
|
||||
"c8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($riwayat_penyakit);
|
||||
//return ($riwayat_penyakit);
|
||||
}
|
||||
|
||||
//riwayat penyakit keluarga
|
||||
function penyakit_keluarga($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$penyakit_keluarga = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT KELUARGA") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$penyakit_keluarga = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "X", "",$gp["value"]) ;
|
||||
}
|
||||
}
|
||||
$tot_baris = ceil( count($arr_result) / 2 ) ;
|
||||
for($i=0; $i < $tot_baris ; $i++) {
|
||||
$left = $arr_result[$i];
|
||||
$right = array("","","","");
|
||||
if ( isset($arr_result[$i+$tot_baris]) ) {
|
||||
$right = $arr_result[$i+$tot_baris];
|
||||
}
|
||||
$penyakit_keluarga[] = array(
|
||||
"d1" => $left[0],
|
||||
"d2" => $left[1],
|
||||
"d3" => $left[2],
|
||||
"d4" => $left[3],
|
||||
"d5" => $right[0],
|
||||
"d6" => $right[1],
|
||||
"d7" => $right[2],
|
||||
"d8" => $right[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($penyakit_keluarga);
|
||||
//return ($penyakit_keluarga);
|
||||
}
|
||||
|
||||
|
||||
function riwayat_alergi($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return "";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return "";
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_alergi = array();
|
||||
foreach($details as $d) {
|
||||
if ($d["title"] == "RIWAYAT PENYAKIT") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_alergi = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
$prev_group = "";
|
||||
$chex_group = array();
|
||||
$tot_baris= 0;
|
||||
$arr_result = array();
|
||||
foreach($d["details"] as $gp) {
|
||||
$group = $gp["name"];
|
||||
if ($group != "Allergi" ) continue;
|
||||
foreach($gp["details"] as $xd ) {
|
||||
if ($xd["chx"] == 1 ) {
|
||||
$arr_result = array($xd["label"], "Ya", "",$xd["value"]) ;
|
||||
} else {
|
||||
$arr_result = array($xd["label"], "Tidak", "X",$xd["value"]) ;
|
||||
}
|
||||
$riwayat_alergi[] = array(
|
||||
"a1" => $arr_result[0],
|
||||
"a2" => $arr_result[1],
|
||||
"a3" => $arr_result[2],
|
||||
"a4" => $arr_result[3],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_alergi);
|
||||
}
|
||||
|
||||
function riwayat_obat($id,$langid) {
|
||||
$sql = "select * from so_resultentry_fisik_umum
|
||||
where So_ResultEntryFisikUmumSo_ResultEntryID= ?
|
||||
and So_ResultEntryFisikUmumM_LangID=?
|
||||
and So_ResultEntryFisikUmumType='riwayat'";
|
||||
$qry = $this->db_smartone->query($sql,array($id,$langid));
|
||||
if (! $qry) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return json_encode(array());
|
||||
}
|
||||
$details = json_decode($rows[0]["So_ResultEntryFisikUmumDetails"],true);
|
||||
//keluhan saat ini
|
||||
$riwayat_obat = array();
|
||||
foreach($details as $d) {
|
||||
|
||||
if ($d["title"] == "RIWAYAT KONSUMSI OBAT TERATUR") {
|
||||
if ($d["flag_normal"] == "Y") {
|
||||
$riwayat_obat = $d["label_flag_normal"];
|
||||
break;
|
||||
} else {
|
||||
foreach($d["details"] as $gp) {
|
||||
if ($gp["chx"] == 1 ) {
|
||||
$arr_result[] = array($gp["label"], "Ya", "Tidak",$gp["value"]) ;
|
||||
$riwayat_obat[] = array(
|
||||
"o1" => $gp["label"],
|
||||
"o2" => "Ya",
|
||||
"o3" => $gp["value"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($riwayat_obat);
|
||||
}
|
||||
function list() {
|
||||
$sql = "select * from m_religion";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
function get($id) {
|
||||
$sql = "select * from m_religion where M_ReligionID=?";
|
||||
$qry = $this->db_smartone->query($sql,$id);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode($rows);
|
||||
} else {
|
||||
echo json_encode(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user