now() join m_patient on T_OrderHeaderM_PatientID = M_PatientID and ( M_PatientM_SexID = 0 or M_PatientM_SexID is null ) join m_title on M_PatientM_TitleID = M_TitleID order by T_OrderHeaderID desc "; $qry = $this->db->query($sql); if (!$qry) { echo "Error : " . $this->db->error()["message"]; exit(); } $rows = $qry->result_array(); foreach ($rows as $idx => $r) { $url_fix_laki = "/one-api/tools/hs_check/fix_patient/" . $r["M_PatientID"] . "/1" ; $url_fix_wanita = "/one-api/tools/hs_check/fix_patient/" . $r["M_PatientID"] . "/2" ; $rows[$idx]["Action"] = ""; $rows[$idx]["Action"] .= ""; unset($rows[$idx]["M_PatientID"]); } $this->print_table_style(); $this->print_table($rows, array_keys($rows[0])); } function aging_fix($id, $aging) { $this->db->trans_begin(); $sql = "update t_ordersample set T_OrderSampleReadyToProcessDateTime = concat(T_OrderSampleReceiveDate, ' ', T_OrderSampleReceiveTime) + interval ? minute where T_OrderSampleID = ? and T_OrderSampleReadyToProcessDateTime is null "; $qry = $this->db->query($sql, [$aging, $id]); if (!$qry) { echo "Error : " . $this->db->error()["message"]; $this->db->trans_rollback(); exit(); } $sql = "select * from t_ordersample where T_OrderSampleID = ?"; $qry = $this->db->query($sql, [$id]); if (!$qry) { echo "Error : " . $this->db->error()["message"]; $this->db->trans_rollback(); exit(); } $rows = $qry->result_array(); $this->print_table_style(); $this->print_table($rows, array_keys($rows[0])); $this->db->trans_commit(); header("Location: /one-api/tools/hs_check/sample_aging"); } function sample_aging_non_hs() { $sql = "select T_OrderHeaderLabNumber, T_OrderSampleT_SampleTypeID, T_SampleTypeName, T_SampleTypeAgingOnHold, T_SampleTypeAgingOnHoldTime, concat(T_OrderSampleReceiveDate, ' ',T_OrderSampleReceiveTime) ReceiveDate, T_OrderSampleReadyToProcessDateTime,T_OrderSampleID, ' ' Action from t_orderheader join t_ordersample on T_OrderHeaderID = T_OrderSampleT_OrderHeaderID and T_OrderHeaderIsActive = 'Y' and T_OrderHeaderDate + interval 1 day > now() join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID and T_SampleTypeAgingOnHold = 'Y' and T_OrderHeaderID not in ( select T_OrderHeaderID from one_hs.t_order) order by T_OrderHeaderID desc "; $qry = $this->db->query($sql); if (!$qry) { echo "Error : " . $this->db->error()["message"]; exit(); } $rows = $qry->result_array(); foreach ($rows as $idx => $r) { if (trim($r["T_OrderSampleReadyToProcessDateTime"]) == "") { $url_fix = "/one-api/tools/hs_check/aging_fix/" . $r["T_OrderSampleID"] . "/" . $r["T_SampleTypeAgingOnHoldTime"]; $rows[$idx]["Action"] = ""; } unset($rows[$idx]["T_OrderSampleID"]); } $this->print_table_style(); $this->print_table($rows, array_keys($rows[0])); } function sample_aging() { $sql = "select T_OrderHeaderLabNumber, T_OrderSampleT_SampleTypeID, T_SampleTypeName, T_SampleTypeAgingOnHold, T_SampleTypeAgingOnHoldTime, concat(T_OrderSampleReceiveDate, ' ',T_OrderSampleReceiveTime) ReceiveDate, T_OrderSampleReadyToProcessDateTime,T_OrderSampleID, ' ' Action from one_hs.t_order join t_orderheader on T_OrderT_OrderHeaderID = T_OrderHeaderID join t_ordersample on T_OrderT_OrderHeaderID = T_OrderSampleT_OrderHeaderID and T_OrderIsActive = 'Y' and T_OrderCreated + interval 2 day > now() join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID and T_SampleTypeAgingOnHold = 'Y' order by T_OrderHeaderID desc "; $qry = $this->db->query($sql); if (!$qry) { echo "Error : " . $this->db->error()["message"]; exit(); } $rows = $qry->result_array(); foreach ($rows as $idx => $r) { if (trim($r["T_OrderSampleReadyToProcessDateTime"]) == "") { $url_fix = "/one-api/tools/hs_check/aging_fix/" . $r["T_OrderSampleID"] . "/" . $r["T_SampleTypeAgingOnHoldTime"]; $rows[$idx]["Action"] = ""; } unset($rows[$idx]["T_OrderSampleID"]); } $this->print_table_style(); $this->print_table($rows, array_keys($rows[0])); } function print_table_style() { echo " "; } public function print_table_one_column($rows) { $rst = ""; foreach ($rows as $r) { $rst .= ""; $rst .= ""; $rst .= ""; } $rst .= "
" . $r . "
"; return $rst; } public function print_table($rows, $keys) { echo ""; echo ""; foreach ($keys as $k) { echo ""; } echo "\n"; foreach ($rows as $r) { echo ""; foreach ($keys as $k) { echo ""; } echo ""; } echo "
$k
" . $r[$k] . "
"; } }