107 lines
3.1 KiB
PHP
107 lines
3.1 KiB
PHP
<?php
|
|
class Auto_verif extends MY_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
function index()
|
|
{
|
|
$start_date = date("Y-m-d 00:00:01");
|
|
$end_date = date("Y-m-d 23:59:59");
|
|
echo "<h5>List Order $start_date s/d $end_date</h5>";
|
|
echo "<div>
|
|
<pre>
|
|
4095 10110100 Hematologi Lengkap
|
|
4097 10110300 Hematologi Lengkap + Retikulosit
|
|
4633 10510100 SGOT
|
|
4634 10510200 SGPT
|
|
4667 10520300 Cholesterol
|
|
4668 10520400 Trigliserida
|
|
4669 10520500 HDL Cholesterol
|
|
4670 10520600 LDL Cholesterol
|
|
4687 10530100 Ureum
|
|
4688 10530200 BUN
|
|
4690 10530400 Serum Creatinin
|
|
4692 10530500 Asam Urat
|
|
4716 10540200 Glukosa Darah Puasa
|
|
4722 10540800 Glukosa Darah Sewaktu</pre>
|
|
</div>";
|
|
$s_nat_test = "4095, 4097, 4633, 4634, 4667,
|
|
4668, 4669, 4670, 4687, 4688,
|
|
4690, 4692, 4716, 4722";
|
|
$sql = "select T_OrderHeaderDate, T_OrderHeaderLabNumber, M_PatientName,
|
|
group_concat(T_OrderDetailT_TestName) Test
|
|
from
|
|
t_orderheader
|
|
join m_patient on T_OrderHeaderIsActive = 'Y'
|
|
and T_OrderHeaderM_PatientID = M_PatientID
|
|
join t_orderdetail on T_OrderHeaderDate > ?
|
|
and T_OrderHeaderDate < ?
|
|
and T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
and T_OrderDetailIsActive = 'Y'
|
|
join t_test on T_OrderDetailT_TestID = T_TestID
|
|
and T_TestNat_TestID in ($s_nat_test)
|
|
group by T_OrderHeaderID
|
|
order by T_OrderHeaderID
|
|
";
|
|
$qry = $this->db->query($sql, [$start_date, $end_date]);
|
|
$this->print_table_style();
|
|
if (!$qry) {
|
|
$arr = [
|
|
"error" =>
|
|
$this->db->error()["message"] .
|
|
"<br/>" .
|
|
$this->db->last_query(),
|
|
];
|
|
$this->print_table([$arr], ["error"]);
|
|
exit();
|
|
}
|
|
$rows = $qry->result_array();
|
|
if (count($rows) > 0) {
|
|
$this->print_table($rows, array_keys($rows[0]));
|
|
} else {
|
|
$arr = [
|
|
"info" =>
|
|
"No Record found." . "<br/>" . $this->db->last_query(),
|
|
];
|
|
$this->print_table([$arr], ["error"]);
|
|
exit();
|
|
}
|
|
}
|
|
public function print_table_style()
|
|
{
|
|
echo "
|
|
<style>
|
|
th, td {
|
|
padding: 15px;
|
|
text-align: left;
|
|
}
|
|
tr:nth-child(even) {background-color: #f2f2f2;}
|
|
table {
|
|
border: solid 1px ;
|
|
min-width:600px;
|
|
}
|
|
</style>
|
|
";
|
|
}
|
|
|
|
public function print_table($rows, $keys)
|
|
{
|
|
echo "<table>";
|
|
echo "<tr>";
|
|
foreach ($keys as $k) {
|
|
echo "<td>$k</td>";
|
|
}
|
|
echo "</tr>\n";
|
|
foreach ($rows as $r) {
|
|
echo "<tr>";
|
|
foreach ($keys as $k) {
|
|
echo "<td>" . $r[$k] . "</td>";
|
|
}
|
|
echo "</tr>";
|
|
}
|
|
echo "</table>";
|
|
}
|
|
}
|