db = $this->load->database("onedev", true); } 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Mikro cek Validation " . print_r($this->db->error(),true),FILE_APPEND); 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Mikro cek Existence " . print_r($this->db->error(),true),FILE_APPEND); 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Mikro set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_mikrodetails set Other_MikroDetailsIsActive = 'N' where Other_MikroDetailsOther_MikroID= ? "; $qry = $this->db->query($sql, array($mikroID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Mikro Details set Inactive" . print_r($this->db->error(),true),FILE_APPEND); 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); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Mikro Add Header" . print_r($this->db->error(),true),FILE_APPEND); return; } $mikroID = $this->db->insert_id(); if ($mikroID == 0 ) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Mikro ID Header" . print_r($this->db->error(),true),FILE_APPEND); 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); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Mikro Add Detail" . print_r($this->db->error(),true),FILE_APPEND); return; } } //cytologi function update_cytologi($detailID, $header, $detail ) { $sql = "select * from t_orderdetail where T_OrderDetailID = ? "; $qry = $this->db->query($sql, array($detailID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Cytologi cek Validation " . print_r($this->db->error(),true),FILE_APPEND); 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Cytologi cek Existence " . print_r($this->db->error(),true),FILE_APPEND); 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Cytologi set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_cytologidetails set Other_CytologiDetailsIsActive = 'N' where Other_CytologiDetailsOther_CytologiID= ? "; $qry = $this->db->query($sql, array($cytologiID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Cytologi Details set Inactive" . print_r($this->db->error(),true),FILE_APPEND); 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); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Cytologi Add Header" . print_r($this->db->error(),true),FILE_APPEND); return; } $cytologiID = $this->db->insert_id(); if ($cytologiID == 0 ) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Cytologi ID Header" . print_r($this->db->error(),true),FILE_APPEND); 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); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Cytologi Add Detail" . print_r($this->db->error(),true),FILE_APPEND); return; } } //fna function update_fna($detailID, $header, $detail ) { $sql = "select * from t_orderdetail where T_OrderDetailID = ? "; $qry = $this->db->query($sql, array($detailID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError FNA cek Validation " . print_r($this->db->error(),true),FILE_APPEND); 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError FNA cek Existence " . print_r($this->db->error(),true),FILE_APPEND); 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError FNA set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_fnadetails set Other_FNADetailsIsActive = 'N' where Other_FNADetailsOther_FNAID= ? "; $qry = $this->db->query($sql, array($fnaID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError FNA Details set Inactive" . print_r($this->db->error(),true),FILE_APPEND); 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); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError FNA Add Header" . print_r($this->db->error(),true),FILE_APPEND); return; } $fnaID = $this->db->insert_id(); if ($fnaID == 0 ) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError FNA ID Header" . print_r($this->db->error(),true),FILE_APPEND); 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); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError FNA Add Detail" . print_r($this->db->error(),true),FILE_APPEND); return; } } // update papsmear function update_papsmear ($detailID, $header, $detail ) { $sql = "select * from t_orderdetail where T_OrderDetailID = ? "; $qry = $this->db->query($sql, array($detailID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear cek Validation " . print_r($this->db->error(),true),FILE_APPEND); 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear cek Existence " . print_r($this->db->error(),true),FILE_APPEND); 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_papsmearbahan set Other_PapSmearBahanIsActive = 'N' where Other_PapSmearBahanOther_PapSmearID= ? "; $qry = $this->db->query($sql, array($papsmearID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Details set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_papsmearcategory set Other_PapSmearCategoryIsActive = 'N' where Other_PapSmearCategoryOther_PapSmearID= ? "; $qry = $this->db->query($sql, array($papsmearID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Category set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_papsmearcheck set Other_PapSmearCheckIsActive = 'N' where Other_PapSmearCheckOther_PapSmearID= ? "; $qry = $this->db->query($sql, array($papsmearID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Check set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_papsmeardetails set Other_PapSmearDetailsIsActive = 'N' where Other_PapSmearDetailsOther_PapSmearID= ? "; $qry = $this->db->query($sql, array($papsmearID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Details set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_papsmearmaturasi set Other_PapSmearMaturasiIsActive = 'N' where Other_PapSmearMaturasiOther_PapSmearID= ? "; $qry = $this->db->query($sql, array($papsmearID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Details set Inactive" . print_r($this->db->error(),true),FILE_APPEND); 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); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Add Header" . print_r($this->db->error(),true),FILE_APPEND); return; } $papsmearID= $this->db->insert_id(); if ($papsmearID == 0 ) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear ID Header" . print_r($this->db->error(),true),FILE_APPEND); 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]); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Add Bahan " . print_r($this->db->error(),true),FILE_APPEND); 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]); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Add Category " . print_r($this->db->error(),true),FILE_APPEND); 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]); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Add Check " . print_r($this->db->error(),true),FILE_APPEND); 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]); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Add Details " . print_r($this->db->error(),true),FILE_APPEND); 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]); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError PapSmear Add Maturasi " . print_r($this->db->error(),true),FILE_APPEND); return; } } } } function update_lcprep($detailID, $header, $detail ) { $sql = "select * from t_orderdetail where T_OrderDetailID = ? "; $qry = $this->db->query($sql, array($detailID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep cek Validation " . print_r($this->db->error(),true),FILE_APPEND); 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep cek Existence " . print_r($this->db->error(),true),FILE_APPEND); 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)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_lcprepadekuasi set Other_LcprepAdekuasiIsActive = 'N' where Other_LcprepAdekuasiOther_LcprepID= ? "; $qry = $this->db->query($sql, array($lcprepID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep Adekuasi set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_lcprepinterpretasi set Other_LcprepInterpretasiIsActive = 'N' where Other_LcprepInterpretasiOther_LcprepID= ? "; $qry = $this->db->query($sql, array($lcprepID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep Interpretasi set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_lcprepdetails set Other_LcprepDetailsIsActive = 'N' where Other_LcprepDetailsOther_LcprepID= ? "; $qry = $this->db->query($sql, array($lcprepID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep Details set Inactive" . print_r($this->db->error(),true),FILE_APPEND); return; } $sql = "update other_lcprepkategoriumum set Other_LcprepKategoriUmumIsActive = 'N' where Other_LcprepKategoriUmumOther_LcprepID= ? "; $qry = $this->db->query($sql, array($lcprepID)); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep KategoriUmum set Inactive" . print_r($this->db->error(),true),FILE_APPEND); 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); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep Add Header" . print_r($this->db->error(),true),FILE_APPEND); return; } $lcprepID= $this->db->insert_id(); if ($lcprepID == 0 ) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep ID Header" . print_r($this->db->error(),true),FILE_APPEND); 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]); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep Add Adekuasi " . print_r($this->db->error(),true),FILE_APPEND); 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]); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep Add Interpretasi " . print_r($this->db->error(),true),FILE_APPEND); 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]); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep Add Details " . print_r($this->db->error(),true),FILE_APPEND); 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]); if(!$qry) { file_put_contents("/xtmp/dbg-xstatus_branch-v3.log", "\nError Lcprep Add KategoriUmum " . print_r($this->db->error(),true),FILE_APPEND); return; } } } } function update() { $prm = $this->sys_input; foreach($prm as $p) { $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; } } echo json_encode( array("status"=>"OK", "message"=>"")); } 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)); $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"]; } } 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, $state, $note, $child_id)); $value = "..."; $detailID = $parentDetailID; } 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)); 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 = ?"; $qry = $this->db->query($sql, array($value,$resultnote, $normalValueID, $detailID)); 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"; $qryn = $this->db->query($sql, array($detailID)); //if (! $qryn ) print_r($this->db->error()); if (! $qryn ) return false; $sql = "call sp_set_normal_value_flag(?)"; $qryu = $this->db->query($sql, array($detailID)); //if (! $qryu ) print_r($this->db->error()); if (! $qryu ) return false; $this->clean_mysqli_connection($this->db->conn_id); } return $qry; } }