790 lines
35 KiB
PHP
790 lines
35 KiB
PHP
<?php
|
|
class Xstatusbranch_lab extends MY_Controller
|
|
{
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->db_msg = "";
|
|
$this->db_msg_nonlab = "";
|
|
$this->debug_sql = "";
|
|
}
|
|
function index() {
|
|
echo "API";
|
|
}
|
|
//mikro
|
|
function update_mikro($detailID, $header, $detail ) {
|
|
$sql = "select * from t_orderdetail where T_OrderDetailID = ? ";
|
|
$qry = $this->db->query($sql, array($detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|mikro select t_orderdetail | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$rows = $qry->result_array();
|
|
if (count($rows) == 0 ) return;
|
|
if ($rows[0]["T_OrderDetailValidation"] == "Y" ) return;
|
|
$sql = "select Other_MikroID from other_mikro where Other_MikroT_OrderDetailID = ? and Other_MikroIsActive = 'Y'";
|
|
$qry = $this->db->query($sql, array($detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|select other_mikro | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$rows = $qry->result_array();
|
|
$mikroID = 0;
|
|
if (count($rows) > 0 ) $mikroID = $rows[0]["Other_MikroID"];
|
|
if ( $mikroID > 0 ) {
|
|
$sql = "update other_mikro set Other_MikroIsActive = 'N' where Other_MikroID = ? ";
|
|
$qry = $this->db->query($sql, array($mikroID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_mikro | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$sql = "update other_mikrodetails set Other_MikroDetailsIsActive = 'N' where Other_MikroDetailsOther_MikroID= ? ";
|
|
$qry = $this->db->query($sql, array($mikroID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_mikrodetails | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
unset($header["Other_MikroID"]);
|
|
$header["Other_MikroCreated"] = date("Y-m-d h:i:s");
|
|
$header["Other_MikroLastUpdated"] =date("Y-m-d h:i:s");
|
|
$header["Other_MikroUserID"] = 3;
|
|
$header["Other_MikroIsActive"] = "Y";
|
|
$header["Other_MikroT_OrderDetailID"] = $detailID;
|
|
$qry = $this->db->insert("other_mikro",$header);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_mikro | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$mikroID = $this->db->insert_id();
|
|
if ($mikroID == 0 ) {
|
|
$this->db_msg_nonlab .= "|gagal insert other_mikro | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
foreach($detail as $idx => $d ) {
|
|
$detail[$idx]["Other_MikroDetailsOther_MikroID"] = $mikroID ;
|
|
$detail[$idx]["Other_MikroDetailsUserID"] = 3;
|
|
$detail[$idx]["Other_MikroDetailsIsActive"] = "Y";
|
|
unset($detail[$idx]["Other_MikroDetailsID"]);
|
|
unset($detail[$idx]["Other_MikroDetailsCreated"]);
|
|
unset($detail[$idx]["Other_MikroDetailsLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_mikrodetails",$detail);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_mikrodetails | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
|
|
//cytologi
|
|
function update_cytologi($detailID, $header, $detail ) {
|
|
$sql = "select * from t_orderdetail where T_OrderDetailID = ? ";
|
|
$qry = $this->db->query($sql, array($detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|cytologi select t_orderdetail | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$rows = $qry->result_array();
|
|
if (count($rows) == 0 ) return;
|
|
if ($rows[0]["T_OrderDetailValidation"] == "Y" ) return;
|
|
$sql = "select Other_CytologiID from other_cytologi where Other_CytologiT_OrderDetailID = ? and Other_CytologiIsActive = 'Y'";
|
|
$qry = $this->db->query($sql, array($detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|select other_cytologi | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$rows = $qry->result_array();
|
|
$cytologiID = 0;
|
|
if (count($rows) > 0 ) $cytologiID = $rows[0]["Other_CytologiID"];
|
|
if ( $cytologiID > 0 ) {
|
|
$sql = "update other_cytologi set Other_CytologiIsActive = 'N' where Other_CytologiID = ? ";
|
|
$qry = $this->db->query($sql, array($cytologiID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_cytologi | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$sql = "update other_cytologidetails set Other_CytologiDetailsIsActive = 'N' where Other_CytologiDetailsOther_CytologiID= ? ";
|
|
$qry = $this->db->query($sql, array($cytologiID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_cytologidetails | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
unset($header["Other_CytologiID"]);
|
|
$header["Other_CytologiCreated"] = date("Y-m-d h:i:s");
|
|
$header["Other_CytologiLastUpdated"] =date("Y-m-d h:i:s");
|
|
$header["Other_CytologiUserID"] = 3;
|
|
$header["Other_CytologiIsActive"] = "Y";
|
|
$header["Other_CytologiT_OrderDetailID"] = $detailID;
|
|
$qry = $this->db->insert("other_cytologi",$header);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_cytologi | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$cytologiID = $this->db->insert_id();
|
|
if ($cytologiID == 0 ) {
|
|
$this->db_msg_nonlab .= "|gagal insert other_cytologi | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
foreach($detail as $idx => $d ) {
|
|
$detail[$idx]["Other_CytologiDetailsOther_CytologiID"] = $cytologiID ;
|
|
$detail[$idx]["Other_CytologiDetailsUserID"] = 3;
|
|
$detail[$idx]["Other_CytologiDetailsIsActive"] = "Y";
|
|
unset($detail[$idx]["Other_CytologiDetailsID"]);
|
|
unset($detail[$idx]["Other_CytologiDetailsCreated"]);
|
|
unset($detail[$idx]["Other_CytologiDetailsLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_cytologidetails",$detail);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_cytologidetails | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
|
|
//fna
|
|
function update_fna($detailID, $header, $detail ) {
|
|
$sql = "select * from t_orderdetail where T_OrderDetailID = ? ";
|
|
$qry = $this->db->query($sql, array($detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|fna select t_orderdetail | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$rows = $qry->result_array();
|
|
if (count($rows) == 0 ) return;
|
|
if ($rows[0]["T_OrderDetailValidation"] == "Y" ) return;
|
|
$sql = "select Other_FNAID from other_fna where Other_FNAT_OrderDetailID = ? and Other_FNAIsActive = 'Y'";
|
|
$qry = $this->db->query($sql, array($detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|select other_fna | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$rows = $qry->result_array();
|
|
$fnaID = 0;
|
|
if (count($rows) > 0 ) $fnaID = $rows[0]["Other_FNAID"];
|
|
if ( $fnaID > 0 ) {
|
|
$sql = "update other_fna set Other_FNAIsActive = 'N' where Other_FNAID = ? ";
|
|
$qry = $this->db->query($sql, array($fnaID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_fna | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$sql = "update other_fnadetails set Other_FNADetailsIsActive = 'N' where Other_FNADetailsOther_FNAID= ? ";
|
|
$qry = $this->db->query($sql, array($fnaID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|select other_fnadetails | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
unset($header["Other_FNAID"]);
|
|
$header["Other_FNACreated"] = date("Y-m-d h:i:s");
|
|
$header["Other_FNALastUpdated"] =date("Y-m-d h:i:s");
|
|
$header["Other_FNAUserID"] = 3;
|
|
$header["Other_FNAIsActive"] = "Y";
|
|
$header["Other_FNAT_OrderDetailID"] = $detailID;
|
|
$qry = $this->db->insert("other_fna",$header);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_fna | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$fnaID = $this->db->insert_id();
|
|
if ($fnaID == 0 ) {
|
|
$this->db_msg_nonlab .= "|gagal insert other_fna | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
foreach($detail as $idx => $d ) {
|
|
$detail[$idx]["Other_FNADetailsOther_FNAID"] = $fnaID ;
|
|
$detail[$idx]["Other_FNADetailsUserID"] = 3;
|
|
$detail[$idx]["Other_FNADetailsIsActive"] = "Y";
|
|
unset($detail[$idx]["Other_FNADetailsID"]);
|
|
unset($detail[$idx]["Other_FNADetailsCreated"]);
|
|
unset($detail[$idx]["Other_FNADetailsLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_fnadetails",$detail);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|gagal insert other_fnadetails | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
// update papsmear
|
|
function update_papsmear ($detailID, $header, $detail ) {
|
|
$sql = "select * from t_orderdetail where T_OrderDetailID = ? ";
|
|
$qry = $this->db->query($sql, array($detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|papsmear select t_orderdetail | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$rows = $qry->result_array();
|
|
if (count($rows) == 0 ) return;
|
|
if ($rows[0]["T_OrderDetailValidation"] == "Y" ) return;
|
|
$sql = "select Other_PapSmearID from other_papsmear where Other_PapSmearT_OrderDetailID = ? and Other_PapSmearIsActive = 'Y'";
|
|
$qry = $this->db->query($sql, array($detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|select other_papsmear | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$rows = $qry->result_array();
|
|
$papsmearID = 0;
|
|
if (count($rows) > 0 ) $papsmearID = $rows[0]["Other_PapSmearID"];
|
|
if ( $papsmearID > 0 ) {
|
|
$sql = "update other_papsmear set Other_PapSmearIsActive = 'N' where Other_PapSmearID = ? ";
|
|
$qry = $this->db->query($sql, array($papsmearID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_papsmear | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$sql = "update other_papsmearbahan set Other_PapSmearBahanIsActive = 'N' where Other_PapSmearBahanOther_PapSmearID= ? ";
|
|
$qry = $this->db->query($sql, array($papsmearID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_papsmearbahan | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
|
|
$sql = "update other_papsmearcategory set Other_PapSmearCategoryIsActive = 'N' where Other_PapSmearCategoryOther_PapSmearID= ? ";
|
|
$qry = $this->db->query($sql, array($papsmearID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_papsmearcategory | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
|
|
$sql = "update other_papsmearcheck set Other_PapSmearCheckIsActive = 'N' where Other_PapSmearCheckOther_PapSmearID= ? ";
|
|
$qry = $this->db->query($sql, array($papsmearID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_papsmearcheck | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
|
|
$sql = "update other_papsmeardetails set Other_PapSmearDetailsIsActive = 'N' where Other_PapSmearDetailsOther_PapSmearID= ? ";
|
|
$qry = $this->db->query($sql, array($papsmearID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_papsmeardetails | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
|
|
$sql = "update other_papsmearmaturasi set Other_PapSmearMaturasiIsActive = 'N' where Other_PapSmearMaturasiOther_PapSmearID= ? ";
|
|
$qry = $this->db->query($sql, array($papsmearID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_papsmearmaturasi | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
unset($header["Other_PapSmearID"]);
|
|
$header["Other_PapSmearCreated"] = date("Y-m-d h:i:s");
|
|
$header["Other_PapSmearLastUpdated"] =date("Y-m-d h:i:s");
|
|
$header["Other_PapSmearUserID"] = 3;
|
|
$header["Other_PapSmearIsActive"] = "Y";
|
|
$header["Other_PapSmearT_OrderDetailID"] = $detailID;
|
|
$qry = $this->db->insert("other_papsmear",$header);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_papsmear | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$papsmearID= $this->db->insert_id();
|
|
if ($papsmearID == 0 ) {
|
|
$this->db_msg_nonlab .= "|gagal insert other_papsmear | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
foreach($detail as $key => $d ) {
|
|
if ($key == "bahan") {
|
|
foreach($d as $idx => $xd) {
|
|
$detail[$key][$idx]["Other_PapSmearBahanOther_PapSmearID"] = $papsmearID ;
|
|
$detail[$key][$idx]["Other_PapSmearBahanUserID"] = 3;
|
|
$detail[$key][$idx]["Other_PapSmearBahanIsActive"] = "Y";
|
|
unset($detail[$key][$idx]["Other_PapSmearBahanID"]);
|
|
unset($detail[$key][$idx]["Other_PapSmearBahanCreated"]);
|
|
unset($detail[$key][$idx]["Other_PapSmearBahanLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_papsmearbahan",$detail[$key]);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_papsmearbahan | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
if ($key == "category") {
|
|
foreach($d as $idx => $xd) {
|
|
$detail[$key][$idx]["Other_PapSmearCategoryOther_PapSmearID"] = $papsmearID ;
|
|
$detail[$key][$idx]["Other_PapSmearCategoryUserID"] = 3;
|
|
$detail[$key][$idx]["Other_PapSmearCategoryIsActive"] = "Y";
|
|
unset($detail[$key][$idx]["Other_PapSmearCategoryID"]);
|
|
unset($detail[$key][$idx]["Other_PapSmearCategoryCreated"]);
|
|
unset($detail[$key][$idx]["Other_PapSmearCategoryLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_papsmearcategory",$detail[$key]);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_papsmearcategory | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
if ($key == "check") {
|
|
foreach($d as $idx => $xd) {
|
|
$detail[$key][$idx]["Other_PapSmearCheckOther_PapSmearID"] = $papsmearID ;
|
|
$detail[$key][$idx]["Other_PapSmearCheckUserID"] = 3;
|
|
$detail[$key][$idx]["Other_PapSmearCheckIsActive"] = "Y";
|
|
unset($detail[$key][$idx]["Other_PapSmearCheckID"]);
|
|
unset($detail[$key][$idx]["Other_PapSmearCheckCreated"]);
|
|
unset($detail[$key][$idx]["Other_PapSmearCheckLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_papsmearcheck",$detail[$key]);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_papsmearcheck | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
if ($key == "details") {
|
|
foreach($d as $idx => $xd) {
|
|
$detail[$key][$idx]["Other_PapSmearDetailsOther_PapSmearID"] = $papsmearID ;
|
|
$detail[$key][$idx]["Other_PapSmearDetailsUserID"] = 3;
|
|
$detail[$key][$idx]["Other_PapSmearDetailsIsActive"] = "Y";
|
|
unset($detail[$key][$idx]["Other_PapSmearDetailsID"]);
|
|
unset($detail[$key][$idx]["Other_PapSmearDetailsCreated"]);
|
|
unset($detail[$key][$idx]["Other_PapSmearDetailsLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_papsmeardetails",$detail[$key]);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_papsmeardetails | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
if ($key == "maturasi") {
|
|
foreach($d as $idx => $xd) {
|
|
$detail[$key][$idx]["Other_PapSmearMaturasiOther_PapSmearID"] = $papsmearID ;
|
|
$detail[$key][$idx]["Other_PapSmearMaturasiUserID"] = 3;
|
|
$detail[$key][$idx]["Other_PapSmearMaturasiIsActive"] = "Y";
|
|
unset($detail[$key][$idx]["Other_PapSmearMaturasiID"]);
|
|
unset($detail[$key][$idx]["Other_PapSmearMaturasiCreated"]);
|
|
unset($detail[$key][$idx]["Other_PapSmearMaturasiLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_papsmearmaturasi",$detail[$key]);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|insert other_papsmearmaturasi | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function update_lcprep($detailID, $header, $detail ) {
|
|
$sql = "select * from t_orderdetail where T_OrderDetailID = ? ";
|
|
$qry = $this->db->query($sql, array($detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|lcprep select t_orderdetail | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$rows = $qry->result_array();
|
|
if (count($rows) == 0 ) return;
|
|
if ($rows[0]["T_OrderDetailValidation"] == "Y" ) return;
|
|
$sql = "select Other_LcprepID from other_lcprep where Other_LcprepT_orderDetailID = ? and Other_LcprepIsActive = 'Y'";
|
|
$qry = $this->db->query($sql, array($detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|select other_lcprep | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$rows = $qry->result_array();
|
|
$lcprepID = 0;
|
|
if (count($rows) > 0 ) $lcprepID = $rows[0]["Other_LcprepID"];
|
|
if ( $lcprepID > 0 ) {
|
|
$sql = "update other_lcprep set Other_LcprepIsActive = 'N' where Other_LcprepID = ? ";
|
|
$qry = $this->db->query($sql, array($lcprepID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_lcprep | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$sql = "update other_lcprepadekuasi set Other_LcprepAdekuasiIsActive = 'N' where Other_LcprepAdekuasiOther_LcprepID= ? ";
|
|
$qry = $this->db->query($sql, array($lcprepID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_lcprepadekuasi | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
|
|
$sql = "update other_lcprepinterpretasi set Other_LcprepInterpretasiIsActive = 'N' where Other_LcprepInterpretasiOther_LcprepID= ? ";
|
|
$qry = $this->db->query($sql, array($lcprepID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_lcprepinterpretasi | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
|
|
$sql = "update other_lcprepdetails set Other_LcprepDetailsIsActive = 'N' where Other_LcprepDetailsOther_LcprepID= ? ";
|
|
$qry = $this->db->query($sql, array($lcprepID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_lcprepdetails | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
|
|
$sql = "update other_lcprepkategoriumum set Other_LcprepKategoriUmumIsActive = 'N' where Other_LcprepKategoriUmumOther_LcprepID= ? ";
|
|
$qry = $this->db->query($sql, array($lcprepID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_lcprepkategoriumum | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
unset($header["Other_LcprepID"]);
|
|
$header["Other_LcprepCreated"] = date("Y-m-d h:i:s");
|
|
$header["Other_LcprepLastUpdated"] =date("Y-m-d h:i:s");
|
|
$header["Other_LcprepUserID"] = 3;
|
|
$header["Other_LcprepIsActive"] = "Y";
|
|
$header["Other_LcprepT_orderDetailID"] = $detailID;
|
|
$qry = $this->db->insert("other_lcprep",$header);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|update other_lcprep | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
$lcprepID= $this->db->insert_id();
|
|
if ($lcprepID == 0 ) {
|
|
$this->db_msg_nonlab .= "|gagal insert other_lcprep | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
foreach($detail as $key => $d ) {
|
|
if ($key == "adekuasi") {
|
|
foreach($d as $idx => $xd) {
|
|
$detail[$key][$idx]["Other_LcprepAdekuasiOther_LcprepID"] = $lcprepID ;
|
|
$detail[$key][$idx]["Other_LcprepAdekuasiUserID"] = 3;
|
|
$detail[$key][$idx]["Other_LcprepAdekuasiIsActive"] = "Y";
|
|
unset($detail[$key][$idx]["Other_LcprepAdekuasiID"]);
|
|
unset($detail[$key][$idx]["Other_LcprepAdekuasiCreated"]);
|
|
unset($detail[$key][$idx]["Other_LcprepAdekuasiLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_lcprepadekuasi",$detail[$key]);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|gagal insert other_lcprepadekuasi | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
if ($key == "interpretasi") {
|
|
foreach($d as $idx => $xd) {
|
|
$detail[$key][$idx]["Other_LcprepInterpretasiOther_LcprepID"] = $lcprepID ;
|
|
$detail[$key][$idx]["Other_LcprepInterpretasiUserID"] = 3;
|
|
$detail[$key][$idx]["Other_LcprepInterpretasiIsActive"] = "Y";
|
|
unset($detail[$key][$idx]["Other_LcprepInterpretasiID"]);
|
|
unset($detail[$key][$idx]["Other_LcprepInterpretasiCreated"]);
|
|
unset($detail[$key][$idx]["Other_LcprepInterpretasiLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_lcprepinterpretasi",$detail[$key]);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|gagal insert other_lcprepinterpretasi | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
if ($key == "details") {
|
|
foreach($d as $idx => $xd) {
|
|
$detail[$key][$idx]["Other_LcprepDetailsOther_LcprepID"] = $lcprepID ;
|
|
$detail[$key][$idx]["Other_LcprepDetailsUserID"] = 3;
|
|
$detail[$key][$idx]["Other_LcprepDetailsIsActive"] = "Y";
|
|
unset($detail[$key][$idx]["Other_LcprepDetailsID"]);
|
|
unset($detail[$key][$idx]["Other_LcprepDetailsCreated"]);
|
|
unset($detail[$key][$idx]["Other_LcprepDetailsLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_lcprepdetails",$detail[$key]);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|gagal insert other_lcprepdetails | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
if ($key == "kategoriumum") {
|
|
foreach($d as $idx => $xd) {
|
|
$detail[$key][$idx]["Other_LcprepKategoriUmumOther_LcprepID"] = $lcprepID ;
|
|
$detail[$key][$idx]["Other_LcprepKategoriUmumUserID"] = 3;
|
|
$detail[$key][$idx]["Other_LcprepKategoriUmumIsActive"] = "Y";
|
|
unset($detail[$key][$idx]["Other_LcprepKategoriUmumID"]);
|
|
unset($detail[$key][$idx]["Other_LcprepKategoriUmumCreated"]);
|
|
unset($detail[$key][$idx]["Other_LcprepKategoriUmumLastUpdated"]);
|
|
}
|
|
$qry = $this->db->insert_batch("other_lcprepkategoriumum",$detail[$key]);
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if(!$qry) {
|
|
$this->db_msg_nonlab .= "|gagal insert other_lcprepkategoriumum | " . $this->db->error()["message"] . "\n";
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function get_param() {
|
|
$zdata = file_get_contents("php://input");
|
|
$data = gzinflate($zdata);
|
|
return json_decode($data,true);
|
|
}
|
|
|
|
function update() {
|
|
$prm = $this->get_param();
|
|
$count = 0;
|
|
$this->db_msg = "";
|
|
$this->db->trans_begin();
|
|
foreach($prm as $p) {
|
|
$count++;
|
|
$deliveryOrderID = $p["incomingRefT_RefDeliveryOrderID"];
|
|
$detailID = $p["incomingRefDetailT_OrderDetailID"];
|
|
$normalValueID = $p["T_OrderDetailNat_NormalValueID"];
|
|
$result = $p["T_OrderDetailResult"];
|
|
$resultnote = $p["T_OrderDetailNote"];
|
|
$validation = $p["T_OrderDetailValidation"];
|
|
$verification = $p["T_OrderDetailVerification"];
|
|
$status = $p["incomingRefDetailStatus"];
|
|
$note = '';
|
|
if (isset($p["note"])) $note = $p["note"];
|
|
if ($validation == "Y") {
|
|
$ret = $this->update_delivery($deliveryOrderID,$detailID,"$result","VALIDATION",$note);
|
|
if ($ret) $ret = $this->update_order($detailID,$result,$resultnote,$normalValueID);
|
|
if (isset($p["nonlab_result"])) {
|
|
$type = $p["nonlab_result"]["type"];
|
|
$header = $p["nonlab_result"]["header"];
|
|
$detail = $p["nonlab_result"]["detail"];
|
|
|
|
if ($type == "mikro" ) {
|
|
$this->update_mikro($detailID,$header,$detail);
|
|
}
|
|
if ($type == "papsmear" ) {
|
|
$this->update_papsmear($detailID,$header,$detail);
|
|
}
|
|
if ($type == "lcprep" ) {
|
|
$this->update_lcprep($detailID,$header,$detail);
|
|
}
|
|
if ($type == "fna" ) {
|
|
$this->update_fna($detailID,$header,$detail);
|
|
}
|
|
if ($type == "cytologi" ) {
|
|
$this->update_cytologi($detailID,$header,$detail);
|
|
}
|
|
}
|
|
} elseif($verification == "Y") {
|
|
$ret = $this->update_delivery($deliveryOrderID,$detailID,"$result","VERIFICATION",$note);
|
|
} elseif($status != "N") {
|
|
$ret = $this->update_delivery($deliveryOrderID,$detailID,"Diterima");
|
|
} else {
|
|
$ret = $this->update_delivery($deliveryOrderID,$detailID,"Ditolak");
|
|
}
|
|
if (! $ret ) {
|
|
echo json_encode( array("status"=>"ERR", "message"=> print_r($this->db->error(),true) ));
|
|
exit;
|
|
}
|
|
}
|
|
if ($this->db_msg != "") {
|
|
$this->db->trans_rollback();
|
|
echo json_encode( array("status" => "ERR", "message" => $this->db_msg,
|
|
"nonlab_msg" => $this->db_msg_nonlab,
|
|
"debug query" => $this->debug_sql
|
|
));
|
|
exit;
|
|
}
|
|
if ($this->db->trans_status === FALSE) {
|
|
$this->db->trans_rollback();
|
|
echo json_encode( array("status" => "ERR", "message" => $this->db_msg . "| transaction false",
|
|
"nonlab_msg" => $this->db_msg_nonlab,
|
|
"debug query" => $this->debug_sql
|
|
));
|
|
exit;
|
|
}
|
|
if ($count == 0) {
|
|
echo json_encode( array("status" => "ERR", "message" => "No Rows for update.",
|
|
"nonlab_msg" => $this->db_msg_nonlab,
|
|
"debug query" => $this->debug_sql
|
|
));
|
|
exit;
|
|
}
|
|
$this->db->trans_commit();
|
|
echo json_encode( array("status"=>"OK",
|
|
"message"=>"$count rows updated.",
|
|
"nonlab_msg" => $this->db_msg_nonlab,
|
|
"debug query" => $this->debug_sql
|
|
));
|
|
}
|
|
|
|
function update_delivery($deliveryOrderID,$detailID,$value,$stage = "", $note = "" ) {
|
|
$sql = "select T_RefDeliveryOrderDetailT_OrderDetailID ,
|
|
T_RefDeliveryOrderDetailID,
|
|
T_RefDeliveryOrderChildID
|
|
from t_ref_deliveryorder_child
|
|
join t_ref_deliveryorder_detail on
|
|
T_RefDeliveryOrderChildT_RefDeliveryOrderDetailID = T_RefDeliveryOrderDetailID
|
|
where T_RefDeliveryOrderDetailT_RefDeliveryOrderID = ?
|
|
and T_RefDeliveryOrderChildT_OrderDetailID = ?";
|
|
$qry = $this->db->query($sql, array($deliveryOrderID, $detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
$flag_child = false;
|
|
$child_id = 0;
|
|
$refDeliveryOrderDetailID = 0;
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
if (count($rows) > 0 ) {
|
|
$flag_child = true;
|
|
$child_id = $rows[0]["T_RefDeliveryOrderChildID"];
|
|
$parentDetailID = $rows[0]["T_RefDeliveryOrderDetailID"];
|
|
}
|
|
} else {
|
|
$this->db_msg .= "|select t_ref_delivery_order_child | " . $this->db->error()["message"] . "\n";
|
|
}
|
|
if ($flag_child) {
|
|
$sql = "update t_ref_deliveryorder_child
|
|
set T_RefDeliveryOrderChildResult = ?,
|
|
T_RefDeliveryOrderChildStage= ? ,
|
|
T_RefDeliveryOrderChildNote = ?
|
|
where T_RefDeliveryOrderChildID=?";
|
|
|
|
$qry = $this->db->query($sql, array($value, $stage, $note, $child_id));
|
|
$value = "...";
|
|
$detailID = $parentDetailID;
|
|
if (!$qry) {
|
|
$this->db_msg .= "|update t_ref_deliveryorder_child | " . $this->db->error()["message"] . "\n";
|
|
}
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
}
|
|
|
|
if ($flag_child) {
|
|
$sql = "update t_ref_deliveryorder_detail
|
|
set T_RefDeliveryOrderDetailResult = ?,
|
|
T_RefDeliveryOrderDetailStage = ?,
|
|
T_RefDeliveryOrderDetailNote = ?
|
|
where T_RefDeliveryOrderDetailT_RefDeliveryOrderID = ?
|
|
and T_RefDeliveryOrderDetailID = ?";
|
|
} else {
|
|
$sql = "update t_ref_deliveryorder_detail
|
|
set T_RefDeliveryOrderDetailResult = ?,
|
|
T_RefDeliveryOrderDetailStage = ?,
|
|
T_RefDeliveryOrderDetailNote = ?
|
|
where T_RefDeliveryOrderDetailT_RefDeliveryOrderID = ?
|
|
and T_RefDeliveryOrderDetailT_OrderDetailID = ?";
|
|
}
|
|
|
|
$qry = $this->db->query($sql, array($value, $stage, $note, $deliveryOrderID, $detailID));
|
|
if (!$qry) {
|
|
$this->db_msg .= "|update t_ref_deliveryorder_detail | " . $this->db->error()["message"] . "\n";
|
|
}
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
return $qry;
|
|
}
|
|
|
|
function update_order($detailID,$value,$resultnote,$normalValueID) {
|
|
$verUserID = 3;
|
|
|
|
$sql = "update t_orderdetail
|
|
set T_OrderDetailResult = ?,
|
|
T_OrderDetailNote = ?,
|
|
T_OrderDetailNat_NormalValueID = ?,
|
|
T_OrderDetailVerification = 'Y',
|
|
T_OrderDetailVerDate = now(),
|
|
T_OrderDetailVerUserID = $verUserID
|
|
where T_OrderDetailID = ?
|
|
and ( T_OrderDetailValidation <>'Y' or T_OrderDetailValidation is null )
|
|
";
|
|
$qry = $this->db->query($sql, array($value,$resultnote, $normalValueID, $detailID));
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
if ( $qry) {
|
|
$sql = "update t_orderdetail, nat_normalvalue, nat_methode
|
|
set T_OrderDetailNat_MethodeID = Nat_NormalValueNat_MethodeID ,
|
|
T_OrderDetailNat_MethodeName = Nat_MethodeName,
|
|
T_OrderDetailNormalValueNote = Nat_NormalValueNote,
|
|
T_OrderDetailNormalValueDescription = Nat_NormalValueDescription,
|
|
T_OrderDetailMinValue = Nat_NormalValueMinValue,
|
|
T_OrderDetailMaxValue = Nat_NormalValueMaxValue,
|
|
T_OrderDetailMinValueInclusive = Nat_NormalValueMinValueInclusive,
|
|
T_OrderDetailMaxValueInclusive = Nat_NormalValueMaxValueInclusive
|
|
where T_OrderDetailID = ?
|
|
and T_OrderDetailNat_NormalValueID = Nat_NormalValueID
|
|
and Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
|
and ( T_OrderDetailValidation <>'Y' or T_OrderDetailValidation is null ) ";
|
|
$qryn = $this->db->query($sql, array($detailID));
|
|
if (!$qryn) {
|
|
$this->db_msg .= "|update t_ref_deliveryorder_detail | " . $this->db->error()["message"] . "\n";
|
|
}
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
|
|
if (! $qryn ) return false;
|
|
$sql = "call sp_set_normal_value_flag(?)";
|
|
$qryu = $this->db->query($sql, array($detailID));
|
|
if (!$qryu) {
|
|
$this->db_msg .= "|call sp_set_normal_value_flag | " . $this->db->error()["message"] . "\n";
|
|
}
|
|
$this->debug_sql .= $this->db->last_query() . "\n";
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
if (! $qryu ) return false;
|
|
} else {
|
|
$this->db_msg .= "|update t_orderdetail | " . $this->db->error()["message"] . "\n";
|
|
}
|
|
return $qry;
|
|
}
|
|
} |